Guest User

Untitled

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