Hirdetés

Új hozzászólás Aktív témák

  • KoVee84

    senior tag

    válasz KoVee84 #19966 üzenetére

    #include <Arduino.h>
    #include "epd_driver.h"
    #include "font/firasans.h"
    #include "font/opensans72eb.h"
    #include "esp_adc_cal.h"
    #include "pins.h"
    #include "time.h"

    int vref = 1100;

    const char* texts[] = {"Kovács","Könözsi","Csepura","Németh"};

    const uint64_t egy_nap = 86400000000;

    RTC_DATA_ATTR unsigned int reboot_counter = 0;


    void setup()
    {
    Serial.begin(115200);
    delay(10);
    epd_init();
    delay(10);

    // Correct the ADC reference voltage
    esp_adc_cal_characteristics_t adc_chars;

    }

    void loop()
    {

    switch (reboot_counter)
    {
    case 0:
    {
    epd_poweron();
    epd_clear();
    delay(10);
    uint16_t v = analogRead(BATT_PIN);
    float battery_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
    String voltage = "Feszültség: " + String(battery_voltage) + "V";
    Serial.println(voltage);
    int cursor_x = 60;
    int cursor_y = 475;
    writeln((GFXfont *)&FiraSans, (char *)voltage.c_str(), &cursor_x, &cursor_y, NULL);
    cursor_x = 180;
    cursor_y = 290;
    writeln((GFXfont *)&OpenSansExtraBold72, (texts[0]), &cursor_x, &cursor_y, NULL);
    reboot_counter++;
    epd_poweroff_all();
    esp_sleep_enable_timer_wakeup(egy_nap * 7);
    esp_deep_sleep_start();
    }

    case 1:
    {
    epd_poweron();
    epd_clear();
    delay(10);
    uint16_t v = analogRead(BATT_PIN);
    float battery_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
    String voltage = "Feszültség: " + String(battery_voltage) + "V";
    Serial.println(voltage);
    int cursor_x = 60;
    int cursor_y = 475;
    writeln((GFXfont *)&FiraSans, (char *)voltage.c_str(), &cursor_x, &cursor_y, NULL);
    cursor_x = 180;
    cursor_y = 290;
    writeln((GFXfont *)&OpenSansExtraBold72, (texts[1]), &cursor_x, &cursor_y, NULL);
    reboot_counter++;
    epd_poweroff_all();
    esp_sleep_enable_timer_wakeup(egy_nap * 7);
    esp_deep_sleep_start();
    }

    case 2:
    {
    epd_poweron();
    epd_clear();
    delay(10);
    uint16_t v = analogRead(BATT_PIN);
    float battery_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
    String voltage = "Feszültség: " + String(battery_voltage) + "V";
    Serial.println(voltage);
    int cursor_x = 60;
    int cursor_y = 475;
    writeln((GFXfont *)&FiraSans, (char *)voltage.c_str(), &cursor_x, &cursor_y, NULL);
    cursor_x = 180;
    cursor_y = 290;
    writeln((GFXfont *)&OpenSansExtraBold72, (texts[2]), &cursor_x, &cursor_y, NULL);
    reboot_counter++;
    epd_poweroff_all();
    esp_sleep_enable_timer_wakeup(egy_nap * 7);
    esp_deep_sleep_start();
    }

    case 3:
    {
    epd_poweron();
    epd_clear();
    delay(10);
    uint16_t v = analogRead(BATT_PIN);
    float battery_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
    String voltage = "Feszültség: " + String(battery_voltage) + "V";
    Serial.println(voltage);
    int cursor_x = 60;
    int cursor_y = 475;
    writeln((GFXfont *)&FiraSans, (char *)voltage.c_str(), &cursor_x, &cursor_y, NULL);
    cursor_x = 180;
    cursor_y = 290;
    writeln((GFXfont *)&OpenSansExtraBold72, (texts[3]), &cursor_x, &cursor_y, NULL);
    reboot_counter++;
    epd_poweroff_all();
    esp_sleep_enable_timer_wakeup(egy_nap * 7);
    esp_deep_sleep_start();
    }

    case 4:
    {
    epd_poweron();
    delay(10);
    int cursor_x = 550;
    int cursor_y = 475;
    writeln((GFXfont *)&FiraSans, ("SZELEKTÍV KUKA"), &cursor_x, &cursor_y, NULL);
    reboot_counter++;
    epd_poweroff_all();
    esp_sleep_enable_timer_wakeup(egy_nap * 6);
    esp_deep_sleep_start();
    }

    case 5:
    {
    esp_restart();
    }
    }
    }

Új hozzászólás Aktív témák