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

Improvement hints #4

Open
HSyr opened this issue Dec 29, 2020 · 0 comments
Open

Improvement hints #4

HSyr opened this issue Dec 29, 2020 · 0 comments

Comments

@HSyr
Copy link

HSyr commented Dec 29, 2020

Just a few quick thoughts:

  • Multi statement macros (e.g. ShiftRegisterPWM_toggleClockPinTwice) should be written using do{"statements"}while(0).
  • Consider calloc in the ShiftRegisterPWM to allocate and clear the memory at the same time, this avoids two nested loops.
  • Also floating point calculation (slow and long) code “value = (uint8_t) (value / 255.0 * resolution + .5)” can be avoided by something like “value = (uint8_t)( ( (uint_16)value * resolution + 127 ) / 255 )”.
  • I think one dimensional array (just to store channel values) is enough for this task as the actual output value is very easy to “compute” in the interrupt by comparing actual time variable to resolution variable. Sure it would be slower compared to the using the precomputed values at the large array.
  • A believe 74595 can be effectively fed by SPI.
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

No branches or pull requests

1 participant