58 lines
1.3 KiB
Arduino
58 lines
1.3 KiB
Arduino
//Library inclusions
|
|
#include <Wire.h>
|
|
#include <Adafruit_GFX.h>
|
|
#include <Adafruit_SSD1306.h>
|
|
#include <Fonts/FreeMono9pt7b.h>
|
|
#include "setup.h"
|
|
#include "dseg7_7seggchan_font_48p_regular.h"
|
|
#include "dseg7_classic_font_12p_regular.h"
|
|
#include "DialogInput_font_12p_regular.h"
|
|
|
|
#define SCREEN_WIDTH 128
|
|
#define SCREEN_HEIGHT 64
|
|
#define OLED_RESET -1
|
|
#define SCREEN_ADDRESS 0x3C
|
|
|
|
float voltage = 0;
|
|
float current = 0;
|
|
float wattage = 0;
|
|
|
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Wire.setSDA(I2C_SDA);
|
|
Wire.setSCL(I2C_SCL);
|
|
Wire.begin();
|
|
|
|
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)){
|
|
Serial.println("Display Error: Check Connections");
|
|
Serial.print("SDA=");
|
|
Serial.println(I2C_SDA);
|
|
Serial.print("SCL:");
|
|
Serial.println(I2C_SCL);
|
|
while(true){
|
|
delay(100);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void loop() {
|
|
drawDisplay();
|
|
|
|
}
|
|
|
|
void drawDisplay() {
|
|
display.clearDisplay();
|
|
display.setTextColor(WHITE);
|
|
display.setTextSize(1);
|
|
display.setFont(&DSEG7_7SEGGCHAN_MINI_Regular_48);
|
|
display.setCursor(84, 64);
|
|
display.println("8");
|
|
display.setCursor(0,64);
|
|
display.setFont(&DialogInput_plain_8);
|
|
display.print("W:");
|
|
display.setFont(&DSEG7_Classic_Mini_Regular_11);
|
|
display.print("12.8");
|
|
display.display();
|
|
} |