Add silent mode for sensor detection and moisture measurement

- Introduced the `silent` parameter to prevent UI progress updates during automatic operations.
- Enhanced CAN robustness with improved bus-off management, retransmission settings, and jitter tolerance.
- Added auto-refresh functionality for plant moisture and sensor detection with configurable enablement.
This commit is contained in:
2026-03-29 14:21:12 +02:00
parent 4cf5f6d151
commit 7121dd0fae
4 changed files with 274 additions and 194 deletions

View File

@@ -248,6 +248,23 @@ async fn main(spawner: Spawner) {
ch32_hal::pac::AFIO.pcfr1().write(|w| w.set_can1_rm(2));
can.add_filter(CanFilter::accept_all());
// Improve CAN robustness for longer cables:
// 1. Enable Automatic Bus-Off Management (ABOM)
// 2. Ensure No Automatic Retransmission (NART) is DISABLED (i.e. we WANT retransmission)
// 3. Enable Receive FIFO Overwrite Mode (RFLM = 0, default)
// 4. Increase Resync Jump Width (SJW) if possible by patching BTIMR
hal::pac::CAN1.ctlr().modify(|w| {
w.set_abom(true);
w.set_nart(false); // HAL default is usually false, but let's be explicit
});
// SJW is bits 24-25 of BTIMR. HAL sets it to 0 (SJW=1).
// Let's try to set it to 3 (SJW=4) for better jitter tolerance.
hal::pac::CAN1.btimr().modify(|w| {
w.set_sjw(3); // 3 means 4TQ
});
// let mut filter = CanFilter::new_id_list();
// filter.get(0).unwrap().set(Id::Standard(standard_identify_id), Default::default());
// can.add_filter(filter);