-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose XPT2046 ability to measure VBAT #552
Comments
hi, [edit] if you submit a PR please make sure to set both base and target to the "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
<#552 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHLHZIFCQ7DR5RAT4235SQ3Y4KRZJAVCNFSM6AAAAABF4NZDNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBSHA4DQMRUHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
bump |
Thanks for the bump! I have been really struggling adapting the read register function from using esp spi functions to using the ones in this library. I'll carry on trying |
error: 'HSPI_HOST' was not declared in this scope; did you mean 'SPI3_HOST'? |
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!
The text was updated successfully, but these errors were encountered: