Skip to content

Commit ab0ca81

Browse files
committed
Process incoming Nexa bits as they arrive
Don't wait for an invalid waveform until we start parsing bits
1 parent 373a80a commit ab0ca81

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libraries/nexa_node

Submodule nexa_node updated 1 file

nexa_decoder/nexa_decoder.ino

+6-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void parse_32bit_cmd(NexaCommand & cmd, const char buf[32])
112112
}
113113

114114
/*
115-
* Parse data form ring buffer, and generate + print NexaCommands.
115+
* Parse data from ring buffer, and generate + print NexaCommands.
116116
*/
117117
void decode_bits(RingBuffer<char> & rx_bits)
118118
{
@@ -142,6 +142,9 @@ void decode_bits(RingBuffer<char> & rx_bits)
142142
parse_12bit_cmd(cmd, buf);
143143
else if (version == NexaCommand::NEXA_32BIT)
144144
parse_32bit_cmd(cmd, buf);
145+
#if DEBUG
146+
Serial.println();
147+
#endif
145148
cmd.print(Serial);
146149
Serial.flush();
147150

@@ -154,13 +157,12 @@ void decode_bits(RingBuffer<char> & rx_bits)
154157

155158
void loop()
156159
{
157-
if (pulse_parser(rf_port.rx_get_pulse()) &&
158-
!rx_bits.r_empty()) {
160+
pulse_parser(rf_port.rx_get_pulse());
161+
if (!rx_bits.r_empty()) {
159162
size_t len = rx_bits.r_buf_len();
160163
do {
161164
#if DEBUG
162165
Serial.write((const byte *) rx_bits.r_buf(), len);
163-
Serial.println();
164166
#endif
165167
decode_bits(rx_bits);
166168
} while (len = rx_bits.r_buf_len());

0 commit comments

Comments
 (0)