From c5172c5b7c633e0e3bf8b8e7e95fc5fac6a7addb Mon Sep 17 00:00:00 2001 From: RogueM Date: Sat, 11 Jun 2016 12:38:40 +0100 Subject: [PATCH 1/3] leg array initialise using type and size --- PiGlow/PiGlow.h | 6 +++--- PiglowArduinoTest/PiglowArduinoTest.ino | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) mode change 100644 => 100755 PiGlow/PiGlow.h create mode 100644 PiglowArduinoTest/PiglowArduinoTest.ino diff --git a/PiGlow/PiGlow.h b/PiGlow/PiGlow.h old mode 100644 new mode 100755 index ff17885..b10aa11 --- a/PiGlow/PiGlow.h +++ b/PiGlow/PiGlow.h @@ -13,9 +13,9 @@ class PiGlow { public: PiGlow(){ - leg0 = { 6, 7, 8, 5, 4, 9 } ; - leg1 = { 17, 16, 15, 13, 11, 10 } ; - leg2 = { 0, 1, 2, 3, 14, 12 } ; + int leg0[6] = { 6, 7, 8, 5, 4, 9 } ; + int leg1[6] = { 17, 16, 15, 13, 11, 10 } ; + int leg2[6] = { 0, 1, 2, 3, 14, 12 } ; } void setup(const int b); void write (int pin, int value); diff --git a/PiglowArduinoTest/PiglowArduinoTest.ino b/PiglowArduinoTest/PiglowArduinoTest.ino new file mode 100644 index 0000000..4c8bcbb --- /dev/null +++ b/PiglowArduinoTest/PiglowArduinoTest.ino @@ -0,0 +1,17 @@ +#include +#include "PiGlow.h" + +#define BRIGHTNESS 50 + +PiGlow piglow; + +void setup() { + piglow.setup(BRIGHTNESS); + piglow.reset(); +} + +void loop() { +for(int pin = 0;pin<18;pin++){ + piglow.write(pin,10); + } +} From 256be45196225a917e3671f0518c9ffe3fd7d39b Mon Sep 17 00:00:00 2001 From: RogueM Date: Sat, 11 Jun 2016 13:13:11 +0100 Subject: [PATCH 2/3] swapped YELLOW and ORANGE index --- PiGlow/PiGlow.h | 4 ++-- PiGlowArduinoDemo/PiGlowArduinoDemo.ino | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PiGlow/PiGlow.h b/PiGlow/PiGlow.h index b10aa11..9a9b983 100755 --- a/PiGlow/PiGlow.h +++ b/PiGlow/PiGlow.h @@ -2,8 +2,8 @@ #define _PIGLOW_H #define PIGLOW_RING_RED 0 -#define PIGLOW_RING_YELLOW 1 -#define PIGLOW_RING_ORANGE 2 +#define PIGLOW_RING_ORANGE 1 +#define PIGLOW_RING_YELLOW 2 #define PIGLOW_RING_GREEN 3 #define PIGLOW_RING_BLUE 4 #define PIGLOW_RING_WHITE 5 diff --git a/PiGlowArduinoDemo/PiGlowArduinoDemo.ino b/PiGlowArduinoDemo/PiGlowArduinoDemo.ino index 697f08b..c105a73 100644 --- a/PiGlowArduinoDemo/PiGlowArduinoDemo.ino +++ b/PiGlowArduinoDemo/PiGlowArduinoDemo.ino @@ -2,8 +2,8 @@ #include "PiGlow.h" #define PIGLOW_RING_RED 0 -#define PIGLOW_RING_YELLOW 1 -#define PIGLOW_RING_ORANGE 2 +#define PIGLOW_RING_ORANGE 1 +#define PIGLOW_RING_YELLOW 2 #define PIGLOW_RING_GREEN 3 #define PIGLOW_RING_BLUE 4 #define PIGLOW_RING_WHITE 5 From 55aec20edb3f5a6d8be9269169adf6ba4d966ce1 Mon Sep 17 00:00:00 2001 From: RogueM Date: Sat, 11 Jun 2016 14:31:12 +0100 Subject: [PATCH 3/3] initialisation when declared as private --- PiGlow/PiGlow.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PiGlow/PiGlow.h b/PiGlow/PiGlow.h index 9a9b983..29b6c37 100755 --- a/PiGlow/PiGlow.h +++ b/PiGlow/PiGlow.h @@ -13,9 +13,9 @@ class PiGlow { public: PiGlow(){ - int leg0[6] = { 6, 7, 8, 5, 4, 9 } ; - int leg1[6] = { 17, 16, 15, 13, 11, 10 } ; - int leg2[6] = { 0, 1, 2, 3, 14, 12 } ; + int leg0[6] ; + int leg1[6] ; + int leg2[6] ; } void setup(const int b); void write (int pin, int value); @@ -27,7 +27,10 @@ PiGlow(){ void setBrightness ( const int b ); void reset(); private: - int leg0[6],leg1[6],leg2[6],brightness; + int leg0[6] = { 6, 7, 8, 5, 4, 9 } ; + int leg1[6] = { 17, 16, 15, 13, 11, 10 } ; + int leg2[6] = { 0, 1, 2, 3, 14, 12 } ; + int brightness; void piGlowCmd( int reg, int data ); };