Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #ifndef _SHMATRIXMAX7219_H__
  2. #define _SHMATRIXMAX7219_H__
  3. #include <Arduino.h>
  4. #include "SHLedControl.h"
  5.  
  6. class SHMatrixMAX7219 {
  7. private:
  8.  
  9. SHLedControl MAX7221;
  10. byte MAX7221_MATRIX_LUMINOSITY = 0;
  11. public:
  12.  
  13. void begin(int DataPin, int ClkPin, int LoadPin) {
  14. MAX7221.begin(DataPin, ClkPin, LoadPin, 1);
  15. MAX7221.shutdown(0, false);
  16. MAX7221.setIntensity(0, 0);
  17. MAX7221.clearDisplay(0);
  18. }
  19.  
  20. void read()
  21. {
  22. // Wait for display data
  23. int newIntensity = FlowSerialTimedRead();
  24. if (newIntensity != MAX7221_MATRIX_LUMINOSITY) {
  25. MAX7221.setIntensity(0, newIntensity);
  26. MAX7221_MATRIX_LUMINOSITY = newIntensity;
  27. }
  28.  
  29. for (int j = 0; j < 8; j++) {
  30. MAX7221.setRow(0, 7 - j, FlowSerialTimedRead());
  31. }
  32. }
  33. };
  34. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement