although there is alot happening here, question is simple, to make an if statement for pinStatus value to display a bitmap, this just simply displays the bitmap in all circumstances, i am able to display.print the pinStatus value in my other simpler code but would rather have it call up a bitmap when pinStatus = 1
forgive my super messy coding, i am new ![]()
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
int pinStatus = 0; initial value of Status
// Bitmap of splashcreen
const unsigned char myBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x67, 0xfe, 0x00, 0x03, 0xfe, 0x67, 0xc0, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x67, 0xf0, 0x80, 0x78, 0xfe, 0x67, 0xf0, 0x00, 0x1f, 0xff, 0x81, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xc7, 0xc0, 0x7f, 0x3f, 0xe0, 0xf8, 0x00, 0x7e, 0x03, 0xe0, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0x9f, 0xe0, 0x7f, 0xcf, 0xe0, 0x3f, 0x01, 0xf0, 0x00, 0xf8, 0x78, 0x00, 0x00,
0x00, 0x00, 0x7e, 0x7f, 0xf0, 0x7f, 0xc7, 0xe0, 0x0f, 0xff, 0xe0, 0x00, 0x7f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xff, 0xf0, 0x7f, 0xc3, 0xe0, 0x03, 0xff, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x78, 0x1f, 0xf8, 0x7f, 0x81, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x78, 0x07, 0xfc, 0x7f, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x70, 0x01, 0xfc, 0x7e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x60, 0x00, 0x60, 0x7c, 0x03, 0x60, 0x38, 0x00, 0x00, 0x1f, 0xe0, 0x80, 0x00, 0x00,
0x00, 0x00, 0x60, 0x00, 0x1f, 0x98, 0x0f, 0x20, 0x3f, 0x00, 0x00, 0x7f, 0xf8, 0x0e, 0x00, 0x00,
0x00, 0x00, 0x6f, 0xff, 0x3f, 0xe0, 0x3f, 0x20, 0x1f, 0xc0, 0x01, 0xf8, 0x7e, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x6f, 0xff, 0x7f, 0xe1, 0xff, 0xa0, 0x03, 0xe0, 0x07, 0xc0, 0x0f, 0x87, 0xc0, 0x00,
0x00, 0x00, 0x4f, 0xff, 0x7f, 0xf7, 0xff, 0xa0, 0x00, 0xfe, 0x7f, 0x00, 0x07, 0xf7, 0xe0, 0x00,
0x00, 0x00, 0x4f, 0xfe, 0x7f, 0xf7, 0xff, 0xa0, 0x00, 0x3f, 0xfc, 0x00, 0x01, 0xff, 0xf0, 0x00,
0x00, 0x00, 0x6f, 0xf0, 0x7f, 0xef, 0xff, 0xa0, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x3f, 0xe0, 0x00,
0x00, 0x00, 0x6f, 0x80, 0xbf, 0xc7, 0xff, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00,
0x00, 0x00, 0x66, 0x01, 0xcf, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x74, 0x03, 0xe0, 0xf0, 0x00, 0x62, 0x00, 0x00, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x00,
0x00, 0x00, 0x70, 0x07, 0xe3, 0xfc, 0x00, 0xe7, 0xc0, 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x78, 0x0f, 0xe1, 0xff, 0x00, 0xe3, 0xf0, 0x00, 0x1f, 0xff, 0xc0, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x7c, 0x1f, 0xe0, 0xff, 0xe1, 0xe0, 0x7c, 0x00, 0x7e, 0x03, 0xf0, 0xf8, 0x00, 0x00,
0x00, 0x00, 0x7e, 0x1f, 0xe0, 0xff, 0xf3, 0xe0, 0x1f, 0x01, 0xf8, 0x00, 0xfc, 0x7c, 0x00, 0x00,
0x00, 0x00, 0x7f, 0x3f, 0xe0, 0x7f, 0xe7, 0xe0, 0x07, 0xff, 0xe0, 0x00, 0x3f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x7f, 0x9f, 0xe0, 0x3f, 0x9f, 0xe0, 0x01, 0xff, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xe3, 0xe0, 0x1e, 0x3f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
0x00, 0x00, 0x67, 0xf8, 0x60, 0x01, 0xfe, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00,
0x00, 0x00, 0x67, 0xff, 0x00, 0x0f, 0xfe, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "06720"; //NRF Address
unsigned long lastRecvTime = 0; //Used for latency check
struct data{
float temper; first piece of data to receive
int pinStatus; second piece of data to receive
};
data receive_data;
void reset_the_Data() //Set default values
{
receive_data.temper=0;
receive_data.pinStatus=0;
}
void receive_the_data() //Read
{
while ( radio.available() ) {
radio.read(&receive_data, sizeof(data));
lastRecvTime = millis();
}
}
void setup() {
radio.begin();
radio.setAutoAck(false);
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.startListening();
Wire.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);// initialize with the I2C addr 0x3C (for the 128x64)(initializing the display)
}
void loop() {
receive_the_data();
int unsigned long now = millis();
if ( now - lastRecvTime > 1000 ) { //Check for latency
reset_the_Data();
}
if (pinStatus = 0);{
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(35,10);
display.print(receive_data.temper,1);
display.setCursor(90,10);
display.print("C");
display.setCursor(0,10);
display.print(receive_data.pinStatus); //displays pinStatus ,, should 0
display.display();
}
else if (pinStatus =1); {
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(35,10);
display.print(receive_data.temper,1);
display.setCursor(90,10);
display.print("C");
display.drawBitmap(0, 0, myBitmap, 128, 32, WHITE); // supposed to display bitmap
display.display();
}
}