Advertisement
Guest User

Untitled

a guest
Dec 24th, 2016
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.87 KB | None | 0 0
  1. #include <Arduino.h>
  2.  
  3. //Nick, 2016
  4.  
  5. #include <NeoPixelBus.h>
  6. #include <NeoPixelAnimator.h>
  7. #include <NeoPixelBrightnessBus.h>
  8. //#include <Adafruit_GFX.h>
  9. //#include <Adafruit_NeoMatrix.h>
  10. //#include <Adafruit_NeoPixel.h>
  11. #include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)
  12. #include "RTClib.h"
  13. #include <BH1750.h>
  14.  
  15. /*
  16.  
  17.   BH1750 can be physically configured to use two I2C addresses:
  18.     - 0x23 (most common) (if ADD pin had < 0.7VCC voltage)
  19.     - 0x5C (if ADD pin had > 0.7VCC voltage)
  20.  
  21.   Library use 0x23 address as default, but you can define any other address.
  22.   If you had troubles with default value - try to change it to 0x5C.
  23.  
  24. */
  25. BH1750 lightMeter(0x23);
  26.  
  27. //IF CLOCK TIME IS WRONG: RUN FILE->EXAMPLE->DS1307RTC->SET TIME
  28. RTC_DS3231 rtc;
  29.  
  30. //LED pin = GPIO 3 for ESP8266, = pin 3 for Oak
  31. typedef ColumnMajorAlternating270Layout MyPanelLayout;
  32. const uint8_t PanelWidth = 16;
  33. const uint8_t PanelHeight = 6;
  34. const uint16_t PixelCount = PanelWidth * PanelHeight;
  35.  
  36. NeoTopology<MyPanelLayout> topo(PanelWidth, PanelHeight);
  37. NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
  38.  
  39. RgbColor red(128, 0, 0);
  40. RgbColor green(0, 128, 0);
  41. RgbColor blue(0, 0, 128);
  42. RgbColor white(128);
  43. RgbColor black(0);
  44.  
  45. const uint16_t left = 0;
  46. const uint16_t right = PanelWidth - 1;
  47. const uint16_t top = 0;
  48. const uint16_t bottom = PanelHeight - 1;
  49.  
  50. const uint8_t AnimationChannels = 5;
  51.  
  52. NeoPixelAnimator animations(AnimationChannels); // NeoPixel animation management object
  53.  
  54. uint16_t effectState = 0;  // general purpose variable used to store effect state
  55.  
  56.  
  57. // what is stored for state is specific to the need, in this case, the colors.
  58. // basically what ever you need inside the animation update function
  59. struct MyAnimationState
  60. {
  61.     RgbColor StartingColor;
  62.     RgbColor EndingColor;
  63. };
  64.  
  65. // one entry per pixel to match the animation timing manager
  66. MyAnimationState animationState[AnimationChannels];
  67.  
  68. //constants
  69. const int wpause = 250;
  70.  
  71. //variables
  72. long lastMillis = 0;
  73. long serialMillis = 0;
  74. int fadeInterval = 25;
  75. int intBrightness = 200;
  76.  
  77. int mytimemonth;
  78. int mytimeday;
  79. int mytimehr;
  80. int mytimemin;
  81. int mytimesec;
  82.  
  83. //states (variables)
  84. int sNEAR = LOW;
  85. int sPAST = LOW;
  86. int sEXACTLY = LOW;
  87. int sA1 = LOW;
  88. int sQUARTER = LOW;
  89. int sTWENTY = LOW;
  90. int sMTEN = LOW;
  91. int sA2 = LOW;
  92. int sMFIVE = LOW;
  93. int sA3 = LOW;
  94. int sHALF = LOW;
  95. int sTO = LOW;
  96. int sPAST2 = LOW;
  97. int sTEN = LOW;
  98. int sFOUR = LOW;
  99. int sTHREE = LOW;
  100. int sE1 = LOW;
  101. int sEIGHT = LOW;
  102. int sSEVEN = LOW;
  103. int sN1 = LOW;
  104. int sNINE = LOW;
  105. int sE2 = LOW;
  106. int sELEVEN = LOW;
  107. int sTWO = LOW;
  108. int sFIVE = LOW;
  109. int sONE = LOW;
  110. int sSIX = LOW;
  111. int sTWELVE = LOW;
  112.  
  113. void setup() {
  114.    Serial.begin(57600);  //Begin serial communcation (for photoresistor to display on serial monitor)
  115.  
  116.    // This info pulled from RTClib.h
  117.  if (! rtc.begin()) {
  118.     //Serial.println("Couldn't find RTC"); //program LEDs to show "NO CLOCK"
  119.     while (1);
  120.   }
  121.  
  122.   if (rtc.lostPower()) {
  123.     Serial.println("RTC lost power, lets set the time!"); //program LEDs to show "SET CLOCK"
  124. //following line sets the RTC to the date & time this sketch was compiled
  125.     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  126.     // This line sets the RTC with an explicit date & time, for example to set
  127.     // January 21, 2014 at 3am you would call:
  128.     // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  129.   }
  130.  
  131.   Serial.println("Power on");
  132.   Particle.publish("Power On", PRIVATE);
  133.  
  134.   lightMeter.begin(BH1750_CONTINUOUS_HIGH_RES_MODE);
  135.   Serial.println(F("BH1750 Test"));
  136.  
  137.   strip.Begin();
  138.   strip.Show();
  139. }
  140.  
  141.  
  142.  
  143.  
  144. void near (int state){
  145.   //this word's details
  146.   int iRow = 0;
  147.   int arrCols[] = {0,1,2,3};
  148.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  149.   int& wstate = sNEAR; //int&
  150.  
  151.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  152.   }
  153.  
  154. void past (int state){
  155.   int iRow = 0;
  156.   int arrCols[] = {4,5,6,7};
  157.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  158.   int& wstate = sPAST; //int&
  159.  
  160.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  161.   }
  162.  
  163. void exactly (int state){
  164.   int iRow = 0;
  165.   int arrCols[] = {8,9,10,11,12,13,14};
  166.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  167.   int& wstate = sEXACTLY;
  168.  
  169.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  170.   }
  171.  
  172. void a1 (int state){
  173.   int iRow = 0;
  174.   int arrCols[] = {15};
  175.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  176.   int& wstate = sA1; //int&
  177.  
  178.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  179.   }
  180.  
  181. void quarter (int state){
  182.   int iRow = 1;
  183.   int arrCols[] = {0,1,2,3,4,5,6};
  184.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  185.   int& wstate = sQUARTER; //int&
  186.  
  187.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  188.   }
  189.  
  190. void twenty (int state){
  191.   int iRow = 1;
  192.   int arrCols[] = {7,8,9,10,11,12};
  193.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  194.   int& wstate = sTWENTY; //int&
  195.   int wait = 1000;
  196.  
  197.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  198.   }
  199.  
  200. void mten (int state){
  201.   int iRow = 1;
  202.   int arrCols[] = {13,14,15};
  203.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  204.   int& wstate = sMTEN; //int&
  205.  
  206.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  207.   }
  208.  
  209. void a2 (int state){
  210.   int iRow = 2;
  211.   int arrCols[] = {0};
  212.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  213.   int& wstate = sA2; //int&
  214.  
  215.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  216.   }
  217.  
  218. void mfive (int state){
  219.   int iRow = 2;
  220.   int arrCols[] = {1,2,3,4};
  221.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  222.   int& wstate = sMFIVE; //int&
  223.  
  224.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  225.   }
  226.  
  227. void a3 (int state){
  228.   int iRow = 2;
  229.   int arrCols[] = {5};
  230.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  231.   int& wstate = sA3; //int&
  232.  
  233.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  234.   }
  235.  
  236. void half (int state){
  237.   int iRow = 2;
  238.   int arrCols[] = {6,7,8,9};
  239.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  240.   int& wstate = sHALF; //int&
  241.  
  242.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  243.   }
  244.  
  245. void to (int state){
  246.   int iRow = 2;
  247.   int arrCols[] = {10,11};
  248.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  249.   int& wstate = sTO; //int&
  250.  
  251.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  252.   }
  253.  
  254. void past2 (int state){
  255.   int iRow = 2;
  256.   int arrCols[] = {12,13,14,15};
  257.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  258.   int& wstate = sPAST2; //int&
  259.  
  260.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  261.   }
  262.  
  263. void ten (int state){
  264.   int iRow = 3;
  265.   int arrCols[] = {0,1,2};
  266.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  267.   int& wstate = sTEN; //int&
  268.  
  269.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  270.   }
  271.  
  272. void four (int state){
  273.   int iRow = 3;
  274.   int arrCols[] = {3,4,5,6};
  275.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  276.   int& wstate = sFOUR; //int&
  277.  
  278.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  279.   }
  280.  
  281. void three (int state){
  282.   int iRow = 3;
  283.   int arrCols[] = {7,8,9,10,11};
  284.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  285.   int& wstate = sTHREE; //int&
  286.  
  287.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  288.   }
  289.  
  290. void eight (int state){
  291.   int iRow = 3;
  292.   int arrCols[] = {11,12,13,14,15};
  293.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  294.   int& wstate = sEIGHT; //int&
  295.  
  296.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  297.   }
  298.  
  299. void seven (int state){
  300.   int iRow = 4;
  301.   int arrCols[] = {0,1,2,3,4};
  302.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  303.   int& wstate = sSEVEN; //int&
  304.  
  305.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  306.   }
  307.  
  308. void nine (int state){
  309.   int iRow = 4;
  310.   int arrCols[] = {4,5,6,7};
  311.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  312.   int& wstate = sNINE; //int&
  313.  
  314.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  315.   }
  316.  
  317. void eleven (int state){
  318.   int iRow = 4;
  319.   int arrCols[] = {7,8,9,10,11,12};
  320.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  321.   int& wstate = sELEVEN; //int&
  322.  
  323.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  324.   }
  325.  
  326. void two (int state){
  327.   int iRow = 4;
  328.   int arrCols[] = {13,14,15};
  329.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  330.   int& wstate = sTWO; //int&
  331.  
  332.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  333.   }
  334.  
  335. void five (int state){
  336.   int iRow = 5;
  337.   int arrCols[] = {0,1,2,3};
  338.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  339.   int& wstate = sFIVE; //int&
  340.  
  341.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  342.   }
  343.  
  344. void one (int state){
  345.   int iRow = 5;
  346.   int arrCols[] = {4,5,6};
  347.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  348.   int& wstate = sONE; //int&
  349.  
  350.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  351.   }
  352.  
  353. void six (int state){
  354.   int iRow = 5;
  355.   int arrCols[] = {7,8,9};
  356.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  357.   int& wstate = sSIX; //int&
  358.  
  359.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  360.   }
  361.  
  362. void twelve (int state){
  363.   int iRow = 5;
  364.   int arrCols[] = {10,11,12,13,14,15};
  365.   int arrSize = (sizeof(arrCols)/sizeof(arrCols[0])); //find array size so we don't read random values
  366.   int& wstate = sTWELVE; //int&
  367.  
  368.   displayWord(iRow, arrCols, arrSize, wstate, state); // not working with state
  369.   }
  370.  
  371. // Display functions
  372.  
  373. void displayWord(int iRow, int arrCols[], int arrSize, int& shownState, int state) { //function to display word, effect if just turned on, no effect (stay on) otherwise
  374.   if (state == ON) {
  375.    //   if (shownState == LOW) {
  376.     //    FadeIn(0.2f, arrCols, arrSize, iRow);
  377.   //      showWord(arrCols, arrSize, iRow, white);
  378.         //void spellWord(int arrCols[], int arrSize, int iRow, RGB color, int wait){
  379.         //spellWord(arrCols, arrSize, iRow, 2500);
  380.    //     shownState = HIGH; //we have now shown the word
  381.    //   } else {
  382.         showWord(arrCols, arrSize, iRow, white);
  383.   //    }
  384.   } else {
  385.     //void hideWord(int arrCols[], int arrSize, int iRow)
  386.     hideWord(arrCols, arrSize, iRow);
  387.     shownState = LOW;
  388.   }
  389. }
  390.  
  391. void hideWord(int arrCols[], int arrSize, int iRow) {
  392.   for (int i = 0; i < arrSize; i++) {
  393.      strip.SetPixelColor(topo.Map(arrCols[i], iRow), black);
  394.   }
  395. }
  396.  
  397. void showWord(int arrCols[], int arrSize, int iRow, RgbColor colour) { //simple show word, no effect
  398.   for (int i = 0; i < arrSize; i++) {
  399.       strip.SetPixelColor(topo.Map(arrCols[i], iRow), colour);
  400.   }
  401. }
  402.  
  403. // simple blend function
  404. void BlendAnimUpdate(const AnimationParam& param)
  405. {
  406.     // this gets called for each animation on every time step
  407.     // progress will start at 0.0 and end at 1.0
  408.     // we use the blend function on the RgbColor to mix
  409.     // color based on the progress given to us in the animation
  410.     RgbColor updatedColor = RgbColor::LinearBlend(
  411.         animationState[param.index].StartingColor,
  412.         animationState[param.index].EndingColor,
  413.         param.progress);
  414.     // apply the color to the strip
  415.     strip.SetPixelColor(param.index, updatedColor);
  416. }
  417.  
  418.  
  419. void FadeIn(float luminance, int arrCols[], int arrSize, int iRow) {
  420.     // Fade upto a random color
  421.     // we use HslColor object as it allows us to easily pick a hue
  422.     // with the same saturation and luminance so the colors picked
  423.     // will have similiar overall brightness
  424.     RgbColor target = HslColor(random(360) / 360.0f, 1.0f, luminance);
  425.     uint16_t time = random(800, 2000);
  426.  
  427.     for (int i = 0; i < arrSize; i++) {
  428.           uint16_t pixel = topo.Map(arrCols[i], iRow);
  429.  
  430.           animationState[0].StartingColor = strip.GetPixelColor(0);
  431.           animationState[0].EndingColor = target;
  432.  
  433.           animations.StartAnimation(pixel, time, BlendAnimUpdate);
  434.     }
  435. }
  436.  
  437.  
  438.  
  439. // Clock
  440.  
  441. void displayClock() {
  442.  
  443. if ((mytimemin== 0)
  444.       | (mytimemin== 5)
  445.       | (mytimemin== 10)
  446.       | (mytimemin== 15)
  447.       | (mytimemin== 20)
  448.       | (mytimemin== 25)
  449.       | (mytimemin == 30)
  450.       | (mytimemin == 35)
  451.       | (mytimemin == 40)
  452.       | (mytimemin == 45)
  453.       | (mytimemin == 50)
  454.       | (mytimemin == 55)) {
  455.     exactly(ON);
  456.   } else {
  457.     exactly(OFF);
  458.   }
  459.   if ((mytimemin == 1)
  460.       | (mytimemin == 2)
  461.       | (mytimemin == 6)
  462.       | (mytimemin == 7)
  463.       | (mytimemin == 11)
  464.       | (mytimemin == 12)
  465.       | (mytimemin == 16)
  466.       | (mytimemin == 17)
  467.       | (mytimemin == 21)
  468.       | (mytimemin == 22)
  469.       | (mytimemin == 26)
  470.       | (mytimemin == 27)
  471.       | (mytimemin == 31)
  472.       | (mytimemin == 32)
  473.       | (mytimemin == 36)
  474.       | (mytimemin == 37)
  475.       | (mytimemin == 41)
  476.       | (mytimemin == 42)
  477.       | (mytimemin == 46)
  478.       | (mytimemin == 47)
  479.       | (mytimemin == 51)
  480.       | (mytimemin == 52)
  481.       | (mytimemin == 56)
  482.       | (mytimemin == 57)) {
  483.         past(ON);
  484.       } else {
  485.         past(OFF);
  486.   }
  487.   if ((mytimemin == 3)
  488.       | (mytimemin == 4)
  489.       | (mytimemin == 8)
  490.       | (mytimemin == 9)
  491.       | (mytimemin == 13)
  492.       | (mytimemin == 14)
  493.       | (mytimemin == 18)
  494.       | (mytimemin == 19)
  495.       | (mytimemin == 23)
  496.       | (mytimemin == 24)
  497.       | (mytimemin == 28)
  498.       | (mytimemin == 29)
  499.       | (mytimemin == 33)
  500.       | (mytimemin == 34)
  501.       | (mytimemin == 38)
  502.       | (mytimemin == 39)
  503.       | (mytimemin == 43)
  504.       | (mytimemin == 44)
  505.       | (mytimemin == 48)
  506.       | (mytimemin == 49)
  507.       | (mytimemin == 53)
  508.       | (mytimemin == 54)
  509.       | (mytimemin == 58)
  510.       | (mytimemin == 59)) {
  511.         near(ON);
  512.     } else {
  513.         near(OFF);
  514.   }
  515.  
  516.  
  517.   //calculate minutes on the hour
  518.     if(mytimemin<3){
  519.       quarter(OFF);
  520.       twenty(OFF);
  521.       mten(OFF);
  522.       mfive(OFF);
  523.       half(OFF);
  524.       to(OFF);
  525.       past2(OFF);
  526.     }
  527.     // do nothing, no minutes it's on the hour
  528.  
  529.     if(mytimemin>2 && mytimemin<8){
  530.       quarter(OFF);
  531.       twenty(OFF);
  532.       mten(OFF);
  533.       mfive(ON);
  534.       half(OFF);
  535.       to(OFF);
  536.       past2(ON);
  537.     }
  538.  
  539.     if(mytimemin>7 && mytimemin<13){
  540.       quarter(OFF);
  541.       twenty(OFF);
  542.       mten(ON);
  543.       mfive(OFF);
  544.       half(OFF);
  545.       to(OFF);
  546.       past2(ON);
  547.     }
  548.     if(mytimemin>12 && mytimemin<18){
  549.       quarter(ON);
  550.       twenty(OFF);
  551.       mten(OFF);
  552.       mfive(OFF);
  553.       half(OFF);
  554.       to(OFF);
  555.       past2(ON);
  556.     }
  557.     if(mytimemin>17 && mytimemin<23){
  558.       quarter(OFF);
  559.       twenty(ON);
  560.       mten(OFF);
  561.       mfive(OFF);
  562.       half(OFF);
  563.       to(OFF);
  564.       past2(ON);
  565.     }
  566.     if(mytimemin>22 && mytimemin<28){
  567.       quarter(OFF);
  568.       twenty(ON);
  569.       mten(OFF);
  570.       mfive(ON);
  571.       half(OFF);
  572.       to(OFF);
  573.       past2(ON);
  574.     }
  575.     if(mytimemin>27 && mytimemin<33){
  576.       quarter(OFF);
  577.       twenty(OFF);
  578.       mten(OFF);
  579.       mfive(OFF);
  580.       half(ON);
  581.       to(OFF);
  582.       past2(ON);
  583.     }
  584.     if(mytimemin>32 && mytimemin<38){
  585.       quarter(OFF);
  586.       twenty(ON);
  587.       mten(OFF);
  588.       mfive(ON);
  589.       half(OFF);
  590.       to(ON);
  591.       past2(OFF);
  592.     }
  593.     if(mytimemin>37 && mytimemin<43){
  594.       quarter(OFF);
  595.       twenty(ON);
  596.       mten(OFF);
  597.       mfive(OFF);
  598.       half(OFF);
  599.       to(ON);
  600.       past2(OFF);
  601.     }
  602.     if(mytimemin>42 && mytimemin<48){
  603.       quarter(ON);
  604.       twenty(OFF);
  605.       mten(OFF);
  606.       mfive(OFF);
  607.       half(OFF);
  608.       to(ON);
  609.       past2(OFF);
  610.     }
  611.     if(mytimemin>47 && mytimemin<53){
  612.       quarter(OFF);
  613.       twenty(OFF);
  614.       mten(ON);
  615.       mfive(OFF);
  616.       half(OFF);
  617.       to(ON);
  618.       past2(OFF);
  619.     }
  620.     if(mytimemin>52 && mytimemin<58){
  621.       quarter(OFF);
  622.       twenty(OFF);
  623.       mten(OFF);
  624.       mfive(ON);
  625.       half(OFF);
  626.       to(ON);
  627.       past2(OFF);
  628.     }
  629.  
  630.  
  631.   // Calculate hour & oclocks
  632.   if(mytimehr==1||mytimehr==13){
  633.     if(mytimemin>32){
  634.       one(OFF);
  635.       two(ON);
  636.       three(OFF);
  637.     }
  638.     else
  639.     {
  640.       one(ON);
  641.       two(OFF);
  642.       twelve(OFF);
  643.     }
  644.   }
  645.   if(mytimehr==2||mytimehr==14){
  646.     if(mytimemin>32){
  647.       two(OFF);
  648.       three(ON);
  649.       four(OFF);
  650.     }
  651.     else
  652.     {
  653.       one(OFF);
  654.       two(ON);
  655.       three(OFF);
  656.     }
  657.   }
  658.     if(mytimehr==3||mytimehr==15){
  659.     if(mytimemin>32){
  660.       three(OFF);
  661.       four(ON);
  662.       five(OFF);
  663.     }
  664.     else
  665.     {
  666.       two(OFF);
  667.       three(ON);
  668.       four(OFF);
  669.     }
  670.   }
  671.   if(mytimehr==4||mytimehr==16){
  672.     if(mytimemin>32){
  673.       four(OFF);
  674.       five(ON);
  675.       six(OFF);
  676.     }
  677.     else
  678.     {
  679.       three(OFF);
  680.       four(ON);
  681.       five(OFF);
  682.     }
  683.   }
  684.   if(mytimehr==5||mytimehr==17){
  685.     if(mytimemin>32){
  686.       five(OFF);
  687.       six(ON);
  688.       seven(OFF);
  689.     }
  690.     else
  691.     {
  692.       four(OFF);
  693.       five(ON);
  694.       six(OFF);
  695.     }
  696.   }
  697.   if(mytimehr==6||mytimehr==18){
  698.     if(mytimemin>32){
  699.       six(OFF);
  700.       seven(ON);
  701.       eight(OFF);
  702.     }
  703.     else
  704.     {
  705.       five(OFF);
  706.       six(ON);
  707.       seven(OFF);
  708.     }
  709.   }
  710.   if(mytimehr==7||mytimehr==19){
  711.     if(mytimemin>32){
  712.       seven(OFF);
  713.       eight(ON);
  714.       nine(OFF);
  715.     }
  716.     else
  717.     {
  718.       six(OFF);
  719.       seven(ON);
  720.       eight(OFF);
  721.     }
  722.   }
  723.   if(mytimehr==8||mytimehr==20){
  724.     if(mytimemin>32){
  725.       eight(OFF);
  726.       nine(ON);
  727.       ten(OFF);
  728.     }
  729.     else
  730.     {
  731.       seven(OFF);
  732.       eight(ON);
  733.       nine(OFF);
  734.     }
  735.   }
  736.   if(mytimehr==9||mytimehr==21){
  737.     if(mytimemin>32){
  738.       nine(OFF);
  739.       ten(ON);
  740.       eleven(OFF);
  741.     }
  742.     else
  743.     {
  744.       eight(OFF);
  745.       nine(ON);
  746.       ten(OFF);
  747.     }
  748.   }
  749.   if(mytimehr==10||mytimehr==22){
  750.     if(mytimemin>32){
  751.       ten(OFF);
  752.       eleven(ON);
  753.       twelve(OFF);
  754.     }
  755.     else
  756.     {
  757.       nine(OFF);
  758.       ten(ON);
  759.       eleven(OFF);
  760.     }
  761.   }
  762.   if(mytimehr==11||mytimehr==23){
  763.     if(mytimemin>32){
  764.       one(OFF);
  765.       eleven(OFF);
  766.       twelve(ON);
  767.     }
  768.     else
  769.     {
  770.       ten(OFF);
  771.       eleven(ON);
  772.       twelve(OFF);
  773.     }
  774.   }
  775.   if(mytimehr==12||mytimehr==24){
  776.     if(mytimemin>32){
  777.       one(ON);
  778.       two(OFF);
  779.       twelve(OFF);
  780.     }
  781.     else
  782.     {
  783.       one(OFF);
  784.       eleven(OFF);
  785.       twelve(ON);
  786.     }
  787.   }
  788. }
  789.  
  790. void loop (){
  791.  
  792.   DateTime now = rtc.now();
  793.   mytimemonth=now.month();
  794.   mytimeday=now.day();
  795.   mytimehr=now.hour();
  796.   mytimemin=now.minute();
  797.   mytimesec=now.second();
  798.  
  799.   displayClock(); //function at bottom
  800.  
  801.     animations.UpdateAnimations();
  802.     strip.Show();    
  803. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement