Dual CANbus monitor and instrumentation cluster
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary by
Diff: main.cpp
- Revision:
- 54:6ce808d0995e
- Parent:
- 51:6187c5264a73
- Child:
- 55:591406a71fa8
--- a/main.cpp Sun Apr 07 17:11:28 2013 +0000 +++ b/main.cpp Tue Apr 09 06:16:26 2013 +0000 @@ -47,6 +47,8 @@ bool logEn = false, logOpen = false; bool yesBattLog = false ; // gg - Batt Log +unsigned char tNavRow = 3 ; // gg - 4x4 touch + FILE *cfile; FILE *file; char fileName[35] = "" ; @@ -155,7 +157,12 @@ t = *localtime(&seconds) ; strftime(sTemp, 32, "%a %m/%d/%Y %X\n", &t); logMsg(sTemp); - sprintf(sTemp,"CANary firmware rev51\n"); + + // revisions + // sprintf(sTemp,"CANary firmware rev51-gg1\n"); // gg - shows 4x4 buttons, + // but the touch areas are still 3x3 + //sprintf(sTemp,"CANary firmware rev51-gg2\n"); // gg - decodes 4x4 button touches, + sprintf(sTemp,"CANary firmware rev51-gg3\n"); // gg - cleaned 4x4 button and touches, logMsg(sTemp); // Look for new binary on thumbdrive @@ -342,6 +349,12 @@ //logMsg(sTemp); touched = false; // clear interrupt flag } + //--------------- + // gg - 4x4 touch + unsigned char tScrn = 0 ; // screen 0 + unsigned char tCol ; + unsigned char tRow ; + if (!userIdle) { if (secsNoTouch<2) {// Recently touched secsNoTouch +=2; // increment to prevent double touch @@ -352,9 +365,20 @@ case 0: // no select break; case 1: // select screen - switch (buttonX(lastTouch.x,3)*10+buttonY(lastTouch.y,3)) { - case 00: - case 30: + // is this col(0:2)*10 + row(0:2) + screen(0:1)*30 + //switch (buttonX(lastTouch.x,3)*10+buttonY(lastTouch.y,3)) { + + //-------------- + // gg - 4x4 touch + tCol = buttonX(lastTouch.x,4) ; + if( tCol >= 4 ){ tCol -= 4; tScrn = 1 ; } // touch is on screen 1 + + tRow = buttonY(lastTouch.y,4) ; + if( tRow == tNavRow ) tRow = 7 ; + + switch ( (tCol*10) + tRow ) { + //--------------------------------- + case 00: // 00 on screen 0 or 1 if (dMode[whichTouched]==monitorScreen||dMode[whichTouched]==changedScreen) { indexOffset=indexOffset>4?indexOffset-4:1; } else if (dMode[whichTouched]==config1Screen) { @@ -369,8 +393,8 @@ } } break; - case 10: - case 40: + //----------------------------------------------- + case 10: // 1,0 (col,row) on screen 0 or 1 if (dMode[whichTouched]==changedScreen) { for(j=0;j<100;j++) msgChanged[j]=0; // clear changed data lastDMode[whichTouched]=99;//force refresh @@ -391,8 +415,8 @@ } } break; - case 20: - case 50: + //-------------------------------------- + case 20: // col 2 and row 0 on either screen 0 or 1 if (dMode[whichTouched]==monitorScreen||dMode[whichTouched]==changedScreen) { indexOffset=indexOffset<77?indexOffset+4:80; } else if (dMode[whichTouched]==config1Screen) { @@ -410,8 +434,9 @@ } } break; - case 01: - case 31: // row 2 left + //---------------------------------- + //---------------------------------- + case 01: // col 0 row 1 if (dMode[whichTouched]==config1Screen) { logEn = !logEn; if (!logEn) repeatPoll=false; // disable auto polling, too @@ -420,8 +445,8 @@ lastDMode[whichTouched]=99; } break; + //------------------------------ case 11: - case 41: // row 2 center if (dMode[whichTouched]==config1Screen){ repeatPoll = !repeatPoll&&logEn; if (repeatPoll) { @@ -467,8 +492,8 @@ lastDMode[whichTouched]=99; } break; - case 21: - case 51: // row 2 right button + //--------------------------------- + case 21: // col 2 row 1 if (dMode[whichTouched]==config1Screen) { // gg - Batt Log Enable Button yesBattLog = !yesBattLog; @@ -477,20 +502,32 @@ lastDMode[whichTouched]=99; } break; - case 02: - case 32: + + //----------------------------------- + //----------------------------------- + // Prev Navigation + case 07: // col 0 row tNavRow dMode[whichTouched]=dMode[whichTouched]>0?dMode[whichTouched]-1:maxScreens; break; - case 12: - case 42: + //----------------------------------- + // Select Screen Navigation + case 17: //secsNoTouch = userTimeout; // immediately exit config mode sMode=0; lastDMode[whichTouched]=99; // Repaint break; - case 22: - case 52: + //----------------------------------- + // Index Navigation + case 27: // col 2 row tNavRow + dMode[whichTouched]= mainScreen; // indexScreen ; // gg - index + break; + //------------------------------------ + // Next Navigation + case 37: // lower right on Nav Line gg - move next dMode[whichTouched]=dMode[whichTouched]<maxScreens?dMode[whichTouched]+1:0; break; + //------------------------------------ + //------------------------------------ default: break; }