generated from luke-else/esp32-std-template
Added GPS and display logic to event loop
This commit is contained in:
parent
d64dd4b0fa
commit
7f35146eea
59
ion
Normal file
59
ion
Normal file
@ -0,0 +1,59 @@
|
||||
[33mcommit d64dd4b0fa1fe53c64d5e2064cd59ef064cd2d07[m[33m ([m[1;36mHEAD -> [m[1;32mmain[m[33m, [m[1;31morigin/main[m[33m, [m[1;31morigin/HEAD[m[33m)[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Mon Nov 13 14:19:50 2023 +0000
|
||||
|
||||
Added draw function to Display
|
||||
|
||||
[33mcommit 6c157f65f66ac590d33e7743f88c327daef5c8a0[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Mon Nov 13 13:59:22 2023 +0000
|
||||
|
||||
Created generic display module
|
||||
|
||||
[33mcommit 6625351e38025e489a18051d2e16340402a56e5f[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Mon Nov 6 23:20:12 2023 +0000
|
||||
|
||||
Chore: Started moving individual components out into modules. Started with GPS. Display and i2c driver to follow.
|
||||
|
||||
[33mcommit a880586321a023dacbc0d02bbf62f05d3da4aad7[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Fri Aug 18 09:57:12 2023 +0100
|
||||
|
||||
Changed the project name in cargo.toml
|
||||
|
||||
[33mcommit 8c7181add2b9519307538d4f32e2d75c26525902[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Tue Jul 25 21:15:59 2023 +0100
|
||||
|
||||
Removed some unecessary code, cleaned up the main UI to show only speed, and finally made a start on implementing some sort of app state for different screens / menus
|
||||
|
||||
[33mcommit 5828d5ead696667d5a979f31f2314cae0a8e2103[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Fri Jul 21 14:29:57 2023 +0100
|
||||
|
||||
Updated some of the error handling and data sources for GPS
|
||||
|
||||
[33mcommit 620ff4b2072f9df94f262505d7ac22e2bf16c6ae[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Fri Jul 21 10:23:23 2023 +0100
|
||||
|
||||
Reverted back to pre async attempt
|
||||
|
||||
[33mcommit 46ca82f379860d275b2d82ef7d2c6e54ab86b09e[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Fri Jul 14 14:01:46 2023 +0100
|
||||
|
||||
Created some very verbose, inefficient and messy code that sends data down an I2C bus for a SSD1306 display to pickup.
|
||||
|
||||
[33mcommit 1f8fe3020ffc50691db385c0dd86857fbd2d6962[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Fri Jul 14 12:23:13 2023 +0100
|
||||
|
||||
Finished code to have data get read from a serial GPS module
|
||||
|
||||
[33mcommit 443ef167c144001b462388922f6dd45917d18952[m
|
||||
Author: Luke Else <mail@luke-else.co.uk>
|
||||
Date: Fri Jul 14 13:12:43 2023 +0200
|
||||
|
||||
Initial commit
|
@ -22,7 +22,8 @@ pub enum GpsError {
|
||||
|
||||
pub struct GPS<'a> {
|
||||
uart: uart::UartRxDriver<'a>,
|
||||
latest: gpsdata::GpsData
|
||||
latest: gpsdata::GpsData,
|
||||
current: gpsdata::GpsData
|
||||
}
|
||||
|
||||
impl<'a> GPS<'a> {
|
||||
@ -42,7 +43,12 @@ impl<'a> GPS<'a> {
|
||||
&config
|
||||
).map_err(|err| Error::EspError(err))?;
|
||||
|
||||
Ok(GPS { uart, latest: gpsdata::GpsData::default() })
|
||||
// Create GPS struct
|
||||
Ok(GPS {
|
||||
uart,
|
||||
latest: gpsdata::GpsData::default(),
|
||||
current: gpsdata::GpsData::default()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn poll(self: &mut GPS<'a>) -> Result<&gpsdata::GpsData, Error> {
|
||||
|
18
src/main.rs
18
src/main.rs
@ -46,10 +46,20 @@ fn main() -> Result<(), Error> {
|
||||
&config
|
||||
).map_err(|err| Error::EspError(err))?;
|
||||
|
||||
let gps: GPS = GPS::new(peripherals.uart0, gps_rx)?;
|
||||
let display: Display<DisplaySize128x64> = Display::new(i2c, DisplaySize128x64, DisplayRotation::Rotate0)?;
|
||||
let mut gps: GPS = GPS::new(peripherals.uart0, gps_rx)?;
|
||||
let mut display: Display<DisplaySize128x64> = Display::new(i2c, DisplaySize128x64, DisplayRotation::Rotate0)?;
|
||||
let mut app_state = appstate::AppState::default();
|
||||
let mut latest_data = gpsdata::GpsData::default();
|
||||
|
||||
Err(error::Error::DisplayError(DisplayError::DrawingError))
|
||||
loop {
|
||||
let text: &str;
|
||||
|
||||
// Get the latest data from GPS module and flush to Display
|
||||
match gps.poll() {
|
||||
Ok(res) => {display.draw(&res.get_speed().as_str())?},
|
||||
Err(e) => {
|
||||
display.draw("NO\nGPS\nDATA");
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user