refactor(firmware): centralize configuration and diagnostics
This commit is contained in:
1 parent
7048ed89d0
commit
387fdaad23
140 files changed
+6891
-4541
No files matched your search
@@ -0,0 +1,25 @@
|
||||
use kaptan_config_derive::{Config, ConfigEnum};
|
||||
|
||||
#[derive(Clone, Copy, ConfigEnum)]
|
||||
#[repr(u8)]
|
||||
enum Mode {
|
||||
Safe = 1,
|
||||
#[config_enum(label = "Full authority")]
|
||||
FullAuthority = 7,
|
||||
}
|
||||
|
||||
#[derive(Config)]
|
||||
struct EnumConfig {
|
||||
#[config(enum, id = 1, key = "mode", unit = "mode")]
|
||||
mode: Mode,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(Mode::Safe.wire_value(), 1);
|
||||
assert!(matches!(Mode::try_from_wire(7), Some(Mode::FullAuthority)));
|
||||
assert_eq!(Mode::CONFIG_ENUM_OPTIONS[1], (7, "Full authority"));
|
||||
assert_eq!(
|
||||
EnumConfig::DESCRIPTORS[0].enum_options,
|
||||
Mode::CONFIG_ENUM_OPTIONS
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user