From 5cb83c52d17ce0fe2bc930d35f8b6e495b331663 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Thu, 15 Sep 2011 23:55:44 +0000 Subject: [PATCH] added Black rf433ctl remote signals for A and B. Timing is still of so it only works 1 out of 15 tries or so --- rf433ctl/rf433ctl.pde | 106 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 23 deletions(-) diff --git a/rf433ctl/rf433ctl.pde b/rf433ctl/rf433ctl.pde index 10dced8..d7e17a5 100644 --- a/rf433ctl/rf433ctl.pde +++ b/rf433ctl/rf433ctl.pde @@ -111,16 +111,22 @@ const rf_bit_t float_bit[] = { { 4, 1 }, const rf_bit_t sync_bit[] = { { 4, 1 }, { 128, 0 }, { 0, 0 } }; + +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[] = { {17, 1}, {6, 0}, { 0, 0 } }; //// 1.86ms gesamt: { 1.4ms HIGH , 0.46ms LOW } +const rf_bit_t pwm_pause_bit[] = { {161, 0}, { 0, 0 } }; //// 12.9ms pause -typedef enum { ZERO = 0, ONE , FLOAT , SYNC } adbit_t; +typedef enum { ZERO = 0, ONE , FLOAT , SYNC , PWM0, PWM1, PWM_PAUSE, WORD_END } adbit_t; typedef byte ad_bit_t; #define WORD_LEN 13 -typedef ad_bit_t word_t[WORD_LEN]; +#define MAX_WORD_LEN 26 +typedef ad_bit_t word_t[MAX_WORD_LEN+1]; -const rf_bit_t* bit_defs[] = { zero_bit, one_bit, float_bit, sync_bit }; +const rf_bit_t* bit_defs[] = { zero_bit, one_bit, float_bit, sync_bit, pwm_0_bit, pwm_1_bit, pwm_pause_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; @@ -148,26 +154,56 @@ byte volatile frame_finished = 1; #define D2_ON 14 #define D2_OFF 15 +#define BLACK_A1_ON 16 +#define BLACK_A1_OFF 17 +#define BLACK_A2_ON 18 +#define BLACK_A2_OFF 19 +#define BLACK_A3_ON 20 +#define BLACK_A3_OFF 21 + +#define BLACK_B1_ON 22 +#define BLACK_B1_OFF 23 +#define BLACK_B2_ON 24 +#define BLACK_B2_OFF 25 +#define BLACK_B3_ON 26 +#define BLACK_B3_OFF 27 + + const word_t words[] = { -{ ZERO, ZERO, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, FLOAT, SYNC }, // A1_ON -{ ZERO, ZERO, FLOAT, FLOAT, ZERO, ZERO, FLOAT, FLOAT, ZERO, FLOAT, FLOAT, ZERO, SYNC }, // A1_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 +{ 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, FLOAT, FLOAT, SYNC, WORD_END, WORD_END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{ + if(current_word[bit_cnt] != WORD_END && bit_cnt < MAX_WORD_LEN) { alpha_cnt = 0; chunk_cnt = 0; if(bit_defs[current_word[bit_cnt]][chunk_cnt].state) @@ -549,6 +585,30 @@ 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') + send_frame(words[BLACK_A1_OFF]); + else if(command == 'J') + send_frame(words[BLACK_A2_ON]); + else if(command == 'j') + send_frame(words[BLACK_A2_OFF]); + else if(command == 'K') + 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') + send_frame(words[BLACK_B1_OFF]); + else if(command == 'M') + send_frame(words[BLACK_B2_ON]); + else if(command == 'm') + send_frame(words[BLACK_B2_OFF]); + else if(command == 'N') + send_frame(words[BLACK_B3_ON]); + else if(command == 'n') + send_frame(words[BLACK_B3_OFF]); else if(command == 'T') { sensorEchoCommand(command); -- 1.7.10.4