screen: Make screen feature work without spat, update splash screen
This commit is contained in:
parent
6991ff5ec5
commit
0bf9e552ff
3 changed files with 86 additions and 34 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
mode=${1:-help}
|
mode=${1:-help}
|
||||||
wasm_target="--chrome --headless"
|
|
||||||
extended=${2:-false}
|
extended=${2:-false}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -19,6 +18,7 @@ features_more=(
|
||||||
spat,gnss_ubx,screen,ble,cam_tx
|
spat,gnss_ubx,screen,ble,cam_tx
|
||||||
spat,gnss_ubx,screen,cam,denm
|
spat,gnss_ubx,screen,cam,denm
|
||||||
spat,gnss_ubx,screen,cam_tx,cam,denm
|
spat,gnss_ubx,screen,cam_tx,cam,denm
|
||||||
|
gnss_ubx,screen,cam_tx,cam,denm
|
||||||
)
|
)
|
||||||
features_test=(
|
features_test=(
|
||||||
spat,cam,denm,uart
|
spat,cam,denm,uart
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
use embedded_graphics::{geometry, mono_font, pixelcolor, primitives, text};
|
use embedded_graphics::{geometry, mono_font, pixelcolor, primitives, text};
|
||||||
|
|
||||||
|
#[cfg(feature = "spat")]
|
||||||
use crate::applogic;
|
use crate::applogic;
|
||||||
|
|
||||||
pub struct DisplaySize {
|
pub struct DisplaySize {
|
||||||
|
|
@ -83,6 +84,7 @@ where
|
||||||
primitives::PrimitiveStyleBuilder::new()
|
primitives::PrimitiveStyleBuilder::new()
|
||||||
.fill_color(pixelcolor::Rgb565::new(10, 50, 0))
|
.fill_color(pixelcolor::Rgb565::new(10, 50, 0))
|
||||||
.build();
|
.build();
|
||||||
|
#[cfg(feature = "spat")]
|
||||||
const BLANK_SIGNAL_STYLE: primitives::PrimitiveStyle<pixelcolor::Rgb565> =
|
const BLANK_SIGNAL_STYLE: primitives::PrimitiveStyle<pixelcolor::Rgb565> =
|
||||||
primitives::PrimitiveStyleBuilder::new()
|
primitives::PrimitiveStyleBuilder::new()
|
||||||
.fill_color(pixelcolor::Rgb565::CSS_GRAY)
|
.fill_color(pixelcolor::Rgb565::CSS_GRAY)
|
||||||
|
|
@ -118,8 +120,11 @@ where
|
||||||
if self.prev_state != state {
|
if self.prev_state != state {
|
||||||
match &state {
|
match &state {
|
||||||
ScreenState::Uninitialized | ScreenState::Initial => self.draw_slash_screen()?,
|
ScreenState::Uninitialized | ScreenState::Initial => self.draw_slash_screen()?,
|
||||||
|
#[cfg(feature = "spat")]
|
||||||
ScreenState::GlosaSearching(_glosa_searching) => self.draw_glosa_searching()?,
|
ScreenState::GlosaSearching(_glosa_searching) => self.draw_glosa_searching()?,
|
||||||
|
#[cfg(feature = "spat")]
|
||||||
ScreenState::GlosaFound(glosa_found) => self.draw_glosa_found(glosa_found)?,
|
ScreenState::GlosaFound(glosa_found) => self.draw_glosa_found(glosa_found)?,
|
||||||
|
#[cfg(feature = "spat")]
|
||||||
ScreenState::GlosaLocked(glosa_data) => {
|
ScreenState::GlosaLocked(glosa_data) => {
|
||||||
let prev_glosa_data =
|
let prev_glosa_data =
|
||||||
if let ScreenState::GlosaLocked(prev_glosa_data) = &self.prev_state {
|
if let ScreenState::GlosaLocked(prev_glosa_data) = &self.prev_state {
|
||||||
|
|
@ -283,7 +288,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[cfg(feature = "spat")]
|
||||||
fn draw_glosa_searching(&mut self) -> Result<(), D::Error> {
|
fn draw_glosa_searching(&mut self) -> Result<(), D::Error> {
|
||||||
// clear whole display and draw text
|
// clear whole display and draw text
|
||||||
self.clear()?;
|
self.clear()?;
|
||||||
|
|
@ -299,7 +304,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[cfg(feature = "spat")]
|
||||||
fn draw_glosa_found(&mut self, data: &applogic::GlosaFound) -> Result<(), D::Error> {
|
fn draw_glosa_found(&mut self, data: &applogic::GlosaFound) -> Result<(), D::Error> {
|
||||||
// clear whole display and draw text
|
// clear whole display and draw text
|
||||||
self.clear()?;
|
self.clear()?;
|
||||||
|
|
@ -324,7 +329,8 @@ where
|
||||||
// uses full screen width and height
|
// uses full screen width and height
|
||||||
// - from 0 to 105+67 = 172 pixels for small screens
|
// - from 0 to 105+67 = 172 pixels for small screens
|
||||||
// - from 0 to 105+67+20 = 192 pixels for big screens
|
// - from 0 to 105+67+20 = 192 pixels for big screens
|
||||||
#[allow(unused, clippy::too_many_lines)]
|
#[cfg(feature = "spat")]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
fn draw_glosa(
|
fn draw_glosa(
|
||||||
&mut self,
|
&mut self,
|
||||||
data: &applogic::GlosaSignalInfo,
|
data: &applogic::GlosaSignalInfo,
|
||||||
|
|
@ -338,7 +344,7 @@ where
|
||||||
&& prev.signal_groups.len() != num_signals
|
&& prev.signal_groups.len() != num_signals
|
||||||
{
|
{
|
||||||
// clear everything if number of signals has changed
|
// clear everything if number of signals has changed
|
||||||
self.clear();
|
self.clear()?;
|
||||||
} else {
|
} else {
|
||||||
// only clear maneuver and timing area otherwise (lane type will clear itself)
|
// only clear maneuver and timing area otherwise (lane type will clear itself)
|
||||||
let sig_total_height = 67 + if is_big_height { 20 } else { 0 };
|
let sig_total_height = 67 + if is_big_height { 20 } else { 0 };
|
||||||
|
|
@ -473,10 +479,11 @@ where
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
fn draw_slash_screen(&mut self) -> Result<(), D::Error> {
|
fn draw_slash_screen(&mut self) -> Result<(), D::Error> {
|
||||||
let text_style = mono_font::MonoTextStyle::new(&profont::PROFONT_18_POINT, Self::COLOR_FG);
|
|
||||||
|
|
||||||
self.clear_all()?;
|
self.clear_all()?;
|
||||||
|
|
||||||
|
let centerline = i32::from(self.size.width) / 2;
|
||||||
|
|
||||||
|
if cfg!(feature = "spat") {
|
||||||
let sig_width = i32::from(self.size.width) / 3;
|
let sig_width = i32::from(self.size.width) / 3;
|
||||||
let circle_dia = 50;
|
let circle_dia = 50;
|
||||||
let circle_margin = (sig_width - circle_dia) / 2;
|
let circle_margin = (sig_width - circle_dia) / 2;
|
||||||
|
|
@ -497,8 +504,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw welcome text
|
// draw welcome text
|
||||||
let centerline = i32::from(self.size.width) / 2;
|
#[cfg(feature = "spat")]
|
||||||
|
|
||||||
embedded_graphics::image::Image::new(
|
embedded_graphics::image::Image::new(
|
||||||
&self.bike_image,
|
&self.bike_image,
|
||||||
geometry::Point::new(centerline - (45 / 2) + 1, 75 + self.size.offset_top),
|
geometry::Point::new(centerline - (45 / 2) + 1, 75 + self.size.offset_top),
|
||||||
|
|
@ -508,15 +514,48 @@ where
|
||||||
text::Text::with_alignment(
|
text::Text::with_alignment(
|
||||||
"C-ITS Signal Phase\nWaiting for GNSS...",
|
"C-ITS Signal Phase\nWaiting for GNSS...",
|
||||||
geometry::Point::new(centerline, 130 + self.size.offset_top),
|
geometry::Point::new(centerline, 130 + self.size.offset_top),
|
||||||
text_style,
|
Self::MID_TEXT_STYLE,
|
||||||
text::Alignment::Center,
|
text::Alignment::Center,
|
||||||
)
|
)
|
||||||
.draw(&mut self.target)?;
|
.draw(&mut self.target)?;
|
||||||
|
} else {
|
||||||
|
text::Text::with_alignment(
|
||||||
|
"C-ITS Companion",
|
||||||
|
geometry::Point::new(centerline, 130 + self.size.offset_top),
|
||||||
|
Self::DEFAULT_TEXT_STYLE,
|
||||||
|
text::Alignment::Center,
|
||||||
|
)
|
||||||
|
.draw(&mut self.target)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// print enabled features
|
||||||
|
text::Text::with_alignment(
|
||||||
|
&alloc::format!(
|
||||||
|
"Features:\n{}",
|
||||||
|
crate::util::get_rx_feature_list().join(",")
|
||||||
|
),
|
||||||
|
geometry::Point::new(centerline, 190 + self.size.offset_top),
|
||||||
|
Self::SMALL_TEXT_STYLE,
|
||||||
|
text::Alignment::Center,
|
||||||
|
)
|
||||||
|
.draw(&mut self.target)?;
|
||||||
|
|
||||||
|
let tx_features = crate::util::get_tx_feature_list();
|
||||||
|
if !tx_features.is_empty() {
|
||||||
|
text::Text::with_alignment(
|
||||||
|
&tx_features.join(","),
|
||||||
|
geometry::Point::new(centerline, 225 + self.size.offset_top),
|
||||||
|
Self::SMALL_TEXT_STYLE,
|
||||||
|
text::Alignment::Center,
|
||||||
|
)
|
||||||
|
.draw(&mut self.target)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "spat")]
|
||||||
fn maneuver_to_str(value: applogic::v2x::map::Maneuvers) -> alloc::string::String {
|
fn maneuver_to_str(value: applogic::v2x::map::Maneuvers) -> alloc::string::String {
|
||||||
alloc::format!(
|
alloc::format!(
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
|
|
|
||||||
17
src/util.rs
17
src/util.rs
|
|
@ -12,8 +12,21 @@ pub(crate) fn get_rx_feature_list() -> Vec<&'static str> {
|
||||||
features.push("denm");
|
features.push("denm");
|
||||||
}
|
}
|
||||||
if cfg!(feature = "spat") {
|
if cfg!(feature = "spat") {
|
||||||
features.push("mapem");
|
features.push("map");
|
||||||
features.push("spatem");
|
features.push("spat");
|
||||||
|
}
|
||||||
|
|
||||||
|
features
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
pub(crate) fn get_tx_feature_list() -> Vec<&'static str> {
|
||||||
|
let mut features = alloc::vec![];
|
||||||
|
if cfg!(feature = "cam_tx") {
|
||||||
|
features.push("auto-cam");
|
||||||
|
}
|
||||||
|
if cfg!(feature = "uart") {
|
||||||
|
features.push("uart-tx");
|
||||||
}
|
}
|
||||||
|
|
||||||
features
|
features
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue