Improving GPIO slowdown

As I noted in this issue, setting --led-slowdown-gpio=5 is not enough when using long chains with the Pi 4. Modifying led-matrix.cc to allow a value of 6 for slowdown is an easy workaround, but also significantly drops the refresh rate.

It looks like the slowdown is passed in when the GPIO is initialized in gpio.cc Init(), and then is used to loop and rewrite the same value in SetBits() and ClearBits(). It seems like another way to handle this would be to define set timings for --led-slowdown-gpio values, write/clear the value once, and delay for the set time.

Has anyone else attempted to do something similar and/or can tell me why this isn’t a good idea?

// Set the bits that are '1' in the output. Leave the rest untouched.
  inline void SetBits(gpio_bits_t value) {
    if (!value) return;
    WriteSetBits(value);
    for (int i = 0; i < slowdown_; ++i) {
      WriteSetBits(value);
    }
  }

  // Clear the bits that are '1' in the output. Leave the rest untouched.
  inline void ClearBits(gpio_bits_t value) {
    if (!value) return;
    WriteClrBits(value);
    for (int i = 0; i < slowdown_; ++i) {
      WriteClrBits(value);
    }
  }

Thanks, I replied on the issue, sounds fair for you to send @hzeller a pull request to increase the value. I know he’s working on other things and may not be very active on the project, but hopefully he’ll see your request :slight_smile: