1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-28 07:29:45 +00:00

Comments in slightly more detail.

This commit is contained in:
Thomas Harte 2019-10-28 22:12:56 -04:00
parent a5057e6540
commit 1135576a3a

View File

@ -48,13 +48,18 @@ class IntelligentKeyboard:
} }
bool serial_line_did_produce_bit(Serial::Line *, int bit) final { bool serial_line_did_produce_bit(Serial::Line *, int bit) final {
// Shift.
command_ = (command_ >> 1) | (bit << 9); command_ = (command_ >> 1) | (bit << 9);
// If that's 10 bits, decode a byte and stop.
bit_count_ = (bit_count_ + 1) % 10; bit_count_ = (bit_count_ + 1) % 10;
if(!bit_count_) { if(!bit_count_) {
dispatch_command(uint8_t(command_ >> 1)); dispatch_command(uint8_t(command_ >> 1));
command_ = 0; command_ = 0;
return false; return false;
} }
// Continue.
return true; return true;
} }