Skip to content
This repository was archived by the owner on Jul 22, 2019. It is now read-only.
This repository was archived by the owner on Jul 22, 2019. It is now read-only.

Limit reads & cache values #2

@ATMakersBill

Description

@ATMakersBill

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

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions