Skip to content

Conversation

Chris0xdeadbeef
Copy link

Description

Use uint8_t for loop index in read() and add if (prec > 0) to prevent division by zero.

Initialize prec via constructor initializer list (: prec(10)) for a safe default.

Minor refactor: replace i++ with ++i.

Benefits: safer read(), cleaner code, and better C++ practices, no API changes.

…y zero

Use uint8_t for loop index to match the `prec` type (byte).
Replace i++ with ++i (minor micro-optimization).
Add if (prec > 0) check before dividing tx and ty to prevent division by zero.
Initialize `prec` to 10 in ArduCAM_Touch constructor.
Ensures that read() works safely even if setPrecision() is not called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant