PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 line
1.2KB

  1. /*
  2. A simple 1-d oscilliscope: scan all the channels, setting the PWM output
  3. value to 4x the analog pin 0 value (0 - 1024 * 4 = 4096). The value will
  4. fade to zero as the channels keep scanning.
  5. See the BasicUse example for hardware setup.
  6. Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */
  7. #include "Tlc5940.h"
  8. #include "tlc_fades.h"
  9. // which analog pin to use
  10. #define ANALOG_PIN 0
  11. // how many millis to strobe over all the LEDs
  12. #define SCOPE_PERIOD (1000 * NUM_TLCS)
  13. #define LED_PERIOD SCOPE_PERIOD / (NUM_TLCS * 16)
  14. TLC_CHANNEL_TYPE channel;
  15. void setup()
  16. {
  17. Tlc.init();
  18. }
  19. void loop()
  20. {
  21. uint32_t lastMillis = millis();
  22. tlc_addFade(channel, // led channel
  23. analogRead(ANALOG_PIN) * 4, // start fade value (0-4095)
  24. 0, // end fade value (0-4095)
  25. lastMillis + 2, // start millis
  26. lastMillis + (uint16_t)SCOPE_PERIOD / 4 // end millis
  27. );
  28. if (channel++ == NUM_TLCS * 16) {
  29. channel = 0;
  30. }
  31. uint32_t currentMillis;
  32. do {
  33. currentMillis = millis();
  34. tlc_updateFades(currentMillis);
  35. } while (currentMillis - lastMillis <= LED_PERIOD);
  36. }