Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.31 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////
  2. //
  3. // таблица символов:
  4. // с е й ч а с б д в а о
  5. // ч е т ы р е д в е о л
  6. // о д и н н а д ц а т о
  7. // т р и д е в о с е м ь
  8. // д е с я т ь ф п я т ь
  9. // ш е с т ь о ч а с о в
  10. // ч а с а я д в а т р и
  11. // п я т н а д ц а т ь л
  12. // ь д е с я т с о р о к
  13. // п я т ь в ф м и н у т
  14.  
  15. // нумерация диодов:
  16. // 100 101 102 103 104 105 106 107 108 109 110
  17. // 99 98 97 96 95 94 93 92 91 90 89
  18. // 78 79 80 81 82 83 84 85 86 87 88
  19. // 77 76 75 74 73 72 71 70 69 68 67
  20. // 56 57 58 59 60 61 62 63 64 65 66
  21. // 55 54 53 52 51 50 49 48 47 46 45
  22. // 34 35 36 37 38 39 40 41 42 43 44
  23. // 33 32 31 30 29 28 27 26 25 24 23
  24. // 12 13 14 15 16 17 18 19 20 21 22
  25. // 11 10 9 8 7 6 5 4 3 2 1
  26. ///////////////////////////////////////////////////////////////////
  27.  
  28.  
  29.  
  30. #include <EEPROM.h>
  31. #include <Wire.h>
  32. #include <Button.h>
  33.  
  34. #include <Adafruit_NeoPixel.h>
  35.  
  36. #define DS1307_ADDRESS 0x68
  37.  
  38. #define arraySize 8
  39.  
  40. #define timeButtonPin 3 //to increment the time
  41.  
  42. #define colourButtonPin 2 //to adjust the colour
  43.  
  44. // Which pin on the Arduino is connected to the NeoPixels?
  45. #define PIN 4
  46. // How many NeoPixels are attached to the Arduino?
  47. #define NUMPIXELS 110// 196
  48.  
  49.  
  50. // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
  51. // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
  52. // example for more information on possible values.
  53. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  54. int delayval = 500; // delay for half a second
  55.  
  56. byte zero = 0x00; //workaround for issue #527
  57.  
  58. //Pin Setup + Configuration
  59. byte o_itis = 0; //сейчас Output
  60. byte o_minutes = 0; //минут Output
  61. byte o_oclock = 0; //часов Output
  62. byte o_to = 0; //час Output
  63. byte o_past = 0; //часа Output
  64.  
  65. byte m_five = 0; //5 Output
  66. byte m_ten = 0; //10 Output
  67. byte m_quarter = 0; //15 Output
  68. byte m_twenty = 0; //20 Output
  69. byte m_half = 0; //30 Output
  70. byte m_forty = 0; //40 Output
  71. byte m_fifty = 0; //50 Output
  72.  
  73. byte h_one = 0; //1 Output
  74. byte h_two = 0; //2 Output
  75. byte h_three = 0; //3 Output
  76. byte h_four = 0; //4 Output
  77. byte h_five = 0; //5 Output
  78. byte h_six = 0; //6 Output
  79. byte h_seven = 0; //7 Output
  80. byte h_eight = 0; //8 Output
  81. byte h_nine = 0; //9 Output
  82. byte h_ten = 0; //10 Output
  83. byte h_eleven = 0; //11 Output
  84. byte h_twelve = 0; //12 Output
  85.  
  86.  
  87. int intHour = 0;
  88. int intMinute = 0;
  89.  
  90. int secondSet = 0; //0-59
  91. int minuteSet = 0; //0-59
  92. int hourSet = 0; //0-23
  93. int weekDaySet = 1; //1-7
  94. int monthDaySet = 1; //1-31
  95. int monthSet = 1; //1-12
  96. int yearSet = 0; //0-99
  97.  
  98. char junk = ' ';
  99.  
  100. int pixelAddress = 0;
  101.  
  102.  
  103. #define coloursDefined 6 //Number of colors defined as we use to cycle later
  104.  
  105. //list colours here
  106. uint32_t colours[] = {pixels.Color(0, 0, 255),
  107. pixels.Color(127, 127, 0),
  108. pixels.Color(127, 0, 127),
  109. pixels.Color(0, 127, 127),
  110. pixels.Color(255, 0, 0),
  111. pixels.Color(0, 255, 0)};
  112.  
  113.  
  114.  
  115. int eepromColorAddress = 0; //location to store the color when powered off
  116.  
  117.  
  118. int memoryColour = 0; //the default color
  119.  
  120.  
  121. //Set the colour globally
  122. uint32_t colourOut;// = colours[memoryColour];
  123.  
  124.  
  125. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  126. void setup() {
  127. Wire.begin();
  128.  
  129.  
  130. Serial.begin(9600);
  131.  
  132.  
  133.  
  134. pinMode(timeButtonPin, INPUT);
  135. pinMode(colourButtonPin, INPUT);
  136.  
  137. //Read back color if stored in EEPROM
  138.  
  139. //EEPROM.write(eepromColorAddress,4);
  140. memoryColour = readColor(); //the colour currently stored
  141.  
  142. colourOut = colours[memoryColour];
  143.  
  144.  
  145. pixels.begin(); // This initializes the NeoPixel library.
  146. }
  147.  
  148.  
  149. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150. void loop() {
  151.  
  152. intHour = getHour();
  153. intMinute = getMinute();
  154.  
  155.  
  156. Serial.print("Hour Value Off RTC: ");
  157. Serial.println(intHour);
  158. Serial.print("Minute Value Off RTC: ");
  159. Serial.println(intMinute);
  160.  
  161. serialConvert(intHour,intMinute);
  162.  
  163. displayTime();
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. //temp test
  175.  
  176. if (digitalRead(colourButtonPin) == HIGH) {
  177. colourButtonPressed();
  178. delay(500);
  179. }
  180. if (digitalRead(timeButtonPin) == HIGH) {
  181. timeButtonPressed();
  182. delay(50);
  183. }
  184.  
  185. }
  186.  
  187.  
  188. //----------------------------------------------------------
  189. //checkHourButton will look to see if button has been pressed on globally set pin
  190. void timeButtonPressed(){
  191. Serial.println("+++ Hour Button Pressed +++");
  192. hourSet = getHour(); //get existing hour
  193.  
  194. minuteSet = getMinute()+1; //0-59, the button increments the minute
  195.  
  196. //When you are at 60 mins, increment the hour and reset the minutes
  197. if (minuteSet >= 60) {
  198. hourSet = getHour()+1; //0-23
  199. minuteSet = minuteSet - 60;
  200. }
  201.  
  202. //When you are past 24 hours, start again
  203. if (hourSet >= 24) {
  204. hourSet = hourSet - 24;
  205. }
  206.  
  207. Wire.beginTransmission(DS1307_ADDRESS);
  208. Wire.write(zero); //stop Oscillator
  209.  
  210. Wire.write(decToBcd(secondSet));
  211. Wire.write(decToBcd(minuteSet));
  212. Wire.write(decToBcd(hourSet));
  213. Wire.write(decToBcd(weekDaySet));
  214. Wire.write(decToBcd(monthDaySet));
  215. Wire.write(decToBcd(monthSet));
  216. Wire.write(decToBcd(yearSet));
  217.  
  218. Wire.write(zero); //start
  219. Wire.endTransmission();
  220. }
  221.  
  222.  
  223. //----------------------------------------------------------
  224. //checkMinuteButton will look to see if button has been pressed on globally set pin
  225. void colourButtonPressed(){
  226.  
  227.  
  228. Serial.println("+++ Colour Button Pressed +++");
  229.  
  230.  
  231.  
  232. memoryColour = memoryColour + 1;
  233.  
  234. if (memoryColour > (coloursDefined-1)) //ensure not out of bounds
  235. {
  236.  
  237. memoryColour = 0;
  238. Serial.println("caught");
  239.  
  240. }
  241. // Serial.println(memoryColour);
  242.  
  243. // switch (memoryColour) {
  244. // case 0:
  245. // colourOut = pixels.Color(0, 0, 255);
  246. // break;
  247. // case 1:
  248. // colourOut = pixels.Color(0, 255,0);
  249. // break;
  250. // case 2:
  251. // colourOut = pixels.Color(255,0,0);
  252. // break;
  253. //
  254. // default:
  255. // memoryColour = 0;
  256. //}
  257.  
  258.  
  259. colourOut = colours[memoryColour];
  260.  
  261. //store to eeprom
  262. updateColor(memoryColour);
  263.  
  264. }
  265.  
  266.  
  267. //----------------------------------------------------------
  268. //getHour pulls the hour integer from DS1307 Real Time Clock
  269. int getHour(){
  270.  
  271. // Reset the register pointer
  272. Wire.beginTransmission(DS1307_ADDRESS);
  273. Wire.write(zero);
  274. Wire.endTransmission();
  275.  
  276. Wire.requestFrom(DS1307_ADDRESS, 7);
  277. //Need to read the whole packet of information even though Hour is only needed
  278. int second = bcdToDec(Wire.read());
  279. int minute = bcdToDec(Wire.read());
  280. int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  281. int weekDay = bcdToDec(Wire.read()); //0-6 -> Sunday - Saturday
  282. int monthDay = bcdToDec(Wire.read());
  283. int month = bcdToDec(Wire.read());
  284. int year = bcdToDec(Wire.read());
  285.  
  286. return hour;
  287. }
  288.  
  289.  
  290. //----------------------------------------------------------
  291. //getMinute pulls the minute integer from DS1307 Real Time Clock
  292. int getMinute(){
  293.  
  294. // Reset the register pointer
  295. Wire.beginTransmission(DS1307_ADDRESS);
  296. Wire.write(zero);
  297. Wire.endTransmission();
  298.  
  299. Wire.requestFrom(DS1307_ADDRESS, 7);
  300. //Need to read the whole packet of information even though Minute is only needed
  301. int second = bcdToDec(Wire.read());
  302. int minute = bcdToDec(Wire.read());
  303. int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  304. int weekDay = bcdToDec(Wire.read()); //0-6 -> Sunday - Saturday
  305. int monthDay = bcdToDec(Wire.read());
  306. int month = bcdToDec(Wire.read());
  307. int year = bcdToDec(Wire.read());
  308.  
  309. return minute;
  310. }
  311.  
  312.  
  313. //----------------------------------------------------------
  314. byte decToBcd(byte val){
  315. // Convert normal decimal numbers to binary coded decimal
  316. return ( (val/10*16) + (val%10) );
  317. }
  318.  
  319.  
  320. //----------------------------------------------------------
  321. byte bcdToDec(byte val) {
  322. // Convert binary coded decimal to normal decimal numbers
  323. return ( (val/16*10) + (val%16) );
  324. }
  325.  
  326.  
  327. //----------------------------------------------------------
  328. //serialConvert expects...
  329. // - inputHour between the valueas of 0-23 (24 Hour)
  330. // - inputMinutes between the valueas of 0-59
  331.  
  332. //serialConvert will populate all the bytes used to display words
  333. void serialConvert(int inputHour, int inputMinute){
  334.  
  335. //Check to see if inputHour and inputMinute are within suitable range
  336. if (inputHour < 0 || inputHour > 23) {
  337. Serial.print(" inputHour is not suitable: ");
  338. Serial.println(inputHour);
  339. Serial.println(" Select a value between 0 and 23");
  340. Serial.println();
  341. return;
  342. }
  343. if (inputMinute < 0 || inputMinute > 59) {
  344. Serial.print(" inputMinute is not suitable: ");
  345. Serial.println(inputMinute);
  346. Serial.println(" Select a value between 0 and 59");
  347. Serial.println();
  348. return;
  349. }
  350.  
  351. clearSerialArray();
  352.  
  353. //IT IS is always on
  354. o_itis = 1;
  355.  
  356. //Minute Serial Conversion
  357. if (inputMinute < 5) { //??:00 --> ??:04
  358. o_oclock = 1;
  359. }
  360. else if (inputMinute >= 30) { //??:30 --> ??:34
  361. o_past = 1;
  362. if (inputMinute >= 35){ //??:35 --> ??:39
  363. m_five = 1;
  364. }
  365. else if (inputMinute >= 15 && inputMinute <20 ) { //??:15 --> ??:19
  366. m_quarter = 1;
  367. }
  368. else {
  369. o_minutes = 1;
  370. if (inputMinute >= 20){ //??:20 --> ??:29
  371. m_twenty = 1;
  372. if (inputMinute >= 25) { //??:25 --> ??:29
  373. m_five = 1;
  374. }
  375. }
  376. else if (inputMinute >= 10){ //??:10 --> ??:14
  377. m_ten = 1;
  378. }
  379. else { //??:05 --> ??:09
  380. m_five = 1;
  381. }
  382. if (inputMinute >= 40){ //??:40 --> ??:49
  383. m_forty = 1;
  384. if (inputMinute >= 45) { //??:45 --> ??:49
  385. m_five = 1;
  386. }
  387. }
  388. if (inputMinute >= 50){ //??:50 --> ??:59
  389. m_fifty = 1;
  390. if (inputMinute >= 55) { //??:55 --> ??:59
  391. m_five = 1;
  392. }
  393. }
  394. }
  395. }
  396.  
  397. //Hour Serial Conversion
  398. if (inputHour >= 12) {
  399. inputHour = inputHour - 12;
  400. if (inputHour == 12) {
  401. inputHour = inputHour - 12;
  402. }
  403. }
  404.  
  405. switch(inputHour){
  406. case 0:
  407. h_twelve = 1;
  408. break;
  409.  
  410. case 1:
  411. h_one = 1;
  412. break;
  413.  
  414. case 2:
  415. h_two = 1;
  416. break;
  417.  
  418. case 3:
  419. h_three = 1;
  420. break;
  421.  
  422. case 4:
  423. h_four = 1;
  424. break;
  425.  
  426. case 5:
  427. h_five = 1;
  428. break;
  429.  
  430. case 6:
  431. h_six = 1;
  432. break;
  433.  
  434. case 7:
  435. h_seven = 1;
  436. break;
  437.  
  438. case 8:
  439. h_eight = 1;
  440. break;
  441.  
  442. case 9:
  443. h_nine = 1;
  444. break;
  445.  
  446. case 10:
  447. h_ten = 1;
  448. break;
  449.  
  450. case 11:
  451. h_eleven = 1;
  452. break;
  453. }
  454. }
  455.  
  456.  
  457. //----------------------------------------------------------
  458. //clearSerialArray will zero all values in outputSerial[]
  459. void clearSerialArray(){
  460.  
  461. //Pin Setup + Configuration
  462. o_itis = 0; //сейчас Output
  463. o_minutes = 0; //минут Output
  464. o_oclock = 0; //часов Output
  465. o_to = 0; //час Output
  466. o_past = 0; //часа Output
  467.  
  468. m_five = 0; //5 Output
  469. m_ten = 0; //10 Output
  470. m_quarter = 0; //15 Output
  471. m_twenty = 0; //20 Output
  472. m_half = 0; //30 Output
  473. m_forty = 0; //40 Output
  474. m_fifty = 0; //50 Output
  475.  
  476. h_one = 0; //1 Output
  477. h_two = 0; //2 Output
  478. h_three = 0; //3 Output
  479. h_four = 0; //4 Output
  480. h_five = 0; //5 Output
  481. h_six = 0; //6 Output
  482. h_seven = 0; //7 Output
  483. h_eight = 0; //8 Output
  484. h_nine = 0; //9 Output
  485. h_ten = 0; //10 Output
  486. h_eleven = 0; //11 Output
  487. h_twelve = 0; //12 Output
  488. }
  489.  
  490.  
  491. void displayTime(){
  492. //clearall
  493. clearAll();
  494.  
  495. //list the time, then in it, list the pixels that are with i
  496. if (o_itis == 1){ //сейчас Output
  497.  
  498. pixels.setPixelColor(110, colourOut);
  499. pixels.setPixelColor(109, colourOut);
  500. pixels.setPixelColor(108, colourOut);
  501. pixels.setPixelColor(107, colourOut);
  502. pixels.setPixelColor(106, colourOut);
  503. pixels.setPixelColor(105, colourOut);
  504.  
  505. }
  506.  
  507. if (o_minutes == 1){ //минут Output
  508. if (NUMPIXELS != 196){
  509. //nothing, no minutes on small version
  510. }
  511. else{
  512. pixels.setPixelColor(5, colourOut);
  513. pixels.setPixelColor(4, colourOut);
  514. pixels.setPixelColor(3, colourOut);
  515. pixels.setPixelColor(2, colourOut);
  516. pixels.setPixelColor(1, colourOut);
  517. }
  518. }
  519.  
  520. if (o_oclock == 1){ //часов Output
  521. pixels.setPixelColor(51, colourOut);
  522. pixels.setPixelColor(52, colourOut);
  523. pixels.setPixelColor(53, colourOut);
  524. pixels.setPixelColor(54, colourOut);
  525. pixels.setPixelColor(55, colourOut);
  526. }
  527.  
  528. if (o_to == 1){ //час Output
  529. pixels.setPixelColor(51, colourOut);
  530. pixels.setPixelColor(52, colourOut);
  531. pixels.setPixelColor(53, colourOut);
  532. }
  533.  
  534. if (o_past == 1){ //часа Output
  535. pixels.setPixelColor(34, colourOut);
  536. pixels.setPixelColor(35, colourOut);
  537. pixels.setPixelColor(36, colourOut);
  538. pixels.setPixelColor(37, colourOut);
  539. }
  540.  
  541. if (m_five == 1){ //5 Output
  542. pixels.setPixelColor(11, colourOut);
  543. pixels.setPixelColor(10, colourOut);
  544. pixels.setPixelColor(9, colourOut);
  545. pixels.setPixelColor(8, colourOut);
  546. }
  547.  
  548. if (m_ten == 1){ //10 Output
  549. pixels.setPixelColor(13, colourOut);
  550. pixels.setPixelColor(14, colourOut);
  551. pixels.setPixelColor(15, colourOut);
  552. pixels.setPixelColor(10, colourOut);
  553. pixels.setPixelColor(9, colourOut);
  554. pixels.setPixelColor(8, colourOut);
  555. }
  556.  
  557. if (m_quarter == 1){ //15 Output
  558. pixels.setPixelColor(33, colourOut);
  559. pixels.setPixelColor(32, colourOut);
  560. pixels.setPixelColor(31, colourOut);
  561. pixels.setPixelColor(30, colourOut);
  562. pixels.setPixelColor(29, colourOut);
  563. pixels.setPixelColor(28, colourOut);
  564. pixels.setPixelColor(27, colourOut);
  565. pixels.setPixelColor(26, colourOut);
  566. pixels.setPixelColor(25, colourOut);
  567. pixels.setPixelColor(24, colourOut);
  568. }
  569.  
  570. if (m_twenty == 1){ //20 Output
  571. pixels.setPixelColor(39, colourOut);
  572. pixels.setPixelColor(40, colourOut);
  573. pixels.setPixelColor(41, colourOut);
  574. pixels.setPixelColor(28, colourOut);
  575. pixels.setPixelColor(27, colourOut);
  576. pixels.setPixelColor(26, colourOut);
  577. pixels.setPixelColor(25, colourOut);
  578. pixels.setPixelColor(24, colourOut);
  579. }
  580.  
  581. if (m_half == 1){ //30 Output
  582. pixels.setPixelColor(42, colourOut);
  583. pixels.setPixelColor(43, colourOut);
  584. pixels.setPixelColor(44, colourOut);
  585. pixels.setPixelColor(28, colourOut);
  586. pixels.setPixelColor(27, colourOut);
  587. pixels.setPixelColor(26, colourOut);
  588. pixels.setPixelColor(25, colourOut);
  589. pixels.setPixelColor(24, colourOut);
  590. }
  591.  
  592. if (m_forty == 1){ //40 Output !!!!!!!!!!!!!!!! если это закоментить, то все ок
  593. pixels.setPixelColor(42, colourOut);
  594. pixels.setPixelColor(43, colourOut);
  595. pixels.setPixelColor(44, colourOut);
  596. pixels.setPixelColor(28, colourOut);
  597. pixels.setPixelColor(27, colourOut);
  598. pixels.setPixelColor(26, colourOut);
  599. pixels.setPixelColor(25, colourOut);
  600. pixels.setPixelColor(24, colourOut);
  601. }
  602. if (m_half == 1){ //50 Output !!!!!!!!!!!!!!!! если это закоментить, то все ок
  603. pixels.setPixelColor(33, colourOut);
  604. pixels.setPixelColor(32, colourOut);
  605. pixels.setPixelColor(31, colourOut);
  606. pixels.setPixelColor(12, colourOut);
  607. pixels.setPixelColor(13, colourOut);
  608. pixels.setPixelColor(14, colourOut);
  609. pixels.setPixelColor(15, colourOut);
  610. pixels.setPixelColor(16, colourOut);
  611. pixels.setPixelColor(17, colourOut);
  612. }
  613.  
  614.  
  615. if (h_one == 1){ //1 Output
  616. if (NUMPIXELS != 196){
  617. pixels.setPixelColor(78, colourOut);
  618. pixels.setPixelColor(79, colourOut);
  619. pixels.setPixelColor(80, colourOut);
  620. pixels.setPixelColor(81, colourOut);
  621. }
  622. }
  623.  
  624. if (h_two == 1){ //2 Output
  625. if (NUMPIXELS != 196){
  626. pixels.setPixelColor(103, colourOut);
  627. pixels.setPixelColor(102, colourOut);
  628. pixels.setPixelColor(101, colourOut);
  629. }
  630. }
  631.  
  632. if (h_three == 1){ //3 Output
  633. if (NUMPIXELS != 196){
  634. pixels.setPixelColor(67, colourOut);
  635. pixels.setPixelColor(68, colourOut);
  636. pixels.setPixelColor(69, colourOut);
  637. }
  638. }
  639.  
  640. if (h_four == 1){ //4 Output
  641. if (NUMPIXELS != 196){
  642. pixels.setPixelColor(89, colourOut);
  643. pixels.setPixelColor(90, colourOut);
  644. pixels.setPixelColor(91, colourOut);
  645. pixels.setPixelColor(92, colourOut);
  646. pixels.setPixelColor(93, colourOut);
  647. pixels.setPixelColor(94, colourOut);
  648. }
  649. }
  650.  
  651. if (h_five == 1){ //5 Output
  652. if (NUMPIXELS != 196){
  653. pixels.setPixelColor(59, colourOut);
  654. pixels.setPixelColor(58, colourOut);
  655. pixels.setPixelColor(57, colourOut);
  656. pixels.setPixelColor(56, colourOut);
  657. }
  658. }
  659.  
  660. if (h_six == 1){ //6 Output
  661. if (NUMPIXELS != 196){
  662. pixels.setPixelColor(45, colourOut);
  663. pixels.setPixelColor(46, colourOut);
  664. pixels.setPixelColor(47, colourOut);
  665. pixels.setPixelColor(48, colourOut);
  666. pixels.setPixelColor(49, colourOut);
  667. }
  668. }
  669.  
  670. if (h_seven == 1){ //7 Output
  671. if (NUMPIXELS != 196){
  672. pixels.setPixelColor(74, colourOut);
  673. pixels.setPixelColor(75, colourOut);
  674. pixels.setPixelColor(76, colourOut);
  675. pixels.setPixelColor(77, colourOut);
  676. }
  677. }
  678.  
  679. if (h_eight == 1){ //8 Output
  680. if (NUMPIXELS != 196){
  681. pixels.setPixelColor(72, colourOut);
  682. pixels.setPixelColor(73, colourOut);
  683. pixels.setPixelColor(74, colourOut);
  684. pixels.setPixelColor(75, colourOut);
  685. pixels.setPixelColor(76, colourOut);
  686. pixels.setPixelColor(77, colourOut);
  687. }
  688. }
  689.  
  690. if (h_nine == 1){ //9 Output
  691. if (NUMPIXELS != 196){
  692. pixels.setPixelColor(70, colourOut);
  693. pixels.setPixelColor(71, colourOut);
  694. pixels.setPixelColor(72, colourOut);
  695. pixels.setPixelColor(63, colourOut);
  696. pixels.setPixelColor(62, colourOut);
  697. pixels.setPixelColor(61, colourOut);
  698. }
  699. }
  700.  
  701. if (h_ten == 1){ //10 Output
  702. if (NUMPIXELS != 196){
  703. pixels.setPixelColor(70, colourOut);
  704. pixels.setPixelColor(71, colourOut);
  705. pixels.setPixelColor(64, colourOut);
  706. pixels.setPixelColor(63, colourOut);
  707. pixels.setPixelColor(62, colourOut);
  708. pixels.setPixelColor(61, colourOut);
  709. }
  710. }
  711.  
  712. if (h_eleven == 1){ //11 Output
  713. if (NUMPIXELS != 196){
  714. pixels.setPixelColor(88, colourOut);
  715. pixels.setPixelColor(87, colourOut);
  716. pixels.setPixelColor(86, colourOut);
  717. pixels.setPixelColor(85, colourOut);
  718. pixels.setPixelColor(84, colourOut);
  719. pixels.setPixelColor(83, colourOut);
  720. pixels.setPixelColor(82, colourOut);
  721. pixels.setPixelColor(81, colourOut);
  722. pixels.setPixelColor(80, colourOut);
  723. pixels.setPixelColor(79, colourOut);
  724. pixels.setPixelColor(78, colourOut);
  725. }
  726. }
  727.  
  728. if (h_twelve == 1){ //12 Output
  729. if (NUMPIXELS != 196){
  730. pixels.setPixelColor(95, colourOut);
  731. pixels.setPixelColor(96, colourOut);
  732. pixels.setPixelColor(97, colourOut);
  733. pixels.setPixelColor(84, colourOut);
  734. pixels.setPixelColor(83, colourOut);
  735. pixels.setPixelColor(82, colourOut);
  736. pixels.setPixelColor(81, colourOut);
  737. pixels.setPixelColor(80, colourOut);
  738. pixels.setPixelColor(79, colourOut);
  739. pixels.setPixelColor(78, colourOut);
  740. }
  741. }
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748. //show them
  749. pixels.show(); // This sends the updated pixel color to the hardware.
  750.  
  751.  
  752.  
  753.  
  754. }
  755.  
  756.  
  757. void clearAll(){
  758.  
  759. for(int i=0;i<NUMPIXELS;i++){
  760. // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
  761. pixels.setPixelColor(i, 0); // Moderately bright green color.
  762. // pixels.show(); // This sends the updated pixel color to the hardware.
  763. //delay(delayval); // Delay for a period of time (in milliseconds).
  764. }
  765.  
  766.  
  767. }
  768.  
  769.  
  770. int readColor(){
  771. int tempColor;
  772. tempColor = EEPROM.read(eepromColorAddress);
  773. //check if valid
  774. //if not, default 0
  775. if (tempColor > (coloursDefined-1) || tempColor < 0) //ensure not out of bounds
  776. {
  777.  
  778. tempColor = 0;
  779. Serial.println("Fixed error in memory read");
  780.  
  781. }
  782.  
  783.  
  784.  
  785.  
  786. return tempColor;
  787. }
  788.  
  789. void updateColor(int colorInput){
  790. int tempColor;
  791. tempColor = EEPROM.read(eepromColorAddress);
  792. if (tempColor != colorInput){
  793. EEPROM.write(eepromColorAddress, colorInput);
  794. }
  795. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement