|
@@ -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);
|
|
|
}
|