15 namespace lightwaverf {
17 static const uint8_t TX_NIBBLE[] = {0xF6, 0xEE, 0xED, 0xEB, 0xDE, 0xDD, 0xDB, 0xBE,
18 0xBD, 0xBB, 0xB7, 0x7E, 0x7D, 0x7B, 0x77, 0x6F};
20 static const uint8_t TX_STATE_IDLE = 0;
21 static const uint8_t TX_STATE_MSGSTART = 1;
22 static const uint8_t TX_STATE_BYTESTART = 2;
23 static const uint8_t TX_STATE_SENDBYTE = 3;
24 static const uint8_t TX_STATE_MSGEND = 4;
25 static const uint8_t TX_STATE_GAPSTART = 5;
26 static const uint8_t TX_STATE_GAPEND = 6;
32 static void IRAM_ATTR isr_t_xtimer(
LwTx *arg) {
47 case TX_STATE_MSGSTART:
52 case TX_STATE_BYTESTART:
57 case TX_STATE_SENDBYTE:
79 case TX_STATE_GAPSTART:
112 for (uint8_t i = 0; i <
TX_MSGLEN; i++) {
113 this->
tx_buf[i] = TX_NIBBLE[msg[i] & 0xF];
114 ESP_LOGD(
"lightwaverf.sensor",
"%x ", msg[i]);
127 for (uint8_t i = 0; i < 5; i++) {
128 this->
tx_buf[i + 4] = TX_NIBBLE[addr[i] & 0xF];
135 void LwTx::lwtx_cmd(uint8_t command, uint8_t parameter, uint8_t room, uint8_t device) {
137 this->
tx_buf[0] = TX_NIBBLE[parameter >> 4];
138 this->
tx_buf[1] = TX_NIBBLE[parameter & 0xF];
139 this->
tx_buf[2] = TX_NIBBLE[device & 0xF];
140 this->
tx_buf[3] = TX_NIBBLE[command & 0xF];
141 this->
tx_buf[9] = TX_NIBBLE[room & 0xF];
156 if (repeats > 0 && repeats < 40) {
191 static LwTx *arg =
this;
192 timer1_attachInterrupt([] { isr_t_xtimer(arg); });
193 timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP);
202 timer1_detachInterrupt();
virtual void digital_write(bool value)=0
virtual void pin_mode(gpio::Flags flags)=0
static const uint8_t TX_MSGLEN
void lwtx_settranslate(bool txtranslate)
Set translate mode.
void lwtx_set_gap_multiplier(uint8_t gap_multiplier)
void lwtx_set_tick_counts(uint8_t low_count, uint8_t high_count, uint8_t trail_count, uint8_t gap_count)
uint8_t tx_gap_multiplier
uint8_t tx_buf[TX_MSGLEN]
void lwtx_setaddr(const uint8_t *addr)
Set 5 char address for future messages.
Helper class to disable interrupts.
Implementation of SPI Controller mode.
void lwtx_cmd(uint8_t command, uint8_t parameter, uint8_t room, uint8_t device)
Send a LightwaveRF message (10 nibbles in bytes)
void lwtx_setup(InternalGPIOPin *pin, uint8_t repeats, bool inverted, int u_sec)
Set things up to transmit LightWaveRF 434Mhz messages.
bool lwtx_free()
Check for send free.
void lwtx_send(const std::vector< uint8_t > &msg)
Send a LightwaveRF message (10 nibbles in bytes)