Sorry for the uneducated topic, learning as I am going and this seems to be something that I can't google/search this forum for guidance
I am developing a board and code to read the CAN data from my aftermarket ECU (Haltech) and display it on a 2.04 OLED
I have base code that reads the CAN address, have code in place to convert the datastream into usable data to display, and I am currently working on a butchered piece of code that I am using to Demo/update for templating reasons.
I have ECU values set which I edit to display in my template to make sure my display.setCursor is all where I want it, the only issue I have is trying to fake display the boolean data from a particular stream and have it display as YES or NO
With my other data, simply having if (VALUE1 > 100) ... display at setcursor A, if (VALUE1 < 100) ... display at setcursor B.
I don't understand how to initially define/reference Boolean states up where my ECU values are (if I even need to) and have it work the same way as the raw data does
My basic thinking was trying to use either 'if (VALUE5 = 0) ... display.print ("NO")' or 'if (VALUE5 = false) ... display.print("NO")' to make it follow the same algorithm that I use for the raw data but it doesn't seem to work.
I have another code that I use in the realworld that interprets the CAN which works, I just have the code below that I use for ironing out templates for my various pages
The data that the Decel Cut and Transient uses are defined in the CAN protocol that I am using as 0=Off, 1=On
Will attach the code in this post as an aid
#include <Adafruit_GFX.h> //OLED GFX Library
#include <Adafruit_SSD1306.h> //OLED Library (for 1.3 inch, should work on 2.4inch)
#include <mcp_can.h> //CAN Library
#include <SPI.h> //Hardware SPI Library
#include <EEPROM.h> //EEPROM Library
const byte led = 13; //Onboard LED used as CAN comms indicator
//const int SPI_CS_PIN = 17; //Define SPI CS for CAN
//OLED Pins Hardware SPI
//#define OLED_VCC 5V RED
//#define OLED_GND GND BLACK
//#define OLED_MOSI MOSI BLUE
//#define OLED_CLK SCK YELLOW
#define OLED_DC 5 //GREEN
#define OLED_CS 6 //ORANGE
#define OLED_RESET 4 //WHITE
Adafruit_SSD1306 display(/*OLED_MOSI, OLED_CLK, */OLED_DC, OLED_RESET, OLED_CS);
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
//SCREEN INFO
//128 x 64
//DIN - MOSI
//CLK - SCLK
//VCC - 5v
//GND - Ground
//CS - Chip Selection
//DS - Data/Command
//BUTTON CONFIG
const byte button = 12; // Button input is D12 (this receives ground which D8 supplies)
long buttonTimer = 0;
long longPressTime = 750;
boolean buttonActive = false;
boolean longPressActive = false;
//EEPROM CONFIG
byte addr = 1; // Initialise the EEPROM address
byte buttonPushCounter = EEPROM.read(1); // Counter for the number of button presses (get value from EEPROM)
//CAN BUS Configuration
unsigned char rxLen = 0; //Message rx Length
unsigned char rxBuf[8]; //Number of bytes (0,1,2...6,7)
MCP_CAN CAN0(17); //Set CAN CS pin (as stated in manual)
byte CANfilterset = 0; //Check if filter is set
//ECU VALUES
int VALUE1 = 1200; // VALUE1 integer
int VALUE2 = 110; // VALUE2 integer
int VALUE3 = 0; // VALUE3 integer
int VALUE4 = 0; // VALUE4 integer
int VALUE5 = 0;
//boolean true = YES;
//boolean false = NO;
float FVALUE1 = 0; // VALUE1 floating point (decimal place numbers)
float FVALUE2 = 0; // VALUE2 floating point (decimal place numbers)
float FVALUE3 = 0; // VALUE3 floating point (decimal place numbers)
float FVALUE4 = 0; // VALUE4 floating point (decimal place numbers)
//SCREEN 1 HEADING, DATA AND MAX/MIN VALUES
int MAX1 = -10000;
int MAX2 = -10000;
int MAX3 = -10000;
int MAX4 = -10000;
int MIN1 = 10000;
int MIN2 = 10000;
int MIN3 = 10000;
int MIN4 = 10000;
float FMAX1 = -10000;
float FMAX2 = -10000;
float FMAX3 = -10000;
float FMAX4 = -10000;
float FMIN1 = 10000;
float FMIN2 = 10000;
float FMIN3 = 10000;
float FMIN4 = 10000;
int ScreenOff = 0;
void setup() {
Serial.begin(115200); // Serial Comms speed
pinMode(led, 13); // Setup Pin D13 as Output Led
if (buttonPushCounter >= 6) // On first run EEPROM could be any value 0-254
{ EEPROM.write(1, 0); // If it is above 3, set it to zero to agree with the 'if' loop
}
display.begin(SSD1306_SWITCHCAPVCC); // Initialise Screen
display.setTextWrap(false);
pinMode(button, INPUT_PULLUP); //Button config, D8 supplies ground to D12
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
display.setRotation(0); // Set rotation (0) Normal, (2) 180 deg
display.clearDisplay();
display.setTextSize(1); // Splash screen
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("JZX100 TEST CODE");
display.display();
delay(500);
display.clearDisplay();
}
void loop(){
////-------------------------------------------------------------------------------------------
display.setTextSize(1);
display.setCursor(23, 0);
display.print("RPM");
if (VALUE1 < 1000) {
display.setTextSize(2);
display.setCursor(13, 12);
display.print(VALUE1, 1);
}
if (VALUE1 > 1000) {
display.setTextSize(2);
display.setCursor(8, 12);
display.print(VALUE1, 1);
}
display.setTextSize(1);
display.setCursor(81, 0);
display.print("SPEED");
if (VALUE2 < 100) {
display.setTextSize(2);
display.setCursor(85, 12);
display.print(VALUE2, 1);
}
if (VALUE2 > 100) {
display.setTextSize(2);
display.setCursor(79, 12);
display.print (VALUE2, 1);
}
display.setTextSize(1);
display.setCursor(5, 32);
display.print("DECEL CUT");
if (VALUE5 = 0) {
display.setTextSize(2);
display.setCursor(15, 44);
display.print(false, 1);
}
if (VALUE5 = 1) {
display.setTextSize(2);
display.setCursor(15, 40);
display.print(true, 1);
}
display.setTextSize(1);
display.setCursor(69, 32);
display.print("TRANSIENT");
if (VALUE5 = 0) {
display.setTextSize(2);
display.setCursor(15, 79);
display.print(false, 1);
}
if (VALUE5 = 1) {
display.setTextSize(2);
display.setCursor(15, 75);
display.print(true, 1);
}
display.display();
delay(50);
}

