chore: 📎 + fmt
This commit is contained in:
@@ -44,7 +44,6 @@ pub mod id {
|
||||
pub const MOISTURE_DATA_OFFSET: u16 = 0; // periodic data from sensor (sensor -> controller)
|
||||
pub const IDENTIFY_CMD_OFFSET: u16 = 32; // identify LED command (controller -> sensor)
|
||||
|
||||
|
||||
#[inline]
|
||||
pub const fn plant_id(message_type_offset: u16, sensor: SensorSlot, plant: u16) -> u16 {
|
||||
match sensor {
|
||||
@@ -56,8 +55,8 @@ pub mod id {
|
||||
/// Kinds of message spaces recognized by the addressing scheme.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum MessageKind {
|
||||
MoistureData, // sensor -> controller
|
||||
IdentifyCmd, // controller -> sensor
|
||||
MoistureData, // sensor -> controller
|
||||
IdentifyCmd, // controller -> sensor
|
||||
}
|
||||
|
||||
/// Try to classify a received 11-bit standard ID into a known message kind and extract plant and sensor slot.
|
||||
@@ -72,11 +71,15 @@ pub mod id {
|
||||
|
||||
// Helper: decode within a given group offset
|
||||
const fn decode_in_group(rel: u16, group_base: u16) -> Option<(u8, SensorSlot)> {
|
||||
if rel < group_base { return None; }
|
||||
if rel < group_base {
|
||||
return None;
|
||||
}
|
||||
let inner = rel - group_base;
|
||||
if inner < PLANTS_PER_GROUP { // A slot
|
||||
if inner < PLANTS_PER_GROUP {
|
||||
// A slot
|
||||
Some((inner as u8, SensorSlot::A))
|
||||
} else if inner >= B_OFFSET && inner < B_OFFSET + PLANTS_PER_GROUP { // B slot
|
||||
} else if inner >= B_OFFSET && inner < B_OFFSET + PLANTS_PER_GROUP {
|
||||
// B slot
|
||||
Some(((inner - B_OFFSET) as u8, SensorSlot::B))
|
||||
} else {
|
||||
None
|
||||
@@ -118,9 +121,9 @@ pub mod id {
|
||||
/// Fits into 5 bytes with bincode-v2 (no varint): u8 + u8 + u16 = 4, alignment may keep 4.
|
||||
#[derive(Debug, Clone, Copy, Encode, Decode)]
|
||||
pub struct MoistureData {
|
||||
pub plant: u8, // 0..MAX_PLANTS-1
|
||||
pub plant: u8, // 0..MAX_PLANTS-1
|
||||
pub sensor: SensorSlot, // A/B
|
||||
pub hz: u16, // measured frequency of moisture sensor
|
||||
pub hz: u16, // measured frequency of moisture sensor
|
||||
}
|
||||
|
||||
/// Request a sensor to report immediately (controller -> sensor).
|
||||
|
||||
Reference in New Issue
Block a user