s1d13700 lcd and CAN-BUS slow to update

Hi all

I'm trying to fix a problem with this LCD S1D13700 and CAN BUS info from an engine ECU
I have it working but the display does not update the CAN BUS info fast enough,

I am also using A0 input with a pot on it and that updates as you turn the pot but the other info from the ECU does not.

if I put a second Arduino with CAN BUS reading I can use serial monitor and see all the addresses and data changing as expected but something I've done is slowing the LCD down.

Can someone have a look at my code and see if I have done something wrong or is it just this display, I don't think its the display as the analogRead is displaying OK

thanks Johnathan

lcd_dashp_s80pro18.ino (3.53 KB)

When you attach a sketch, you force someone to download it and then have to open up the Arduino IDE to read it.

Just post the code.

ok thanks here you go

#include <S1D13700.h>
#include "lucida_font.h"
#include <mcp_can.h>
#include <SPI.h>



long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];

int rpm = 0;
int airTemp = 0;
int Battery = 0;
int WaterTemp = 0;
int Gear = 0;
int fuelP = 0;
int Kph = 0;
int oilP = 0;
int fuelLevel = 0;
int val = 0;
int last_val;


MCP_CAN CAN(53);


S1D13700 glcd;



char newData[12];
char newRPM[12];
char newTemp[12];
char newBattery[12];
char newfuelP[12];
char newKph[12];
char newoilP[12];
char newval[12];


void setup()
{
  //Serial.begin(115200);
  CAN.begin(CAN_1000KBPS);                       // init can bus : baudrate = 1000k 
  pinMode(2, INPUT);                            // Setting pin 2 for /INT input
  

  {

  
    glcd.initLCD();

    glcd.clearText();
    glcd.clearGraphic();


    glcd.textGoTo(10,1);

    
    glcd.writeBitmapText("JDM Dyno ",100,100, LUCIDA_FONT);

    delay(2000);

    /*Clear the screen */
    glcd.clearText();
    glcd.clearGraphic();

    glcd.writeBitmapText("Water Temp: ",10, 5, LUCIDA_FONT); 
    
  }      
  { 
 
    glcd.writeBitmapText("Fuel P:",10, 40, LUCIDA_FONT);
  }    
  {
  
    glcd.writeBitmapText("Oil P:",10, 80, LUCIDA_FONT);
    
  }
  {
    
    glcd.writeBitmapText("Battery:",10, 120, LUCIDA_FONT);    
  }
  {

    glcd.writeBitmapText("MPH:",10, 160, LUCIDA_FONT);
  }
  {
    glcd.writeBitmapText("Fuel Level:",10, 200, LUCIDA_FONT);
    
  }
}

void loop()

{
  if(!digitalRead(2))                         // If pin 2 is low, read receive buffer
  {
    CAN.readMsgBuf(&len, rxBuf);              // Read data: len = data length, buf = data byte(s)
    rxId = CAN.getCanId();                    // Get message ID
{
      val = analogRead(A0);           // reads the value of the potentiometer (value between 0 and 1023) 
      val = map(val, 0, 1023, -1, 101); 
      delay(100);
      if(last_val!=val) 
      
      {  
       
        last_val = val;
       // Serial.println(val);


      }
    /*Serial.print("oilP: ");
     Serial.println(oilP);
     
     
     Serial.print("WaterTemp: ");
     Serial.println(WaterTemp);
     
     
     Serial.print("Battery: ");
     Serial.println(Battery); 
     
     
     Serial.print("Gear: ");
     Serial.println(Gear);   
     
     
     Serial.print("fuel: ");
     Serial.println(newval);
     
     Serial.println();
     
     */
    {
      itoa (WaterTemp, newTemp, 10);
    
      glcd.writeBitmapText(newTemp,190, 5, LUCIDA_FONT);
     

    {    
      itoa (fuelP, newfuelP, 10);
      glcd.writeBitmapText(newfuelP,125, 40, LUCIDA_FONT);
    }  


    {  
    
      glcd.writeBitmapText("    ",140, 80, LUCIDA_FONT);

      itoa (oilP, newoilP, 10);
      glcd.writeBitmapText(newoilP,110, 80, LUCIDA_FONT);
    } 


    {
      itoa (Battery, newBattery, 10);
      glcd.writeBitmapText(newBattery,150, 120, LUCIDA_FONT);
    }
  
    {
      itoa (Kph, newKph, 10);
      
      glcd.writeBitmapText("    ",120, 160, LUCIDA_FONT);
      glcd.writeBitmapText(newKph,80, 160, LUCIDA_FONT);
    }
    {

      itoa (val, newval, 10);
      glcd.writeBitmapText(" %    ",220, 200, LUCIDA_FONT);
      glcd.writeBitmapText(newval,190, 200, LUCIDA_FONT);
    }
     

    switch (rxId){

    case 0x2000:
      rpm = rxBuf[1] * 256 + rxBuf[0];
      airTemp = rxBuf[6];
      WaterTemp = rxBuf[4];
      break;

  
    case 0x2002:
      fuelP = rxBuf[0];
      Battery = rxBuf[4] ;
      break;

    case 0x2003:
      Gear = rxBuf[0];
      break;
      
   case 0x2001:
      Kph = rxBuf[4] / 1.6;
      oilP = rxBuf[6];
      break;

    }
    
    }

  }

  }
}

Hope someone can help

let me know if you need the #included files

thanks

anyone know any thing I can try to speed up the rate than the canbus info is displayed I think its something to do with the switch case on the id's is there a better way to do this?