Coding problem using ssd-1306 oled display(IM NOOB)

This is the code -

static const unsigned char PROGMEM  my_logo[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0xf8, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xf8, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf0, 0x3c, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0xc0, 0xf8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xf8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf1, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf1, 0xf0, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0xf1, 0xfc, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf1, 0xf0, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 
	0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x31, 0x80, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 
	0x00, 0x00, 0x01, 0xfe, 0x00, 0x80, 0x00, 0x31, 0x80, 0x00, 0x00, 0x01, 0x81, 0xb0, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x30, 0x03, 0xe0, 0x00, 0x31, 0x80, 0x00, 0x00, 0x03, 0xc3, 0x10, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x30, 0x03, 0x70, 0x00, 0x31, 0x80, 0x00, 0x00, 0x06, 0xc6, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x30, 0x04, 0x30, 0x00, 0x31, 0x80, 0x07, 0xe0, 0x06, 0xc4, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x30, 0x04, 0x18, 0x00, 0x31, 0x80, 0x07, 0xf0, 0x00, 0x64, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x60, 0x08, 0x1c, 0x00, 0x31, 0x80, 0x0c, 0xfe, 0x00, 0x6c, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x60, 0x08, 0x1e, 0x00, 0x31, 0x80, 0x0c, 0x1f, 0x00, 0x3c, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x40, 0x08, 0x1b, 0x01, 0xf1, 0x80, 0x08, 0x11, 0x80, 0x38, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x40, 0x08, 0x1b, 0x07, 0xf1, 0x80, 0x0c, 0x10, 0x80, 0x30, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x40, 0x0e, 0x19, 0x87, 0x31, 0xb0, 0x0e, 0x30, 0x80, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x40, 0x07, 0xf1, 0x86, 0x31, 0xfc, 0x0f, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x07, 0x31, 0xcc, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x07, 0xf1, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0xe1, 0x8d, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x8f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8f, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x7f, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x7e, 0x00, 0x00, 0x18, 0x07, 0x00, 0x00, 0x03, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x03, 0x80, 0x00, 0x03, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0xc8, 0x40, 0x00, 0x07, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xfc, 0x60, 0x00, 0x07, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x8f, 0xfe, 0x60, 0x00, 0x7f, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x1c, 0x86, 0x20, 0x00, 0x4b, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x73, 0x30, 0x00, 0x7c, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x3b, 0x3f, 0x90, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x02, 0x3f, 0x09, 0x90, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x02, 0x27, 0xcf, 0x90, 0x00, 0x03, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x02, 0x39, 0x33, 0x90, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x02, 0x30, 0xc9, 0x80, 0x00, 0x03, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x3e, 0x4f, 0x90, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x3d, 0xd3, 0x30, 0x71, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x01, 0x1c, 0x8e, 0x20, 0x51, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x7c, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x07, 0x80, 0x7f, 0xc7, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x40, 0x44, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x40, 0x44, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc7, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc7, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };


#include <SPI.h>
#include <nRF24L01.h>            
#include <RF24.h>              
#include <Wire.h>
#include <Adafruit_GFX.h>         
#include <Adafruit_SSD1306.h>     
#include <EEPROM.h>


#define OLED_RESET 8
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 5
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix this in the Adafruit_SSD1306.h!");
#endif


const uint64_t pipeOut = 0xE8E8F0F0E1LL;

RF24 radio(9, 10); 

struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
};

MyData data;


int battery_in = A7;                 
int buttons_analog_in = A6;         
int toggle_1 = 3; 
int toggle_2 = 2;
int throttle_in = A0;
int yaw_in = A1;
int pitch_in = A2;
int roll_in = A3;
int mode_in = 4;
int buzzer = 5;

float battery_level = 0;
int throttle_fine = 0;
int yaw_fine = 0;
int pitch_fine = 0;
int roll_fine = 0;
int button_read = 0;

int throttle_to_send = 0;
int yaw_to_send = 0;
int pitch_to_send = 0;
int roll_to_send = 0; 

bool throttle_inverted = false; 
bool yaw_inverted = true; 
bool pitch_inverted = true; 
bool roll_inverted = false; 

bool yaw_decrease = false;
bool throttle_decrease = false;
bool pitch_decrease = false;
bool roll_decrease = false;

bool yaw_increase = false;
bool throttle_increase = false;
bool pitch_increase = false;
bool roll_increase = false;

bool mode = true;
bool mode_button_pressed = false;
bool sound = true;
int counter = 0;
int invert_counter = 0;
bool sound_changed = false;

void resetData() 
{

  data.throttle = 127;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2 = 0;
}

void setup()
{
  if( EEPROM.read(1) != 55)
  {
    EEPROM.write(2, 127);
    EEPROM.write(3, 127);
    EEPROM.write(4, 127);
    EEPROM.write(5, 127); 
    EEPROM.write(6, 0);
    EEPROM.write(7, 1);
    EEPROM.write(8, 1);
    EEPROM.write(9, 0);    
    EEPROM.write(1, 55);
  }

  throttle_fine = EEPROM.read(2);
  yaw_fine = EEPROM.read(3);
  pitch_fine = EEPROM.read(4);
  roll_fine = EEPROM.read(5);
  throttle_inverted = EEPROM.read(6);
  yaw_inverted = EEPROM.read(7);
  pitch_inverted = EEPROM.read(8);
  roll_inverted = EEPROM.read(9);
  
  pinMode(buttons_analog_in, INPUT);
  pinMode(mode_in, INPUT_PULLUP);
  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer,LOW);
    
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  delay(100);
  display.clearDisplay();
  display.setTextSize(1);             
  display.setTextColor(WHITE);        
  display.drawBitmap(0, 0,  my_logo, 128, 64, 1);
  
  digitalWrite(buzzer,HIGH);
  delay(40);
  digitalWrite(buzzer,LOW);  
  delay(40);
  digitalWrite(buzzer,HIGH);
  delay(40);
  digitalWrite(buzzer,LOW);  

  display.display();
  delay(2000);
  

  radio.begin();
  radio.setAutoAck(false);
  radio.setPALevel(RF24_PA_HIGH);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
  resetData();
}


int map_normal(int val, int lower, int middle, int upper, bool reverse)
{
  val = constrain(val, lower, upper);
  if ( val < middle )
    val = map(val, lower, middle, 0, 128);
  else
    val = map(val, middle, upper, 128, 255);
  return ( reverse ? 255 - val : val );
}


int map_exponential(int val, bool reverse)
{
  val = constrain(val, 0, 1023);
  float cube = ((pow((val - 512),3)/520200) + 258.012) / 2; 
  return ( reverse ? 255 - cube : cube );
}


void loop() 
{
  battery_level = analogRead(battery_in) * (5.0/1024)*((4700.0 + 10000.0)/10000.0);
  
  button_read = analogRead(buttons_analog_in);
  
  if(button_read > 820)
  {
    yaw_decrease = false;
    throttle_decrease = false;
    pitch_decrease = false;
    roll_decrease = false;
    yaw_increase = false;
    throttle_increase = false;
    pitch_increase = false;
    roll_increase = false;
  }
  
  
  
  if(button_read < 260 && button_read > 200 && !yaw_decrease)
  {
    yaw_fine = yaw_fine + 1;
    yaw_decrease = true;
    EEPROM.write(3, yaw_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  if(button_read < 120 && button_read > 50 && !yaw_increase)
  {
    yaw_fine = yaw_fine - 1;
    yaw_increase = true;
    EEPROM.write(3, yaw_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  
  
  
  if(button_read < 500 && button_read > 430 && !throttle_decrease)
  {
    throttle_fine = throttle_fine + 1;
    throttle_decrease = true;
    EEPROM.write(2, throttle_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  if(button_read < 380 && button_read > 320 && !throttle_increase)
  {
    throttle_fine = throttle_fine - 1;
    throttle_increase = true;
    EEPROM.write(2, throttle_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  

  
  if(button_read < 610 && button_read > 550 && !pitch_decrease)
  {
    pitch_fine = pitch_fine + 1;
    pitch_decrease = true;
    EEPROM.write(4, pitch_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  if(button_read < 690 && button_read > 630 && !pitch_increase)
  {
    pitch_fine = pitch_fine - 1;
    pitch_increase = true;
    EEPROM.write(4, pitch_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  

  
  if(button_read < 820 && button_read > 760 && !roll_decrease)
  {
    roll_fine = roll_fine + 1;
    roll_decrease = true;
    EEPROM.write(5, roll_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  if(button_read < 760 && button_read > 700 && !roll_increase)
  {
    roll_fine = roll_fine - 1;
    roll_increase = true;
    EEPROM.write(5, roll_fine);
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }

  if(!digitalRead(mode_in) && !mode_button_pressed)
  {
    mode = !mode;
    mode_button_pressed = true;
    if(sound)
    {
      digitalWrite(buzzer,HIGH);
      delay(50);
      digitalWrite(buzzer,LOW); 
    }
  }
  
  if(!digitalRead(mode_in) && !sound_changed)
  {
    if(counter > 20)
    {
      sound = !sound;
      counter = 0;
      sound_changed = true;
      if(sound)
      {
        digitalWrite(buzzer,HIGH);
        delay(50);
        digitalWrite(buzzer,LOW); 
      }
    }
    counter = counter + 1;
  }


  if(button_read < 500 && button_read > 430)
  {
    if(invert_counter > 30)
    {
      throttle_inverted = !throttle_inverted;
      invert_counter = 0;
      EEPROM.write(6, throttle_inverted);
      display.clearDisplay();            
      display.setCursor(13,30);           
      display.print("Throttle inverted");      
      display.display();    
      if(sound)
      {
        digitalWrite(buzzer,HIGH);
        delay(50);
        digitalWrite(buzzer,LOW); 
      }
      delay(1500);
    }
    invert_counter = invert_counter + 1;
  }

 
  if(button_read < 260 && button_read > 200)
  {
    if(invert_counter > 30)
    {
      yaw_inverted = !yaw_inverted;
      invert_counter = 0;
      EEPROM.write(7, yaw_inverted);
      display.clearDisplay();            
      display.setCursor(15,30);            
      display.print("  Yaw inverted");      
      display.display();    
      if(sound)
      {
        digitalWrite(buzzer,HIGH);
        delay(50);
        digitalWrite(buzzer,LOW); 
      }
      delay(1500);
    }
    invert_counter = invert_counter + 1;
  }

  
  if(button_read < 610 && button_read > 550)
  {
    if(invert_counter > 30)
    {
      pitch_inverted = !pitch_inverted;
      invert_counter = 0;
      EEPROM.write(8, pitch_inverted);
      display.clearDisplay();             
      display.setCursor(13,30);            
      display.print("  Pitch inverted");      
      display.display();    
      if(sound)
      {
        digitalWrite(buzzer,HIGH);
        delay(50);
        digitalWrite(buzzer,LOW); 
      }
      delay(1500);
    }
    invert_counter = invert_counter + 1;
  }


  if(button_read < 820 && button_read > 760)
  {
    if(invert_counter > 30)
    {
      roll_inverted = !roll_inverted;
      invert_counter = 0;
      EEPROM.write(9, roll_inverted);
      display.clearDisplay();            
      display.setCursor(15,30);            
      display.print("  Roll inverted");      
      display.display();    
      if(sound)
      {
        digitalWrite(buzzer,HIGH);
        delay(50);
        digitalWrite(buzzer,LOW); 
      }
      delay(1500);
    }
    invert_counter = invert_counter + 1;
  }

  


  
  if(digitalRead(mode_in) && mode_button_pressed)
  {
    mode_button_pressed= false;    
    sound_changed = false;
    counter = 0;
    invert_counter = 0;
  }
  
    
  if(!mode)
  {
  throttle_to_send = map_normal(analogRead(throttle_in), 0, 512, 1023, throttle_inverted);
  yaw_to_send = map_normal(analogRead(yaw_in), 0, 512, 1023,           yaw_inverted);
  pitch_to_send = map_normal(analogRead(pitch_in), 0, 512, 1023,       pitch_inverted);
  roll_to_send = map_normal(analogRead(roll_in), 0, 512, 1023,         roll_inverted);  
  }
  
  if(mode)
  {
  throttle_to_send = map_exponential(analogRead(throttle_in), throttle_inverted);
  yaw_to_send = map_exponential(analogRead(yaw_in),           yaw_inverted);
  pitch_to_send = map_exponential(analogRead(pitch_in),       pitch_inverted);
  roll_to_send = map_exponential(analogRead(roll_in),         roll_inverted);  
  }

  


  throttle_to_send = throttle_to_send  + throttle_fine - 127;
  yaw_to_send = yaw_to_send  + yaw_fine - 127;
  pitch_to_send = pitch_to_send  + pitch_fine - 127;
  roll_to_send = roll_to_send  + roll_fine - 127;  
  
  
  data.throttle = constrain(throttle_to_send,0,255);
  data.yaw      = constrain(yaw_to_send,0,255);
  data.pitch    = constrain(pitch_to_send,0,255);
  data.roll     = constrain(roll_to_send,0,255);
  data.AUX1     = digitalRead(toggle_1);
  data.AUX2     = digitalRead(toggle_2);

  radio.write(&data, sizeof(MyData));


  display.clearDisplay();            
  if(sound)
  {
    display.setCursor(0,0);           
    display.print("Sound ON");      
  }
  if(!sound)
  {
    display.setCursor(0,0);            
    display.print("Sound OFF");      
  }
  display.setCursor(90,0);           
  display.print(battery_level,1);      
  display.print("V");     
  display.setCursor(0,16);         
  display.print("T: ");             
  display.print(throttle_to_send);     
  display.print("      P: ");  
  display.print(pitch_to_send);    
  display.setCursor(0,29);
  display.print("Y: ");             
  display.print(yaw_to_send);     
  display.print("      R: ");  
  display.print(roll_to_send);  
 
  display.setCursor(0,42);
  display.print("SW1: ");             
  display.print(digitalRead(toggle_1));     
  display.print("      SW2: ");  
  display.print(digitalRead(toggle_2));  
  if(mode)
  {
    display.setCursor(0,56);
    display.print("Mode: ");      
    display.print("Exponential"); 
  }
  if(!mode)
  {
    display.setCursor(0,56);
    display.print("Mode: ");      
    display.print("Linear"); 
  }
  
  display.display();    


  
}

And this is the error-

error: #error ("Height incorrect, please fix this in the Adafruit_SSD1306.h!");
 #error("Height incorrect, please fix this in the Adafruit_SSD1306.h!");
  ^~~~~
exit status 1

Compilation error: #error ("Height incorrect, please fix this in the Adafruit_SSD1306.h!");

What can I do to fix it

I would have thought that was perfectly obvious from the error message. It's literally telling you what to change, and where.

Or, you could change your sketch to not use a deprecated for years now constructor, specify the display dimensions in your sketch, and remove the now unnecessary height test. Like so:

#include <Adafruit_SSD1306.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#include <SPI.h>
#include <nRF24L01.h>            
#include <RF24.h>              
#include <Wire.h>
#include <Adafruit_GFX.h>         
#include <Adafruit_SSD1306.h>     
#include <EEPROM.h>


#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64 

#define OLED_RESET     -1 
#define SCREEN_ADDRESS 0x3C


#define OLED_RESET 8
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define NUMFLAKES 5
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix this in the Adafruit_SSD1306.h!");
#endif

still the same error is coming
with updated code

Remove these lines, there is no need to check the value of SSD1306_LCDHEIGHT when specifying the display height and width in the constructor. Originally the constructor did not have a method of defining the height and width, that had to be set in the library header file, and the if statement was put into code to verify that setting was correct.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.