(SOLVED) OLED doesn't Light up

Hello!
I’m working hard on this code and I saw one bug! I’ve tested this code and it seems like my OLED doesn’t light up! I uploaded Adafruit example and everything worked fine! Here are 3 main files:

PowerOS.ino

// Adafruit SSD1306 - Version: Latest 
#include <Adafruit_SSD1306.h>
#include <splash.h>
#include "PowerOS.h"
#include <SPI.h>
#include <Wire.h>


int left_button = 1;
int right_button = 2;
int ok_button = 3;
int cancel_button = 4;

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(2000);
  display.clearDisplay();
  startup();
  
}

void loop() {
  if (digitalRead(left_button) == HIGH){
    if (currentState==3){
      main2();
      delay(500);
    }
    else if (currentState==2){
      main1();
      delay(500);
    }
    else if (currentState==4){
      main3();
      delay(500);
    }
    else if (currentState==5){
      main4();
      delay(500);
    }
    else if (currentState==7){
      game = game-1;
    }
  }
  if (digitalRead(ok_button) == HIGH){
    if (currentState==2){
      pgames();
      delay(500);
    }
    else if (currentState==3){
      about();
      delay(500);
    }
    else if (currentState==5){
      psettings();
      delay(500);
    }
    else if (currentState==7){
      if (game==1){
        //game-mytja.game1();
      }
      else if (game==2){
        //game-mytja.TestGame();
      }
    }
  }
  if (digitalRead(right_button) == HIGH){
    if (currentState==1){
      main2();
      delay(500);
    }
    else if (currentState==2){
      main3();
      delay(500);
    }
    else if (currentState==3){
      main4();
      delay(500);
    }
    else if (currentState==4){
      main5();
      delay(500);
    }
    else if (currentState==7){
      game = game+1;
    }
  }
  if (digitalRead(cancel_button) == HIGH){
    if (currentState==7){
      main2();
      delay(500);
    }
    else if (currentState==8){
      main3();
      delay(500);
    }
    else if (currentState==10){
      main5();
      delay(500);
    }
  }
}

PowerOS.h

#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include "PowerLib.h"
#define OLED_ADDR   0x3C
#include <Wire.h>
#define BATTERY_MODE_SOLID 1
#define CHARGE_AREA_START_X     20
#define CHARGE_AREA_START_Y     18
#define CHARGE_AREA_WIDTH       83
#define CHARGE_AREA_HEIGHT      28
#define YELLOW 0xFFE0
#define BLUE 0x001F

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);


int game = 1;
int cursor = 1;
int led = 6;


void showBatteryLevel(uint8_t percent)
{
    uint8_t width;

    if (percent > 100)
        percent = 100;

    display.clearDisplay();
    display.drawBitmap(0, 0, battery_bitmap, 128, 64, WHITE);

    if (BATTERY_MODE_SOLID)
    {
        width = (percent * CHARGE_AREA_WIDTH) / 100;
        display.drawRect(CHARGE_AREA_START_X, CHARGE_AREA_START_Y, width, CHARGE_AREA_HEIGHT, WHITE);
    } else {
        uint8_t bars;
        
        if (percent >= 66)
        {
            // Show three bars
            bars = 3;
        } else if (percent >= 33)
        {
            // Show two bars
            bars = 2;
        } else if (percent > 0)
        {
            // Show one bar
            bars = 1;
        } else {
            // Show nothing
            bars = 0;
        }

        uint8_t offset = CHARGE_AREA_START_X;
        for (uint8_t i = 0; i < bars; i++)
        {
            display.drawRect(offset, CHARGE_AREA_START_Y, 27, CHARGE_AREA_HEIGHT, WHITE);
            offset += 28;
        }
    }

    display.display();
}
int percent = 100;
int currentState = 0;

void main1(){
  display.clearDisplay();
  showBatteryLevel(percent);
    
  if (percent){
    percent--;
  }
  else{
    percent = 100;
  }
  delay(50);
  display.display();
  currentState = 1;
}

void startup(){
 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //or 0x3C
  display.clearDisplay(); //for Clearing the display
  display.drawBitmap(0, 0, poweros_logo, 32, 64, BLUE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
  display.setTextSize(3);
  display.setTextColor(YELLOW);
  display.setCursor(40, 32);
  display.print("PowerOS");
  display.setTextSize(1);
  
  display.setCursor(40, 50);
  display.print("Loading");
  display.display();
  currentState = 0;
  delay(3000);
  main1();
  
}

void main2(){
  display.clearDisplay();
  display.drawBitmap(0, 0, poweros_logo, 32, 64, BLUE);
  display.setTextSize(3);
  display.setTextColor(YELLOW);
  display.setCursor(40, 32);
  display.print("PGames");
  display.display();
  currentState = 2;
}

void main3(){
  display.clearDisplay();
  display.drawBitmap(0, 0, poweros_logo, 32, 64, BLUE);
  display.setTextSize(3);
  display.setTextColor(YELLOW);
  display.setCursor(40, 32);
  display.print("ABOUT");
  display.display();
  currentState = 3;
}

void main4(){
  display.clearDisplay();
  display.drawBitmap(0, 0, poweros_logo, 64, 32, BLUE);
  display.setTextSize(1);
  display.setTextColor(YELLOW);
  display.setCursor(64, 32);
  display.print("FLASHLIGHT");
  display.display();
  display.setCursor(110, 46);
  if (digitalRead(led)==HIGH){
    display.print("ON");
  }
  else{
    display.print("OFF");
  }
  currentState = 4;
}

void main5(){
  display.clearDisplay();
  display.drawBitmap(0, 0, poweros_logo, 96, 32, BLUE);
  display.setTextSize(1);
  display.setTextColor(YELLOW);
  display.setCursor(64, 46);
  display.print("SETTINGS");
  display.display();
  currentState = 5;
}

void pgames(){
  display.setTextSize(3);
  display.setTextColor(BLUE);
  display.setCursor(64, 10);
  display.print("Welcome to PGames Game Selector!");
  display.setTextColor(YELLOW);
  display.setTextSize(1);
  display.setCursor(64, 20);
  display.print("Game1");
  display.display();
  currentState = 7;
}

void about(){
  display.clearDisplay();
  display.drawBitmap(0, 0, poweros_logo, 64, 32, BLUE);
  display.setTextSize(1);
  display.setTextColor(YELLOW);
  display.setCursor(64, 0);
  display.print("copyright MyTja");
  display.setCursor(0, 35);
  display.print("Language: Arduino C");
  display.setCursor(0, 43);
  display.print("version 1.0.1");
  display.setCursor(0, 50);
  display.print("www.mytja.tk");
  display.display();
  currentState = 8;
}

void psettings(){
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(BLUE);
  display.setCursor(0, 0);
  display.print("PSettings");
  display.setTextColor(YELLOW);
  display.setCursor(0, 10);
  display.print("Language: English (UK)");
  display.setCursor(0, 20);
  display.print("License: Open-source");
  display.setCursor(0, 30);
  display.print("Wireless charging: OFF");
  currentState = 10;
}

PowerLib.h
It is on GitHub, because I reached the limit of characters (if you need it, it is full of HEX values)

Yeah, I checked. My OLED is on 0x3C
This is a little bit modified version, because I tried a lot of things, but nothing worked! If you want to check GitHub respository, here it is: https://github.com/mytja/PowerOS-MyTja! Newest version is v1.0.2!

Sorry for my English and thanks for your time!

Hello Mitjas,
Welcome to the forum.

Some possible reasons for no one helping:

  • No one knows the answer.
  • You marked this urgent; nothing is urgent here, we are volunteers trying to help, we answer when we want to. If it really is urgent then post in gigs and collaborations and give some indication of how much you are willing to pay for a quick response.
  • We need to see how you have it wired up, maybe a photo and a schematic. Something not lighting up suggests a wiring problem.
  • You have posted a long an complex bit of code for what is likely to be a simple problem. Write a very simple program that illustrates the problem.

Probably nothing to do with the problem you are asking about but consider your use of delay. Please study blink without delay, which is in the examples in the IDE under digital and apply the lessons learnt to your code. Delay might be working OK for you now in simple code, but the more complex your code gets the more delay will cause you problems.
In answer to the question “my code is not very responsive and I don’t know why”, which you will be asking in a month or 3; “It’s because of all the delays”.

Sorry for my English and thanks for your time!

Your English is fine! Better than many native speakers of English!

@Mitjas

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

And while you are at it, since I see you have figured out how to edit your posts, go back to the first and remove the rude "[URGENT]" claim from the subject line.

This sort of thing actually makes people less likely to help you. Refer to Aesop's fables.

Yes, thanks to all!
I'm so dumb! Solution was so easy!
I just needed to replace BLUE and YELLOW with WHITE!

Thank you for tidying up your subject line.

You are welcome!