18 Commits
Author SHA1 Message Date
vicentebearth 747cb9402d Upload files to "/" 2026-08-27 19:15:10 +02:00
vicentebearth 9f940a09fd Update rp2040-zero/images.h 2026-08-27 18:32:05 +02:00
vicentebearth 9d185c3d54 Update rp2040-zero/setup.h 2026-08-27 18:31:29 +02:00
vicentebearth ade1c83ff0 Update rp2040-zero/voltage-current-monitor-usb.ino 2026-08-27 17:54:42 +02:00
vicentebearth be5b9e6dc6 Update README.md 2026-08-27 17:29:12 +02:00
vicentebearth f174b4eb5c Update README.md 2026-08-27 12:57:50 +02:00
vicentebearth 32d7b899a5 Update README.md 2026-08-27 12:57:19 +02:00
vicentebearth b95467479e Update README.md 2026-08-27 12:56:44 +02:00
vicentebearth 853132fe4f Update README.md 2026-08-27 12:47:01 +02:00
vicentebearth 50fa496c9b Update README.md 2026-08-27 12:46:42 +02:00
vicentebearth 4699e748e3 Update README.md 2026-08-27 12:44:00 +02:00
vicentebearth c7a55101e7 Update README.md 2026-08-27 09:11:54 +02:00
vicentebearth b62089e7ab Update README.md 2026-08-27 09:11:34 +02:00
vicentebearth 47d5fb899c Update README.md 2026-08-27 09:11:20 +02:00
vicentebearth e96a05ce62 also for the readme 2026-08-27 08:26:01 +02:00
vicentebearth 2f6aa86de7 Update README.md 2026-08-27 08:25:25 +02:00
vicentebearth 812fb95a0e needed for readme.md :3 2026-08-27 07:47:42 +02:00
vicentebearth 91e51e3616 made the readme better >:) 2026-08-27 07:46:12 +02:00
7 changed files with 235 additions and 207 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

+19
View File
@@ -0,0 +1,19 @@
# St-stop!
d-dont read me!
i know im called README but im not finished yet *baka*!
And its *not* because my creator is lazy.
*hmph*
[[IMG_5542.jpeg]]
although…
he created me 2 months ago…
and didnt edit me until now…
so maybe he *is* lazy
BUT DONT TALK ABOUT HIM LIKE THAT *OK*?
o-oki y-you can leave now, user-san
***AND DONT THINK I LIKE YOU, BAKA***
[[IMG_5552.gif]]
<small>*why am i doing this...*
BIN
View File
Binary file not shown.
+7
View File
@@ -14,3 +14,10 @@ const unsigned char clock_bitmap [] PROGMEM = {
0x83, 0xe1, 0x80, 0x01, 0x80, 0x01, 0x40, 0x02, 0x40, 0x02, 0x20, 0x04, 0x18, 0x18, 0x07, 0xe0
};
const unsigned char placeholder [] PROGMEM = {
};
const unsigned char placeholder2 [] PROGMEM = {
};
+6 -3
View File
@@ -1,7 +1,7 @@
//Setup file for main sketch
const float shunt_resistance = -1; //resistance of current shunt in milliohms
const float voltage_divider = 2;
const float shunt_resistance = 50; //resistance of current shunt in milliohms
const float voltage_divider = 2;//by what does the voltage get divided
const char mcu_model[] ={"RP2040-Zero"};//currently unused, might be useful later
const int default_usbscore = -1;
@@ -15,4 +15,7 @@ const int default_usbscore = -1;
const bool use_7seggchan = true ; //pls use him he did nothing wrong [pleading face]
const bool use_default_fonts = false ; //use custom fonts or default fonts (custom fonts reccomended, set to true and dont include fonts if memory usage is too high)
const bool use_bitmaps = true;//use bitmaps (reccomended, set to false and dont include images.h if memory usage is too high)
const bool use_usbscore = true; //(doesnt work if 7segg-chan is set to false)calculates usb score (value from 0-9) and prints it in 7segg-chan font to determine quality (reccomended)
const bool use_usbscore = true; //(doesnt work if 7segg-chan is set to false)calculates usb score (value from 0-9) and prints it in 7segg-chan font to determine quality (reccomended)
const bool draw_splash = true; //use splash screen, included in images.h
const bool use_version_splash = true; //use version-specific splash screen, also included in images.h
const unsigned long splash_time = 1000;
+203 -204
View File
@@ -2,13 +2,13 @@
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeMono9pt7b.h>//not needed, idk why its here
#include "setup.h" //setup file, dont delete, else needed variables wont be declared
#include "dseg7_7seggchan_mini_font_48p_regular.h"//7segg-chan lives here! (fontfile, comment out if 7segg-chan is disabled (i told you not to >:( ) or default fonts are enabled))
#include "dseg7_classic_mini_font_11p_regular.h"//font, comment out or delete if default fonts are enabled
#include "DejaVu_Sans_Mono_font_12p_regular.h"//font, comment out or delete if default fonts are enabled
#include <hardware/adc.h> //files for adc
#include "images.h"//bitmaps, comment out or delete if bitmaps are disabled
#include <Fonts/FreeMono9pt7b.h> //not needed, idk why its here
#include "setup.h" //setup file, dont delete, else needed variables wont be declared
#include "dseg7_7seggchan_mini_font_48p_regular.h" //7segg-chan lives here! (fontfile, comment out if 7segg-chan is disabled (i told you not to >:( ) or default fonts are enabled))
#include "dseg7_classic_mini_font_11p_regular.h" //font, comment out or delete if default fonts are enabled
#include "DejaVu_Sans_Mono_font_12p_regular.h" //font, comment out or delete if default fonts are enabled
#include <hardware/adc.h> //files for adc
#include "images.h" //bitmaps, comment out or delete if bitmaps are disabled
//screen definitions
#define SCREEN_WIDTH 128
@@ -26,15 +26,19 @@ int uptime_sec = 0;
int raw_voltage = 0;
int raw_current = 0;
int counter = 0;
unsigned long old_millis = 0;
unsigned long old_millis_blink = 0;
unsigned long old_millis_clock = 0;
unsigned long old_millis_main = 0;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
old_millis = millis();
//set old milli values
old_millis_blink = millis();
old_millis_clock = millis();
old_millis_main = millis();
analogReadResolution(12);
//adc_init();
//adc_set_temp_sensor_enabled(true);
@@ -46,233 +50,228 @@ void setup() {
Wire.begin();
//display init
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)){
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println("Display Error: Check Connections");
Serial.print("SDA=");
Serial.print("SDA:");
Serial.println(I2C_SDA);
Serial.print("SCL:");
Serial.println(I2C_SCL);
while(true){
delay(100);
while (true) {
delay(100);
}
}
drawSplash();
delay(splash_time);
}
void loop() {
raw_voltage = analogRead(VOLTAGE_PIN);
voltage = (raw_voltage / 4095.0) * 3.3 * voltage_divider;
raw_current = analogRead(CURRENT_PIN);
current = (raw_current / 4095.0) * 3.3 * 20 ;
wattage = current * voltage;
if(use_usbscore){
usb_score = calculateUSBScore();
if (millis() - old_millis_main >= 100) {
raw_voltage = analogRead(VOLTAGE_PIN);
voltage = (raw_voltage / 4095.0) * 3.3 * voltage_divider;
raw_current = analogRead(CURRENT_PIN);
current = (raw_current / 4095.0f) * 3.3f * (1000.0f / shunt_resistance);
wattage = current * voltage;
if (use_usbscore) {
usb_score = calculateUSBScore();
} else {
usb_score = default_usbscore;
}
drawDisplay();
}
else{
usb_score = default_usbscore;
}
drawDisplay();
old_millis_main = millis();
runCounter(1000);
countUptime();
delay(100);
}
//display draw function
void drawDisplay() {
if(!use_default_fonts){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
if(use_7seggchan){
display.setFont(&DSEG7_7SEGGCHAN_MINI_Regular_48);
display.setCursor(84, 66);
if(usb_score == -1){
display.println("-");
}
else if (usb_score == -2) {
display.println(" ");
}
else {
display.println(usb_score);
}
display.drawFastVLine(80,16,48,WHITE);
if (!use_default_fonts) {
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
if (use_7seggchan) {
display.setFont(&DSEG7_7SEGGCHAN_MINI_Regular_48);
display.setCursor(84, 66);
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);
display.setCursor(0,64);
display.setFont(&DialogInput_plain_12);
display.print("W:");
display.setCursor(0, 48);
display.print("A:");
display.setCursor(0,32);
display.print("V:");
display.setFont(&DSEG7_Classic_Mini_Regular_11);
display.setCursor(13, 64);
display.print(wattage);
display.setCursor(13,48);
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°");
if(use_bitmaps){
display.drawBitmap(65,0,clock_bitmap,16,16,WHITE);
display.setCursor(82,16);
}
else{
display.setCursor(82,16);
}
display.drawFastVLine(62,0,16,WHITE);
if(uptime_min<10){
display.print("0");
}
display.print(uptime_min);
display.print(":");
display.setFont(&DSEG7_Classic_Mini_Regular_11);
if(uptime_sec < 10){
display.print("0");
}
display.print(uptime_sec);
display.display();
}
else {
display.clearDisplay();
display.drawFastHLine(0,16,128,WHITE);
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,56);
display.setFont(NULL);
display.print("W:");
display.setCursor(0, 44);
display.print("A:");
display.setCursor(0,32);
display.print("V:");
display.setFont(NULL);
display.setCursor(13, 56);
display.print(wattage);
display.setCursor(13,44);
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(NULL);
display.setCursor(16,8);
}
else {
display.setCursor(0,8);
}
display.print(analogReadTemp(),1);
display.print(" C");
if(use_bitmaps){
display.setCursor(16,0);
display.drawBitmap(0,0,temperature_bitmap,16,16,WHITE);
display.setCursor(16,16);
}
else {
display.setCursor(0,8);
}
display.drawFastHLine(0, 16, 128, WHITE);
display.setCursor(0, 64);
display.setFont(&DialogInput_plain_12);
display.print("W:");
display.setCursor(0, 48);
display.print("A:");
display.setCursor(0, 32);
display.print("V:");
display.setFont(&DSEG7_Classic_Mini_Regular_11);
display.setCursor(13, 64);
display.print(wattage);
display.setCursor(13, 48);
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°");
if (use_bitmaps) {
display.drawBitmap(65, 0, clock_bitmap, 16, 16, WHITE);
display.setCursor(82, 16);
} else {
display.setCursor(82, 16);
}
display.drawFastVLine(62, 0, 16, WHITE);
if (uptime_min < 10) {
display.print("0");
}
display.print(uptime_min);
display.print(":");
display.setFont(&DSEG7_Classic_Mini_Regular_11);
if (uptime_sec < 10) {
display.print("0");
}
display.print(uptime_sec);
display.display();
} else {
display.clearDisplay();
display.drawFastHLine(0, 16, 128, WHITE);
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 56);
display.setFont(NULL);
display.print("W:");
display.setCursor(0, 44);
display.print("A:");
display.setCursor(0, 32);
display.print("V:");
display.setFont(NULL);
display.setCursor(13, 56);
display.print(wattage);
display.setCursor(13, 44);
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(NULL);
display.setCursor(16, 8);
} else {
display.setCursor(0, 8);
}
display.print(analogReadTemp(), 1);
display.print(" C");
if (use_bitmaps) {
display.setCursor(16, 0);
display.drawBitmap(0, 0, temperature_bitmap, 16, 16, WHITE);
display.setCursor(16, 16);
} else {
display.setCursor(0, 8);
}
if(use_bitmaps){
display.drawBitmap(65,0,clock_bitmap,16,16,WHITE);
display.setCursor(82,8);
}
else{
display.setCursor(94,8);
}
display.drawFastVLine(62,0,16,WHITE);
if(uptime_min<10){
display.print("0");
}
display.print(uptime_min);
display.print(":");
display.setFont(NULL);
if(uptime_sec < 10){
display.print("0");
}
display.print(uptime_sec);
display.display();
if (use_bitmaps) {
display.drawBitmap(65, 0, clock_bitmap, 16, 16, WHITE);
display.setCursor(82, 8);
} else {
display.setCursor(94, 8);
}
display.drawFastVLine(62, 0, 16, WHITE);
if (uptime_min < 10) {
display.print("0");
}
display.print(uptime_min);
display.print(":");
display.setFont(NULL);
if (uptime_sec < 10) {
display.print("0");
}
display.print(uptime_sec);
display.display();
}
}
int calculateUSBScore(){ //returns score depending on usb voltage, gets displayed as 7segg-chan
if(voltage < 3 || voltage > 8){
if(counter == 0){
return -1 ;
int calculateUSBScore() { //returns score depending on usb voltage, gets displayed as 7segg-chan
if (voltage < 3 || voltage > 8) {
if (counter == 0) {
return -1;
} else {
return -2;
}
else {
return -2 ;
}
}
else if (voltage <3.5 || voltage > 6.5){
return 0 ;
}
else if(voltage < 3.7 || voltage > 6.3){
return 1 ;
}
else if (voltage < 4 || voltage > 6) {
return 2 ;
}
else if (voltage < 4.2 || voltage > 5.8 ){
return 3 ;
}
else if (voltage < 4.4 || voltage > 5.6){
return 4 ;
}
else if (voltage < 4.6 || voltage > 5.4){
} else if (voltage < 3.5 || voltage > 6.5) {
return 0;
} else if (voltage < 3.7 || voltage > 6.3) {
return 1;
} else if (voltage < 4 || voltage > 6) {
return 2;
} else if (voltage < 4.2 || voltage > 5.8) {
return 3;
} else if (voltage < 4.4 || voltage > 5.6) {
return 4;
} else if (voltage < 4.6 || voltage > 5.4) {
return 5;
}
else if (voltage < 4.7 || voltage > 5.3){
} else if (voltage < 4.7 || voltage > 5.3) {
return 6;
}
else if (voltage < 4.8 || voltage > 5.2){
return 7 ;
}
else if (voltage < 4.9 || voltage > 5.1){
return 8 ;
}
else if (voltage < 5.1 || voltage > 4.9){
return 9 ;
}
else {
return -1 ;
} else if (voltage < 4.8 || voltage > 5.2) {
return 7;
} else if (voltage < 4.9 || voltage > 5.1) {
return 8;
} else if (voltage < 5.1 || voltage > 4.9) {
return 9;
} else {
return -1;
}
}
//counter for any blink animations
void runCounter(int time){
if (millis() > old_millis + time){
if(counter == 0){
counter = counter + 1;
}
else {
void runCounter(int time) {
if (millis() > old_millis_blink + time) {
if (counter == 0) {
counter = counter + 1;
} else {
counter = 0;
}
old_millis = millis();
old_millis_blink = millis();
}
}
//counts uptime
void countUptime(){
if (old_millis_clock+1000 < millis()){//old millidonalds had a farm heia heya hoo
uptime_sec =uptime_sec + 1;
if (uptime_sec >59){
uptime_sec = 0;
uptime_min = uptime_min +1;
}
if (uptime_min > 99){
uptime_min = 0;
uptime_sec = 0;
}
old_millis_clock = millis();
void countUptime() {
if (old_millis_clock + 1000 < millis()) { //old millidonalds had a farm heia heya hoo
uptime_sec = uptime_sec + 1;
if (uptime_sec > 59) {
uptime_sec = 0;
uptime_min = uptime_min + 1;
}
if (uptime_min > 99) {
uptime_min = 0;
uptime_sec = 0;
}
old_millis_clock = millis();
}
}
}
//draws splash screen
void drawSplash() {
if (draw_splash){
if (use_version_splash){
display.drawBitmap(0, 0, placeholder, 128, 64, WHITE);
}
else{
display.drawBitmap(0, 0, placeholder, 128, 64, WHITE);
}
}
}