Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller
Dependencies: SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed
Fork of CANary by
Diff: main.cpp
- Revision:
- 25:ddf0ec209f03
- Parent:
- 23:cd03f9c3395e
- Child:
- 26:462ccb580472
--- a/main.cpp Thu Mar 14 05:02:15 2013 +0000 +++ b/main.cpp Fri Mar 15 04:28:34 2013 +0000 @@ -63,9 +63,10 @@ volatile bool userIdle; bool touched=0; //flag to read touchscreen char counter = 0; -unsigned char dMode[2] = {1,8}; //display mode +unsigned char dMode[2] = {dteScreen,brakeScreen}; //display mode unsigned char sMode = 0; // setup mode unsigned char lastDMode[2] = {0,0}; //last screen mode +unsigned char dtMode = 6; char displayLog[20][40]; unsigned char displayLoc = 0; unsigned char indexOffset = 1; @@ -107,7 +108,7 @@ secsNoTouch = 0; // is it a date before 2012 ? - if ((t.tm_year + 1900) < 2012 ) { + /*if ((t.tm_year + 1900) < 2012 ) { // before 2012, so the RTC probably lost power // So, set a near-recent date in 2012 // enter people-values here @@ -129,7 +130,7 @@ // printf("Set RTC to:\n" ); // strftime(sTemp, 32, "%a %m/%d/%Y %X", localtime(&seconds)); // printf("%s\n", sTemp); // DAY MM/DD/YYYY HH:MM:SS - } + }*/ t = *localtime(&seconds) ; strftime(sTemp, 32, "%a %m/%d/%Y %X\n", &t); logMsg(sTemp); @@ -218,15 +219,15 @@ } // if > 1/16 full, canbus has stopped, or PB1 pressed } // if logOpen if (canIdle&&userIdle) { // canbus idle --> sleep to save power - if (logOpen){ + if (logOpen){ fclose(file); } // if (logOpen)*/ seconds = time(NULL); t = *localtime(&seconds) ; strftime(sTemp, 40, "Sleeping: %a %m/%d/%Y %X\n", &t); logMsg(sTemp); - //updateDisplay(0); //Added for turbo3 who has a display override and wants to see the sleep message before going to sleep - //updateDisplay(1); + updateDisplay(0); //Added for turbo3 who has a display override and wants to see the sleep message before going to sleep + updateDisplay(1); //LPC_RTC->CIIR=0x00; // block RTC interrupts led1=0; led2=0; @@ -241,6 +242,7 @@ Sleep(); //DeepPowerDown(); } + secsNoTouch=0; canIdle=secsNoMsg>canTimeout; userIdle=secsNoTouch>userTimeout; dled=0.8; // turn on display LED @@ -289,7 +291,7 @@ case 30: if (dMode[i]==monitorScreen||dMode[i]==changedScreen) { indexOffset=indexOffset>4?indexOffset-4:1; - } else if (dMode[i]==configScreen) { + } else if (dMode[i]==config1Screen) { wait_ms(500); tt.calibrate(); } @@ -301,7 +303,7 @@ lastDMode[i]=99;//force refresh } else if (dMode[i]==cpScreen) { pollCP=true; - } else if (dMode[i]==configScreen) { + } else if (dMode[i]==config1Screen) { mbed_reset(); } break; @@ -309,23 +311,34 @@ case 50: if (dMode[i]==monitorScreen||dMode[i]==changedScreen) { indexOffset=indexOffset<77?indexOffset+4:80; - } else if (dMode[i]==configScreen) { + } else if (dMode[i]==config1Screen) { sprintf(sTemp,"Saving config file.\n"); logMsg(sTemp); - //zxcsaveConfig(); + saveConfig(); } break; case 01: case 31: - if (dMode[i]==configScreen) { + if (dMode[i]==config1Screen) { logEn = !logEn; + } else if (dMode[i]==config2Screen){ + dtMode=(dtMode<6)?dtMode+1:0; + lastDMode[i]=99; } break; case 11: case 41: + if (dMode[i]==config2Screen){ + upDate(dtMode,true); + lastDMode[i]=99; + } break; case 21: case 51: + if (dMode[i]==config2Screen){ + upDate(dtMode,false); + lastDMode[i]=99; + } break; case 02: case 32: @@ -334,14 +347,15 @@ case 12: case 42: secsNoTouch = userTimeout; // immediately exit config mode - if (dMode[i]==configScreen) mbed_reset(); + if (dMode[i]==config1Screen) mbed_reset(); break; case 22: case 52: dMode[i]=dMode[i]<maxScreens?dMode[i]+1:0; break; default: - } + break; + } break; case 2: // numpad break; @@ -368,6 +382,11 @@ showCP=true; } display=display<1?display+1:0; // toggle display + //spkr.beep(1000,0.2); + //wait(0.25); updateDisplay(display); + //updateDisplay(1); + //spkr.beep(2000,0.2); + //wait(0.25); } //while (true) } \ No newline at end of file