2023-03-02 21:05:48 +00:00
|
|
|
#ifndef _DISPLAY_H_
|
|
|
|
#define _DISPLAY_H_
|
|
|
|
|
|
|
|
#include <Wire.h>
|
|
|
|
#include <Adafruit_GFX.h>
|
|
|
|
#include <Adafruit_SSD1306.h>
|
|
|
|
|
|
|
|
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
|
|
|
#define SCREEN_HEIGHT 32 // 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);
|
|
|
|
|
|
|
|
void display_init();
|
2023-04-15 22:13:02 +00:00
|
|
|
void display_update();
|
2023-03-02 21:05:48 +00:00
|
|
|
|
|
|
|
void display_init(){
|
|
|
|
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
|
|
|
Serial.println(F("SSD1306 allocation failed"));
|
|
|
|
}
|
|
|
|
display.clearDisplay();
|
2023-04-15 22:13:02 +00:00
|
|
|
display.setTextSize(1); // Normal 1:1 pixel scale
|
|
|
|
display.setTextColor(SSD1306_WHITE); // Draw white text
|
|
|
|
display.setCursor(0,0); // Start at top-left corner
|
2023-03-02 21:05:48 +00:00
|
|
|
display.display();
|
|
|
|
}
|
|
|
|
|
2023-04-15 22:13:02 +00:00
|
|
|
void display_update(){
|
2023-03-02 21:05:48 +00:00
|
|
|
display.clearDisplay();
|
|
|
|
display.setTextSize(1); // Normal 1:1 pixel scale
|
|
|
|
display.setTextColor(SSD1306_WHITE); // Draw white text
|
|
|
|
display.setCursor(0,0); // Start at top-left corner
|
2023-04-15 22:13:02 +00:00
|
|
|
display.print(F("Speed : ")); display.println(meanSpeedms);
|
|
|
|
display.print(F("Throttle: ")); display.println(throttle_pos);
|
|
|
|
display.print(F("Brake : ")); display.println(brake_pos);
|
|
|
|
display.print(F("Current : ")); display.println(filtered_currentAll);
|
|
|
|
|
|
|
|
|
2023-03-02 21:05:48 +00:00
|
|
|
display.display();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|