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

  • KoVee84

    senior tag

    Nem raktam deep sleepet... :W
    órakezelésben tudtok segíteni? :R
    Íme a kód:

    #ifndef BOARD_HAS_PSRAM
    #error "Please enable PSRAM !!!"
    #endif

    #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 unsigned long het1 = 604800000UL;
    const unsigned long het2 = 1209600000UL;
    const unsigned long het3 = 1814400000UL;
    const unsigned long het4 = 2419200000UL;
    const unsigned long szelektiv = 2332800000UL; // utolsó nap

    //teszt
    //const uint32_t het1 = 20000;
    //const uint32_t het2 = 40000;
    //const uint32_t het3 = 60000;
    //const uint32_t het4 = 80000;
    //const uint32_t szelektiv = 70000;

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

    // Correct the ADC reference voltage
    esp_adc_cal_characteristics_t adc_chars;

    epd_init();
    epd_poweron();
    epd_clear();
    delay(10);

    // első hét

    //feszültség
    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);

    //név
    cursor_x = 180;
    cursor_y = 290;
    writeln((GFXfont *)&OpenSansExtraBold72, (texts[0]), &cursor_x, &cursor_y, NULL);
    epd_poweroff_all();
    }

    void loop()
    {
    unsigned long currentMillis = millis();

    switch (currentMillis)
    {
    case het1:
    {
    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);
    epd_poweroff_all();
    break;
    }

    case het2:
    {
    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);
    epd_poweroff_all();
    }

    case het3:
    {
    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);
    break;
    }

    case szelektiv:
    {
    epd_poweron();
    delay(10);
    int cursor_x = 550;
    int cursor_y = 475;
    writeln((GFXfont *)&FiraSans, ("SZELEKTÍV KUKA"), &cursor_x, &cursor_y, NULL);
    epd_poweroff_all();
    break;
    }

    case het4:
    {
    esp_restart();
    }
    }
    }

    [ Szerkesztve ]

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