1use core::default;
2
3#[allow(unused_imports)]
5#[allow(dead_code)]
6use log::debug;
8use bitfield::bitfield;
9use log::info;
11
12
13#[allow(unused_imports)] #[derive(Debug, PartialEq, Clone, Copy)]
18pub struct Measurements {
19 pub distanceToStorm: f64,
21 pub energyStrike: f64,
23}
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
27#[allow(non_camel_case_types)]
28#[repr(u8)]
29pub enum Location {
30 #[default]
31 Indoor,
32 Outdoor,
33}
34
35
36#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
37#[allow(non_camel_case_types)]
38#[repr(u8)]
39pub enum LocationMask {
40 #[default]
41 Indoor = 0x09, Outdoor = 0x07, }
44
45impl From<u8> for LocationMask {
46 fn from(v: u8) -> Self {
47 match (v) {
48 0x09 => Self::Indoor,
49 0x07 => Self::Outdoor,
50 _ => unreachable!(),
51 }
52 }
53}
54
55
56bitfield! {
57 pub struct AFE_GAIN(u8);
59 impl Debug;
60
61 pub bool, get_powerdown, set_powerdown: 0; pub into LocationMask, get_location_mask, set_location_mask: 5,1; }
65
66bitfield! {
67 pub struct THRESHOLDS(u8);
69 impl Debug;
70
71 pub u8, get_noise_floor, set_noise_floor: 6, 4; pub u8, get_wd_threshold, set_wd_threshold: 3, 0; }
75
76#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
77#[allow(non_camel_case_types)]
78#[repr(u8)]
79pub enum MinStrikes {
81 #[default]
82 ONE = 0x00, FIVE = 0x01, NINE = 0x02, SIXTEEN = 0x03, }
87
88impl From<u8> for MinStrikes {
89 fn from(v: u8) -> Self {
90 match (v) {
91 0x00 => Self::ONE,
92 0x01 => Self::FIVE,
93 0x02 => Self::NINE,
94 0x03 => Self::SIXTEEN,
95 _ => Self::ONE,
96 }
97 }
98}
99
100bitfield! {
101 pub struct LightningReg(u8);
103 impl Debug;
104
105 pub bool, get_clear_stats, set_clear_stats: 6; pub into MinStrikes, get_min_strikes, set_min_strikes: 5, 4; pub u8, get_spike_reject, set_spike_reject: 3, 0; }
110
111#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
112#[allow(non_camel_case_types)]
113#[repr(u8)]
114pub enum INTType {
116 #[default]
117 NoiseHigh = 0b0001,
118 Disturber = 0b0100,
119 Lightning = 0b1000,
120 Nothing = 0b0000,
121}
122
123impl From<u8> for INTType {
124 fn from(v: u8) -> Self {
125 match (v) {
126 0b0001 => Self::NoiseHigh,
127 0b0100 => Self::Disturber,
128 0b1000 => Self::Lightning,
129 0b0000 => Self::Nothing,
130 _ => unreachable!(),
131 }
132 }
133}
134
135bitfield! {
136 pub struct INTReg(u8);
138 impl Debug;
139
140 pub u8, get_freq_div, set_freq_div: 7, 6; pub bool, get_mask_dist, set_mask_dist: 5; pub into INTType, get_int_type, _: 3, 0; }
144
145
146#[derive(Debug, Clone, Copy, PartialEq, Eq)]
147pub enum StormFrontDistance {
149 OutOfRange,
151 Range_km(u8),
153 Overhead,
155}
156
157#[derive(Debug, Clone, Copy, PartialEq, Eq)]
167#[repr(u8)]
168pub enum Oscillator {
169 TRCO = 0b00100000, SRCO = 0b01000000, LCO = 0b10000000, }
173