Update T-Watch support (add PMIC support)

This commit is contained in:
yetanothercarbot 2025-03-12 19:50:24 +10:00
parent 945e06da9f
commit d5b8f83850
5 changed files with 69 additions and 2 deletions

View File

@ -451,6 +451,11 @@ long Esp32Device::get_uptime()
#elif defined(M5STACK) || defined(M5STACKLGFX) #elif defined(M5STACK) || defined(M5STACKLGFX)
#warning Building for M5Stack core2 #warning Building for M5Stack core2
#include "dev/esp32/m5stackcore2.h" #include "dev/esp32/m5stackcore2.h"
#elif defined(TWATCH)
#warning Building for TTGo T-Watch
#include "dev/esp32/twatch.h"
#else #else
dev::Esp32Device haspDevice; dev::Esp32Device haspDevice;
#endif #endif

View File

@ -86,6 +86,8 @@ class Esp32Device : public BaseDevice {
#elif defined(M5STACK) || defined (M5STACKLGFX) #elif defined(M5STACK) || defined (M5STACKLGFX)
// #warning Building for M5Stack core2 // #warning Building for M5Stack core2
#include "m5stackcore2.h" #include "m5stackcore2.h"
#elif defined(TWATCH)
#include "twatch.h"
#else #else
using dev::Esp32Device; using dev::Esp32Device;
extern dev::Esp32Device haspDevice; extern dev::Esp32Device haspDevice;

39
src/dev/esp32/twatch.cpp Normal file
View File

@ -0,0 +1,39 @@
#include "twatch.h"
#if defined(TWATCH)
#include "Wire.h"
#include "dev/esp32/esp32.h"
/*
* This covers the TWatch 2019 and 2020 PMIC. Only the init function is implemented
* because the TWatch 2020 v1 variant has not just the backlight connected to LDO2,
* but also the power for the display controller. This shouldn't get regulated down
* or be switched off (since the latter would require display being re-inited) so we
* don't let the user switch it off.
*
* This *could* get fixed, by detecting hardware type and changing behaviour, but
* this device isn't particularly common and OpenHASP probably isn't the proper tool
* for this hardware. It's nice to have some support though.
*/
namespace dev {
void TWatch::init(void) {
Wire.begin();
Wire.beginTransmission(53);
Wire.write(0x12);
Wire.write(0b00000110); // Enable LDO2, DC-DC3, disable others
Wire.endTransmission();
// Section set LDO2 to 3.3V
uint8_t ldo_ctrl = ~0;
Wire.beginTransmission(53);
Wire.write(0x28);
Wire.write(ldo_ctrl);
Wire.endTransmission();
}
}
dev::TWatch haspDevice;
#endif

20
src/dev/esp32/twatch.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef HASP_DEVICE_TWATCH
#define HASP_DEVICE_TWATCH
#if defined(TWATCH)
#include "esp32.h"
namespace dev {
class TWatch : public Esp32Device {
public:
void init() override;
};
}
using dev::TWatch;
extern dev::TWatch haspDevice;
#endif
#endif

View File

@ -28,6 +28,7 @@ build_flags =
-D TOUCH_RST=-1 -D TOUCH_RST=-1
-D TOUCH_SDA=23 -D TOUCH_SDA=23
-D TOUCH_SCL=32 -D TOUCH_SCL=32
-D TWATCH=1
;endregion ;endregion
lib_deps = lib_deps =
@ -40,7 +41,7 @@ extends = ttgo-t-watch, flash_16mb
build_flags = build_flags =
${ttgo-t-watch.build_flags} ${ttgo-t-watch.build_flags}
-D HASP_MODEL="TTgo T-Watch 2019" -D HASP_MODEL="TTGo T-Watch 2019"
-D INVERT_COLORS=1 -D INVERT_COLORS=1
[env:ttgo-t-watch-2020] [env:ttgo-t-watch-2020]
@ -48,7 +49,7 @@ extends = ttgo-t-watch, flash_16mb
build_flags = build_flags =
${ttgo-t-watch.build_flags} ${ttgo-t-watch.build_flags}
-D HASP_MODEL="TTgo T-Watch 2020" -D HASP_MODEL="TTGo T-Watch 2020"
-D TFT_ROTATION=0 -D TFT_ROTATION=0
;-D TFT_ROTATION=2 ;-D TFT_ROTATION=2
-D TOUCH_OFFSET_ROTATION=4 ; 1=swap xy, 2=invert x, 4=inverty -D TOUCH_OFFSET_ROTATION=4 ; 1=swap xy, 2=invert x, 4=inverty