Help with building your Speeduino, installing it, getting it to run etc.
By LPG2CV
#44145
Good catch dazq

Not sure the code posted was working though. :)

I'll look for mine as it may be an improvement, and peeps can use different aspects of the code. Just can't remember how far I got with it because I was given an android tablet and went across to msdroid. :)
By Mariano3
#44149
dazq wrote: Wed Jul 08, 2020 9:02 pm That code is meant to be used on a mega2560, your screenshot shows you using a Uno!
That is true. I was working on uno and forgot to change it to mega2560.
But on mega i have another error.
Code: Select all
 Arduino: 1.8.13 (Windows Store 1.8.39.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"





















C:\Users\podga\Desktop\starlet-dash-5inch-nextion.ino\starlet-dash-5inch-nextion.ino.ino: In function 'void realtime_gauges()':

starlet-dash-5inch-nextion.ino:316:17: error: 'TPSBar' was not declared in this scope

   Serial2.print(TPSBar);

                 ^~~~~~

C:\Users\podga\Desktop\starlet-dash-5inch-nextion.ino\starlet-dash-5inch-nextion.ino.ino:316:17: note: suggested alternative: 'TPS'

   Serial2.print(TPSBar);

                 ^~~~~~

                 TPS

starlet-dash-5inch-nextion.ino:366:17: error: 'advancer' was not declared in this scope

   Serial2.print(advancer);

                 ^~~~~~~~

C:\Users\podga\Desktop\starlet-dash-5inch-nextion.ino\starlet-dash-5inch-nextion.ino.ino:366:17: note: suggested alternative: 'advance'

   Serial2.print(advancer);

                 ^~~~~~~~

                 advance

starlet-dash-5inch-nextion.ino:437:3: error: 'matBar' was not declared in this scope

   matBar = map(iatRaw, -40, 210, 0, 100);

   ^~~~~~

C:\Users\podga\Desktop\starlet-dash-5inch-nextion.ino\starlet-dash-5inch-nextion.ino.ino:437:3: note: suggested alternative: 'iatBar'

   matBar = map(iatRaw, -40, 210, 0, 100);

   ^~~~~~

   iatBar

Multiple libraries were found for "Nextion.h"

 Used: C:\Users\podga\Documents\Arduino\libraries\Nextion

 Not used: C:\Users\podga\Documents\Arduino\libraries\Nextion-2.0.2

 Not used: C:\Users\podga\Documents\Arduino\libraries\NeoNextion

 Not used: C:\Users\podga\Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-master

exit status 1

'TPSBar' was not declared in this scope



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
]
User avatar
By garcia w
#44293
Sorry guys I switched display. To an Android headunit months ago. I really like the nextion and tried very hard at it to get it working for a long time, but I got fed up with it because I was testing with it in car and nothing was hardwire to allow easy removal so I code work on code and test out of the car. I kept burning out the nextion display 1 ( 3.2") , 1(4.3") & 1(5") display all damaged so was time stop & another thing I did like was when you have a problem you trying to work out and you ask a question on the nextion forum you get treated like sh*$ for asking someting you don't know. So I switch to Android headunit places in my Dash and running realdash. World of difference and easiest thing to setup and figure out..

I might still have the code I was using last
(will check after work)
working but as dazq said NOT complete.
So if guy are still interested can continue where I left off.

Though I would recommend using realdash and the guys over there are very helpful and will take the time to look into any issues you may have.
User avatar
By garcia w
#46266
Code: Select all
     /*
 * 
 * I will start off by saying "I AM NOT A CODER" I learn as i go, and the way this works is probably different from the way i understand it. with that out the way
 * i started this thread with the intention to use the nextion as a full time display in my car connected to 
 * speeduino but burnt a few during testing due to not having a case. so decide to scrap it for an android setup. 
 * i have seen a lot of interest in people want to use the nextion and couple wks ago a member asked on speeduino fb group for hints on how the 2 works 
 * together. so i took it upon myself to help him out so i rewrite this code in its most simplest form trying to explain using //comments as much
 * as i could to explain how it works and what the code doing between mega2560 & speeduino. i dont have a nextion anymore so all testing|debugging 
 * was done via serial monitor, code was sent to Mariusz who did a short test and confirmed it works. 
 * I wont be continuing with anymore code since i dont have and not using the nextion anymore. 
 * I do not have any nextion files to upload to match the gauge names: but its pretty straight forwards to understand once you play around with nextion software.
 * but i feel it will help people who want to learn how to use it in basic form then advance up on what it can do.
 * am using a ARDUINO MEGA2560 | UA4C SPEEDUINO .....for the NEXTION Display baud rate must be set to ***115200*** or it will NOT WORK...
 */
#define PACKETLENGTH 75                                                                                            // serial3 packetlength 75 
#define UA4C_Serial3 Serial3                                                                                      // UA4C SEAWOLF ECU Secondary serial link
#define NEXTION_Serial2 Serial2                                                                                  // NEXTION DISPLAY serial link

 int  cltbar, tpsbar,rpmbar,fuelbar;                                                                           //remap fullstatus names for nextion bar/analog gauges
 unsigned int    freeRAM, TPS, advance, tpsDOT,ethanolPct, flexCorrection,flexIgnCorrection, afrTarget,rpmDOT,
 idleLoad, testOutputs, baro, O2_2, O2,  VE, corrections, AEamount,RPM, PW1,battery10,batCorrection,
 wueCorrection, iatCorrection, egoCorrection,canin0, canin1, canin2, canin3, canin4,
 canin5, canin6, canin7, canin8,canin9, canin10, canin11, canin12, canin13, canin14,
 canin15, getNextError ;
  
  byte     engine, spark, boostTarget, boostDuty, loopsPerSecond, coolant, IAT, MAP,dwell, secl,tpsADC ;
  boolean  Running, Crank, Launch_hard, Launch_soft, Limit_hard, Limit_soft, Boostcut_spark, warmup ,Error, Ase, Sync;
  boolean  status1; 
  
                                                                         
int  revZ = 0;                                                   // Analog Tachometer example (just need to create a anlog gauge called Tacho   
              
//int  buttonPin = 6;                              // a button connected to digital pin 6 using pullup its used to switch between multiple displays(advance nextion)
int page_counter = 0;                                         // Store page_ counter
int buttonState = 0;                                         // store current state of the button
int lastButtonState = 0;                                    // store previous state of the button

int PWR_LED = 13;
const int ProcessUA4C = 100;

int  databox;                                                            // am going to call this databox, databox store incoming data from UA4C_serial3
byte  fullStatus[PACKETLENGTH];                                         // speeduino max packetlenght 114 serial0 | but since we using serial3 we only need 75
                                                                       // fullStatus is moreso the name of the list of 75 realtime data we want to read

void setup() {
 // pinMode(buttonPin, INPUT_PULLUP);                                      //code INACTIVE - input_pullup worked using a teensy internal pullup resistor 
                                                                          //code (INPUT_PULLUP) probably needs changing to work on Mega2560
  
 Serial.begin(115200);                                         // Set serial monitor to baud rate to 115200
 NEXTION_Serial2.begin(115200);                               // Mega2560 Serial2  to  Nextion serial IO Display (rx2 to tx||tx2 to tx) "MUST set Nextion display baud 115200"
 UA4C_Serial3.begin(115200);                                 // Mega2560 Serial3  to UA4C secondary serial3 data output.  tx3 to rx3 & rx3 to tx3 

 Serial.print(F("Speeduino 2019.08-ser"));                 // so we are clear which Speeduino version am reading from
}
           


void loop() {
//Switch_Page();                                                      // (loop INACTIVE) for multiple nextion display page button.(de-activated for code simplicity)
UA4C_ECU_SERIAL3();                                                  // run UA4C_ECU_SERIAL() Loop
    }


void UA4C_ECU_SERIAL3(){                                                  //UA4C_ECU_SERIAL loop begins
    
  if (UA4C_Serial3.available() >= 0) {                                  //If mega2560 Serial3 have data available from the ua4c serial3 do the following steps inside {}
    pinMode(PWR_LED, OUTPUT);                                          //power ON onboard led pin 13
    digitalWrite(PWR_LED, 1);                                         //led ON        
   
 UA4C_Serial3.write("A");                                           // since data is available we send/write "A" request to UA4C to command some specific data
 databox = (UA4C_Serial3.read());                                  // Speeduino responds and send data requested from "A" list ,so we read the data from the ua4c serial3 and save in a databox 
 for (int databox = 0; databox <PACKETLENGTH; databox++)          // we need whole packetlength which 75 total from the list but we need it the right order 
 fullStatus[databox] = UA4C_Serial3.read();                      //fullStatus is the list in which "A" data values 0-74 is organized on speeduino so same list here so can read matching values
 delay(ProcessUA4C);                                            // delay here a little work great in order slow down stream to read in the data 
                       
//--------------------Now we have to create that "A" command data list(75) that we called fullStatus 0-74= 75 total to match the ua4c cancommand "A" list--------------------------
       
  secl         = fullStatus[0];                                                             //increment seconds
  status1      = fullStatus[1];                                                            // bitfield status1
  engine       = fullStatus[2];                                                           // engine bitfield status
  dwell        = fullStatus[3];                                                          // igntion dwell
  MAP          = ((fullStatus[5] << 8) | (fullStatus[4]));                                   // engine MAP kPa (2bytes) so we group fullStatus 4&5 together
  IAT            = fullStatus[6];                                                         // Intake Temp
  coolant        = fullStatus[7];                                                        // coolant Temp
  batCorrection  = fullStatus[8];                                                       // batt corr
  battery10      = fullStatus[9];                                                      // batt voltage
  O2             = fullStatus[10];                                                    // O2 afr
  egoCorrection   = fullStatus[11];                                                     // ego corr
  iatCorrection   = fullStatus[12];                                                    // iat corr
  wueCorrection  = fullStatus[13];                                                    // warmup enrich corr
  RPM          = ((fullStatus[15] << 8) | (fullStatus[14]));                           // rpm (2 bytes)       "                           "
  AEamount      = fullStatus[16];                                                   // AE
  corrections   = fullStatus[17];                                                  // correction
  VE          = fullStatus[18];                                                      // VE
  afrTarget   = fullStatus[19];                                                     // afr Target
  PW1         = ((fullStatus[21] << 8) | (fullStatus[20]));                          // pulse width1
  tpsDOT           = fullStatus[22];                                              // tpsDOT
  advance          = fullStatus[23];                                             // timing adv
  TPS              = fullStatus[24];                                            // throttle
 loopsPerSecond    = ((fullStatus[26] << 8) | (fullStatus[25]));                    // loops Per Second  (2 bytes)
 freeRAM           = ((fullStatus[28] << 8) | (fullStatus[27]));                   // free ram    (2bytes)
 boostTarget       = fullStatus[29];                                            // boost target
 boostDuty         = fullStatus[30];                                           // boost duty
 spark             = fullStatus[31];                                          // spark bitfield
 rpmDOT            = ((fullStatus[33] << 8) | (fullStatus[32]));             // rpm dot
 ethanolPct        = fullStatus[34];                                           // ethanol content%
 flexCorrection    = fullStatus[35];                                          // flex fuel corr
 flexIgnCorrection = fullStatus[36];                                         // flex ign corr
 idleLoad        = fullStatus[37];                                          // idle load
 testOutputs      = fullStatus[38];                                        // test outputs
 O2_2            = fullStatus[39];                                           // O2_2  afr2
 baro            = fullStatus[40];                                          // baro
 canin0          = ((fullStatus[42] << 8) | (fullStatus [41]));            // auxin 0
 canin1          = ((fullStatus[44] << 8) | (fullStatus [43]));           // auxin  1
 canin2          = ((fullStatus[46] << 8) | (fullStatus [45]));          //  auxin  2
 canin3          = ((fullStatus[48] << 8) | (fullStatus [47]));         //   "   "   3
 canin4          = ((fullStatus[50] << 8) | (fullStatus [49])); 
 canin5          = ((fullStatus[52] << 8) | (fullStatus [51])); 
 canin6          = ((fullStatus[54] << 8) | (fullStatus [53])); 
 canin7          = ((fullStatus[56] << 8) | (fullStatus [55])); 
 canin8          = ((fullStatus[58] << 8) | (fullStatus [57])); 
 canin9          = ((fullStatus[60] << 8) | (fullStatus [59])); 
 canin10          = ((fullStatus[62] << 8) | (fullStatus [61])); 
 canin11          = ((fullStatus[64] << 8) | (fullStatus [63]));
 canin12          = ((fullStatus[66] << 8) | (fullStatus [65])); 
 canin13          = ((fullStatus[68] << 8) | (fullStatus [67])); 
 canin14          = ((fullStatus[70] << 8) | (fullStatus [69])); 
 canin15          = ((fullStatus[72] << 8) | (fullStatus [71]));          // auxin 15
 tpsADC           = fullStatus[73];                                      // tpsADC voltage
 getNextError     = fullStatus[74];                                     //  get error
                                 
                                       //STATUS BITS
//---------------------------(engine) is a bitfield status- it contains muplitple bits each for a different engine running status------------------------------
                       Running        = bitRead(engine, 0);
                       Crank          = bitRead(engine, 1);
                       Ase            = bitRead(engine, 2);
                       warmup         = bitRead(engine, 3);
//---------------------------(spark) is a bitfield status- it contains muplitple bits each for differnt spark status------------------------------ 
                       Launch_hard    = bitRead(spark, 0);
                       Launch_soft    = bitRead(spark, 1);
                       Limit_hard     = bitRead(spark, 2);
                       Limit_soft     = bitRead(spark, 3);
                       Boostcut_spark = bitRead(spark, 4);
                       Error          = bitRead(spark, 5);
                       Sync           = bitRead(spark, 7);

 //--------------------------testing i dont have nextion anymore so testing the values i read in from speeduino and test print to serial monitor------------------
//after testing you can simply put //  too comment out all the serial.print line so it doesnt print to serial monitor anymore.
 
Serial.println("************************* start *******************************************");     //start 

Serial.println("free Ram");
Serial.println(freeRAM);

Serial.println("loops Per Sec");
Serial.println(loopsPerSecond);

Serial.println("secl");
Serial.println(secl);

 
 Serial.println("batter corr");
 Serial.println(batCorrection);                         
 Serial.println("iat");
 Serial.println(IAT - 40);                             // -40C offset  iat  for it read correct temp

 Serial.println("coolant");
 Serial.println(coolant - 40);                        //-40C offset  coolant for it to read correct temp


 Serial.println("afr");
 Serial.println(O2/10.0);

 Serial.println("afr 2");
Serial.println(O2_2 /10.0);

Serial.println("tps adc");
Serial.println(tpsADC);

Serial.println("VE%");
Serial.println(VE);

Serial.println("ego Corrwections");
Serial.println(egoCorrection);


 Serial.println("baro");
 Serial.println(baro);

Serial.println("Map kpa");
Serial.println(MAP);

Serial.println("afrTarget");
Serial.println(afrTarget/10.0);

Serial.println("TPS");
Serial.println(TPS);

Serial.println("*************************************End ****************************************");

  //---------------------end of debugging------------------------------
 
                                                  
 // print whatever you like here/below to nextion display 
   
    
  NEXTION_Serial2.print("kpa.txt=");                                             //  print MAP  values to nextion object "name kpa.txt=" aka your txt gauge readout you created on your nextion display
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.print(MAP);                                                  //map kpa readout
  //Serial.print((MAP - baro)* 0.145038);                                      // print psi readout  to (serial monitor debugging)
  NEXTION_Serial2.write(0x22);                                                 // if the nextion gauge you created is a (.txt=) you need to write (0x22) after to the serial port
  NEXTION_Serial2.write(0xff);                                                 // and you need to write (0xff) x3 time to the serial port aswell for every data that you print to the nextion display
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

  //-----------------------------for (.val=) you dont need to write 0x22)--------------------------------------------
  NEXTION_Serial2.print("clt.val=");                                          //   print coolant values to nextion object "name clt.val="  bar type gauge 
  cltbar = map(coolant - 40 , -40, 220, 0, 100);                             //  offset -40 Celcius readout   (remove -40 to get F readout)
  NEXTION_Serial2.print(cltbar);
   NEXTION_Serial2.write(0xff);                    
  NEXTION_Serial2.write(0xff);                                             // as above send (0xff)everytime 3x
  NEXTION_Serial2.write(0xff);
 
 /* NEXTION_Serial2.print("fuel.val=");
  fuelbar = map(canin0, 0,100, 0, 100);                                  //  gauge name:fuel = fuel level input, 3 wire sending unit wired to (speeduino analog pin A8-
  NEXTION_Serial2.print(fuelbar);                                       //  local auxin0 analog input on speeduino) untested.
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
*/
  
  NEXTION_Serial2.print("afr.txt=");
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.print(O2 / 10.0);               //(afr/10.0) give you decimal(.)point so readout would be 14.7 if you only print(afr) your afr vale shows as 147
  NEXTION_Serial2.write(0x22);                    
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

   
  NEXTION_Serial2.print("batt.txt=");
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.print(battery10 / 10.0);                     // as above see afr/10.0 example
  NEXTION_Serial2.write(0x22);  
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

  NEXTION_Serial2.print("tps.val=");                        // .val=  (number gauge)  gauge name: tps
  tpsbar = map(TPS, 0, 100, 0, 100);
  NEXTION_Serial2.print(tpsbar);                           //bar gauge
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

  
  
  NEXTION_Serial2.print("ign.txt=");                    //.txt= gauge name: ign     text gaugebfor (igition advance) 
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.print(advance);
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

  
  NEXTION_Serial2.print("iat.txt=");
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.print(IAT - 40);                    // offset -40  C readout ( removed -40to get F readout)
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

  
  NEXTION_Serial2.print("pw1.txt=");              // gauge name: pw1  note: you dont have to use the names i put you can change them to whatever you wish.
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.print(PW1);
  NEXTION_Serial2.write(0x22);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);

   //--------------------------a bit more complicated but this how you go about making a analog gaugein this case a analog rpm tach-----------(advanced nextion)
   
 revZ=map(RPM, 0, 7500, 226, 497);                                        //(EXAMPLE:  {Analog TACHOmeter} needle gauge starts at 270degrees = 0rpm  ends at 130 degrees = 490 
                                                                          // clock is 360degrees 360+130 = 490degrees --(MAP,0,7500,270,485)  start270 end130 = 485
   if(revZ >359)                                                         // MAP ,0rpm,7500redline,270deg starting 0rpm, 490deg end rpm redline.
   {
    revZ = revZ - 360;
   }
   
  NEXTION_Serial2.print("tach.val=");              // gauge name: tach
  NEXTION_Serial2.print(revZ);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  
  NEXTION_Serial2.print("rpm.val=");             // gauge name : rpm
  rpmbar = map(RPM, 0, 9000, 0, 100);           // just a normal rpm bar gauge type  0-9000rpm mapped over 0-100 range| can set to 0-7000rpm whatever you want to see
  NEXTION_Serial2.print(rpmbar);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  //-------a bit thinking outside the box ,i want to display a image# to reprsent every 1000rpm 1=1000  , 4=4000, 7=000, 9=9000rpm as rev increased or decreased------
   if ((RPM >=250) && (RPM < 1000)){                      //250 - 1000rpm        (9 images|image gauge) named: (rev1 - rev9)  1 for each 1000 rpm  up to 9000rpm
  NEXTION_Serial2.print("vis rev1,1");                   // image#1 name:rev1   display/visable at rpm 250- 1000 rpm 
   NEXTION_Serial2.write(0xff); 
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { NEXTION_Serial2.print("vis rev1,0");            // image#1 name:rev1   NOT visable at below rpm 250 or above 1000 rpm  
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }

   if ((RPM >= 1010) && (RPM < 2000 )){               // image#2 name:rev2   display/visable at rpm 1010- 2000 rpm 
  NEXTION_Serial2.print("vis rev2,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { NEXTION_Serial2.print("vis rev2,0");             // image#2 name:rev2   NOT visable at below rpm1010 or above 2000 rpm  
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }
if ((RPM >= 2010) && (RPM < 3000)){                 // you get the idea how these works now
  NEXTION_Serial2.print("vis rev3,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { NEXTION_Serial2.print("vis rev3,0");            //  see above  "   "
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }
    if ((RPM >= 3010) && (RPM < 4000)){
  NEXTION_Serial2.print("vis rev4,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { NEXTION_Serial2.print("vis rev4,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }
  if ((RPM >= 4010) && (RPM < 5000)){
  NEXTION_Serial2.print("vis rev5,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { NEXTION_Serial2.print("vis rev5,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }

   if ((RPM >= 5010) && (RPM < 6000)){
  NEXTION_Serial2.print("vis rev6,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { 
    NEXTION_Serial2.print("vis rev6,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }
if ((RPM >= 6010) && (RPM < 7000))
{
  NEXTION_Serial2.print("vis rev7,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   {
    NEXTION_Serial2.print("vis rev7,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }
    if ((RPM >= 7100) && (RPM < 8000))
    {
  NEXTION_Serial2.print("vis rev8,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { 
    NEXTION_Serial2.print("vis rev8,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }

   if ((RPM >= 8010) && (RPM < 9000)){               // (9 images) named (rev1 - rev9)  1 for each 1000 rpm  up to 9000rpm
  NEXTION_Serial2.print("vis rev9,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
    }
    else 
   { 
  NEXTION_Serial2.print("vis rev9,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
   }
                                   //-___----__-----____------__------------Speeduino STATUS Alerts------____------____-------____------__-----------------------
  
if (Launch_soft){  
  NEXTION_Serial2.print("vis LaunchS,1");                   // create a image name: LaunchS   display as picture gauge for Lanuch_soft limit
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis LaunchS,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
//--------------------------------------HARD LAUNCH-------------------------------------------------

if (Launch_hard){
  NEXTION_Serial2.print("vis LaunchH,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis LaunchH,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
 //-----------------------------------------SOFT REV LIMIT--------------------------------------------------------
 if (Limit_soft){
  NEXTION_Serial2.print("vis RevS,1");
 NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis RevS,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }  
  //-------------------------------------HARD REV LIMIT--------------------------------------------------
if (Limit_hard){
  NEXTION_Serial2.print("vis RevH,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis RevH,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
//-----------------------------------BOOSTCUT-------------------------------------------
if (Boostcut_spark){
  NEXTION_Serial2.print("vis BoostCut,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis BoostCut,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  //------------------------------------ASE--------------------------------------------------
if (Ase){
  NEXTION_Serial2.print("vis Ase,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis Ase,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
//-------------------------------------WARMUP--------------------------------------------------------------
if (warmup){
   NEXTION_Serial2.print("vis Warmup,1");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis Warmup,0");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
//--------------------------------ERROR---------------------------------------
if (Error){
  NEXTION_Serial2.print("vis Error,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis Error,0");
   NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
//-------------------------------------SYNC-------------------------------------------------  
  if (Sync){
  NEXTION_Serial2.print("vis Sync,1");                                      // all status gauge are same as launchS picture gauge
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis Sync,0");                           
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
//----------------------------------------------------Running--------------------
if (Running){
  NEXTION_Serial2.print("vis Running,1");                 // create an picture named: Running to display as a engine runnning status an seen on tunerstudio
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis Running,0"); 
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  //-----------------------------------------------------CRANKING-------------------------
  if (Crank){         //Crank
  NEXTION_Serial2.print("vis Cranking,1");
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  }
  else
  { 
  NEXTION_Serial2.print("vis Cranking,0");                
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  NEXTION_Serial2.write(0xff);
  //---------------you can add more to print to nextion here or can delete and print to your own liking-----------
  }
  }
  delay(50);           // i delay it by 500 to be able to see whats goin on in serial monitor to slow it down bigger#  ,to speed up bigger #.
   while (UA4C_Serial3.available()>PACKETLENGTH)        // clear serial buffer for new data
   {
    UA4C_Serial3.read();                      
    }
}
//-------------inACTIVE---------------------a bit more advance stuff as you get familar with nextion how it works. below is a button attached to Mega2560
// used to switch between display pages on the nextion. bascically you cant have multiple display designs that you can switch between with press of a button.
//for simplicity sake i deactive this section of code once you are more familar with nextion cant explore futher into what the display can do.
/*
void Switch_Page(){                           
  buttonState = digitalRead(buttonPin);

                                              // compare the buttonState to its last state
  if (buttonState != lastButtonState) {      // if the state changed, increment the counter by +1
    if (buttonState == HIGH) {               // if the current state is HIGH then the button went from off to on:
        if(page_counter < 3){              // 3 (total of pages) for 3 differnt diplay
     //  page_counter = page_counter +1;    //Page up
     page_counter++;
        }
    else{
     page_counter = 1;  
       }
        }
        switch (page_counter){

        case 1: 
   NEXTION_Serial2.print("click button1,0"); // create nextion button  and  
   command base on Nextion Instruction Set
   NEXTION_Serial2.write(0xFF);
   NEXTION_Serial2.write(0xFF);
   NEXTION_Serial2.write(0xFF);
  break;
        
            case 2: 
   NEXTION_Serial2.print("click button2,0"); // command base on Nextion Instruction Set
   NEXTION_Serial2.write(0xFF);
   NEXTION_Serial2.write(0xFF);
   NEXTION_Serial2.write(0xFF);
   break;
        
            case 3: 
   NEXTION_Serial2.print("click button3,0"); // command base on Nextion Instruction Set
   NEXTION_Serial2.write(0xFF);
   NEXTION_Serial2.write(0xFF);
   NEXTION_Serial2.write(0xFF);
  break;
  default:
  return;
}
  }
}
*/
By dazq
#46321
I too am looking at moving away from the nextion I was using (a 7" enhanced) and going to android using a 7" head unit.
It means most features are already done( it's for a central infotainment unit) and I am working on adding the additional features using a custom app linked via usb to a teensy which switches the outputs and reads the inputs .
I have done some prototype tests and am happy so have ordered the head unit. It's 7" with 2gb ram and 16gb Rom, cost only 53gbp on eBay and it's even in the UK! Delivery due Thursday.
I will take some snaps when it gets in.... :-)
User avatar
By garcia w
#46368
That's Kool Dazq, post up pics when you get it going .
The headunit am using is same specs as you mentioned. I Paid $250 but it's use for everything. Tunes,maps, dash .am Curious to see what you got going with your custom app.
By dazq
#46384
garcia w wrote: Tue Nov 10, 2020 11:55 pm That's Kool Dazq, post up pics when you get it going .
The headunit am using is same specs as you mentioned. I Paid $250 but it's use for everything. Tunes,maps, dash .am Curious to see what you got going with your custom app.
My head unit has arrived ,so I have started a new thread here to keep along with progress rather than mixing things up in this one

viewtopic.php?f=19&t=4342
Ignition Angle doubled?

Please post a log with tune it was taken with. p[…]

Ok, I feel so stupid. I was running the Uno output[…]

Let's all have a laugh for second. There's trash[…]

It has been done more than a few times, there was […]

Still can't find what you're looking for?