1use std::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum DeviceModel {
6 VolcanoHybrid,
7 Venty,
8 Veazy,
9 Crafty,
10}
11
12impl fmt::Display for DeviceModel {
13 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14 match self {
15 DeviceModel::VolcanoHybrid => write!(f, "Volcano Hybrid"),
16 DeviceModel::Venty => write!(f, "Venty"),
17 DeviceModel::Veazy => write!(f, "Veazy"),
18 DeviceModel::Crafty => write!(f, "Crafty"),
19 }
20 }
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
25pub enum HeaterMode {
26 Off = 0,
28 Normal = 1,
30 Boost = 2,
32 SuperBoost = 3,
34}
35
36impl fmt::Display for HeaterMode {
37 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38 match self {
39 HeaterMode::Off => write!(f, "off"),
40 HeaterMode::Normal => write!(f, "normal"),
41 HeaterMode::Boost => write!(f, "boost"),
42 HeaterMode::SuperBoost => write!(f, "superboost"),
43 }
44 }
45}
46
47impl HeaterMode {
48 pub fn from_u8(val: u8) -> Self {
50 match val {
51 1 => HeaterMode::Normal,
52 2 => HeaterMode::Boost,
53 3 => HeaterMode::SuperBoost,
54 _ => HeaterMode::Off,
55 }
56 }
57}
58
59#[derive(Debug, Clone, PartialEq, Default)]
61pub struct DeviceState {
62 pub current_temp: Option<f32>,
64 pub target_temp: Option<f32>,
66 pub boost_temp: Option<f32>,
68 pub super_boost_temp: Option<f32>,
70 pub heater_mode: Option<HeaterMode>,
72 pub heater_on: bool,
74 pub pump_on: bool,
76 pub fan_on: bool,
78 pub setpoint_reached: bool,
80 pub raw_activity: Option<u32>,
82 pub settings: Option<DeviceSettings>,
84}
85
86impl fmt::Display for DeviceState {
87 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
88 write!(
89 f,
90 "State(heater={}, pump={}, fan={}, current={:?}°C, target={:?}°C)",
91 self.heater_on, self.pump_on, self.fan_on, self.current_temp, self.target_temp
92 )
93 }
94}
95
96#[derive(Debug, Clone, PartialEq, Default)]
98pub struct DeviceSettings {
99 pub is_celsius: bool,
101 pub setpoint_reached: bool,
103 pub boost_visualization: bool,
105 pub charge_current_optimization: bool,
107 pub charge_voltage_limit: bool,
109 pub permanent_bluetooth: bool,
111 pub vibration: bool,
113 pub auto_shutdown_seconds: Option<u16>,
115 pub battery_level: Option<u8>,
117 pub is_charging: bool,
119}
120
121#[derive(Debug, Clone, PartialEq, Default)]
123pub struct DeviceInfo {
124 pub serial_number: Option<String>,
126 pub firmware_version: Option<String>,
128 pub firmware_ble_version: Option<String>,
130 pub color_index: Option<u8>,
132 pub heater_runtime_minutes: Option<u32>,
134 pub battery_charging_time_minutes: Option<u32>,
136 pub hours_of_heating: Option<u16>,
138 pub minutes_of_heating: Option<u16>,
140}
141
142pub mod volcano_flags {
144 pub const HEATER_ENABLED: u16 = 0x0020;
145 pub const FAN_ENABLED: u16 = 0x0400;
146 pub const AUTO_SHUTDOWN: u16 = 0x0200;
147 pub const PUMP_ENABLED: u16 = 0x2000;
148 pub const DISPLAY_ON_COOLING: u16 = 0x1000;
149 pub const FAHRENHEIT_ENA: u16 = 0x0200;
150}
151
152pub mod volcano_vibration_flags {
154 pub const VIBRATION: u32 = 0x0400;
155}