2828
2929void ui_DrawUISprite (const uint8_t color , const uint8_t spriteNo , const int x , const uint8_t y ) {
3030 bool colorAlt = !(color > 131 && color % 8 > 3 );
31- const gfx_sprite_t * uiIcons [22 ] = {battery , charging , paint , info , settings , lArrow , rArrow , dArrow , check , cursorAlpha , cursorNumber , batteryAlt , chargingAlt , paintAlt , infoAlt , settingsAlt , lArrowAlt , rArrowAlt , dArrowAlt , checkAlt , cursorAlphaAlt , cursorNumberAlt };
31+ const gfx_sprite_t * uiIcons [24 ] = {battery , charging , paint , info , settings , lArrow , rArrow , dArrow , check , cursorNumber , cursorUpper , cursorLower , batteryAlt , chargingAlt , paintAlt , infoAlt , settingsAlt , lArrowAlt , rArrowAlt , dArrowAlt , checkAlt , cursorNumberAlt , cursorUpperAlt , cursorLowerAlt };
3232 gfx_TransparentSprite_NoClip (uiIcons [spriteNo + colorAlt * 11 ], x , y );
3333 gfx_SetTextFGColor (colorAlt * 255 );
3434}
@@ -262,10 +262,14 @@ bool ui_DeleteConf(uint8_t *colors, const int x, const uint8_t y) {
262262 return retVal ;
263263}
264264
265- bool ui_RenameBox (uint8_t * colors , char * newName ) {
265+ bool ui_RenameBox (uint8_t * colors , char * newName , bool useLower ) {
266266 gfx_BlitScreen ();
267- const char * charAlpha = "\0\0\0\0\0\0\0\0\0\0\0WRMH\0\0\0[VQLG\0\0\0ZUPKFC\0\0YTOJEBX\0XSNIDA\0\0\0\0\0\0\0\0" ;
268- const char * charNums = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "369\0\0\0\0\0" "258\0\0\0\0" "0147\0\0\0X\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ;
267+
268+ static const char chars [3 ][56 ] =
269+ {{'\0' , '\0' , '\0' , '\0' , '\0' ,'\0' , '\0' , '\0' , '\0' , '\0' , '+' , '-' , '*' , '/' , '^' , '\0' , '\0' , '\0' , '3' , '6' , '9' , ')' , '\0' , '\0' , '\0' , '.' , '2' , '5' , '8' , '(' , '\0' , '\0' , '\0' , '0' , '1' , '4' , '7' , ',' , '\0' , '\0' , 'X' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' },
270+ {'\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\"' , 'W' , 'R' , 'M' , 'H' , '\0' , '\0' , '?' , '[' , 'V' , 'Q' , 'L' , 'G' , '\0' , '\0' , ':' , 'Z' , 'U' , 'P' , 'K' , 'F' , 'C' , '\0' , ' ' , 'Y' , 'T' , 'O' , 'J' , 'E' , 'B' , 'X' , '\0' , 'X' , 'S' , 'N' , 'I' , 'D' , 'A' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' },
271+ {'\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\"' , 'w' , 'r' , 'm' , 'h' , '\0' , '\0' , '?' , '[' , 'v' , 'q' , 'l' , 'g' , '\0' , '\0' , ':' , 'z' , 'u' , 'p' , 'k' , 'f' , 'c' , '\0' , ' ' , 'y' , 't' , 'o' , 'j' , 'e' , 'b' , '\0' , '\0' , 'x' , 's' , 'n' , 'i' , 'd' ,'a' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' }};
272+
269273 uint8_t length = strlen (newName );
270274 gfx_SetColor (colors [0 ]);
271275 gfx_FillRectangle_NoClip (129 , 182 , 62 , 11 );
@@ -279,7 +283,7 @@ bool ui_RenameBox(uint8_t *colors, char *newName) {
279283 while (kb_AnyKey ());
280284 uint8_t key = os_GetCSC ();
281285 bool redraw ;
282- bool alphaPressed = false; // Number mode?
286+ uint8_t inputMode = INPUT_UPPER ;
283287 bool cursor = false;
284288 timer_Set (1 , 0 );
285289
@@ -296,16 +300,9 @@ bool ui_RenameBox(uint8_t *colors, char *newName) {
296300 redraw = true;
297301 }
298302
299- if (!alphaPressed ) {
300- if (charAlpha [key ] && length < 8 ) {
301- newName [length ++ ] = charAlpha [key ];
302- redraw = true;
303- }
304- } else {
305- if (charNums [key ] && length < 8 && length ) {
306- newName [length ++ ] = charNums [key ];
307- redraw = true;
308- }
303+ if (chars [inputMode ][key ]) {
304+ newName [length ++ ] = chars [inputMode ][key ];
305+ redraw = true;
309306 }
310307
311308 if (redraw ) {
@@ -323,11 +320,15 @@ bool ui_RenameBox(uint8_t *colors, char *newName) {
323320 }
324321
325322 if (key == sk_Alpha ) {
326- alphaPressed = !alphaPressed ;
323+ if (inputMode < 2 - !(useLower )) {
324+ inputMode ++ ;
325+ } else {
326+ inputMode = 0 ;
327+ }
327328 }
328329 } else {
329330 if (cursor ) {
330- ui_DrawUISprite (colors [1 ], UI_CURSOR_A + alphaPressed , gfx_GetTextX () + 1 , gfx_GetTextY ());
331+ ui_DrawUISprite (colors [1 ], UI_CURSOR_1 + inputMode , gfx_GetTextX () + 1 , gfx_GetTextY ());
331332 } else {
332333 gfx_SetColor (colors [2 ]);
333334 gfx_FillRectangle_NoClip (gfx_GetTextX () + 1 , gfx_GetTextY (), 7 , 14 );
@@ -692,7 +693,7 @@ void ui_NewUser(void) {
692693 }
693694}
694695
695- uint8_t ui_CopyNewMenu (uint8_t * colors , char * name ) {
696+ uint8_t ui_CopyNewMenu (uint8_t * colors , char * name , bool useLower ) {
696697 bool returnVal = false;
697698 while (kb_AnyKey ());
698699 shapes_RoundRectangleFill (colors [0 ], 9 , 208 , 20 , 56 , 204 );
@@ -732,13 +733,17 @@ uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
732733 gfx_SetTextScale (2 , 2 );
733734 gfx_SetTextXY (111 , 207 );
734735 gfx_BlitBuffer ();
735- const char * charAlpha = "\0\0\0\0\0\0\0\0\0\0\0WRMH\0\0\0[VQLG\0\0\0ZUPKFC\0\0YTOJEBX\0XSNIDA\0\0\0\0\0\0\0\0" ;
736- const char * charNums = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "369\0\0\0\0\0" "258\0\0\0\0" "0147\0\0\0X\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ;
736+
737+ static const char chars [3 ][56 ] =
738+ {{'\0' , '\0' , '\0' , '\0' , '\0' ,'\0' , '\0' , '\0' , '\0' , '\0' , '+' , '-' , '*' , '/' , '^' , '\0' , '\0' , '\0' , '3' , '6' , '9' , ')' , '\0' , '\0' , '\0' , '.' , '2' , '5' , '8' , '(' , '\0' , '\0' , '\0' , '0' , '1' , '4' , '7' , ',' , '\0' , '\0' , 'X' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' },
739+ {'\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\"' , 'W' , 'R' , 'M' , 'H' , '\0' , '\0' , '?' , '[' , 'V' , 'Q' , 'L' , 'G' , '\0' , '\0' , ':' , 'Z' , 'U' , 'P' , 'K' , 'F' , 'C' , '\0' , ' ' , 'Y' , 'T' , 'O' , 'J' , 'E' , 'B' , 'X' , '\0' , 'X' , 'S' , 'N' , 'I' , 'D' , 'A' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' },
740+ {'\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\"' , 'w' , 'r' , 'm' , 'h' , '\0' , '\0' , '?' , '[' , 'v' , 'q' , 'l' , 'g' , '\0' , '\0' , ':' , 'z' , 'u' , 'p' , 'k' , 'f' , 'c' , '\0' , ' ' , 'y' , 't' , 'o' , 'j' , 'e' , 'b' , '\0' , '\0' , 'x' , 's' , 'n' , 'i' , 'd' ,'a' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' , '\0' }};
741+
737742 asm("ei" );
738743 uint8_t length = 0 ;
739744 uint8_t key = os_GetCSC ();
740745 bool redraw ;
741- bool alphaPressed ; // Number mode?
746+ uint8_t inputMode = INPUT_UPPER ;
742747 bool cursor = false;
743748 timer_Set (1 , 0 );
744749
@@ -755,16 +760,9 @@ uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
755760 redraw = true;
756761 }
757762
758- if (!alphaPressed ) {
759- if (charAlpha [key ] && length < 8 ) {
760- name [length ++ ] = charAlpha [key ];
761- redraw = true;
762- }
763- } else {
764- if (charNums [key ] && length < 8 && length ) {
765- name [length ++ ] = charNums [key ];
766- redraw = true;
767- }
763+ if (chars [inputMode ][key ]) {
764+ name [length ++ ] = chars [inputMode ][key ];
765+ redraw = true;
768766 }
769767
770768 if (redraw ) {
@@ -782,11 +780,15 @@ uint8_t ui_CopyNewMenu(uint8_t *colors, char *name) {
782780 }
783781
784782 if (key == sk_Alpha ) {
785- alphaPressed = !alphaPressed ;
783+ if (inputMode < 2 - !(useLower )) {
784+ inputMode ++ ;
785+ } else {
786+ inputMode = 0 ;
787+ }
786788 }
787789 } else {
788790 if (cursor ) {
789- ui_DrawUISprite (colors [1 ], UI_CURSOR_A + alphaPressed , gfx_GetTextX () + 1 , gfx_GetTextY ());
791+ ui_DrawUISprite (colors [1 ], UI_CURSOR_1 + inputMode , gfx_GetTextX () + 1 , gfx_GetTextY ());
790792 } else {
791793 gfx_SetColor (colors [0 ]);
792794 gfx_FillRectangle_NoClip (gfx_GetTextX () + 1 , gfx_GetTextY (), 7 , 14 );
0 commit comments