瀏覽代碼

Some fixes in main and stripe

Philipp Hinz 8 年之前
父節點
當前提交
1754d0c769
共有 4 個文件被更改,包括 24 次插入19 次删除
  1. 1 1
      CoffeeCode/buildno
  2. 17 16
      CoffeeCode/main.cpp
  3. 5 1
      CoffeeCode/stripe.cpp
  4. 1 1
      CoffeeCode/stripe.h

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-55
+59

+ 17 - 16
CoffeeCode/main.cpp

@@ -34,7 +34,6 @@ int verbose = 0;
 bool optDate = false;
 bool optPower = false;
 
-
 void *mainLoop(void *threadid);
 void terminationHandler(int signum);
 void usr1Handler(int signum);
@@ -52,7 +51,7 @@ int main(int argc, char *argv[]) {
 	int opt;
 	int prev_ind;
 
-	logger(V_NONE, LOG_INFO, "CoffeePi by Philipp Hinz - "
+	logger(V_NONE, LOG_INFO, "CoffeePi by Philipp Hinz and Sebastian Vendt - "
 			"Build number %d\n", buildno);
 
 	// Argument handling
@@ -116,6 +115,15 @@ int main(int argc, char *argv[]) {
 		return 1;
 	}
 
+	logger_reset();
+	initTimers();
+	lcd = lcdInit();
+	if (lcd < 0)
+		logger_error("Error: unable to init LCD (%d)\n", lcd);
+	lcdClear(lcd);
+	lcdHome(lcd);
+	lcdPrintf(lcd, "    CoffeePi   ", buildno);
+
 	// http://www.tutorialspoint.com/cplusplus/cpp_multithreading.htm
 
 	// Initialize and set thread joinable
@@ -137,19 +145,12 @@ int main(int argc, char *argv[]) {
 		else if (i == THREAD_COFFEE)
 			rc = pthread_create(&thread[i], NULL, coffeeThread, (void *) i);
 		if (rc) {
-			logger_error("Error:unable to create thread, %d\n", rc);
+			logger_error("Error:unable to create thread %d (%d)\n", i, rc);
 			exit(-1);
 		}
 	}
 
-	logger_reset();
-	initTimers();
 	halInit();
-	lcd = lcdInit();
-	if (lcd < 0) logger_error("Error: unable to init LCD (%d)\n", lcd);
-	lcdClear(lcd);
-	lcdHome(lcd);
-	lcdPrintf(lcd,"    CoffeePi   ", buildno);
 
 	// free attribute and wait for the other threads
 	pthread_attr_destroy(&attr);
@@ -160,7 +161,6 @@ int main(int argc, char *argv[]) {
 
 	sleep(2);
 
-
 	rc = pthread_join(thread[0], &status);
 	if (rc) {
 		logger_error("Error:unable to join, %d\n", rc);
@@ -243,11 +243,12 @@ void *mainLoop(void *threadid) {
  * Temporary timer for displaying the current time
  */
 void timeHandler(void) {
-    time_t rawtime;
-    struct tm * timeinfo;
+	time_t rawtime;
+	struct tm * timeinfo;
 
-    time ( &rawtime );
-    timeinfo = localtime ( &rawtime );
+	time(&rawtime);
+	timeinfo = localtime(&rawtime);
 	lcdPosition(lcd, 0, 1);
-	lcdPrintf(lcd, "    %.2d:%.2d:%.2d    ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
+	lcdPrintf(lcd, "    %.2d:%.2d:%.2d    ", timeinfo->tm_hour,
+			timeinfo->tm_min, timeinfo->tm_sec);
 }

+ 5 - 1
CoffeeCode/stripe.cpp

@@ -51,9 +51,12 @@ void *stripeThread(void *threadid) {
 
 	stripe_color col;
 	col.red = 255;
-	//stripeEffectPulse(col);
+	col.green = 0;
+	col.blue = 0;
+	stripeEffectPulse(col);
 	int tmp = 0, inc = 1;
 	while (1) {
+		pause();
 		stripeEffectHeating(tmp);
 		logger(V_NONE, LOG_ERRORC, "Simulating %d%% percent heating\n", tmp);
 		sleep(1);
@@ -271,3 +274,4 @@ void stripeEffectPulse(stripe_color color) {
 	stripeTimer.setDivider(40);
 	stripeTimer.start();
 }
+

+ 1 - 1
CoffeeCode/stripe.h

@@ -26,7 +26,7 @@
 typedef enum {
 	TRANS_DIRECT = 0,
 	TRANS_FAST = 6,
-	TRANS_MEDIUM = 35,
+	TRANS_MEDIUM = 33,
 	TRANS_SLOW = 200
 } stripe_transient_t;