Wydanie prawie gotowe - poprawka rtylko na napieciu zasilania

This commit is contained in:
sieja
2025-08-25 18:01:06 +02:00
parent 9f59a70e36
commit 77ee1a9a05

View File

@@ -10,10 +10,10 @@
#include "SD.h"
#include "SPI.h"
#define Version "0.6"
#define Version "0.8"
#define WIRE Wire
#define DHTTYPE DHT22
#define DHTPIN 4 //GPIO04 D4
#define DHTPIN 2 //GPIO02 D2
#define SD_CS 5 //GPIO05 D5
#define BTN_UP 33 //GPIO33 D33
@@ -105,7 +105,7 @@ float quickBatteryVoltage3 = 0;
float quickBatteryVoltage4 = 0;
float currentBatteryVoltage = 0;
float lastBatteryVoltage = 0;
int battLifeMins = 998;
int battLifeMins = 4000;
int estHours = 0;
int estMins = 0;
@@ -144,7 +144,7 @@ float voltageToPercentage(float voltage) {
// Reprezentatywne punkty (wolt, procent)
const int nPoints = 9;
// Napięcia uporządkowane malejąco
float vPoints[nPoints] = { 4.06, 4.00, 3.95, 3.90, 3.85, 3.80, 3.70, 3.45, 2.75 };
float vPoints[nPoints] = { 4.180, 4.115, 4.060, 4.005, 3.951, 3.896, 3.787, 3.514, 2.750 };
// Odpowiednie poziomy naładowania
float pPoints[nPoints] = { 100, 95, 90, 80, 70, 60, 50, 10, 0 };
if (voltage >= vPoints[0])
@@ -172,30 +172,10 @@ float chargeVoltageToPercentage(float voltage) {
// Przykładowe punkty (napięcie w V rosnąco)
// Dopasuj je do własnych obserwacji / charakterystyki baterii
const int nPoints = 10;
float vPoints[nPoints] = {
4.03, // ~0%
4.06, // ~1%
4.12, // ~5%
4.14, // ~10%
4.16, // ~30%
4.18, // ~60%
4.19, // ~80%
4.20, // ~95%
4.21, // ~98%
4.22 // 100%
};
float pPoints[nPoints] = {
0, // 4.03 V
1, // 4.06 V
5, // 4.12 V
10, // 4.14 V
30, // 4.16 V
60, // 4.18 V
80, // 4.19 V
95, // 4.20 V
98, // 4.21 V
100 // 4.22 V
};
float vPoints[nPoints] = { 3.100, 3.274, 3.621, 3.737, 3.853, 3.968, 4.026, 4.084, 4.142, 4.200 };
float pPoints[nPoints] = { 0, 1, 5, 10, 30, 60, 80, 95, 98, 100 };
// 1. Jeśli napięcie jest poniżej najniższego punktu, zwróć minimalny procent
if (voltage <= vPoints[0]) {
@@ -225,8 +205,6 @@ void setup() {
if (!rtc.begin()) {
Serial.println("Nie znaleziono DS3231 RTC!");
while (1)
; // Zatrzymaj program, jeśli RTC nie jest dostępny
}
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
display.setTextSize(1);
@@ -270,9 +248,9 @@ void setup() {
dhtL.begin();
dhtM.begin();
dhtH.begin();
pinMode(BTN_UP, INPUT_PULLDOWN);
pinMode(BTN_ENTER, INPUT_PULLDOWN);
pinMode(BTN_DOWN, INPUT_PULLDOWN);
pinMode(BTN_UP, INPUT);
pinMode(BTN_ENTER, INPUT);
pinMode(BTN_DOWN, INPUT);
rtc.now();
DateTime now = rtc.now();
years = now.year();
@@ -652,7 +630,7 @@ void loop() {
if (currentBatteryVoltage >= 4.20) {
display.print("Full");
chrgState = "FUL";
} else if ((lastBatteryVoltage < currentBatteryVoltage && currentBatteryVoltage >= 2.0 && currentBatteryVoltage >= 4.0) || currentBatteryVoltage >= 4.10) {
} else if ((lastBatteryVoltage < currentBatteryVoltage && currentBatteryVoltage >= 3.1)|| currentBatteryVoltage >= 4.20) {
display.print("Charging");
chrgState = "CHR";
} else if (lastBatteryVoltage >= currentBatteryVoltage && currentBatteryVoltage >= 2.0) {