Sebastian Vendt 5 лет назад
Родитель
Сommit
239dc580e6
6 измененных файлов с 24 добавлено и 9 удалено
  1. 1 1
      CoffeeCode/buildno
  2. 4 0
      CoffeeCode/coffee.cpp
  3. 10 6
      CoffeeCode/display2.cpp
  4. 5 1
      CoffeeCode/hal.cpp
  5. 1 1
      CoffeeCode/logger.cpp
  6. 3 0
      CoffeeCode/main.cpp

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-346
+358

+ 4 - 0
CoffeeCode/coffee.cpp

@@ -69,6 +69,10 @@ void *coffeeThread(void *threadid) {
 	menuTimer.stop();
 	menuTimeout = 0;
 
+	brewTimer.setDivider(2);
+	brewTimer.stop();
+	brewTime = 0;
+
 	initalHeating = true;
 	mode = MODE_STATE; //Unless we enter the menu we start in state mode
 	page = PAGE_SOFTOFF;

+ 10 - 6
CoffeeCode/display2.cpp

@@ -1,8 +1,9 @@
 /*
- * display.cpp
+ * display2.cpp
  *
  *  Created on: Sep 26, 2017
- *      Author: Philipp Hinz
+ *  Updated:
+ *      Author: Philipp Hinz/Sebastian Vendt
  */
 #include <stdlib.h>
 #include <pthread.h>
@@ -307,6 +308,7 @@ void displayTerminate(event_t *e) {
 void* displayThread(void* threadid) {
 	//sleep(1); // Wait for other components to initialize
 	displayTimer.start();
+	logger(V_BASIC, "Initialized display Thread. Timer state: %d \n", displayTimer.isActive());
 	while (1) {
 		pause();
 		if (1) {
@@ -367,10 +369,10 @@ void displayInit(void) {
 	//lcdPrintf(lcd, "    CoffeePi       booting...");
 
 
-	setRefreshRate(refresh_std);
+	//setRefreshRate(refresh_std);
+	currentRefreshRate = refresh_std;
+	displayTimer.setDivider(20 / refresh_std);
 
-	logger(V_BASIC, "display2.cpp Initialized display with a refresh rate of %d Hz\n",
-			refresh_std);
 	/**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
@@ -386,6 +388,9 @@ void displayInit(void) {
 	event_subscribe("pagechange", &displayPageUpdated);
 	event_subscribe("terminate", &displayTerminate);
 	event_subscribe("descaling", &displayDescaling);
+
+	logger(V_BASIC, "display2.cpp Initialized display with a refresh rate of %d Hz\n",
+				refresh_std);
 }
 
 /**
@@ -464,7 +469,6 @@ void setSwitchToNextTimeout(idx_t idx, uint16_t millis) {
 void displayRefresh(void) {
 	//handle mode trainsitions
 	switchToNextMode(coffeeMode);
-
 	//FSM of the display
 	if (coffeeMode[CURRENT] == MODE_STATE) {
 		//handle state transitions

+ 5 - 1
CoffeeCode/hal.cpp

@@ -126,7 +126,6 @@ void halInit(void) {
 	Int1Time = 0;
 
 	flowResetTimer.setDivider(20); //1000ms
-
 	flowTimer.setDivider(4); // 100ms
 
 	flagIgnoreRlsInt0 = false;
@@ -166,6 +165,7 @@ void halInit(void) {
 		//pthread_exit(EXIT_SUCCESS);
 		exit(EXIT_FAILURE);
 	}
+	logger(V_BASIC, "hal.cpp Initialized hal\n");
 }
 
 /**
@@ -432,6 +432,8 @@ double halgetHeatingTime(void){
 	//TODO check return value on negative times
 	//TODO move the tracking of the heating time into hal.cpp and fix issue of wrong tracking -> inital pressure close is not
 	//recognized and so heatingCycle has no time
+	//quickfix:
+	return 0;
 	if (halIsHeating()) {
 		logger(V_HAL, "Hot Heating Time: %f\n", difftime(time(NULL), heatingCycle[0]));
 		return difftime(time(0), heatingCycle[0]);
@@ -710,9 +712,11 @@ void halTerminate(event_t *event){
  * writing back non volatile variables of the hal to the database: SweepCounter
  */
 void halWriteBackCache(){
+	/*
 	if (sqlSetConf(CFGSweepCounter, logcycle)) {
 		logger_error("hal.cpp: Couldn't write logcycle to database");
 		return;
 	}
 	logger(V_BREW, "Writing back logcycle %d\n", logcycle);
+	*/
 }

+ 1 - 1
CoffeeCode/logger.cpp

@@ -12,7 +12,7 @@
 #include "logger.h"
 
 int lastlog = 0;
-
+//TODO print to stdout and to file
 /**
  * Prints a timestamp
  * @param stream target stream (stdout, stderr)

+ 3 - 0
CoffeeCode/main.cpp

@@ -133,9 +133,12 @@ int main(int argc, char *argv[]) {
 	DS18B20_init();
 	openhabInit();
 
+
+
 	// http://www.tutorialspoint.com/cplusplus/cpp_multithreading.htm
 
 	// Initialize and set thread joinable
+	logger(V_BASIC, "main.cpp creating threads...\n");
 	pthread_attr_init(&attr);
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 	rc = pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP);