Parcourir la source

adding settings pages

Sebastian Vendt il y a 5 ans
Parent
commit
1bd5258023
5 fichiers modifiés avec 237 ajouts et 10 suppressions
  1. 1 1
      CoffeeCode/buildno
  2. 148 8
      CoffeeCode/coffee.cpp
  3. 9 0
      CoffeeCode/coffee.h
  4. 28 0
      CoffeeCode/display2.cpp
  5. 51 1
      CoffeeCode/display2.h

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-367
+369

+ 148 - 8
CoffeeCode/coffee.cpp

@@ -40,10 +40,39 @@ bool descaling; //flag to indicate descaling and cleaning
 uint16_t descBrewcount;
 time_t descRawTimestamp;
 
-const char* PageName[] = { "SoftOff", "Kill", "Stats", "Stats2", "Descaling", "Temp", "Clean", "Restart",
-		"Exit" };
-const char* StateName[] = { "OFF", "HEATING", "INITHEAT", "IDLE", "BREW",
-		"BREWMAN", "CLEAN", "ERROR", "WAITOFF" };
+const char* PageName[] = {
+		"SOFTOFF",
+		"KILL",
+		"STATS",
+		"STATS2",
+		"DESCALING",
+		"TEMP",
+		"CLEAN",
+		"RESTART",
+		"SETTINGS",
+		"RESETKWH",
+		"CHANGEPREINF",
+		"CHANGEBREWTIME",
+		"CHANGEBREWML",
+		"CHANGESOAKTIME",
+		"LEAVESETTINGS",
+		"Exit",
+		"PAGE_NULL"
+};
+
+const char* StateName[] = {
+		"OFF",
+		"HEATING",
+		"INITHEAT",
+		"IDLE",
+		"BREW",
+		"BREWMAN",
+		"CLEAN",
+		"ERROR",
+		"WAITOFF",
+		"FULLTANK",
+		"STATE_NULL",
+};
 
 /**
  * Thread for the finite state machine
@@ -119,9 +148,8 @@ void *coffeeThread(void *threadid) {
 	logger(V_BREW, "Starting Coffee FSM\n");
 	//begin FSM
 	while (1) {
-
 		/*
-		 * Menue FSM
+		 * Menu FSM
 		 */
 		switch (page) {
 		case PAGE_NULL:
@@ -277,7 +305,7 @@ void *coffeeThread(void *threadid) {
 
 			switch (getSigValue(MODE_MENU)) {
 			case SigRotCW:
-				changePage(PAGE_EXIT);
+				changePage(PAGE_SETTINGS);
 				break;
 
 			case SigRotCCW:
@@ -285,6 +313,118 @@ void *coffeeThread(void *threadid) {
 				break;
 			}
 			break;
+		case PAGE_SETTINGS:
+			if (SigValueEmpty() && mode == MODE_MENU)
+				pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+				changePage(PAGE_RESETKWH);
+				break;
+			case SigRotCW:
+				changePage(PAGE_EXIT);
+				break;
+			case SigRotCCW:
+				changePage(PAGE_DESCALING);
+				break;
+			}
+			break;
+		case PAGE_RESETKWH:
+			if (SigValueEmpty() && mode == MODE_MENU)
+				pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+
+				break;
+			case SigRotCW:
+				changePage(PAGE_CHANGEPREINF);
+				break;
+			case SigRotCCW:
+				changePage(PAGE_LEAVESETTINGS);
+				break;
+			}
+			break;
+		case PAGE_CHANGEPREINF:
+			if (SigValueEmpty() && mode == MODE_MENU)
+			    pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+
+			    break;
+			case SigRotCW:
+			    changePage(PAGE_CHANGEBREWTIME);
+			    break;
+			case SigRotCCW:
+			    changePage(PAGE_RESETKWH);
+			    break;
+			}
+			break;
+		case PAGE_CHANGEBREWTIME:
+			if (SigValueEmpty() && mode == MODE_MENU)
+			    pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+
+			    break;
+			case SigRotCW:
+				changePage(PAGE_CHANGEBREWML);
+			    break;
+			case SigRotCCW:
+				changePage(PAGE_CHANGEPREINF);
+			    break;
+			}
+			break;
+		case PAGE_CHANGEBREWML:
+			if (SigValueEmpty() && mode == MODE_MENU)
+			    pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+
+			    break;
+			case SigRotCW:
+				changePage(PAGE_CHANGESOAKTIME);
+			    break;
+			case SigRotCCW:
+				changePage(PAGE_CHANGEBREWTIME);
+			    break;
+			}
+			break;
+		case PAGE_CHANGESOAKTIME:
+			if (SigValueEmpty() && mode == MODE_MENU)
+			    pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+
+			    break;
+			case SigRotCW:
+				changePage(PAGE_LEAVESETTINGS);
+			    break;
+			case SigRotCCW:
+				changePage(PAGE_CHANGEBREWML);
+			    break;
+			}
+			break;
+		case PAGE_LEAVESETTINGS:
+			if (SigValueEmpty() && mode == MODE_MENU)
+				pause();
+
+			switch (getSigValue(MODE_MENU)) {
+			case SigInt0Rls:
+				changePage(PAGE_SETTINGS);
+				break;
+			case SigRotCW:
+				changePage(PAGE_RESETKWH);
+				break;
+			case SigRotCCW:
+				changePage(PAGE_CHANGESOAKTIME);
+				break;
+			}
+			break;
 		case PAGE_EXIT:
 			if (SigValueEmpty() && mode == MODE_MENU)
 				pause();
@@ -305,7 +445,7 @@ void *coffeeThread(void *threadid) {
 				break;
 
 			case SigRotCCW:
-				changePage(PAGE_DESCALING);
+				changePage(PAGE_SETTINGS);
 				break;
 			}
 			break;

+ 9 - 0
CoffeeCode/coffee.h

@@ -24,6 +24,7 @@ typedef enum {
 	STATE_WAIT_OFF,
 	STATE_FULLTANK,
 	STATE_NULL
+	//Entering new States? Don't forget to update statenames in coffee.cpp!
 } coffee_status_t;
 
 typedef enum {
@@ -41,8 +42,16 @@ typedef enum {
 	PAGE_TEMP,
 	PAGE_CLEAN,
 	PAGE_RESTART,
+	PAGE_SETTINGS,
+	PAGE_RESETKWH,
+	PAGE_CHANGEPREINF,
+	PAGE_CHANGEBREWTIME,
+	PAGE_CHANGEBREWML,
+	PAGE_CHANGESOAKTIME,
+	PAGE_LEAVESETTINGS,
 	PAGE_EXIT,
 	PAGE_NULL
+	//Entering new PAGES? Don't forget to update pagenames in coffee.cpp!
 } coffee_menuPage_t;
 
 extern const char* StateName[];

+ 28 - 0
CoffeeCode/display2.cpp

@@ -579,6 +579,34 @@ void displayRefresh(void) {
 			displayPrintLn(0, displayGetString(str_menu), true);
 			displayPrintLn(1, displayGetString(str_menu_exit), true);
 			break;
+		case PAGE_SETTINGS:
+			displayPrintLn(0, displayGetString(str_menu), true);
+			displayPrintLn(1, displayGetString(str_menu_settings), true);
+			break;
+		case PAGE_RESETKWH:
+			displayPrintLn(0, displayGetString(str_menu_settings), true);
+			displayPrintLn(1, displayGetString(str_menu_resetkwh), true);
+			break;
+		case PAGE_CHANGEPREINF:
+			displayPrintLn(0, displayGetString(str_menu_settings), true);
+			displayPrintLn(1, displayGetString(str_menu_changepreinf), true);
+			break;
+		case PAGE_CHANGEBREWTIME:
+			displayPrintLn(0, displayGetString(str_menu_settings), true);
+			displayPrintLn(1, displayGetString(str_menu_changebrewtime), true);
+			break;
+		case PAGE_CHANGEBREWML:
+			displayPrintLn(0, displayGetString(str_menu_settings), true);
+			displayPrintLn(1, displayGetString(str_menu_changebrewml), true);
+			break;
+		case PAGE_CHANGESOAKTIME:
+			displayPrintLn(0, displayGetString(str_menu_settings), true);
+			displayPrintLn(1, displayGetString(str_menu_changesoaktime), true);
+			break;
+		case PAGE_LEAVESETTINGS:
+			displayPrintLn(0, displayGetString(str_menu_settings), true);
+			displayPrintLn(1, displayGetString(str_menu_leavesettings), true);
+			break;
 		default:
 			displayPrintLn(0, displayGetString(str_menu), true);
 			displayPrintLn(1, "???", true);

+ 51 - 1
CoffeeCode/display2.h

@@ -61,6 +61,13 @@ typedef enum {
 	str_menu_clean,
 	str_menu_restart,
 	str_menu_exit,
+	str_menu_settings,
+	str_menu_resetkwh,
+	str_menu_changepreinf,
+	str_menu_changebrewtime,
+	str_menu_changebrewml,
+	str_menu_changesoaktime,
+	str_menu_leavesettings,
 	str_postBrew,
 	str_last
 } display_strings_t;
@@ -149,7 +156,8 @@ static const display_string_t display_strings[str_last] =
 						"Stats",
 						"Stats"
 				}
-		},{ // str_menu_stats2
+		},
+		{ // str_menu_stats2
 				{
 						"Energieverbrauch",
 						"Energy consumed"
@@ -185,6 +193,48 @@ static const display_string_t display_strings[str_last] =
 						"Leave menu"
 				}
 		},
+		{ // str_menu_settings
+				{
+						"Einstellungen",
+						"Settings"
+				}
+		},
+		{ // str_menu_resetkwh
+				{
+						"Reset kWh Zähler",
+						"Reset kWh"
+				}
+		},
+		{ // str_change_preinf
+		        {
+		                "Vorbrühmenge",
+		                "Preinfusion"
+		        }
+		},
+		{ // str_change_brewtime
+		        {
+		                "Extraktionszeit",
+		                "Brewing time"
+		        }
+		},
+		{ // str_changebrewml
+		        {
+		                "Menge Espresso",
+		                "Amount Dbl Espr"
+		        }
+		},
+		{ // str_changesoaktime
+		        {
+		                "Quellzeit",
+		                "Soak time"
+		        }
+		},
+		{ // str_leavesettings
+		        {
+		                "Verlassen",
+		                "Leave"
+		        }
+		},
 		{ // str_postBrew
 				{
 						"Qualitaet:",