condense rfc433ctl word array to save space
authorBernhard Tittelbach <xro@realraum.at>
Tue, 20 Sep 2011 10:55:12 +0000 (10:55 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Tue, 20 Sep 2011 10:55:12 +0000 (10:55 +0000)
repeat frame only 9 instead of 10 times
remove trailing whitespace

rf433ctl/rf433ctl.pde

index efd72da..1a365c4 100644 (file)
@@ -27,8 +27,8 @@
 OneWire  onewire(ONE_WIRE_PIN);
 DallasTemperature dallas_sensors(&onewire);
 DeviceAddress onShieldTemp = { 0x10, 0xE7, 0x77, 0xD3, 0x01, 0x08, 0x00, 0x3F };
-IRsend irsend; 
-#define TEMPC_OFFSET_ARDUINO_GENEREATED_HEAT 
+IRsend irsend;
+#define TEMPC_OFFSET_ARDUINO_GENEREATED_HEAT
 
 //********************************************************************//
 // IR Codes, 32 bit, NEC
@@ -115,19 +115,24 @@ const rf_bit_t sync_bit[] = { {   4, 1 },
 //WORKS @ alpha=0.0775ms
 //const rf_bit_t pwm_0_bit[] = {  {7, 1}, {24, 0}, {  0, 0 } };     // 1.86ms gesamt: { 0.46ms HIGH , 1.4ms LOW }
 //const rf_bit_t pwm_1_bit[] = {  {18, 1}, {24, 0}, {  0, 0 } };    // 1.86ms gesamt: { 1.4ms HIGH , 0.46ms LOW }
-//const rf_bit_t pwm_pause_bit[] = {  {168, 0}, {  0, 0 } };        // 13ms pause 
+//const rf_bit_t pwm_pause_bit[] = {  {168, 0}, {  0, 0 } };        // 13ms pause
 
 //WORKS @ alpha=0.08ms
 const rf_bit_t pwm_0_bit[] = {  {6, 1}, {23, 0}, {  0, 0 } };   // 1.86ms gesamt: { 0.46ms HIGH , 1.4ms LOW }
 const rf_bit_t pwm_1_bit[] = {  {18, 1}, {23, 0}, {  0, 0 } };  // 1.86ms gesamt: { 1.4ms HIGH , 0.46ms LOW }
-const rf_bit_t pwm_pause_bit[] = {  {162, 0}, {  0, 0 } };      // 13ms pause 
-
-typedef enum { ZERO = 0, ONE , FLOAT , SYNC , PWM0, PWM1, PWM_PAUSE, WORD_END } adbit_t;
+const rf_bit_t pwm_pause_bit[] = { {162, 0}, {  0, 0 } };      // 13ms pause
+const rf_bit_t pwm_00_bit[] = {  {6, 1},  {23, 0}, {29, 1}, {46, 0}, { 0, 0 } }; // pwm_0 pwm_0
+const rf_bit_t pwm_01_bit[] = {  {6, 1},  {23, 0}, {41, 1}, {46, 0}, { 0, 0 } }; // pwm_0 pwm_1
+const rf_bit_t pwm_10_bit[] = {  {18, 1}, {23, 0}, {29, 1}, {46, 0}, { 0, 0 } }; // pwm_1 pwm_0
+const rf_bit_t pwm_11_bit[] = {  {18, 1}, {23, 0}, {41, 1}, {46, 0}, { 0, 0 } }; // pwm_1 pwm_1
+const rf_bit_t pwm_end_bit[] = { {6, 1},  {23, 0}, {185, 0}, { 0, 0 } };      // pwm_0 pwm_pause
+
+typedef enum { ZERO = 0, ONE , FLOAT , SYNC , PWM0, PWM1, PWM_00, PWM_01, PWM_10, PWM_11, PWM_END, PWM_PAUSE, WORD_END } adbit_t;
 typedef byte ad_bit_t;
-#define MAX_WORD_LEN 27
+#define MAX_WORD_LEN 13
 typedef ad_bit_t word_t[MAX_WORD_LEN];
 
-const rf_bit_t* bit_defs[] = { zero_bit, one_bit, float_bit, sync_bit, pwm_0_bit, pwm_1_bit, pwm_pause_bit };
+const rf_bit_t* bit_defs[] = { zero_bit, one_bit, float_bit, sync_bit, pwm_0_bit, pwm_1_bit, pwm_00_bit, pwm_01_bit, pwm_10_bit, pwm_11_bit, pwm_end_bit, pwm_pause_bit };
 
 byte alpha_cnt = 0;
 byte bit_cnt = 0;
@@ -136,7 +141,7 @@ byte word_cnt = 0;
 const ad_bit_t* current_word;
 byte volatile frame_finished = 1;
 
-#define FRAME_LEN 10
+#define FRAME_LEN 9
 
 #define A1_ON  0
 #define A1_OFF 1
@@ -189,111 +194,112 @@ byte volatile frame_finished = 1;
 //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
-#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
+//WORD_END can be used to terminate word prematurely, otherwise word ends after 13 bits
+
+#define BLACK_SW_A  PWM_11,PWM_01,PWM_01,PWM_01
+#define BLACK_SW_B  PWM_01,PWM_11,PWM_01,PWM_01
+#define BLACK_SW_C  PWM_01,PWM_01,PWM_11,PWM_01
+#define BLACK_SW_D  PWM_01,PWM_01,PWM_01,PWM_11
+
+#define BLACK_BT_1  PWM_11,PWM_01,PWM_01
+#define BLACK_BT_2  PWM_01,PWM_11,PWM_01
+#define BLACK_BT_3  PWM_01,PWM_01,PWM_11
 
 const word_t words[]  = {
-{ ZERO,  ZERO,  FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END}, // A1_ON
-{ ZERO,  ZERO,  FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END}, // A1_OFF
-{ ZERO,  ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // A2_ON
-{ ZERO,  ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // A2_OFF
-
-{ FLOAT, ZERO,  FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // B1_ON
-{ FLOAT, ZERO,  FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // B1_OFF
-{ FLOAT, ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // B2_ON
-{ FLOAT, ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // B2_OFF
-
-{ ZERO,  FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // C1_ON
-{ ZERO,  FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // C1_OFF
-{ ZERO,  FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // C2_ON
-{ ZERO,  FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // C2_OFF
-
-{ FLOAT, FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // D1_ON
-{ FLOAT, FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // D1_OFF
-{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT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_OFF
+{ ZERO,  ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // A2_ON
+{ ZERO,  ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // A2_OFF
+
+{ FLOAT, ZERO,  FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // B1_ON
+{ FLOAT, ZERO,  FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // B1_OFF
+{ FLOAT, ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // B2_ON
+{ FLOAT, ZERO,  FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // B2_OFF
+
+{ ZERO,  FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // C1_ON
+{ ZERO,  FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // C1_OFF
+{ ZERO,  FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // C2_ON
+{ ZERO,  FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // C2_OFF
+
+{ FLOAT, FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // D1_ON
+{ FLOAT, FLOAT, FLOAT, FLOAT, ZERO,  ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // D1_OFF
+{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC}, // D2_ON
+{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC}, // D2_OFF
+
+{BLACK_SW_A,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_A1_ON
+{BLACK_SW_A,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_A1_OFF
+{BLACK_SW_A,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_A2_ON
+{BLACK_SW_A,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_A2_OFF
+{BLACK_SW_A,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_A3_ON
+{BLACK_SW_A,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_A3_OFF
+
+{BLACK_SW_B,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_B1_ON
+{BLACK_SW_B,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_B1_OFF
+{BLACK_SW_B,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_B2_ON
+{BLACK_SW_B,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_B2_OFF
+{BLACK_SW_B,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_B3_ON
+{BLACK_SW_B,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_B3_OFF
+
+{BLACK_SW_C,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_C1_ON
+{BLACK_SW_C,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_C1_OFF
+{BLACK_SW_C,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_C2_ON
+{BLACK_SW_C,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_C2_OFF
+{BLACK_SW_C,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_C3_ON
+{BLACK_SW_C,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_C3_OFF
+
+{BLACK_SW_D,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_D1_ON
+{BLACK_SW_D,BLACK_BT_1,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_D1_OFF
+{BLACK_SW_D,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_D2_ON
+{BLACK_SW_D,BLACK_BT_2,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_END}, // BLACK_D2_OFF
+{BLACK_SW_D,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_11,PWM_00,PWM_END}, // BLACK_D3_ON
+{BLACK_SW_D,BLACK_BT_3,PWM_00,PWM_00,PWM_00,PWM_00,PWM_11,PWM_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
-{RSL336T_SWBT_1,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_2_OFF
-{RSL336T_SWBT_1,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_3_ON
-{RSL336T_SWBT_1,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_3_OFF
-{RSL336T_SWBT_1,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_4_ON
-{RSL336T_SWBT_1,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_I_4_OFF
-
-{RSL336T_SWBT_2,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM0, PWM_PAUSE, WORD_END}, // RSL366T_II_1_ON
-{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_1,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_I_1_ON
+{RSL336T_SWBT_1,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_I_1_OFF
+{RSL336T_SWBT_1,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_I_2_ON
+{RSL336T_SWBT_1,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_I_2_OFF
+{RSL336T_SWBT_1,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_I_3_ON
+{RSL336T_SWBT_1,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_I_3_OFF
+{RSL336T_SWBT_1,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_I_4_ON
+{RSL336T_SWBT_1,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_I_4_OFF
+
+{RSL336T_SWBT_2,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_II_1_ON
+{RSL336T_SWBT_2,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_II_1_OFF
+{RSL336T_SWBT_2,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_II_2_ON
+{RSL336T_SWBT_2,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_II_2_OFF
+//{RSL336T_SWBT_2,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_II_3_ON
+//{RSL336T_SWBT_2,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_II_3_OFF
+//{RSL336T_SWBT_2,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_II_4_ON
+//{RSL336T_SWBT_2,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM_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_3,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_III_1_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_III_1_OFF
+//{RSL336T_SWBT_3,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_III_2_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_III_2_OFF
+//{RSL336T_SWBT_3,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_III_3_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_III_3_OFF
+//{RSL336T_SWBT_3,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_III_4_ON
+//{RSL336T_SWBT_3,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM_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_4,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_IV_1_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_1,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_IV_1_OFF
+//{RSL336T_SWBT_4,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_IV_2_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_2,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_IV_2_OFF
+//{RSL336T_SWBT_4,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_IV_3_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_3,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}, // RSL366T_IV_3_OFF
+//{RSL336T_SWBT_4,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_01,PWM_END}, // RSL366T_IV_4_ON
+//{RSL336T_SWBT_4,RSL336T_SWBT_4,PWM_01,PWM_01,PWM_01,PWM_00,PWM_END}  // RSL366T_IV_4_OFF
 };
 
 
@@ -303,9 +309,9 @@ void start_timer()
 {
   // timer 1: 2 ms
   TCCR1A = 0;                    // prescaler 1:8, WGM = 4 (CTC)
-  TCCR1B = 1<<WGM12 | 1<<CS11;   // 
+  TCCR1B = 1<<WGM12 | 1<<CS11;   //
 //  OCR1A = 39;        // (1+39)*8 = 320 -> 0.02ms @ 16 MHz -> 1*alpha
-//default: alpha=0.08  
+//default: alpha=0.08
   OCR1A = 159;        // (1+159)*8 = 1280 -> 0.08ms @ 16 MHz -> 1*alpha
 //  OCR1A = 154;        // (1+154)*8 = 1240 -> 0.0775ms @ 16 MHz -> 1*alpha
 //  OCR1A = 207;        // (1+207)*8 = 1664 -> 0.104ms @ 16 MHz -> 1*alpha
@@ -349,7 +355,7 @@ ISR(TIMER1_COMPA_vect)
       digitalWrite(RF_DATA_OUT_PIN, HIGH);
     return;
   }
-  
+
   bit_cnt++;
   if(current_word[bit_cnt] != WORD_END && bit_cnt < MAX_WORD_LEN) {
     alpha_cnt = 0;
@@ -420,11 +426,11 @@ void updateLightLevel(unsigned int pin)
   if (light_sample_time_ < PHOTO_SAMPLE_INTERVAL)
     return;
   light_sample_time_ = 0;
-  
+
   unsigned int value = analogRead(pin);
   if (value == light_level_mean_)
     return;
-  
+
   unsigned int diff = abs(value - light_level_mean_);
   if (diff > 100)
     light_level_mean_ = value;
@@ -534,7 +540,7 @@ void send_yamaha_ir_signal(char codebyte)
   code <<= 8;
   code |= (0xff ^ codebyte) & 0xFF;
   code |= YAMAHA_CODE_BASE;
-  
+
   //irsend changes PWM Timer Frequency among other things
   //.. doesn't go well with PWM output using the same timer
   //.. thus we just set output to 255 so whatever frequency is used, led is off for the duration
@@ -556,24 +562,24 @@ void setup()
   pinMode(RF_DATA_OUT_PIN, OUTPUT);
   digitalWrite(RF_DATA_OUT_PIN, HIGH);
   pinMode(IR_MOVEMENT_PIN, INPUT);      // set pin to input
-  digitalWrite(IR_MOVEMENT_PIN, LOW);  // turn off pullup resistors  
-  digitalWrite(IR_MOVEMENT_PIN2, LOW);  // turn off pullup resistors  
+  digitalWrite(IR_MOVEMENT_PIN, LOW);  // turn off pullup resistors
+  digitalWrite(IR_MOVEMENT_PIN2, LOW);  // turn off pullup resistors
   pinMode(PANIC_BUTTON_PIN, INPUT);      // set pin to input
-  digitalWrite(PANIC_BUTTON_PIN, LOW);  // turn of pullup resistors 
+  digitalWrite(PANIC_BUTTON_PIN, LOW);  // turn of pullup resistors
   analogWrite(PANICLED_PWM_PIN,255);
   analogWrite(BLUELED_PWM_PIN,255); //pwm sink(-) instead of pwm + (better for mosfets)
   pinMode(IRREMOTE_SEND_PIN, OUTPUT);
   digitalWrite(IRREMOTE_SEND_PIN, HIGH);
-  
+
   Serial.begin(9600);
-  
+
   onewire.reset();
   onewire.reset_search();
   dallas_sensors.begin();
   //in case we change temp sensor:
-  if (!dallas_sensors.getAddress(onShieldTemp, 0)) 
-    Serial.println("Error: Unable to find address for Device 0"); 
-  dallas_sensors.setResolution(onShieldTemp, 9);  
+  if (!dallas_sensors.getAddress(onShieldTemp, 0))
+    Serial.println("Error: Unable to find address for Device 0");
+  dallas_sensors.setResolution(onShieldTemp, 9);
 
   //save prev timer states:
   save_tcnt2 = TCNT2;
@@ -605,7 +611,7 @@ void loop()
   if (pb_time < PB_TRESHOLD)
     pb_time++;
   pb_state=(digitalRead(PANIC_BUTTON_PIN) == HIGH);
-  
+
   if (ir_time == 0)
   {
     if (ir_count >= IR_TRESHOLD || ir_count2 >= IR_TRESHOLD)
@@ -617,11 +623,11 @@ void loop()
     ir_count=0;
     ir_count2=0;
   }
-  
+
   if (pb_state == pb_last_state && pb_time >= PB_TRESHOLD)
   {
     if (pb_state && ! pb_postth_state)
-    {   
+    {
       pb_postth_state=1;
       Serial.println("PanicButton");
       flash_led(0, 28, 1, 4, 0 );
@@ -635,14 +641,14 @@ void loop()
     pb_time=0;
     pb_last_state=pb_state;
   }
-  
+
   updateLightLevel(PHOTO_ANALOGPIN);
   calculate_led_level();
   check_frame_done();
-  
+
   if(Serial.available()) {
     char command = Serial.read();
-    
+
     if(command == 'A')
       send_frame(words[A1_ON]);
     else if(command == 'a')
@@ -678,7 +684,7 @@ void loop()
       send_frame(words[D2_ON]);
     else if(command == 'h')
       send_frame(words[D2_OFF]);
-      
+
     else if(command == 'I')
       send_frame(words[BLACK_A1_ON]);
     else if(command == 'i')
@@ -691,7 +697,7 @@ void loop()
       send_frame(words[BLACK_A3_ON]);
     else if(command == 'k')
       send_frame(words[BLACK_A3_OFF]);
-      
+
     else if(command == 'L')
       send_frame(words[BLACK_B1_ON]);
     else if(command == 'l')
@@ -704,7 +710,7 @@ void loop()
       send_frame(words[BLACK_B3_ON]);
     else if(command == 'n')
       send_frame(words[BLACK_B3_OFF]);
-      
+
     else if(command == 'O')
       send_frame(words[BLACK_C1_ON]);
     else if(command == 'o')
@@ -717,7 +723,7 @@ void loop()
       send_frame(words[BLACK_C3_ON]);
     else if(command == 'q')
       send_frame(words[BLACK_C3_OFF]);
-            
+
     else if(command == 'R')
       send_frame(words[BLACK_D1_ON]);
     else if(command == 'r')
@@ -755,7 +761,7 @@ void loop()
       send_frame(rsl336T_words[RSL336T_INDEX(1,1,0)]);
     else if (command == 'z')
       send_frame(rsl336T_words[RSL336T_INDEX(1,1,1)]);
-    
+
     else if(command == '*')
     {
       sensorEchoCommand(command);