Skip to content

Instantly share code, notes, and snippets.

@reefwing
Last active December 12, 2022 07:56
Show Gist options
  • Select an option

  • Save reefwing/643c9ad98c7eac67f91773f9669e8fa1 to your computer and use it in GitHub Desktop.

Select an option

Save reefwing/643c9ad98c7eac67f91773f9669e8fa1 to your computer and use it in GitHub Desktop.
T-Watch-2020 Battery Charge Example
void setup() {
ttgo = TTGOClass::getWatch();
ttgo->begin();
ttgo->openBL(); // Turn on the backlight
//Turn on AXP202 ADC so the PMU can monitor
ttgo->power->adc1Enable(AXP202_VBUS_VOL_ADC1 | AXP202_VBUS_CUR_ADC1 | AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
}
void loop() {
int batSOC = ttgo->power->getBattPercentage();
int temp = ttgo->power->getTemp();
ttgo->tft->setTextSize(2);
ttgo->tft->setCursor(0, 0);
ttgo->tft->setTextColor(TFT_ORANGE, TFT_BLACK);
ttgo->tft->print("Bat: ");
ttgo->tft->print(batSOC); ttgo->tft->println(" % ");
ttgo->tft->print("Temp: ");
ttgo->tft->print(temp);
ttgo->tft->print((char)247);
ttgo->tft->print("C");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment