You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
2.8 KiB

void GxepdPage1()
{
display.setRotation(4);
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
// display.setFont(&prazo_Regular_224pt7b);
DrawBattery( 0, 20);
DrawRSSI(95, 20, wifi_signal);
display.setFont(&FreeMonoBold18pt7b);
display.setCursor(0, 75);
display.print(CurrentHour);//время с нтп часы
display.print(":");
if(CurrentMin<10){display.print("0");}
display.print(CurrentMin );//минуты
display.setFont(&FreeMonoBold9pt7b);
if(CurrentSec<10){display.print("0");}
display.print(CurrentSec );//секунды
// display.setFont(&FreeMonoBold9pt7b);
// display.setCursor(20, 15);
// display.print(Date_str + " " + Time_str);
// display.print(Time_str);
// display.print("W");
// display.print(wifi_signal);
display.setCursor(0, 110);
display.print(Date_str);
display.update();
display.setFont();
SleepPage();
}
void DrawRSSI(int x, int y, int rssi) //график силы вай-фай
{
int WIFIsignal = 0;
int xpos = 1;
for (int _rssi = -100; _rssi <= rssi; _rssi = _rssi + 20) {
if (_rssi <= -20) WIFIsignal = 15; // <-20dbm displays 5-bars
if (_rssi <= -40) WIFIsignal = 12; // -40dbm to -21dbm displays 4-bars
if (_rssi <= -60) WIFIsignal = 9; // -60dbm to -41dbm displays 3-bars
if (_rssi <= -80) WIFIsignal = 6; // -80dbm to -61dbm displays 2-bars
if (_rssi <= -100) WIFIsignal = 3; // -100dbm to -81dbm displays 1-bar
display.fillRect(x + xpos * 4, y - WIFIsignal, 2, WIFIsignal, GxEPD_BLACK);
xpos++;
}
}
void DrawBattery(int x, int y) {
uint8_t percentage = 100;
esp_adc_cal_characteristics_t adc_chars;
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 1100, &adc_chars);
if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) {
Serial.printf("eFuse Vref:%u mV", adc_chars.vref);
vref = adc_chars.vref;
}
if (voltage > 1 ) { // Only display if there is a valid reading
Serial.println("\nVoltage = " + String(voltage));
percentage = 2836.9625 * pow(voltage, 4) - 43987.4889 * pow(voltage, 3) + 255233.8134 * pow(voltage, 2) - 656689.7123 * voltage + 632041.7303;
if (voltage >= 4.20) percentage = 100;
if (voltage <= 3.20) percentage = 0; // orig 3.5
display.fillRect(x , y - 14, 40, 15,GxEPD_WHITE );
display.drawRect(x + 2, y - 14, 30, 15,GxEPD_BLACK);
display.fillRect(x + 32, y - 10, 4, 7,GxEPD_BLACK);
display.fillRect(x + 4, y - 12, 26 * percentage / 100.0, 11,GxEPD_BLACK);
display.setTextColor(GxEPD_BLACK);
display.setFont();
display.setCursor(x + 40, y-15 );
display.print( String(percentage) + "% ");
display.setCursor(x + 40, y-5 );
display.print( String(voltage, 1) + "v");
}
}