Update voltage-current-monitor-usb.ino
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
#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 "dseg7_7seggchan_mini_font_48p_regular.h"
|
||||
#include "dseg7_classic_mini_font_11p_regular.h"
|
||||
#include "DialogInput_font_12p_regular.h"
|
||||
#include <hardware/adc.h>
|
||||
#include "images.h"
|
||||
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
@@ -16,9 +18,12 @@
|
||||
float voltage = 0;
|
||||
float current = 0;
|
||||
float wattage = 0;
|
||||
int usb_score = -1;
|
||||
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
void setup() {
|
||||
adc_init();
|
||||
adc_set_temp_sensor_enabled(true);
|
||||
Serial.begin(115200);
|
||||
Wire.setSDA(I2C_SDA);
|
||||
Wire.setSCL(I2C_SCL);
|
||||
@@ -50,7 +55,15 @@ void drawDisplay() {
|
||||
if(use_7seggchan){
|
||||
display.setFont(&DSEG7_7SEGGCHAN_MINI_Regular_48);
|
||||
display.setCursor(84, 66);
|
||||
display.println("8");
|
||||
if(usb_score == -1){
|
||||
display.println("-");
|
||||
}
|
||||
else if (usb_score == -2) {
|
||||
display.println(" ");
|
||||
}
|
||||
else {
|
||||
display.println(usb_score);
|
||||
}
|
||||
display.drawFastVLine(80,16,48,WHITE);
|
||||
}
|
||||
display.drawFastHLine(0,16,128,WHITE);
|
||||
@@ -68,6 +81,17 @@ void drawDisplay() {
|
||||
display.print(current);
|
||||
display.setCursor(13,32);
|
||||
display.print(voltage);
|
||||
if(use_bitmaps){
|
||||
display.setCursor(16,0);
|
||||
display.drawBitmap(0,0,temperature_bitmap,16,16,WHITE);
|
||||
display.setFont(&DSEG7_Classic_Mini_Regular_11);
|
||||
display.setCursor(16,16);
|
||||
}
|
||||
else {
|
||||
display.setCursor(0,16);
|
||||
}
|
||||
display.print(analogReadTemp(),1);
|
||||
display.print(" C°");
|
||||
display.display();
|
||||
}
|
||||
else {
|
||||
@@ -89,6 +113,19 @@ void drawDisplay() {
|
||||
display.print(current);
|
||||
display.setCursor(13,32);
|
||||
display.print(voltage);
|
||||
if(use_bitmaps){
|
||||
display.setCursor(16,0);
|
||||
display.drawBitmap(0,0,temperature_bitmap,16,16,WHITE);
|
||||
display.setFont(&DSEG7_Classic_Mini_Regular_11);
|
||||
display.setCursor(16,16);
|
||||
}
|
||||
else {
|
||||
display.setCursor(0,16);
|
||||
}
|
||||
display.print(analogReadTemp(),1);
|
||||
display.print(" C°");
|
||||
display.display();
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user