main/buttons.c

changeset 19
49e2960d4642
parent 1
ad2c8b13eb88
child 38
537ffe280775
--- a/main/buttons.c	Fri Oct 26 13:29:14 2018 +0200
+++ b/main/buttons.c	Fri Oct 26 21:23:46 2018 +0200
@@ -13,6 +13,9 @@
 extern uint16_t			VNC_pointer_x;		///< Mouse coordinate X
 extern uint16_t			VNC_pointer_y;		///< Mouse coordinate Y
 
+const char 			*mashTypes[] = { "Infusion", "Temperature", "Decoction" };
+const char			*SSR2Types[] = { "Uit", "HLT of MLT", "HLT en MLT", "Idle" };
+
 
 #define	EDIT_TYPE_TEXT		0			///< Editor type is text
 #define	EDIT_TYPE_INT		1			///< Editor type is integer
@@ -55,7 +58,7 @@
     Buttons[order].w = w;
     Buttons[order].h = h;
     strncpy(Buttons[order].text, txt, 11);
-    Buttons[order].dark = Buttons[order].small = false;
+    Buttons[order].dark = Buttons[order].small = Buttons[order].lock = false;
 }
 
 
@@ -610,23 +613,9 @@
 {
     _fg = TFT_LIGHTGREY;
     TFT_print("SSR2 ", x, y);
-   _fg = TFT_YELLOW;
-   TFT_clearStringRect(TFT_X, TFT_Y, "HLT en MLT");
-
-   switch (val) {
-	case SSR2_OFF:		TFT_print("Uit", LASTX, LASTY);
-				break;
-	case SSR2_HLT_SHARE:	TFT_print("HLT of MLT", LASTX, LASTY);
-				break;
-
-	case SSR2_HLT_IND:	TFT_print("HLT en MLT", LASTX, LASTY);
-				break;
-
-	case SSR2_ON_IDLE:	TFT_print("Idle", LASTX, LASTY);
-				break;
-
-	default:		TFT_print("N/A", LASTX, LASTY);
-   }
+    _fg = TFT_YELLOW;
+    TFT_clearStringRect(TFT_X, TFT_Y, "HLT en MLT");
+    TFT_print((char *)SSR2Types[val], LASTX, LASTY);
 }
 
 
@@ -945,24 +934,25 @@
     TFT_fillScreen(_bg);
     TFT_resetclipwin();
     TopMessage("Wijzigen");
-    TFT_setFont(DEFAULT_FONT, NULL);
-    ShowSSR2(2, 28, value);
 
     Buttons_Clear();
-    Buttons_Add( 20,  60,120, 40, "Uit", 0);
-    Buttons_Add(180,  60,120, 40, "HLT of MLT",  1);
-    Buttons_Add( 20, 130,120, 40, "HLT en MLT",  2);
-    Buttons_Add(180, 130,120, 40, "Idle",  3);
+    Buttons_Add( 20,  60,120, 40, (char *)SSR2Types[0], 0);
+    Buttons_Add(180,  60,120, 40, (char *)SSR2Types[1], 1);
+    Buttons_Add( 20, 130,120, 40, (char *)SSR2Types[2], 2);
+    Buttons_Add(180, 130,120, 40, (char *)SSR2Types[3], 3);
     Buttons_Add(120, 200, 80, 40, "Ok",  4);
+    Buttons[4].dark = true;
+    Buttons[value].lock = true;
     Buttons_Show();
 
     while (loop) {
 	key = Buttons_Scan();
 
 	if (key >= 0 && key <= 3) {
+	    Buttons[value].lock = false;
 	    value = key;
-	    TFT_setFont(DEFAULT_FONT, NULL);
-	    ShowSSR2(2, 28, value);
+	    Buttons[value].lock = true;
+	    Buttons_Show();
 	} else if (key == 4) {
 	    loop = false;
 	}
@@ -973,6 +963,45 @@
 
 
 
+void EditMashType(uint8_t *val)
+{
+    bool        loop = true;
+    int		value = (int)*val;
+    int         key;
+
+    _bg = TFT_BLACK;
+    TFT_fillScreen(_bg);
+    TFT_resetclipwin();
+    TopMessage("Wijzigen");
+
+    Buttons_Clear();
+    Buttons_Add( 80,  40,160, 40, (char *)mashTypes[0], 0);
+    Buttons_Add( 80,  90,160, 40, (char *)mashTypes[1], 1);
+    Buttons_Add( 80, 140,160, 40, (char *)mashTypes[2], 2);
+    Buttons_Add(120, 200, 80, 40, "Ok",  3);
+    Buttons[3].dark = true;
+    Buttons[value].lock = true;
+    Buttons_Show();
+
+    while (loop) {
+	key = Buttons_Scan();
+
+	if (key >= 0 && key <= 2) {
+	    Buttons[value].lock = false;
+	    value = key;
+	    Buttons[value].lock = true;
+	    Buttons_Show();
+	} else if (key == 3) {
+	    loop = false;
+	}
+	vTaskDelay(20 / portTICK_PERIOD_MS);
+    }
+    Buttons[value].lock = false;
+    *val = (uint8_t)value;
+}
+
+
+
 int Confirm(char *top, char *ack, char *nak)
 {
     int		rc = false;

mercurial