Guest User

Untitled

a guest
May 20th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <PxMatrix.h>
  2. #ifdef ESP32
  3.  
  4. #define P_LAT 22
  5. #define P_A 19
  6. #define P_B 23
  7. #define P_C 18
  8. #define P_D 5
  9. #define P_E 15
  10. #define P_OE 2
  11. hw_timer_t * timer = NULL;
  12. portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
  13.  
  14. #endif
  15.  
  16. #ifdef ESP8266
  17.  
  18. #include <Ticker.h>
  19. Ticker display_ticker;
  20. #define P_LAT 16
  21. #define P_A 5
  22. #define P_B 4
  23. #define P_C 15
  24. #define P_D 12
  25. #define P_E 0
  26. #define P_OE 2
  27.  
  28. #endif
  29. // Pins for LED MATRIX
  30.  
  31. PxMATRIX display(32,16,P_LAT, P_OE,P_A,P_B,P_C,P_D);
  32. //PxMATRIX display(64,32,P_LAT, P_OE,P_A,P_B,P_C,P_D);
  33. //PxMATRIX display(64,64,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);
  34.  
  35. #ifdef ESP8266
  36. // ISR for display refresh
  37. void display_updater()
  38. {
  39. // display.displayTestPixel(70);
  40. display.display(50);
  41. }
  42. #endif
  43.  
  44. #ifdef ESP32
  45. void IRAM_ATTR display_updater(){
  46. // Increment the counter and set the time of ISR
  47. portENTER_CRITICAL_ISR(&timerMux);
  48. //isplay.display(70);
  49. display.displayTestPattern(70);
  50. portEXIT_CRITICAL_ISR(&timerMux);
  51. }
  52. #endif
  53.  
  54.  
  55. uint16_t myCYAN = display.color565(0, 255, 255);
  56. void setup() {
  57. // put your setup code here, to run once:
  58. Serial.begin(9600);
  59. display.begin(4);
  60. display.setMuxPattern(STRAIGHT);
  61. display.setScanPattern(ZAGGIZ);
  62. display.flushDisplay();
  63. display.setTextColor(myCYAN);
  64. display.setCursor(2,0);
  65. // display.print("Pixel");
  66. // Serial.println("hello");
  67.  
  68. #ifdef ESP8266
  69. display_ticker.attach(0.002, display_updater);
  70. #endif
  71.  
  72. #ifdef ESP32
  73. timer = timerBegin(0, 80, true);
  74. timerAttachInterrupt(timer, &display_updater, true);
  75. timerAlarmWrite(timer, 2000, true);
  76. timerAlarmEnable(timer);
  77. #endif
  78.  
  79. delay(1000);
  80. }
  81.  
  82.  
  83. void loop() {
  84. for (int xx=0; xx<16;xx++) {
  85. display.drawPixelRGB888 (xx,xx,128,128,0);
  86. delay(300);
  87. }
  88. }
Add Comment
Please, Sign In to add comment