Guest User

Untitled

a guest
Aug 6th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include "SmartMatrix.h"
  2. #include "FastLED.h"
  3. #include "Time.h"
  4.  
  5. #define kMatrixWidth 32
  6. #define kMatrixHeight 32
  7. const bool kMatrixSerpentineLayout = false;
  8.  
  9. #define NUM_LEDS (kMatrixWidth * kMatrixHeight)
  10.  
  11. CRGB leds[kMatrixWidth * kMatrixHeight];
  12.  
  13. const rgb24 COLOR_BLACK = { 0,0,0 };
  14. const rgb24 COLOR_WHITE = { 255,255,255};
  15.  
  16. time_t getTeensy3Time()
  17. {
  18. return Teensy3Clock.get();
  19. }
  20.  
  21. void setup() {
  22. LEDS.addLeds<SmartMatrix>(leds,NUM_LEDS);
  23. LEDS.setBrightness(DEFAULT_BRIGHTNESS);
  24. pSmartMatrix->setColorCorrection(cc24);
  25. setSyncProvider(getTeensy3Time);
  26. pSmartMatrix->fillScreen(COLOR_BLACK);
  27. LEDS.show();
  28. }
  29.  
  30. void loop() {
  31. digitalClock();
  32. }
  33.  
  34. void digitalClock() {
  35. if(millis() >= nextFrame) {
  36. char str[32];
  37. sprintf(str,"%02d", hour());
  38. pSmartMatrix->setFont(font5x7);
  39. pSmartMatrix->fillScreen(CRGB(CHSV(100,0,255)));
  40. pSmartMatrix->fillRectangle(0,0,31,15,CRGB(CHSV(0,255,255)));
  41. pSmartMatrix->fillRoundRectangle(3,12,28,19,1,CRGB(CHSV(0,0,0)));
  42. pSmartMatrix->drawString(4,13,CRGB(CHSV(255,0,255)),str);
  43. sprintf(str,"%02d", minute());
  44. pSmartMatrix->drawString(19,13,CRGB(255,255,255),str);
  45. if(second()%2) {
  46. pSmartMatrix->drawString(13,12,CRGB(255,255,255),":");
  47. }
  48. nextFrame = millis() + 1000;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment