fix pokial 0 a 1 je predefinovana pouzivatelom
This commit is contained in:
@@ -45,11 +45,11 @@ async fn main(spawner: Spawner) {
|
||||
|
||||
info!("starting loop");
|
||||
loop {
|
||||
msg_encode(b"ahoj", &sender).await;
|
||||
msg_encode(b"hello", &sender).await;
|
||||
let _ = msg_encode(b"ahoj", &sender).await;
|
||||
let _ = msg_encode(b"hello", &sender).await;
|
||||
|
||||
let data = [0x01, 0x02, 0x03, 0x04];
|
||||
msg_encode(&data, &sender).await;
|
||||
let _ = msg_encode(&data, &sender).await;
|
||||
|
||||
info!("frame sent");
|
||||
embassy_time::Timer::after(Duration::from_secs(1)).await;
|
||||
|
||||
@@ -70,10 +70,18 @@ async fn sample_byte(
|
||||
#[embassy_executor::task]
|
||||
pub async fn bit_receive_and_decode(mut pin: ExtiInput<'static>, encoding: Encoding) {
|
||||
loop {
|
||||
pin.wait_for_falling_edge().await;
|
||||
if level_for_bit(1) {
|
||||
pin.wait_for_falling_edge().await;
|
||||
} else {
|
||||
pin.wait_for_rising_edge().await;
|
||||
}
|
||||
let t1 = embassy_time::Instant::now();
|
||||
|
||||
pin.wait_for_rising_edge().await;
|
||||
if level_for_bit(1) {
|
||||
pin.wait_for_rising_edge().await;
|
||||
} else {
|
||||
pin.wait_for_falling_edge().await;
|
||||
}
|
||||
let bit_time = embassy_time::Instant::now().duration_since(t1);
|
||||
|
||||
// stred data bitu
|
||||
@@ -84,6 +92,7 @@ pub async fn bit_receive_and_decode(mut pin: ExtiInput<'static>, encoding: Encod
|
||||
let mut ticker = Ticker::every(bit_time);
|
||||
let mut last_level = level_for_bit(1);
|
||||
|
||||
// First START bit is the already detected logical 0, sample the remaining 7 bits.
|
||||
let mut start_byte = 0u8;
|
||||
for _ in 0..7 {
|
||||
let bit = match encoding {
|
||||
|
||||
Reference in New Issue
Block a user