1#![no_std]
2
3#[derive(Copy, Clone, PartialEq)]
4pub struct PixelRatio(pub u8, pub u8);
5
6impl From<(u8, u8)> for PixelRatio {
7 fn from(tuple: (u8, u8)) -> Self {
8 Self(tuple.0, tuple.1)
9 }
10}
11
12#[macro_export]
13macro_rules! pixel_ratio {
14 ($w:tt: $h:tt) => {
15 PixelRatio($w, $h)
16 };
17}
18
19#[derive(Copy, Clone, PartialEq)]
20pub struct AspectRatio(pub u8, pub u8);
21
22impl From<(u8, u8)> for AspectRatio {
23 fn from(tuple: (u8, u8)) -> Self {
24 Self(tuple.0, tuple.1)
25 }
26}
27
28#[macro_export]
29macro_rules! aspect_ratio {
30 ($w:tt: $h:tt) => {
31 AspectRatio($w, $h)
32 };
33}
34
35impl AspectRatio {
36 pub fn diagonal_to_width(&self, diagonal: usize) -> usize {
37 match self {
38 AspectRatio(16, 9) => diagonal * 1600 / 1835,
39 AspectRatio(4, 3) => diagonal * 4 / 5,
40 _ => diagonal * 1000 / 1414,
41 }
42 }
43
44 pub fn diagonal_to_height(&self, diagonal: usize) -> usize {
45 match self {
46 AspectRatio(16, 9) => diagonal * 900 / 1835,
47 AspectRatio(4, 3) => diagonal * 3 / 5,
48 _ => diagonal * 1000 / 1414,
49 }
50 }
51}
52
53#[cfg(test)]
54mod test_utils;
55
56mod altitude;
57mod aoa;
58mod battery;
59mod drawable;
60mod g_force;
61mod heading_tape;
62mod height;
63pub mod hud;
64mod note;
65mod pitch_ladder;
66mod rssi;
67mod speed;
68mod speed_vector;
69mod steerpoint;
70mod steerpoint_vector;
71pub mod symbol;
72pub mod telemetry;
73mod vario;
74
75extern crate micromath;
76
77#[cfg(test)]
78#[macro_use]
79extern crate std;
80
81#[cfg(test)]
82extern crate ascii;