Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Mon Apr 15 14:33:53 2013 +0000
Parent:
74:e491e92b0bef
Child:
76:fb6779d0963e
Commit message:
Fixed overrun reporting bug but has problem with mbed41 library

Changed in this revision

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/main.cpp	Mon Apr 15 11:40:25 2013 +0000
+++ b/main.cpp	Mon Apr 15 14:33:53 2013 +0000
@@ -64,9 +64,10 @@
 unsigned char battData[256]={0};
 unsigned char msgChanged[100]; // inidcates which bytes changed
 char c;
-volatile int writePointer = 0;
-volatile int secsNoMsg = 0;
-volatile int secsNoTouch = 0;
+volatile unsigned short writePointer = 0;
+unsigned short readPointer=0;
+volatile unsigned short secsNoMsg = 0;
+volatile unsigned short secsNoTouch = 0;
 volatile bool canIdle;
 volatile bool userIdle;
 bool touched=false; //flag to read touchscreen
@@ -119,7 +120,6 @@
 unsigned short pointerSep;
 
 int main() {
-    int readPointer=0;
     char sTemp[40];
     unsigned long secs;
     unsigned char i,j,display=0,lwt=0;
@@ -273,11 +273,12 @@
                     spkr.beep(1000,0.25);
                     logEn=false;
                 } else {
-                    if (pointerSep>(maxBufLen*7/8)) { // Hi-water mark
-                        sprintf(sTemp,"Write buffer overrun.\n");
-                        logMsg(sTemp); // write buffer overrun
-                        spkr.beep(1000,0.25);
-                    }
+                    //moved overrun detection to the write code in utility.cpp
+                    //if (pointerSep>(maxBufLen*7/8)) { // Hi-water mark
+                    //    sprintf(sTemp,"Write buffer overrun.\n");
+                    //    logMsg(sTemp); // write buffer overrun
+                    //    spkr.beep(1000,0.25);
+                    //}
                     while (readPointer != writePointer) {
                         for (j = 0; j<13; j++){
                             fprintf(file,"%c",writeBuffer[readPointer][j]);
--- a/utility.cpp	Mon Apr 15 11:40:25 2013 +0000
+++ b/utility.cpp	Mon Apr 15 14:33:53 2013 +0000
@@ -60,6 +60,12 @@
             for(i=5;i<13;i++){ // Is there a better way to do this? (writeBuffer[writePointer][i]=canRXmsg.data?)
                 writeBuffer[writePointer][i]=canRXmsg.data[i-5];
             }
+            if (writePointer==readPointer) {
+                // Just overwrote an entry that hasn't been sent to thumbdrive
+                sprintf(sTemp,"Write buffer overrun.\n");
+                logMsg(sTemp); // write buffer overrun
+                spkr.beep(1000,0.25);
+            }
             if (++writePointer >= maxBufLen) {
                 writePointer = 0;
                 led3 = !led3;
--- a/utility.h	Mon Apr 15 11:40:25 2013 +0000
+++ b/utility.h	Mon Apr 15 14:33:53 2013 +0000
@@ -6,8 +6,8 @@
 #include "TOUCH_TFTx2.h"
 
 extern Timer timer;
-extern volatile int secsNoMsg;
-extern volatile int secsNoTouch;
+extern volatile unsigned short secsNoMsg;
+extern volatile unsigned short secsNoTouch;
 extern volatile bool canIdle;
 extern volatile bool userIdle;
 extern char displayLog[20][40];
@@ -19,6 +19,7 @@
 extern bool showCP;
 extern char writeBuffer[maxBufLen][13];
 extern volatile int writePointer;
+extern unsigned short readPointer;
 extern DigitalOut led1,led2,led3,led4;
 extern char indexLastMsg[0x800];
 extern unsigned char dMode[2];