TTGO-T18V2.2
Lib install:
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
}
}
Module 2 Button Right -- Wifi scan
switch (loop_mode) {
case WIFI_SCAN:
wifi_test();
loop_mode = -1;
break;
}
}
Module 3 Button Up -- Deep sleep 10s
void loop()
{
btn_loop();
switch (loop_mode) {
case DEEPSLEEP:
enter_sleep();
break;
}
}
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;
}
}
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;
}
}