Tick Tock / Mbed 2 deprecated CANary

Dependencies:   SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2_ILI9341 mbed

Fork of CANary_corrupt by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Wed Mar 20 13:57:00 2013 +0000
Parent:
33:a277743ebdeb
Child:
35:5acbd8a64a89
Commit message:
Added auto-dim

Changed in this revision

displayModes.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
utility.cpp Show annotated file Show diff for this revision Revisions of this file
utility.h Show annotated file Show diff for this revision Revisions of this file
--- a/displayModes.cpp	Tue Mar 19 04:43:43 2013 +0000
+++ b/displayModes.cpp	Wed Mar 20 13:57:00 2013 +0000
@@ -88,10 +88,9 @@
         tt.locate(10,200);
         printf("%4.1f kWh\n",(float)gids*0.08);
         tt.set_font((unsigned char*) SCProSB31x55);
-        //tt.set_font((unsigned char*) Neu42x35);
         tt.foreground(Green);
         tt.locate(60,96);
-        printf("%4.1f mi  \n",(float)(gids-5)*0.33); // Approx for now
+        printf("%4.1f mi  \n",(float)(gids-5)*0.31); // Approx for now
         lgids=gids;
     }
     if(force||SOC!=lSOC){
--- a/main.cpp	Tue Mar 19 04:43:43 2013 +0000
+++ b/main.cpp	Wed Mar 20 13:57:00 2013 +0000
@@ -80,7 +80,8 @@
 bool showCP = false;
 bool pollCP = false;
 bool repeatPoll = false;
-bool daylight = false;
+bool headlights = false;
+bool tick = false;
 
 int main() {
     int readPointer=0;
@@ -382,19 +383,23 @@
 
         display=display<1?display+1:0; // toggle display
         updateDisplay(display);
+
         if(pollCP){ // We do this inside main loop instead of ticker so CAN RX will not be blocked
             sendCPreq(); // send cellpair data request.
             wait_ms(16);
             sendTreq(); //send temperature request
             wait_ms(16);
+            showCP=true;
             pollCP=false;
-            showCP=true;
         }
-        if(daylight){
-            dled = 0.75;
-        }else{
-            dled = 0.1;
+        
+        if(tick){ // Executes once a second
+            if(!headlights){
+                dled = 0.75;
+            }else{
+                dled = 0.1;
+            }
+            tick=false;
         }
-
     } //while (true)
 }
\ No newline at end of file
--- a/utility.cpp	Tue Mar 19 04:43:43 2013 +0000
+++ b/utility.cpp	Wed Mar 20 13:57:00 2013 +0000
@@ -9,6 +9,7 @@
     canIdle=(++secsNoMsg>canTimeout)?true:false;
     userIdle=(++secsNoTouch>userTimeout)?true:false;
     LPC_RTC->ILR |= (1<<0); // clear interrupt to prepare for next
+    tick=true;
 }
 
 extern "C" void RTC_Init (void) {
@@ -73,8 +74,8 @@
         msgChanged[indexLastMsg[canRXmsg.id]]=changed;
     }
     lastMsg[indexLastMsg[canRXmsg.id]]=canRXmsg; //Store in table
-    if((mType==2)&&(canRXmsg.id==0x358)){ // is daylight sensor
-        daylight = (canRXmsg.data[1]&0x80)?false:true;
+    if((mType==2)&&(canRXmsg.id==0x358)){ // headlight/turn signal indicator
+        headlights = (canRXmsg.data[1]&0x80)?true:false;
     } else if((mType==1)&&(canRXmsg.id==0x7bb)){ // is battery data?  Need to store all responses
         if(canRXmsg.data[0]<0x20){
             if(canRXmsg.data[3]==2){//cellpair data
@@ -89,7 +90,7 @@
             lasti=0;
         }
         i=canRXmsg.data[0]&0x0f; //lower nibble of D0 is index
-        if(lasti>i){ //detect rolloever and offset index appropriately
+        if(lasti>i){ //detect rollover and offset index appropriately
             bdi=0x10;
         }
         lasti=i; //remember the msb to detect rollover next time around
@@ -129,6 +130,7 @@
     can1.monitor(false); // set to active mode
     can1SleepMode = 0; // enable TX
     can1.write(CANMessage(0x79b, data, 8));
+    logCan(1,CANMessage(0x79b, data, 8));
     data[0]=0x30; //change to request next line message
     data[1]=0x01;
     data[2]=0x00;
@@ -146,6 +148,7 @@
     can1.monitor(false); // set to active mode
     can1SleepMode = 0; // enable TX
     can1.write(CANMessage(0x79b, data, 8));
+    logCan(1,CANMessage(0x79b, data, 8));
     data[0]=0x30; //change to request next line message
     data[1]=0x01;
     data[2]=0x00;
--- a/utility.h	Tue Mar 19 04:43:43 2013 +0000
+++ b/utility.h	Wed Mar 20 13:57:00 2013 +0000
@@ -25,7 +25,8 @@
 extern CAN can1,can2;
 extern DigitalOut can1SleepMode,can2SleepMode;
 extern bool pollCP;
-extern bool daylight;
+extern bool tick;
+extern bool headlights;
 extern TOUCH_TFTx2 tt;
 
 extern "C" {