screen, spat: Add more information and update indicator
This commit is contained in:
parent
c1315f10aa
commit
fc0c9b61da
3 changed files with 403 additions and 175 deletions
49
src/main.rs
49
src/main.rs
|
|
@ -36,6 +36,10 @@ mod radio;
|
|||
mod screen;
|
||||
|
||||
const WIFI_CHANNEL: radio::Channel = 180;
|
||||
#[cfg(feature = "screen")]
|
||||
pub const DISPLAY_WIDTH: u16 = 320;
|
||||
#[cfg(feature = "screen")]
|
||||
pub const DISPLAY_HEIGHT: u16 = 172;
|
||||
|
||||
// This creates a default app-descriptor required by the esp-idf bootloader.
|
||||
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
||||
|
|
@ -84,13 +88,13 @@ async fn main(spawner: Spawner) -> ! {
|
|||
// SCL: D8/ GPIO8 (SPI_SCK)
|
||||
// SDA: D10/ GPIO10 (SPI_MOSI)
|
||||
// RES: D3/ GPIO7
|
||||
// DC: D4/ GPIO23
|
||||
// CS: D5/ GPIO24
|
||||
// BL: TODO (hard-wire to high? or D1/ GPIO0)
|
||||
// DC: D4/ GPIO23 (display clear)
|
||||
// CS: D5/ GPIO24 (chip select)
|
||||
// BL: D1/ GPIO0 (backlight)
|
||||
#[cfg(feature = "screen")]
|
||||
let mut spi_buffer = [0_u8; 512];
|
||||
#[cfg(feature = "screen")]
|
||||
let mut display = {
|
||||
let mut screen = {
|
||||
let (spi, cs) = setup_st7789_spi(
|
||||
peripherals.GPIO8,
|
||||
peripherals.GPIO10,
|
||||
|
|
@ -109,20 +113,24 @@ async fn main(spawner: Spawner) -> ! {
|
|||
let spi_device = embedded_hal_bus::spi::ExclusiveDevice::new_no_delay(spi, cs)
|
||||
.expect("Failed to initialize SPI device");
|
||||
|
||||
mipidsi::Builder::new(
|
||||
let display = mipidsi::Builder::new(
|
||||
mipidsi::models::ST7789,
|
||||
mipidsi::interface::SpiInterface::new(spi_device, dc_output, &mut spi_buffer),
|
||||
)
|
||||
.display_size(screen::HEIGHT + 34, screen::WIDTH) // somehow this display has 34 px of invisible space on the left (in native orientation)
|
||||
.display_size(DISPLAY_HEIGHT + 34, DISPLAY_WIDTH) // somehow this display has 34 px of invisible space on the left (in native orientation)
|
||||
.reset_pin(rst_output)
|
||||
.invert_colors(mipidsi::options::ColorInversion::Inverted)
|
||||
.orientation(mipidsi::options::Orientation::new().rotate(mipidsi::options::Rotation::Deg90))
|
||||
.init(&mut display_delay)
|
||||
.expect("Failed to initialize display")
|
||||
.expect("Failed to initialize display");
|
||||
|
||||
screen::Handler::new(display, DISPLAY_WIDTH, DISPLAY_HEIGHT)
|
||||
};
|
||||
|
||||
#[cfg(feature = "screen")]
|
||||
let _ = screen::draw_slash_screen(&mut display).inspect_err(log_screen_error);
|
||||
let _ = screen
|
||||
.update(screen::ScreenState::Initial)
|
||||
.inspect_err(log_screen_error);
|
||||
|
||||
// Setup WiFi
|
||||
let (_wifi_controller, interfaces) = esp_radio::wifi::new(
|
||||
|
|
@ -171,13 +179,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||
let gnss_update_ref = GNSS_UPDATE.borrow(cs);
|
||||
|
||||
if let Some(fix) = gnss_update_ref.replace(None) {
|
||||
let prev_state = state.initialized();
|
||||
state.update_with_gpsfix(&fix);
|
||||
|
||||
if prev_state != state.initialized() {
|
||||
let _ = screen::clear(&mut display).inspect_err(log_screen_error);
|
||||
}
|
||||
|
||||
new_position = true;
|
||||
}
|
||||
});
|
||||
|
|
@ -188,18 +190,21 @@ async fn main(spawner: Spawner) -> ! {
|
|||
// run GLOSA algorithm
|
||||
#[cfg(feature = "spat")]
|
||||
{
|
||||
let signal_groups = state.run_glosa();
|
||||
let glosa_data = state.run_glosa();
|
||||
|
||||
for sig in &signal_groups {
|
||||
let duration_str = sig
|
||||
.end_sec
|
||||
.map(|v| alloc::format!("for {v} s"))
|
||||
.unwrap_or_default();
|
||||
println!("GLOSA: {} {} {duration_str}", sig.maneuver, sig.phase);
|
||||
if let applogic::GlosaOutput::Locked(data) = &glosa_data {
|
||||
for sig in &data.signal_groups {
|
||||
let duration_str = sig
|
||||
.end_sec
|
||||
.map(|v| alloc::format!("for {v} s"))
|
||||
.unwrap_or_default();
|
||||
println!("GLOSA: {} {} {duration_str}", sig.maneuver, sig.phase);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "screen")]
|
||||
let _ = screen::draw_glosa(&mut display, &signal_groups)
|
||||
let _ = screen
|
||||
.update(glosa_data.into())
|
||||
.inspect_err(log_screen_error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue