LilyGO / TTGO-T-ControllerV2.2

T18V2.2
21 stars 4 forks source link

TTGO-T18V2.2

image

Lib install:

lib1:https://github.com/lewisxhe/Button2

lib2:https://github.com/ThingPulse/esp8266-oled-ssd1306

Module 1 Button Left -- Battery voltage detection

void showVoltage()
{
    static uint64_t timeStamp = 0;
    if (millis() - timeStamp > 1000) {
        timeStamp = millis();
        uint16_t v = analogRead(ADC_PINS);
        float battery_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
#ifdef ENABLE_SSD1306
        String voltage = "Voltage :" + String(battery_voltage) + "V";
        oled.clear();
        oled.drawString(oled.getWidth() / 2, oled.getHeight() / 2, voltage);
        oled.display();
#else
        Serial.println("DEBUG: Value: " + String(v) + " ,Battery Voltage is" + String(battery_voltage) + "V");
#endif
    }
}

image

Module 2 Button Right -- Wifi scan

switch (loop_mode) {
    case WIFI_SCAN:
        wifi_test();
        loop_mode = -1;
        break;
         }
}

image

Module 3 Button Up -- Deep sleep 10s

void loop()
{
    btn_loop();
    switch (loop_mode) {

    case DEEPSLEEP:
        enter_sleep();
        break;
         }
}

image

Module 4 Button Down -- Down

void loop()
{
    btn_loop();
    switch (loop_mode) {
    case KEY1:
        oled.clear();
        oled.drawString(oled.getWidth() / 2, oled.getHeight() / 2, "DOWN");
        oled.display();
        loop_mode = -1;
        break;
         }
}

image

Module 5 Button Center -- OK

void loop()
{
    btn_loop();
    switch (loop_mode) {
    case KEY2:
        oled.clear();
        oled.drawString(oled.getWidth() / 2, oled.getHeight() / 2, "OK");
        oled.display();
        loop_mode = -1;
        break;
         }
}

image