Skip to content

Instantly share code, notes, and snippets.

View reefwing's full-sized avatar

David Such reefwing

View GitHub Profile
@reefwing
reefwing / PCF8563_Class.h
Last active December 12, 2022 22:47
TWatch RTC API Extract from header file
PCF8563_Class(I2CBus &bus, uint8_t addr = PCF8563_SLAVE_ADDRESS);
void check(); // Compares compile time with RTC
void setDateTime(uint16_t year,
uint8_t month,
uint8_t day,
uint8_t hour,
uint8_t minute,
uint8_t second);
void setDateTime(RTC_Date date);
@reefwing
reefwing / pcf8563.h
Created December 12, 2022 22:25
Extract from PCF8563 RTC Header File
class RTC_Date
{
public:
RTC_Date();
RTC_Date(const char *date, const char *time);
RTC_Date(uint16_t year,
uint8_t month,
uint8_t day,
uint8_t hour,
uint8_t minute,
@reefwing
reefwing / RTC.ino
Created December 12, 2022 06:36
TWatch-2020 RTC Alarm Example
TTGOClass *ttgo;
bool rtcIrq = false;
void setup() {
ttgo = TTGOClass::getWatch();
ttgo->begin();
ttgo->openBL();
pinMode(RTC_INT_PIN, INPUT_PULLUP);
@reefwing
reefwing / charge-icon.ino
Created December 12, 2022 01:41
TWatch-2020 Charge Icon Example
int chargeOffset = map(batSOC, 0, 100, 0, 17);
// Draw Battery Charged Icon
ttgo->tft->fillRect(150, 0, 20, 10, TFT_GREEN);
ttgo->tft->fillRect(146, 3, 4, 4, TFT_GREEN);
ttgo->tft->fillRect(152, 2, 16 - chargeOffset, 6, TFT_BLACK);
@reefwing
reefwing / t-watch-battery.ino
Last active December 12, 2022 07:56
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() {
@reefwing
reefwing / t-watch-text.ino
Created December 11, 2022 00:16
T-Watch-2020 Text Example
ttgo->tft->setTextSize(2);
ttgo->tft->setCursor(0, 0);
ttgo->tft->setTextColor(TFT_YELLOW);
ttgo->tft->print("Reefwing Software");
@reefwing
reefwing / twatch2020_v1.h
Created December 9, 2022 08:17
Pin Mapping for the TWatch 2020 v1
#pragma once
#define TFT_WIDTH 240
#define TFT_HEIGHT 240
#define TWATCH_TFT_MISO (gpio_num_t)0
#define TWATCH_TFT_MOSI (gpio_num_t)19
#define TWATCH_TFT_SCLK (gpio_num_t)18
#define TWATCH_TFT_CS (gpio_num_t)5
#define TWATCH_TFT_DC (gpio_num_t)27
@reefwing
reefwing / LilyGoWatch.h
Last active December 11, 2022 00:03
Peripheral definition for the TWatch Variants
// Extract from LilyGoWatch.h...
#elif defined(LILYGO_WATCH_2020_V1)
#include "board/twatch2020_v1.h"
// Has
#define LILYGO_WATCH_HAS_TOUCH // ->getTouch() defined
#define LILYGO_WATCH_HAS_DISPLAY // ->tft defined
#define LILYGO_WATCH_HAS_BUZZER
#define LILYGO_WATCH_HAS_MOTOR // ->motor_begin() & shake()
#define LILYGO_WATCH_HAS_PCF8563 // ->rtc defined
@reefwing
reefwing / config.h
Created December 9, 2022 08:00
Standard config.h file used for the T-WATCH-2020
// => Hardware select
// #define LILYGO_WATCH_2019_WITH_TOUCH // To use T-Watch2019 with touchscreen, please uncomment this line
// #define LILYGO_WATCH_2019_NO_TOUCH // To use T-Watch2019 Not touchscreen , please uncomment this line
#define LILYGO_WATCH_2020_V1 // To use T-Watch2020 V1, please uncomment this line
// #define LILYGO_WATCH_2020_V2 // To use T-Watch2020 V2, please uncomment this line
// #define LILYGO_WATCH_2020_V3 // To use T-Watch2020 V3, please uncomment this line
// #define LILYGO_LILYPI_V1 //LILYPI / TBLOCK requires an external display module
// #define LILYGO_WATCH_BLOCK //LILYPI / TBLOCK requires an external display module
@reefwing
reefwing / BasicSetup.ino
Created December 9, 2022 07:56
TWatch 2020 Watch Object Setup
#include "config.h"
#include <soc/rtc.h>
TTGOClass *ttgo;
void setup() {
ttgo = TTGOClass::getWatch();
ttgo->begin();
}