Nathan Yonkee / Mbed OS Seeed_Grove_4_Digit_Display_Clock

Dependencies:   Data_Clock_Pair Seeed_Chainable_LED Seeed_Four_Digit_Disp Seeed_IR_Temp_Sensor Seeed_Led_Bar

Fork of Seeed_Grove_4_Digit_Display_Clock by Seeed

Revision:
15:abda719ba6e6
Parent:
12:a16d86fac131
--- a/SeeedLedBar.h	Thu Apr 27 16:10:16 2017 -0600
+++ b/SeeedLedBar.h	Thu May 18 10:47:08 2017 -0600
@@ -10,12 +10,12 @@
     void pin_delay(int delay_us = 2);
     static const int glbCmdMode_ = 0x00;
     void send_sixtn_bits(int sixtnBits);
-    void set_leds(int ledPower[]);
+    void set_leds(int (&ledPower )[10]);
   public:
     SeeedLedBar(DataClockPair pins);
     void ten_on();
     void ten_off();
-    void ten_set(int ledPower[]);
+    void ten_set(int (&ledPower )[10]);
 };
 
 SeeedLedBar::SeeedLedBar(DataClockPair pins) : datPin_(pins.dataPin), clkPin_(pins.clockPin) { }
@@ -28,15 +28,15 @@
     for (int i = 0; i < 16; i++) {
         pin_delay();
         datPin_ = sixtnBits & 0x8000;
+        sixtnBits <<= 1;
         pin_delay();
         clkPin_ = !clkPin_;
-        sixtnBits <<= 1;
     }
 }
 
-void SeeedLedBar::set_leds(int ledPower[]) {
+void SeeedLedBar::set_leds(int (&ledPower )[10]) {
     send_sixtn_bits(glbCmdMode_);
-    for (int i = 0; i < 10; i++) send_sixtn_bits(ledPower[i]);
+    for (auto& i : ledPower) send_sixtn_bits(i);
     // Two extra empty bits for padding the command to the correct length
     send_sixtn_bits(0x00);
     send_sixtn_bits(0x00);
@@ -52,16 +52,16 @@
 }
 
 void SeeedLedBar::ten_on() {
-    int all_on[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+    int all_on[10] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
     set_leds(all_on);
 }
 
 void SeeedLedBar::ten_off() {
-    int all_off[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+    int all_off[10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
     set_leds(all_off);
 }
 
-void SeeedLedBar::ten_set(int ledPower[]) {
+void SeeedLedBar::ten_set(int (&ledPower )[10]) {
     set_leds(ledPower);
 }