dji_log_parser/record/
mc_param.rs1use binrw::binread;
2use serde::Serialize;
3#[cfg(target_arch = "wasm32")]
4use tsify_next::Tsify;
5
6use crate::utils::sub_byte_field;
7
8#[binread]
9#[derive(Serialize, Debug)]
10#[serde(rename_all = "camelCase")]
11#[br(little)]
12#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
13pub struct MCParams {
14 #[br(map = |x:u8| FailSafeProtectionType::from(x))]
15 pub fail_safe_protection: FailSafeProtectionType,
16
17 #[br(temp)]
18 _bitpack1: u8,
19 #[br(calc(sub_byte_field(_bitpack1, 0x01) == 1))]
20 pub mvo_func_enabled: bool,
21 #[br(calc(sub_byte_field(_bitpack1, 0x02) == 1))]
22 pub avoid_obstacle_enabled: bool,
23 #[br(calc(sub_byte_field(_bitpack1, 0x04) == 1))]
24 pub user_avoid_enabled: bool,
25}
26
27#[derive(Serialize, Debug)]
28#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
29pub enum FailSafeProtectionType {
30 Hover,
31 Landing,
32 GoHome,
33 #[serde(untagged)]
34 Unknown(u8),
35}
36
37impl FailSafeProtectionType {
38 fn from(value: u8) -> Self {
39 match value {
40 0 => FailSafeProtectionType::Hover,
41 1 => FailSafeProtectionType::Landing,
42 2 => FailSafeProtectionType::GoHome,
43 _ => FailSafeProtectionType::Unknown(value),
44 }
45 }
46}