diff -r 8d0287a1a9e1 -r 47253f294a9f main/buttons.c --- a/main/buttons.c Sun Jun 07 22:30:07 2020 +0200 +++ b/main/buttons.c Wed Jun 10 09:43:51 2020 +0200 @@ -577,12 +577,19 @@ * Data show and edit functions. */ -void ShowText(uint16_t x, uint16_t y, char *label, char *txt) +void ShowLabel(uint16_t x, uint16_t y, char *label) { _fg = TFT_LIGHTGREY; TFT_print(label, x, y); _fg = TFT_YELLOW; TFT_print((char *)" ", LASTX, LASTY); +} + + + +void ShowText(uint16_t x, uint16_t y, char *label, char *txt) +{ + ShowLabel(x, y, label); TFT_print(txt, LASTX, LASTY); } @@ -592,10 +599,8 @@ { char tmp[32]; - _fg = TFT_LIGHTGREY; - TFT_print(label, x, y); - _fg = TFT_YELLOW; - sprintf(tmp, " %d", val); + ShowLabel(x, y, label); + sprintf(tmp, "%d", val); TFT_print(tmp, LASTX, LASTY); if (suffix) { _fg = TFT_LIGHTGREY; @@ -607,22 +612,18 @@ void ShowBool(uint16_t x, uint16_t y, char *label, bool val) { - _fg = TFT_LIGHTGREY; - TFT_print(label, x, y); - _fg = TFT_YELLOW; + ShowLabel(x, y, label); if (val) - TFT_print((char *)" J", LASTX, LASTY); + TFT_print((char *)"J", LASTX, LASTY); else - TFT_print((char *)" N", LASTX, LASTY); + TFT_print((char *)"N", LASTX, LASTY); } void ShowSSR2(uint16_t x, uint16_t y, int val) { - _fg = TFT_LIGHTGREY; - TFT_print((char *)"SSR2 ", x, y); - _fg = TFT_YELLOW; + ShowLabel(x, y, (char *)"SSR2"); TFT_clearStringRect(TFT_X, TFT_Y, (char *)"HLT en MLT"); TFT_print((char *)SSR2Types[val], LASTX, LASTY); } @@ -633,10 +634,8 @@ { char tmp[32]; - _fg = TFT_LIGHTGREY; - TFT_print(label, x, y); - _fg = TFT_YELLOW; - sprintf(tmp, " %.*f", decimals, val); + ShowLabel(x, y, label); + sprintf(tmp, "%.*f", decimals, val); TFT_print(tmp, LASTX, LASTY); if (suffix) { _fg = TFT_LIGHTGREY; @@ -650,10 +649,8 @@ { char tmp[32]; - _fg = TFT_LIGHTGREY; - TFT_print(label, x, y); - _fg = TFT_YELLOW; - sprintf(tmp, " %.*f", decimals, val); + ShowLabel(x, y, label); + sprintf(tmp, "%.*f", decimals, val); TFT_print(tmp, LASTX, LASTY); if (suffix) { _fg = TFT_LIGHTGREY; @@ -663,14 +660,21 @@ +void EditerTop(char *label) +{ + _bg = TFT_BLACK; + TFT_fillScreen(_bg); + TFT_resetclipwin(); + TopMessage(label); +} + + + void Editer(char *label, char *txt, char *errmsg, int len, int type) { int key; - _bg = TFT_BLACK; - TFT_fillScreen(_bg); - TFT_resetclipwin(); - TopMessage((char *)"Wijzigen"); + EditerTop((char *)"Wijzigen"); _fg = TFT_LIGHTGREY; TFT_setFont(DEFAULT_FONT, NULL); TFT_print(label, 2, 28); @@ -892,10 +896,7 @@ bool loop = true, value = *val; int curpos; - _bg = TFT_BLACK; - TFT_fillScreen(_bg); - TFT_resetclipwin(); - TopMessage((char *)"Wijzigen"); + EditerTop((char *)"Wijzigen"); _fg = TFT_LIGHTGREY; TFT_setFont(DEFAULT_FONT, NULL); TFT_print(label, 2, 28); @@ -939,10 +940,7 @@ int value = *val; int key; - _bg = TFT_BLACK; - TFT_fillScreen(_bg); - TFT_resetclipwin(); - TopMessage((char *)"Wijzigen"); + EditerTop((char *)"Wijzigen"); Buttons_Clear(); Buttons_Add( 20, 60,120, 40, (char *)SSR2Types[0], 0); @@ -978,10 +976,7 @@ int value = (int)*val; int key; - _bg = TFT_BLACK; - TFT_fillScreen(_bg); - TFT_resetclipwin(); - TopMessage((char *)"Wijzigen"); + EditerTop((char *)"Wijzigen"); Buttons_Clear(); Buttons_Add( 80, 40,160, 40, (char *)mashTypes[0], 0); @@ -1016,8 +1011,7 @@ int rc = false; bool loop = true; - TFT_fillScreen(TFT_BLACK); - TopMessage(top); + EditerTop(top); Buttons_Clear(); Buttons_Add( 40, 100, 80, 40, ack, 0); Buttons_Add(200, 100, 80, 40, nak, 1);