Watch
0
0
Fork
You've already forked esp32-c_its-companion
0

WIP denm: Show warning symbol

TODO: Show distance to DENM?
This commit is contained in:
Jannik Beyerstedt 2026-09-07 13:41:48 +02:00
commit e56466da30
4 changed files with 103 additions and 8 deletions

View file

@ -130,5 +130,8 @@ You can convert them using [ImageMagick](https://imagemagick.org) like this:
# resize to 25px height, adding a black background to the white symbol and vice versa
magick Sinnbild_Radfahrer_StVO_1992-200px-white.png -resize x25 -background black -alpha background -flatten -alpha off -verbose Sinnbild_Radfahrer_StVO_1992-25px-white.tga
magick Sinnbild_Radfahrer_StVO_1992-200px-black.png -resize x25 -background white -alpha background -flatten -alpha off -verbose Sinnbild_Radfahrer_StVO_1992-25px-black.tga
```
magick Stationary_Emergency_Vehicle_Dreieck_Rot.png -resize x200 -background black -alpha background -flatten -alpha off -verbose Stationary_Emergency_Vehicle_Dreieck_Rot-200px.tga
magick Stationary_Vehicle_Dreieck_Rot.png -resize x200 -background black -alpha background -flatten -alpha off -verbose Stationary_Vehicle_Dreieck_Rot-200px.tga
magick Work_Zone_Dreieck_Rot.png -resize x200 -background black -alpha background -flatten -alpha off -verbose Work_Zone_Dreieck_Rot-200px.tga
```

View file

@ -1,13 +1,14 @@
//! C-ITS DENM Evaluation
use c_its_parser::standards::cdd_2_2_1::etsi_its_cdd;
use c_its_parser::standards::denm_2_2_1::denm_pdu_description;
use log::info;
pub fn handle_denm(etsi: &denm_pdu_description::DENM) {
pub fn handle_denm(etsi: &denm_pdu_description::DENM) -> Option<etsi_its_cdd::CauseCodeChoice> {
let mgmt = &etsi.denm.management;
if mgmt.termination.is_some() {
return;
return None;
}
if let (Some(sit), Some(loc)) = (&etsi.denm.situation, &etsi.denm.location) {
@ -38,7 +39,11 @@ pub fn handle_denm(etsi: &denm_pdu_description::DENM) {
"DENN: {station_id}/{seq_num} CC {cc}/{scc} at {lat_deg:.3}°N, {lon_deg:.3}°E until {end_time:?}"
);
}
Some(sit.event_type.cc_and_scc.clone())
} else {
info!("DENM: One of situation or location container not available");
None
}
}

View file

@ -578,7 +578,15 @@ async fn main(spawner: Spawner) -> ! {
transport: _,
ref etsi,
} => {
applogic::denm::handle_denm(etsi);
match applogic::denm::handle_denm(etsi) {
#[cfg(feature = "screen")]
Some(cc) => {
let _ = screen
.update(screen::ScreenState::DenmWarning(cc))
.inspect_err(log_screen_error);
}
_ => {}
}
// Send data to BLE thread
#[cfg(feature = "ble")]

View file

@ -1,5 +1,7 @@
//! Screen Output
#[cfg(feature = "denm")]
use c_its_parser::standards::cdd_2_2_1;
use embedded_graphics::prelude::*;
use embedded_graphics::{geometry, mono_font, pixelcolor, primitives, text};
@ -26,7 +28,13 @@ where
// assets
#[cfg(feature = "spat")]
bike_image: tinytga::Tga<'static, pixelcolor::Rgb565>,
bike_image: tinytga::Tga<'static, pixelcolor::Rgb565>, // 45x25px
#[cfg(feature = "denm")]
sv_image: tinytga::Tga<'static, pixelcolor::Rgb565>, // 200x200 px
#[cfg(feature = "denm")]
ev_image: tinytga::Tga<'static, pixelcolor::Rgb565>, // 200x200 px
#[cfg(feature = "denm")]
rww_image: tinytga::Tga<'static, pixelcolor::Rgb565>, // 200x200 px
}
#[derive(Debug, Default, PartialEq, Eq)]
@ -42,6 +50,8 @@ pub enum ScreenState {
GlosaFound(applogic::GlosaFound),
#[cfg(feature = "spat")]
GlosaLocked(applogic::GlosaSignalInfo),
#[cfg(feature = "denm")]
DenmWarning(cdd_2_2_1::etsi_its_cdd::CauseCodeChoice),
}
#[cfg(feature = "spat")]
@ -99,9 +109,26 @@ where
pub fn new(target: D, display_size: DisplaySize) -> Self {
#[cfg(feature = "spat")]
let data = include_bytes!("../graphics/Sinnbild_Radfahrer_StVO_1992-25px-white.tga");
#[cfg(feature = "spat")]
let bike_image = tinytga::Tga::from_slice(data).expect("Failed to parse TGA image");
let bike_image = tinytga::Tga::from_slice(include_bytes!(
"../graphics/Sinnbild_Radfahrer_StVO_1992-25px-white.tga"
))
.expect("Failed to parse TGA image");
#[cfg(feature = "denm")]
let sv_image = tinytga::Tga::from_slice(include_bytes!(
"../graphics/Stationary_Vehicle_Dreieck_Rot-200px.tga"
))
.expect("Failed to parse TGA image");
#[cfg(feature = "denm")]
let ev_image = tinytga::Tga::from_slice(include_bytes!(
"../graphics/Stationary_Emergency_Vehicle_Dreieck_Rot-200px.tga"
))
.expect("Failed to parse TGA image");
#[cfg(feature = "denm")]
let rww_image = tinytga::Tga::from_slice(include_bytes!(
"../graphics/Work_Zone_Dreieck_Rot-200px.tga"
))
.expect("Failed to parse TGA image");
Self {
target,
@ -111,6 +138,12 @@ where
gnss_hb_state: false,
#[cfg(feature = "spat")]
bike_image,
#[cfg(feature = "denm")]
sv_image,
#[cfg(feature = "denm")]
ev_image,
#[cfg(feature = "denm")]
rww_image,
}
}
@ -131,6 +164,10 @@ where
self.draw_glosa(glosa_data, prev_glosa_data)?;
}
ScreenState::Error(msg) => self.draw_message(msg)?,
#[cfg(feature = "denm")]
ScreenState::DenmWarning(cause_code_choice) => {
self.draw_denm_warning(cause_code_choice)?
}
}
}
@ -470,6 +507,48 @@ where
Ok(())
}
#[cfg(feature = "denm")]
pub fn draw_denm_warning(
&mut self,
cc: &cdd_2_2_1::etsi_its_cdd::CauseCodeChoice,
) -> Result<(), D::Error> {
// clear whole display and draw image
self.clear()?;
let centerline = i32::from(self.size.width) / 2;
let image_pos = geometry::Point::new(centerline - (200 / 2), self.size.offset_top + 20);
match cc {
cdd_2_2_1::etsi_its_cdd::CauseCodeChoice::slowVehicle26(_)
| cdd_2_2_1::etsi_its_cdd::CauseCodeChoice::stationaryVehicle94(_) => {
embedded_graphics::image::Image::new(&self.sv_image, image_pos)
.draw(&mut self.target)?;
}
cdd_2_2_1::etsi_its_cdd::CauseCodeChoice::rescueAndRecoveryWorkInProgress15(_)
| cdd_2_2_1::etsi_its_cdd::CauseCodeChoice::emergencyVehicleApproaching95(_) => {
embedded_graphics::image::Image::new(&self.ev_image, image_pos)
.draw(&mut self.target)?;
}
cdd_2_2_1::etsi_its_cdd::CauseCodeChoice::roadworks3(_) => {
embedded_graphics::image::Image::new(&self.rww_image, image_pos)
.draw(&mut self.target)?;
}
_ => {
text::Text::with_alignment(
"Unknown DENM",
geometry::Point::new(i32::from(self.size.width) / 2, 40 + self.size.offset_top),
Self::DEFAULT_TEXT_STYLE,
text::Alignment::Center,
)
.draw(&mut self.target)?;
}
}
Ok(())
}
#[allow(unused)]
fn draw_slash_screen(&mut self) -> Result<(), D::Error> {
let text_style = mono_font::MonoTextStyle::new(&profont::PROFONT_18_POINT, Self::COLOR_FG);