Sebastian 7 роки тому
батько
коміт
91c334a15c
4 змінених файлів з 24 додано та 17 видалено
  1. 0 1
      CoffeeCode/DS18B20.cpp
  2. 3 2
      CoffeeCode/coffee.cpp
  3. 20 13
      CoffeeCode/display.cpp
  4. 1 1
      CoffeeCode/hal.cpp

+ 0 - 1
CoffeeCode/DS18B20.cpp

@@ -67,7 +67,6 @@ void DS18B20_cmd(uint8_t cmd) {
  * Reads the Temperature of the DS18B20 Sensor
  * It rounds the value read from the Sensor rounded to the next integer
  */
-
 int8_t DS18B20_readTemp (void){
 	DS18B20_cmd(CONVERT_T);
 	while(!OW_readBit()){

+ 3 - 2
CoffeeCode/coffee.cpp

@@ -205,7 +205,7 @@ void *coffeeThread(void *threadid) {
 				break;
 			}
 			break;
-
+		//TODO: Add page heating time in minutes and Wh
 		case PAGE_STATS:
 			if (SigValueEmpty() && mode == MODE_MENU)
 				pause();
@@ -216,7 +216,7 @@ void *coffeeThread(void *threadid) {
 				break;
 			}
 			break;
-
+		//TODO: Add page when next descaling is necessary
 		case PAGE_EXIT:
 			if (SigValueEmpty() && mode == MODE_MENU)
 				pause();
@@ -739,6 +739,7 @@ void coffeeBrew(void) {
 	}
 	stopBrewing();
 	return;
+	//TODO: I want to see the total elapes brewing time!!
 }
 
 /*

+ 20 - 13
CoffeeCode/display.cpp

@@ -53,7 +53,10 @@ void displayPrintTime(int line) {
  * Prints out the current temperature in a centered position
  * @param line Target line in display
  */
-
+//TODO: the temperature is wrong(old value) the first time the page is opened
+//after the first refresh the right temperature is displayed
+//no idea where this comes from, datasheet says nothing about dummy readouts.
+//no old values are used, conversion is started before every readout...
 void displayPrintTemp(int line) {
 	if (line > DISPLAY_ROWS)
 		line = 0;
@@ -206,19 +209,8 @@ void displayTerminate(event_t *e) {
  */
 
 void* displayThread(void* threadid) {
-	//TODO: the display is loosing the first events here since it is waiting before it is subscribing
-	//its loosing the descaling event triggered at the beginning of coffee initialization
-	sleep(1); // Wait for other components to initialize
-	int tmp = sqlGetConf(CFGdisplaylang);
-	if (!tmp || tmp >= lang_last)
-		tmp = DEFAULT_LANG;
-	displaySetLang((display_lang_t) tmp);
+	//sleep(1); // Wait for other components to initialize
 	displayTimer.start();
-	event_subscribe("statechange", &displayStateUpdated);
-	event_subscribe("modechange", &displayModeUpdated);
-	event_subscribe("pagechange", &displayPageUpdated);
-	event_subscribe("terminate", &displayTerminate);
-	event_subscribe("descaling", &displayDescaling);
 	while (1) {
 		pause();
 		if (1) {
@@ -294,6 +286,21 @@ void displayInit(void) {
 
 	logger(V_BASIC, "Initialized display with a refresh rate of %d Hz\n",
 	REFRESH_RATE);
+	/**The following block comes from void* displayThread(void* threadid)
+	 * The idea is that the initialization functions get the component ready to react on external events
+	 * once the threads start, events might be triggered and every component can process them
+	 * This should fix the TO_DO where a descaling event was triggered during startup of the coffeethread and
+	 * the displaythread did not react to it since it hadn't subscribed to the event yet
+	 */
+	int tmp = sqlGetConf(CFGdisplaylang);
+	if (!tmp || tmp >= lang_last)
+		tmp = DEFAULT_LANG;
+	displaySetLang((display_lang_t) tmp);
+	event_subscribe("statechange", &displayStateUpdated);
+	event_subscribe("modechange", &displayModeUpdated);
+	event_subscribe("pagechange", &displayPageUpdated);
+	event_subscribe("terminate", &displayTerminate);
+	event_subscribe("descaling", &displayDescaling);
 }
 
 /**

+ 1 - 1
CoffeeCode/hal.cpp

@@ -273,7 +273,7 @@ void halIntPressure(void) {
 /**
  * Function to read the heating time in sec
  * If called during a heating process, it returns the time elapsed since the heating started
- * If called after a heating process, it returns the total time elapes during the heating cycle
+ * If called after a heating process, it returns the total time elapsed during the heating cycle
  */
 double halgetHeatingTime(void){
 	if (halIsHeating()) {