summaryrefslogtreecommitdiff
path: root/apps/screens.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/screens.c')
-rw-r--r--apps/screens.c172
1 files changed, 4 insertions, 168 deletions
diff --git a/apps/screens.c b/apps/screens.c
index f3e00dfc0a..978d2a12f8 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -47,6 +47,7 @@
47#include "sound.h" 47#include "sound.h"
48#include "abrepeat.h" 48#include "abrepeat.h"
49#include "wps-display.h" 49#include "wps-display.h"
50#include "splash.h"
50#if defined(HAVE_LCD_BITMAP) 51#if defined(HAVE_LCD_BITMAP)
51#include "widgets.h" 52#include "widgets.h"
52#endif 53#endif
@@ -155,7 +156,7 @@ int mmc_remove_request(void)
155 struct event ev; 156 struct event ev;
156 157
157 lcd_clear_display(); 158 lcd_clear_display();
158 splash(1, true, str(LANG_REMOVE_MMC)); 159 gui_syncsplash(1, true, str(LANG_REMOVE_MMC));
159 if (global_settings.talk_menu) 160 if (global_settings.talk_menu)
160 talk_id(LANG_REMOVE_MMC, false); 161 talk_id(LANG_REMOVE_MMC, false);
161 162
@@ -771,175 +772,10 @@ bool quick_screen(int context, int button)
771} 772}
772#endif 773#endif
773 774
774#ifdef HAVE_LCD_BITMAP
775#define SPACE 3 /* pixels between words */
776#define MAXLETTERS 128 /* 16*8 */
777#define MAXLINES 10
778#else
779#define SPACE 1 /* one letter space */
780#undef LCD_WIDTH
781#define LCD_WIDTH 11
782#undef LCD_HEIGHT
783#define LCD_HEIGHT 2
784#define MAXLETTERS 22 /* 11 * 2 */
785#define MAXLINES 2
786#endif
787
788void splash(int ticks, /* how long the splash is displayed */
789 bool center, /* FALSE means left-justified, TRUE means
790 horizontal and vertical center */
791 const char *fmt, /* what to say *printf style */
792 ...)
793{
794 char *next;
795 char *store=NULL;
796 int x=0;
797 int y=0;
798 int w, h;
799 unsigned char splash_buf[MAXLETTERS];
800 va_list ap;
801 unsigned char widths[MAXLINES];
802 int line=0;
803 bool first=true;
804#ifdef HAVE_LCD_BITMAP
805 int maxw=0;
806#endif
807
808#ifdef HAVE_LCD_CHARCELLS
809 lcd_double_height (false);
810#endif
811 va_start( ap, fmt );
812 vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap );
813
814 if(center) {
815
816 /* first a pass to measure sizes */
817 next = strtok_r(splash_buf, " ", &store);
818 while (next) {
819#ifdef HAVE_LCD_BITMAP
820 lcd_getstringsize(next, &w, &h);
821#else
822 w = strlen(next);
823 h = 1; /* store height in characters */
824#endif
825 if(!first) {
826 if(x+w> LCD_WIDTH) {
827 /* Too wide, wrap */
828 y+=h;
829 line++;
830 if((y > (LCD_HEIGHT-h)) || (line > MAXLINES))
831 /* STOP */
832 break;
833 x=0;
834 first=true;
835 }
836 }
837 else
838 first = false;
839
840 /* think of it as if the text was written here at position x,y
841 being w pixels/chars wide and h high */
842
843 x += w+SPACE;
844 widths[line]=x-SPACE; /* don't count the trailing space */
845#ifdef HAVE_LCD_BITMAP
846 /* store the widest line */
847 if(widths[line]>maxw)
848 maxw = widths[line];
849#endif
850 next = strtok_r(NULL, " ", &store);
851 }
852#ifdef HAVE_LCD_BITMAP
853 /* Start displaying the message at position y. The reason for the
854 added h here is that it isn't added until the end of lines in the
855 loop above and we always break the loop in the middle of a line. */
856 y = (LCD_HEIGHT - (y+h) )/2;
857#else
858 y = 0; /* vertical center on 2 lines would be silly */
859#endif
860 first=true;
861
862 /* Now recreate the string again since the strtok_r() above has ruined
863 the one we already have! Here's room for improvements! */
864 vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap );
865 }
866 va_end( ap );
867
868 if(center)
869 {
870 x = (LCD_WIDTH-widths[0])/2;
871 if(x < 0)
872 x = 0;
873 }
874
875#ifdef HAVE_LCD_BITMAP
876 /* If we center the display, then just clear the box we need and put
877 a nice little frame and put the text in there! */
878 if(center && (y > 2)) {
879 int xx = (LCD_WIDTH-maxw)/2 - 2;
880 /* The new graphics routines handle clipping, so no need to check */
881#if LCD_DEPTH > 1
882 lcd_set_background(LCD_LIGHTGRAY);
883#endif
884 lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
885 lcd_fillrect(xx, y-2, maxw+4, LCD_HEIGHT-y*2+4);
886 lcd_set_drawmode(DRMODE_SOLID);
887 lcd_drawrect(xx, y-2, maxw+4, LCD_HEIGHT-y*2+4);
888 }
889 else
890#endif
891 lcd_clear_display();
892 line=0;
893 next = strtok_r(splash_buf, " ", &store);
894 while (next) {
895#ifdef HAVE_LCD_BITMAP
896 lcd_getstringsize(next, &w, &h);
897#else
898 w = strlen(next);
899 h = 1;
900#endif
901 if(!first) {
902 if(x+w> LCD_WIDTH) {
903 /* too wide */
904 y+=h;
905 line++; /* goto next line */
906 first=true;
907 if(y > (LCD_HEIGHT-h))
908 /* STOP */
909 break;
910 if(center) {
911 x = (LCD_WIDTH-widths[line])/2;
912 if(x < 0)
913 x = 0;
914 }
915 else
916 x=0;
917 }
918 }
919 else
920 first=false;
921#ifdef HAVE_LCD_BITMAP
922 lcd_putsxy(x, y, next);
923#else
924 lcd_puts(x, y, next);
925#endif
926 x += w+SPACE; /* pixels space! */
927 next = strtok_r(NULL, " ", &store);
928 }
929#if LCD_DEPTH > 1
930 lcd_set_background(LCD_WHITE);
931#endif
932 lcd_update();
933
934 if(ticks)
935 /* unbreakable! */
936 sleep(ticks);
937}
938
939#if defined(HAVE_CHARGING) || defined(SIMULATOR) 775#if defined(HAVE_CHARGING) || defined(SIMULATOR)
940void charging_splash(void) 776void charging_splash(void)
941{ 777{
942 splash(2*HZ, true, str(LANG_BATTERY_CHARGE)); 778 gui_syncsplash(2*HZ, true, str(LANG_BATTERY_CHARGE));
943 button_clear_queue(); 779 button_clear_queue();
944} 780}
945#endif 781#endif
@@ -1254,7 +1090,7 @@ bool shutdown_screen(void)
1254 1090
1255 lcd_stop_scroll(); 1091 lcd_stop_scroll();
1256 1092
1257 splash(0, true, str(LANG_CONFIRM_SHUTDOWN)); 1093 gui_syncsplash(0, true, str(LANG_CONFIRM_SHUTDOWN));
1258 1094
1259 while(!done) 1095 while(!done)
1260 { 1096 {