I don't need timeout here

This commit is contained in:
okhsunrog 2024-08-08 23:36:40 +03:00
parent 195ecf9bfa
commit 05b468e8ba
2 changed files with 31 additions and 2 deletions

32
.idea/cody_history.xml generated
View file

@ -87,9 +87,39 @@
<speaker value="ASSISTANT" />
<text value="Certainly! Here's how we can create a single task that monitors both input pins using `select` and prints logs using `info!`:&#10;&#10;```rust&#10;use embassy_futures::select::{select, Either};&#10;&#10;#[embassy_executor::task]&#10;async fn monitor_pins(mut input4: Input&lt;'static, GpioPin&lt;4&gt;&gt;, mut input5: Input&lt;'static, GpioPin&lt;5&gt;&gt;) {&#10; loop {&#10; match select(input4.wait_for_rising_edge(), input5.wait_for_rising_edge()).await {&#10; Either::First(_) =&gt; info!(&quot;Rising edge detected on Pin 4!&quot;),&#10; Either::Second(_) =&gt; info!(&quot;Rising edge detected on Pin 5!&quot;),&#10; }&#10; Timer::after(Duration::from_millis(100)).await;&#10; }&#10;}&#10;&#10;#[main]&#10;async fn main(spawner: Spawner) {&#10; // ... (previous code remains the same)&#10;&#10; let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);&#10; let input4 = Input::new(io.pins.gpio4, Pull::Down);&#10; let input5 = Input::new(io.pins.gpio5, Pull::Down);&#10;&#10; spawner.spawn(monitor_pins(input4, input5)).unwrap();&#10;&#10; // ... (rest of the code remains the same)&#10;}&#10;```&#10;&#10;This implementation creates a single task `monitor_pins` that takes both input pins as parameters. It uses `select` to wait for a rising edge on either pin, then prints the appropriate log message using `info!`. The task is spawned in the `main` function, passing both input pins as arguments." />
</message>
<message>
<speaker value="HUMAN" />
<text value="we have to keep the name of the type in the constants here, right?&#10;embassy tasks can't contain generics&#10;" />
</message>
<message>
<speaker value="ASSISTANT" />
</message>
<message>
<speaker value="HUMAN" />
<text value="we have to keep the name of the type in the constants here, right?&#10;embassy tasks can't contain generics&#10;" />
</message>
<message>
<speaker value="ASSISTANT" />
</message>
<message>
<speaker value="HUMAN" />
<text value="we have to keep the name of the pins in the type here, right?&#10;embassy tasks can't contain generics:&#10;&#10;#[embassy_executor::task]&#10;async fn monitor_pins(&#10; mut input4: Input&amp;lt;'static, GpioPin&amp;lt;4&amp;gt;&amp;gt;,&#10; mut input5: Input&amp;lt;'static, GpioPin&amp;lt;5&amp;gt;&amp;gt;,&#10;) {" />
</message>
<message>
<speaker value="ASSISTANT" />
<text value="Yes, that's correct. In this case, we need to keep the specific pin numbers in the type signatures for `input4` and `input5`. Embassy tasks indeed cannot contain generics, so specifying the exact pin types `GpioPin&lt;4&gt;` and `GpioPin&lt;5&gt;` is the right approach. This ensures type safety and allows the compiler to verify that we're using the correct pins throughout our code." />
</message>
<message>
<speaker value="HUMAN" />
<text value="analog of dracut's install_items+=&amp;quot; /etc/zfs/zroot.key &amp;quot; in mkinitcpio for arch" />
</message>
<message>
<speaker value="ASSISTANT" />
<text value="To achieve the equivalent of dracut's `install_items+=&quot; /etc/zfs/zroot.key &quot;` in mkinitcpio for Arch Linux, you can use the `FILES` array in your mkinitcpio configuration. &#10;&#10;Add the following line to your `/etc/mkinitcpio.conf`:&#10;&#10;```&#10;FILES=(/etc/zfs/zroot.key)&#10;```&#10;&#10;This will include the specified file in your initramfs image. If you need to add multiple files, you can separate them with spaces:&#10;&#10;```&#10;FILES=(/etc/zfs/zroot.key /path/to/another/file)&#10;```&#10;&#10;After making this change, remember to regenerate your initramfs:&#10;&#10;```&#10;mkinitcpio -P&#10;```&#10;&#10;This approach will ensure that your ZFS key file is included in the initramfs, similar to how dracut's `install_items` works." />
</message>
</list>
</messages>
<updatedAt value="2024-08-08T23:07:31.542436259" />
<updatedAt value="2024-08-08T23:29:01.352549629" />
</chat>
</list>
</chats>

View file

@ -29,7 +29,6 @@ async fn monitor_pins(
Either::First(_) => info!("Rising edge detected on Pin 4!"),
Either::Second(_) => info!("Rising edge detected on Pin 5!"),
}
Timer::after(Duration::from_millis(100)).await;
}
}