fix glasgow sample decoding

master
Sebastien Bourdeauducq 2019-10-08 15:20:39 +08:00
parent e9a5132de5
commit 3eac707635
1 changed files with 2 additions and 2 deletions

View File

@ -114,8 +114,8 @@ pub fn sample(command: &str, mut callback: impl FnMut(u8, u8)) {
let mut last_sample = 0; let mut last_sample = 0;
loop { loop {
reader.read_exact(&mut buffer).unwrap(); reader.read_exact(&mut buffer).unwrap();
for shift in [4u8, 0u8].iter() { for shift in [2u8, 0u8].iter() {
let sample = (buffer[0] >> shift) & 0x0f; let sample = (buffer[0] >> shift) & 0x03;
let rising = sample & !last_sample; let rising = sample & !last_sample;
let falling = !sample & last_sample; let falling = !sample & last_sample;
callback(rising, falling); callback(rising, falling);