Restructured Repo before adding Hardware-Files
This commit is contained in:
42
Software/src/oled_display.cpp
Normal file
42
Software/src/oled_display.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "oled_display.h"
|
||||
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);
|
||||
|
||||
void OLED_Init()
|
||||
{
|
||||
|
||||
// reset OLED display via software
|
||||
pinMode(OLED_RST, OUTPUT);
|
||||
digitalWrite(OLED_RST, LOW);
|
||||
delay(20);
|
||||
digitalWrite(OLED_RST, HIGH);
|
||||
|
||||
// initialize OLED
|
||||
Wire.begin(OLED_SDA, OLED_SCL);
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false))
|
||||
{ // Address 0x3C for 128x32
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
}
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextColor(WHITE);
|
||||
display.setTextSize(1);
|
||||
display.setCursor(0, 0);
|
||||
display.print("DISPLAY INIT");
|
||||
display.display();
|
||||
}
|
||||
|
||||
void OLED_Process()
|
||||
{
|
||||
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 0);
|
||||
display.printf("LiPo: %d%%\n", globals.battery_level);
|
||||
display.print(PersistenceData.activeFaction == FACTION_1 ? "> " : " ");
|
||||
display.printf("%-5s: %02d:%02d:%02d\n", FACTION_1_NAME, PersistenceData.faction_1_timer / 3600, (PersistenceData.faction_1_timer / 60) % 60, PersistenceData.faction_1_timer % 60);
|
||||
display.print(PersistenceData.activeFaction == FACTION_2 ? "> " : " ");
|
||||
display.printf("%-5s: %02d:%02d:%02d\n", FACTION_2_NAME, PersistenceData.faction_2_timer / 3600, (PersistenceData.faction_2_timer / 60) % 60, PersistenceData.faction_2_timer % 60);
|
||||
display.print(PersistenceData.activeFaction == FACTION_3 ? "> " : " ");
|
||||
display.printf("%-5s: %02d:%02d:%02d\n", FACTION_3_NAME, PersistenceData.faction_3_timer / 3600, (PersistenceData.faction_3_timer / 60) % 60, PersistenceData.faction_3_timer % 60);
|
||||
display.display();
|
||||
}
|
Reference in New Issue
Block a user