Skip to content

Improvement hints #4

Description

@HSyr

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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