arduino bugfix
authorBernhard Tittelbach <xro@realraum.at>
Mon, 19 Sep 2011 23:13:06 +0000 (23:13 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Mon, 19 Sep 2011 23:13:06 +0000 (23:13 +0000)
rf433ctl/rf433ctl.pde

index b083a91..efd72da 100644 (file)
@@ -186,8 +186,8 @@ byte volatile frame_finished = 1;
 #define BLACK_D3_ON 38
 #define BLACK_D3_OFF 39
 
-#define RSL336T_INDEX(SW,BT,OFF)   40+(2*4*SW)+(2*BT)+OFF
-
+//SW 0..3 / BT 0..3 / OFF? 1  ON? 0
+//#define RSL336T_INDEX(SW,BT,OFF)   40+(2*4*SW)+(2*BT)+OFF
 
 #define PWM_01 PWM0,PWM1
 #define PWM_00 PWM0,PWM0
@@ -243,8 +243,22 @@ const word_t words[]  = {
 {PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0,PWM0,PWM0, PWM_PAUSE, WORD_END}, // BLACK_D2_ON  
 {PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0, PWM_PAUSE, WORD_END}, // BLACK_D2_OFF  
 {PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0,PWM0,PWM0, PWM_PAUSE, WORD_END}, // BLACK_D3_ON
-{PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0, PWM_PAUSE, WORD_END},  // BLACK_D3_OFF
+{PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0, PWM_PAUSE, WORD_END}  // BLACK_D3_OFF
+};
+
+//SW 0..3 / BT 0..3 / OFF? 1  ON? 0
+#define RSL336T_INDEX(SW,BT,OFF)   (8*SW)+(2*BT)+OFF
+
+#define PWM_01 PWM0,PWM1
+#define PWM_00 PWM0,PWM0
+#define RSL336T_SWBT_1  PWM_00,PWM_01,PWM_01,PWM_01
+#define RSL336T_SWBT_2  PWM_01,PWM_00,PWM_01,PWM_01
+#define RSL336T_SWBT_3  PWM_01,PWM_01,PWM_00,PWM_01
+#define RSL336T_SWBT_4  PWM_01,PWM_01,PWM_01,PWM_00
+
 
+// note: code on atmel breaks if array below becomes too big
+const word_t rsl336T_words[]  = {
 {RSL336T_SWBT_1,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_1_ON
 {RSL336T_SWBT_1,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_1_OFF
 {RSL336T_SWBT_1,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_2_ON
@@ -258,28 +272,28 @@ const word_t words[]  = {
 {RSL336T_SWBT_2,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_1_OFF
 {RSL336T_SWBT_2,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_2_ON
 {RSL336T_SWBT_2,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_2_OFF
-{RSL336T_SWBT_2,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_3_ON
-{RSL336T_SWBT_2,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_3_OFF
-{RSL336T_SWBT_2,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_4_ON
-{RSL336T_SWBT_2,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_4_OFF
-
-{RSL336T_SWBT_3,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_1_ON
-{RSL336T_SWBT_3,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_1_OFF
-{RSL336T_SWBT_3,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_2_ON
-{RSL336T_SWBT_3,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_2_OFF
-{RSL336T_SWBT_3,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_3_ON
-{RSL336T_SWBT_3,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_3_OFF
-{RSL336T_SWBT_3,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_4_ON
-{RSL336T_SWBT_3,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_4_OFF
-
-{RSL336T_SWBT_4,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_1_ON
-{RSL336T_SWBT_4,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_1_OFF
-{RSL336T_SWBT_4,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_2_ON
-{RSL336T_SWBT_4,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_2_OFF
-{RSL336T_SWBT_4,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_3_ON
-{RSL336T_SWBT_4,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_3_OFF
-{RSL336T_SWBT_4,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_4_ON
-{RSL336T_SWBT_4,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}  // RSL366T_IV_4_OFF
+//{RSL336T_SWBT_2,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_3_ON
+//{RSL336T_SWBT_2,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_3_OFF
+//{RSL336T_SWBT_2,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_4_ON
+//{RSL336T_SWBT_2,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_4_OFF
+//
+//{RSL336T_SWBT_3,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_1_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_1_OFF
+//{RSL336T_SWBT_3,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_2_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_2_OFF
+//{RSL336T_SWBT_3,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_3_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_3_OFF
+//{RSL336T_SWBT_3,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_4_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_III_4_OFF
+//
+//{RSL336T_SWBT_4,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_1_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_1_OFF
+//{RSL336T_SWBT_4,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_2_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_2_OFF
+//{RSL336T_SWBT_4,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_3_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_3_OFF
+//{RSL336T_SWBT_4,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_IV_4_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}  // RSL366T_IV_4_OFF
 };
 
 
@@ -718,29 +732,29 @@ void loop()
       send_frame(words[BLACK_D3_OFF]);
 
     else if (command == 'U')
-      send_frame(words[RSL336T_INDEX(0,0,0)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,0,0)]);
     else if (command == 'u')
-      send_frame(words[RSL336T_INDEX(0,0,1)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,0,1)]);
     else if (command == 'V')
-      send_frame(words[RSL336T_INDEX(0,1,0)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,1,0)]);
     else if (command == 'v')
-      send_frame(words[RSL336T_INDEX(0,1,1)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,1,1)]);
     else if (command == 'W')
-      send_frame(words[RSL336T_INDEX(0,2,0)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,2,0)]);
     else if (command == 'w')
-      send_frame(words[RSL336T_INDEX(0,2,1)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,2,1)]);
     else if (command == 'X')
-      send_frame(words[RSL336T_INDEX(0,3,0)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,3,0)]);
     else if (command == 'x')
-      send_frame(words[RSL336T_INDEX(0,3,1)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(0,3,1)]);
     else if (command == 'Y')
-      send_frame(words[RSL336T_INDEX(1,0,0)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(1,0,0)]);
     else if (command == 'y')
-      send_frame(words[RSL336T_INDEX(1,0,1)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(1,0,1)]);
     else if (command == 'Z')
-      send_frame(words[RSL336T_INDEX(1,1,0)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(1,1,0)]);
     else if (command == 'z')
-      send_frame(words[RSL336T_INDEX(1,1,1)]);
+      send_frame(rsl336T_words[RSL336T_INDEX(1,1,1)]);
     
     else if(command == '*')
     {