Skip to content
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

Open
garethhcoleman opened this issue Apr 8, 2024 · 5 comments
Open

Expose XPT2046 ability to measure VBAT #552

garethhcoleman opened this issue Apr 8, 2024 · 5 comments
Labels
enhancement New feature or request pinned exempt from stale bot

Comments

@garethhcoleman
Copy link

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!

@garethhcoleman garethhcoleman added the enhancement New feature or request label Apr 8, 2024
@tobozo
Copy link
Collaborator

tobozo commented Apr 8, 2024

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() { }

};

@garethhcoleman
Copy link
Author

garethhcoleman commented Apr 8, 2024 via email

@github-actions github-actions bot added the stale Inactive issues label May 8, 2024
@tobozo
Copy link
Collaborator

tobozo commented May 8, 2024

bump

@garethhcoleman
Copy link
Author

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

@github-actions github-actions bot removed the stale Inactive issues label May 8, 2024
@github-actions github-actions bot added the stale Inactive issues label Jun 7, 2024
@tobozo tobozo removed the stale Inactive issues label Jun 7, 2024
Repository owner deleted a comment from github-actions bot Jun 7, 2024
Repository owner deleted a comment from github-actions bot Jun 7, 2024
@github-actions github-actions bot added the stale Inactive issues label Jul 7, 2024
@tobozo tobozo added pinned exempt from stale bot and removed stale Inactive issues labels Jul 7, 2024
Repository owner deleted a comment from github-actions bot Jul 7, 2024
@vednildip
Copy link

error: 'HSPI_HOST' was not declared in this scope; did you mean 'SPI3_HOST'?
73 | cfg.spi_host = HSPI_HOST;// 使用するSPIを選択 (HSPI_HOST or VSPI_HOST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned exempt from stale bot
Projects
None yet
Development

No branches or pull requests

3 participants