Wskaźnik baterii
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
#include "SD.h"
|
#include "SD.h"
|
||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
|
|
||||||
#define Version "menu : 0.1menu"
|
#define Version "menu : 0.4batt"
|
||||||
#define WIRE Wire
|
#define WIRE Wire
|
||||||
#define DHTTYPE DHT22
|
#define DHTTYPE DHT22
|
||||||
#define DHTPIN 4
|
#define DHTPIN 4
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
#define BTN_ENTER 34
|
#define BTN_ENTER 34
|
||||||
#define BTN_DOWN 35
|
#define BTN_DOWN 35
|
||||||
#define VOLT_IN 36
|
#define VOLT_IN 36
|
||||||
|
const float voltageDividerFactor = 1.51;//1.56;
|
||||||
|
const float adcMaxVoltage = 3.3;
|
||||||
|
const int adcResolution = 4095;
|
||||||
|
|
||||||
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE);
|
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE);
|
||||||
DHT dht(DHTPIN, DHTTYPE);
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
@@ -44,6 +47,9 @@ int hoursToSet = -1;
|
|||||||
|
|
||||||
int adcVoltValue;
|
int adcVoltValue;
|
||||||
|
|
||||||
|
float measuredVoltage = 0;
|
||||||
|
float batteryVoltage = 0;
|
||||||
|
int batteryBarWidth = 0;
|
||||||
char dateString[21];
|
char dateString[21];
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@@ -100,6 +106,8 @@ void setup() {
|
|||||||
}
|
}
|
||||||
display.display();
|
display.display();
|
||||||
delay(500);
|
delay(500);
|
||||||
|
// rtc.adjust(DateTime(2025,2,15, 17, 44,59));
|
||||||
|
|
||||||
//setup END
|
//setup END
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +175,7 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (menuL0 == 8 ) {
|
if (menuL0 == 9 ) {
|
||||||
if (digitalRead(BTN_ENTER) == HIGH and menuL1 == 10) {
|
if (digitalRead(BTN_ENTER) == HIGH and menuL1 == 10) {
|
||||||
menuL1 = 9;
|
menuL1 = 9;
|
||||||
}
|
}
|
||||||
@@ -275,16 +283,32 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuL0 == 9 ) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (menuL0 == 8 ) {
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
display.print("MENU TECH");
|
display.print("MENU TECH");
|
||||||
adcVoltValue = analogRead(VOLT_IN); // Odczyt wartości ADC z GPIO36
|
adcVoltValue = analogRead(VOLT_IN); // Odczyt wartości ADC z GPIO36
|
||||||
display.setCursor(0,8);
|
measuredVoltage = (adcVoltValue * adcMaxVoltage) / adcResolution;
|
||||||
display.print("ADC:");
|
batteryVoltage = (measuredVoltage * voltageDividerFactor)+0.1;
|
||||||
display.setCursor(20, 24);
|
display.setCursor(70,0);
|
||||||
display.print(adcVoltValue);
|
display.print("V:");
|
||||||
|
display.setCursor(85, 0);
|
||||||
|
display.print(batteryVoltage);
|
||||||
|
display.drawRect(0, 9, 124, 7, SSD1306_WHITE);
|
||||||
|
display.fillRect(124, 10, 5, 5, SSD1306_WHITE);
|
||||||
|
batteryBarWidth = (((batteryVoltage-3)/1.2)*122);
|
||||||
|
if (batteryBarWidth >122){
|
||||||
|
batteryBarWidth = 122;
|
||||||
|
}
|
||||||
|
display.fillRect(1, 10, batteryBarWidth, 5, SSD1306_WHITE);
|
||||||
|
if (batteryVoltage < 2 ){
|
||||||
|
display.setCursor(60,8);
|
||||||
|
display.print("xxx");
|
||||||
|
}
|
||||||
|
|
||||||
Serial.println(adcVoltValue);
|
|
||||||
|
|
||||||
if (digitalRead(BTN_UP) == HIGH) {
|
if (digitalRead(BTN_UP) == HIGH) {
|
||||||
display.setCursor(0, 24);
|
display.setCursor(0, 24);
|
||||||
|
|||||||
Reference in New Issue
Block a user