1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::str::FromStr;

/// Divoom device information returned from Divoom backend service
#[derive(Debug, PartialOrd, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct DivoomDeviceInfo {
    pub device_name: String,
    pub device_id: u64,
    pub device_private_ip: String,
}

/// All settings of a pixoo device.
/// Supported settings could be very different device per device, hence we scope this to pixoo device only.
#[derive(Debug, PartialOrd, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct DivoomPixooDeviceSettings {
    pub brightness: i32,
    pub rotation_flag: i32,
    pub clock_time: i32,
    pub gallery_time: i32,
    pub single_gallery_time: i32,
    pub power_on_channel_id: i32,
    pub gallery_show_time_flag: i32,
    pub cur_clock_id: i32,
    pub time24_flag: DivoomDeviceHourMode,
    pub temperature_mode: DivoomDeviceTemperatureUnit,
    pub gyrate_angle: DivoomDeviceRotationAngle,
    pub mirror_flag: DivoomDeviceMirrorMode,
    pub light_switch: i32,
}

/// High light mode
#[derive(Debug, PartialOrd, PartialEq, Copy, Clone)]
pub enum DivoomDeviceHighLightMode {
    Off,
    On,
    Raw(i32),
}

impl_divoom_dto_enum_traits!(DivoomDeviceHighLightMode, Off: "off", On: "on");

/// Hour mode, 12-hours o 24-hours.
#[derive(Debug, PartialOrd, PartialEq, Copy, Clone)]
pub enum DivoomDeviceHourMode {
    Hour12,
    Hour24,
    Raw(i32),
}

impl_divoom_dto_enum_traits!(DivoomDeviceHourMode, Hour12: "12h", Hour24: "24h");

/// Mirror mode.
#[derive(Debug, PartialOrd, PartialEq, Copy, Clone)]
pub enum DivoomDeviceMirrorMode {
    Off,
    On,
    Raw(i32),
}

impl_divoom_dto_enum_traits!(DivoomDeviceMirrorMode, Off: "off", On: "on");

/// Temperature unit. Used in weather report.
#[derive(Debug, PartialOrd, PartialEq, Copy, Clone)]
pub enum DivoomDeviceTemperatureUnit {
    Celsius,
    Fahrenheit,
    Raw(i32),
}

impl_divoom_dto_enum_traits!(DivoomDeviceTemperatureUnit, Celsius: "c", Fahrenheit: "f");

/// Device screen rotation angle.
#[derive(Debug, PartialOrd, PartialEq, Copy, Clone)]
pub enum DivoomDeviceRotationAngle {
    None,
    Rotate90,
    Rotate180,
    Rotate270,
    Raw(i32),
}

impl_divoom_dto_enum_traits!(DivoomDeviceRotationAngle, None: "0", Rotate90: "90", Rotate180: "180", Rotate270: "270");

/// Device screen power state.
#[derive(Debug, PartialOrd, PartialEq, Copy, Clone)]
pub enum DivoomDeviceScreenPowerState {
    Off,
    On,
    Raw(i32),
}

impl_divoom_dto_enum_traits!(DivoomDeviceScreenPowerState, Off: "off", On: "on");