sparkfun / SparkFun_SX1509_Arduino_Library

Arduino library for the SX1509 16-I/O GPIO expander.
44 stars 38 forks source link

[BUG] Multiple typecasting issues in this library. #23

Open yashmulgaonkar opened 1 year ago

yashmulgaonkar commented 1 year ago

This is a very poorly written library, with blatant errors.

There are multiple instances where variables are incorrectly typecasted. Durations are requested in milliseconds, but are typecasted as uint8_t.

Here is one such example: tOn requested as milliseconds: void SX1509::blink(uint8_t pin, unsigned long tOn, unsigned long tOff, uint8_t onIntensity, uint8_t offIntensity)

Later typecasted as uint8_t: void SX1509::setupBlink(uint8_t pin, uint8_t tOn, uint8_t tOff, uint8_t onIntensity, uint8_t offIntensity, uint8_t tRise, uint8_t tFall, bool log)

yashmulgaonkar commented 1 year ago

Looks like this was caused by what looks like a careless "replace all" operation in this commit: https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library/commit/3ba49b6a5f39bb3d40db114dd3a54b010b804e7d

nseidle commented 1 year ago

You're probably right. Maybe you can fix it. PRs are always welcome.

gb-123-git commented 11 months ago

@yashmulgaonkar I went through the earlier commits. I don't think this has been caused by "replace all". (Disclaimer: It ("replace all") was not done by me btw)

The code for void SX1509::blink & void SX1509::setupBlink seems to be different. In void SX1509::setupBlink, remarks are specifically mentioning that tOn for this method should not be more than 5 bits.

There seems to be some other problem.