Open garethhcoleman opened 4 weeks ago
hi,
[edit] if you submit a PR please make sure to set both base and target to the develop
branch
"battery capacity" sounds a bit out of scope for a touch driver, implementing a more generic method would make more sense e.g.
int16_t Touch_XPT2046::readRegister( uint8_t register );
then you can add you own dedicated temp/bat/aux reading functions to your custom driver implementation:
class LGFX : public lgfx::LGFX_Device
{
public:
lgfx::Bus_Whatever _bus_instance;
lgfx::Panel_Blah _panel_instance;
lgfx::Touch_XPT2046 _touch_instance;
LGFX(void)
{
{
auto cfg = _panel_instance.config();
// ... panel config here
_panel_instance.config(cfg);
}
{
auto cfg = _bus_instance.config();
cfg.panel = &_panel_instance;
// ... panel bus config here
_bus_instance.config(cfg);
}
_panel_instance.setBus(&_bus_instance);
{
auto cfg = _touch_instance.config();
// ... touch config here
_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}
setPanel(&_panel_instance);
}
// custom functions here
int16_t getTouchRegister( uint8_t register )
{
return _touch_instance.readRegister( register );
}
// specialized functions based on getTouchRegister()
float getVBat() { }
float getAuxIn() { }
float getTemp() { }
float getTempF() { }
};
Yes I agree it is a bit odd but the xpt2046 supports it and we've used it...
I greatly appreciate your quick response and advice.
I will work on the approach you suggested and let you know how it goes
Many thanks again
On Mon, 8 Apr 2024, 15:22 tobozo, @.***> wrote:
hi,
"battery capacity" sounds a bit out of scope for a touch driver, implementing a more generic method would make more sense e.g.
int16_t Touch_XPT2046::readRegister( uint8_t register );
then you can add you own dedicated temp/bat/aux reading functions to your custom driver implementation:
class LGFX : public lgfx::LGFX_Device {public:
lgfx::Bus_Whatever _bus_instance; lgfx::Panel_Blah _panel_instance; lgfx::Touch_XPT2046 _touch_instance;
LGFX(void) { { auto cfg = _panel_instance.config(); // ... panel config here _panel_instance.config(cfg); } { auto cfg = _bus_instance.config(); cfg.panel = &_panel_instance; // ... panel bus config here _bus_instance.config(cfg); } _panel_instance.setBus(&_bus_instance);
{ auto cfg = _touch_instance.config(); // ... touch config here _touch_instance.config(cfg); _panel_instance.setTouch(&_touch_instance); } setPanel(&_panel_instance);
}
// custom functions here
int16_t getTouchRegister( uint8_t register ) { return _touch_instance.readRegister( register ); }
// specialized functions based on getTouchRegister() float getVBat() { } float getAuxIn() { } float getTemp() { } float getTempF() { }
};
— Reply to this email directly, view it on GitHub https://github.com/lovyan03/LovyanGFX/issues/552#issuecomment-2042888249, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHLHZIFCQ7DR5RAT4235SQ3Y4KRZJAVCNFSM6AAAAABF4NZDNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBSHA4DQMRUHE . You are receiving this because you authored the thread.Message ID: @.***>
I am the co-designer of the unphone (Device Shop) which is open source hardware and software.
We use the XPT2046 touchscreen already supported by this code, very nicely done thank you!
We would like to expose the XPT2046 battery measurement capability in the LovyanGFX drivers for ourselves and other users.
I have some candidate functions that I will introduce in a PR for your consideration. Please just let me know any improvements or changes I should make or if my approach should be modified.
Thank you again for all your work creating this library!