black remote works, all codes included now
authorBernhard Tittelbach <xro@realraum.at>
Sun, 18 Sep 2011 22:48:06 +0000 (22:48 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Sun, 18 Sep 2011 22:48:06 +0000 (22:48 +0000)
rf433ctl/rf433ctl.pde

index 0049401..7212b89 100644 (file)
@@ -111,35 +111,19 @@ const rf_bit_t float_bit[] = { {  4, 1 },
 const rf_bit_t sync_bit[] = { {   4, 1 },
                               { 128, 0 },
                               {   0, 0 } };
-                      
-// whole word duration: ~46.80 ms
-// pause duration: ~14.9ms - 1.86ms = ~13ms
-// bit duration: 1.860 ms
-
-// in theory better but non-working timings @ alpha=0.0775ms
-//const rf_bit_t pwm_0_bit[] = {  {6, 1}, {18, 0}, {  0, 0 } };     // 1.86ms gesamt: { 0.46ms HIGH , 1.4ms LOW }
-//const rf_bit_t pwm_1_bit[] = {  {18, 1}, {6, 0}, {  0, 0 } };  //// 1.86ms gesamt: { 1.4ms HIGH , 0.46ms LOW }
-//const rf_bit_t pwm_pause_bit[] = {  {167, 0}, {  0, 0 } };  //// 13ms pause 
-
-// somewhat working timings @ alpha=0.0775ms
-const rf_bit_t pwm_0_bit[] = {  {7, 1}, {17, 0}, {  0, 0 } };     // 1.86ms gesamt: { 0.46ms HIGH , 1.4ms LOW }
-const rf_bit_t pwm_1_bit[] = {  {18, 1}, {6, 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 
-
-// // exact but non-working timings @ alpha=0.02ms
-// const rf_bit_t pwm_0_bit[] = {  {23, 1}, {70, 0}, {  0, 0 } };     // 1.86ms gesamt: { 0.46ms HIGH , 1.4ms LOW }
-// const rf_bit_t pwm_1_bit[] = {  {70, 1}, {23, 0}, {  0, 0 } };  //// 1.86ms gesamt: { 1.4ms HIGH , 0.46ms LOW }
-// const rf_bit_t pwm_pause_bit[] = {  {215, 0}, {  0, 0 } };  //// 1/3* 12.9ms pause 
-
-//default:
-// almost as good somwhat working approximate timings @ alpha=0.08ms
-//const rf_bit_t pwm_0_bit[] = {  {6, 1}, {17, 0}, {  0, 0 } };     // 1.86ms gesamt: { 0.46ms HIGH , 1.4ms LOW }
-//const rf_bit_t pwm_1_bit[] = {  {18, 1}, {6, 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 
+
+//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 
+
+//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;
 typedef byte ad_bit_t;
-#define WORD_LEN 13
 #define MAX_WORD_LEN 27
 typedef ad_bit_t word_t[MAX_WORD_LEN];
 
@@ -147,7 +131,6 @@ const rf_bit_t* bit_defs[] = { zero_bit, one_bit, float_bit, sync_bit, pwm_0_bit
 
 byte alpha_cnt = 0;
 byte bit_cnt = 0;
-byte current_word_len = WORD_LEN;
 byte chunk_cnt = 0;
 byte word_cnt = 0;
 const ad_bit_t* current_word;
@@ -189,6 +172,20 @@ byte volatile frame_finished = 1;
 #define BLACK_B3_ON 26
 #define BLACK_B3_OFF 27
 
+#define BLACK_C1_ON 28
+#define BLACK_C1_OFF 29
+#define BLACK_C2_ON 30
+#define BLACK_C2_OFF 31
+#define BLACK_C3_ON 32
+#define BLACK_C3_OFF 33
+
+#define BLACK_D1_ON 34
+#define BLACK_D1_OFF 35
+#define BLACK_D2_ON 36
+#define BLACK_D2_OFF 37
+#define BLACK_D3_ON 38
+#define BLACK_D3_OFF 39
+
 
 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
@@ -209,7 +206,7 @@ const word_t words[]  = {
 { 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, FLOAT, FLOAT, SYNC, WORD_END, WORD_END,WORD_END }, // D2_ON
-{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END },  // D2_OFF
+{ FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO,  SYNC, WORD_END, WORD_END,WORD_END }, // D2_OFF
 
 {PWM1,PWM1,PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM1,PWM0,PWM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M0,PWM1,PWM0,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0,PWM0,PWM0, PWM_PAUSE, WORD_END}, // BLACK_D1_ON  
+{PWM0,PWM1,PWM0,PWM1,PWM0,PWM1,PWM1,PWM1,PWM1,PWM1,PWM0,PWM1,PWM0,PWM1,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM0,PWM1,PWM1,PWM0, PWM_PAUSE, WORD_END}, // BLACK_D1_OFF  
+{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
 };
 
 
@@ -236,8 +247,8 @@ void start_timer()
   TCCR1B = 1<<WGM12 | 1<<CS11;   // 
 //  OCR1A = 39;        // (1+39)*8 = 320 -> 0.02ms @ 16 MHz -> 1*alpha
 //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 = 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
   TCNT1 = 0;          // reseting timer
   TIMSK1 = 1<<OCIE1A; // enable Interrupt
@@ -608,6 +619,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')
@@ -620,6 +632,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')
@@ -632,12 +645,39 @@ 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')
+      send_frame(words[BLACK_C1_OFF]);
+    else if(command == 'P')
+      send_frame(words[BLACK_C2_ON]);
+    else if(command == 'p')
+      send_frame(words[BLACK_C2_OFF]);
+    else if(command == 'Q')
+      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')
+      send_frame(words[BLACK_D1_OFF]);
+    else if(command == 'S')
+      send_frame(words[BLACK_D2_ON]);
+    else if(command == 's')
+      send_frame(words[BLACK_D2_OFF]);
     else if(command == 'T')
+      send_frame(words[BLACK_D3_ON]);
+    else if(command == 't')
+      send_frame(words[BLACK_D3_OFF]);
+      
+    else if(command == '*')
     {
       sensorEchoCommand(command);
       printTemperature(onShieldTemp);
     }
-    else if(command == 'P')
+    else if(command == '?')
     {
       sensorEchoCommand(command);
       printLightLevel();