Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Limit reads & cache values #2

Closed
@caternuson

Description

@caternuson

NOTE This issue by @ATMakersBill transferred from original repo.

It looks like there's code to read the i2c bus and keep the results for future calls to joystick, acceleration, and buttons. However, the button code doesn't seem to update the buffer.

It looks like it would be possible to make fewer reads and improve performance. Here's my suggestion....

  1. Add an optional parameter to the init() that takes a maxAge parameter (default to .1sec?).
  2. In __read_data() keep track of whether it's been over maxAge since the last read. If not use the current buffer. If you do a read, update the last read time
  3. If maxAge is set to zero, then it would always fetch on every read.
  4. If maxAge is set to -1 then the data read calls would never call read_data: the user would need to call a public method (read_data()?) to fetch the data.

I think that would give full control to the clients of the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions