Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
rnd-ash committed Dec 26, 2023
1 parent 96c6a01 commit 485d6e2
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 69 deletions.
14 changes: 7 additions & 7 deletions config_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ serde = { version = "1.0.148", features = ["derive"] }
backend={path="../backend/"}
config_app_macros={path="../config_app_macros/"}
image = "0.24.5"
rfd="0.11.4"
rfd="0.12.1"
pollster = "0.3.0"
eframe = {default-features=false, version="0.21.0", features=["dark-light", "wgpu", "default_fonts"]}
egui_extras = "0.21.0"
eframe = {default-features=false, version="0.24.1", features=["wgpu", "x11", "default_fonts"]}
egui_extras = {default-features=false, version="0.24.2", features=["image"]}
static_assertions = "1.1.0"
env_logger="0.10.0"
#egui-toast="0.5.0"
egui-toast={git = "https://github.com/rnd-ash/egui-toast"}
egui-toast="0.10.1"
chrono = "0.4.23"
nom="7.1.1"
plotters-backend="0.3.4"
plotters={version="0.3.4", default_features = false, features=["surface_series"]}
packed_struct="0.10.0"
ehttp="0.2.0"
ehttp="0.3.1"
octocrab = {git = "https://github.com/XAMPPRocky/octocrab", commit="7061b48c9bb799cb7effa0ecb8fd366a23f13de2"}
tokio = { version = "1.17.0", features = ["full"] }
zip="0.6.6"
curl = "0.4.43"
egui_plot = "0.24.1"

[patch.crates-io]
winit = { git = "https://github.com/PolyMeilex/winit ", branch = "master" }
Expand All @@ -43,4 +43,4 @@ winit = { git = "https://github.com/PolyMeilex/winit ", branch = "master" }
name = "Ultimate-NAG52-Config-App"
identifier = "com.rndash.un52configapp"
short_description = "Ultimate-NAG52 configuration suite"
osx_url_schemes = ["com.rndash.un52configapp"]
osx_url_schemes = ["com.rndash.un52configapp"]
31 changes: 19 additions & 12 deletions config_app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use eframe::{epaint::Vec2, IconData, NativeOptions};
use std::sync::Arc;

use eframe::{NativeOptions, egui::IconData};
use ui::launcher::Launcher;

#[cfg(windows)]
Expand All @@ -16,24 +18,29 @@ compile_error!("Windows can ONLY be built using the i686-pc-windows-msvc target!
fn main() {
env_logger::init();

let icon = image::load_from_memory(include_bytes!("../icon.png"))
.unwrap()
.to_rgba8();
let (icon_w, icon_h) = icon.dimensions();

#[cfg(target_os="linux")]
std::env::set_var("WINIT_UNIX_BACKEND", "x11");

let mut app = window::MainWindow::new();
app.add_new_page(Box::new(Launcher::new()));
let mut native_options = NativeOptions::default();
native_options.vsync = true;
native_options.icon_data = Some(IconData {
rgba: icon.into_raw(),
width: icon_w,
height: icon_h,
});
native_options.initial_window_size = Some(Vec2::new(1280.0, 720.0));
native_options.window_builder = Some(
Box::new(|mut wb| {
let icon = image::load_from_memory(include_bytes!("../icon.png"))
.unwrap()
.to_rgba8();
let (icon_w, icon_h) = icon.dimensions();

wb.inner_size = Some((1280.0, 720.0).into());
wb.icon = Some(Arc::new(IconData {
rgba: icon.into_raw(),
width: icon_w,
height: icon_h,
}));
wb
})
);
#[cfg(windows)]
{
native_options.renderer = Renderer::Wgpu;
Expand Down
15 changes: 3 additions & 12 deletions config_app/src/ui/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,26 +367,17 @@ impl crate::window::InterfacePage for ConfigPage {
ui.horizontal(|row| {
row.vertical(|col| {
col.label("V1.1 - Red PCB (12/12/21)");
col.image(
self.pcb_11_img.texture_id(col.ctx()),
Vec2::from((200.0, 150.0)),
);
col.image(include_image!("../../../res/pcb_11.jpg"));
});
row.separator();
row.vertical(|col| {
col.label("V1.2 - Black PCB (07/07/22) with TRRS support");
col.image(
self.pcb_12_img.texture_id(col.ctx()),
Vec2::from((200.0, 150.0)),
);
col.image(include_image!("../../../res/pcb_12.jpg"));
});
row.separator();
row.vertical(|col| {
col.label("V1.3 - Black PCB (12/12/22) - Latest PCB");
col.image(
self.pcb_13_img.texture_id(col.ctx()),
Vec2::from((230.0, 150.0)),
);
col.image(include_image!("../../../res/pcb_13.jpg"));
});
});
let mut ver = efuse.board_ver;
Expand Down
34 changes: 16 additions & 18 deletions config_app/src/ui/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::window::{PageAction, StatusBar, get_context};
use backend::diag::Nag52Diag;
use backend::ecu_diagnostics::kwp2000::{KwpSessionTypeByte, KwpSessionType};
use chrono::Local;
use eframe::egui::plot::{Legend, Line, Plot};
use egui_plot::{Legend, Line, Plot, PlotPoints};
use eframe::egui::{Color32, RichText, Ui, Context};
use eframe::epaint::Stroke;
use eframe::epaint::mutex::RwLock;
Expand Down Expand Up @@ -194,23 +194,22 @@ impl crate::window::InterfacePage for DiagnosticsPage {
data.to_table(ui);
}
});

if let Some(data) = current_val {
ui.vertical(|col| {
let start_time = self.rli_start_time.load(Ordering::Relaxed);
let legend = Legend::default().position(eframe::egui::plot::Corner::LeftTop);
let legend = Legend::default().position(egui_plot::Corner::LeftTop);
let space_per_chart = (ui_height / data.get_chart_data().len() as f32) - (10.0 * data.get_chart_data().len() as f32);

for (idx, d) in data.get_chart_data().iter().enumerate() {
let mut lines = Vec::new();
let mut lines: Vec<Line> = Vec::new();
col.heading(d.group_name.clone());
let mut unit: Option<&'static str> = d.data[0].2.clone();
let unit: Option<&'static str> = d.data[0].2.clone();

for (i, (key, _, _, color)) in d.data.iter().enumerate() {
let mut points: Vec<[f64; 2]> = Vec::new();
for (timestamp, point) in chart_data.iter() {
points.push([*timestamp as f64 - start_time as f64, point[idx].data[i].1 as f64])
}
lines.push(Line::new(points).name(key.clone()).stroke(Stroke::new(2.0,
color.clone())))
let points: PlotPoints = chart_data.iter().map(|(timestamp, value)| {
[*timestamp as f64 - start_time as f64, value[idx].data[i].1 as f64]
}).collect();
lines.push(Line::new(points).name(key.clone()).stroke(Stroke::new(2.0, color.clone())));
}

let now = self.launch_time.elapsed().as_millis() - start_time as u128;
Expand All @@ -219,19 +218,18 @@ impl crate::window::InterfacePage for DiagnosticsPage {
last_bound = 0.0;
}
let x = unit.clone();

let mut plot = Plot::new(d.group_name.clone())
.height(space_per_chart)
.allow_drag(false)
.include_x(now as f64 - 100.0)
.include_x(last_bound)
.include_x(std::cmp::max(20000, now) as f64)
.auto_bounds_x()
.legend(legend.clone())
.x_axis_formatter(|f, r| {
.x_axis_formatter(|f, _nc, r| {
let seconds = f / 1000.0;
let mins = f / 60000.0;
format!("{:02.0}:{:02.1}", mins, seconds)
let mins = (f / 60000.0) as u32;
format!("{:02}:{:02.1}", mins, seconds)
})
.y_axis_formatter(move |f, r| {
.y_axis_formatter(move |f, _nc, r| {
if let Some(u) = x.clone() {
format!("{}{}", f, u)
} else {
Expand Down
8 changes: 4 additions & 4 deletions config_app/src/ui/diagnostics/solenoids.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use backend::{diag::Nag52Diag, ecu_diagnostics::kwp2000::{KwpSessionTypeByte, KwpSessionType}};
use eframe::egui::plot::{Bar, BarChart, Legend, Line, Plot, PlotPoints};
use egui_plot::{Bar, BarChart, Legend, Line, Plot, PlotPoints};
use std::{
ops::RangeInclusive,
sync::{
Expand Down Expand Up @@ -142,7 +142,7 @@ impl crate::window::InterfacePage for SolenoidPage {

let mut bars = Vec::new();
let mut legend = Legend::default();
let x_fmt = |y, _range: &RangeInclusive<f64>| {
let x_fmt = |y, _nc, _range: &RangeInclusive<f64>| {
match y as usize {
1 => "MPC",
2 => "SPC",
Expand Down Expand Up @@ -214,7 +214,7 @@ impl crate::window::InterfacePage for SolenoidPage {
)
.name("Y5"),
);
let mut y_fmt_pwm = |x, _range: &RangeInclusive<f64>| format!("{} %", x);
let mut y_fmt_pwm = |x, _nc, _range: &RangeInclusive<f64>| format!("{} %", x);
plot = plot.y_axis_formatter(y_fmt_pwm);
plot = plot.include_y(100);
} else {
Expand Down Expand Up @@ -266,7 +266,7 @@ impl crate::window::InterfacePage for SolenoidPage {
)
.name("Y5"),
);
let mut y_fmt_current = |x, _range: &RangeInclusive<f64>| format!("{} mA", x);
let mut y_fmt_current = |x, _nc, _range: &RangeInclusive<f64>| format!("{} mA", x);
plot = plot.y_axis_formatter(y_fmt_current);
plot = plot.include_y(2000);
}
Expand Down
2 changes: 1 addition & 1 deletion config_app/src/ui/io_maipulator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use backend::{diag::Nag52Diag, ecu_diagnostics::kwp2000::KwpSessionType};
use eframe::egui::plot::{Legend, Line, Plot};
use egui_plot::{Legend, Line, Plot};
use std::{
char::MAX,
sync::{
Expand Down
6 changes: 3 additions & 3 deletions config_app/src/ui/map_editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ use backend::{
use eframe::{
egui::{
self,
plot::{Bar, BarChart, CoordinatesFormatter, HLine, Legend, Line, LineStyle, PlotPoints},
Layout, Response, RichText, TextEdit, Ui,
},
epaint::{vec2, Color32, FontId, Stroke, TextShape, Rect, Pos2}, emath::lerp,
};
use egui_plot::{Bar, BarChart, CoordinatesFormatter, HLine, Legend, Line, LineStyle, PlotPoints};
use egui_extras::{Size, Table, TableBuilder, Column};
use egui_toast::ToastKind;
use nom::number::complete::le_u16;
Expand Down Expand Up @@ -472,7 +472,7 @@ impl Map {
let key = self.get_y_label(x);
bars.push(Bar::new(x as f64, value as f64).name(key))
}
egui::plot::Plot::new(format!("PLOT-{}", self.eeprom_key))
egui_plot::Plot::new(format!("PLOT-{}", self.eeprom_key))
.allow_drag(false)
.allow_scroll(false)
.allow_zoom(false)
Expand All @@ -496,7 +496,7 @@ impl Map {
}
lines.push(Line::new(points).name(self.get_y_label(y_idx)));
}
egui::plot::Plot::new(format!("PLOT-{}", self.eeprom_key))
egui_plot::Plot::new(format!("PLOT-{}", self.eeprom_key))
.allow_drag(false)
.allow_scroll(false)
.allow_zoom(false)
Expand Down
97 changes: 97 additions & 0 deletions config_app/src/ui/routine_tests/atf_temp_cal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering}};

use backend::{diag::Nag52Diag, ecu_diagnostics::kwp2000::KwpSessionType};
use eframe::egui::Context;

use crate::window::PageAction;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[repr(u8)]
enum AtfCommand {
ResetCalibration = 2,
CalibrateToEngineOilTemp = 0
}

pub struct AtfTempCalibrationPage {
nag: Nag52Diag,
status: Arc<RwLock<String>>,
running: Arc<AtomicBool>
}

impl AtfTempCalibrationPage {
pub fn new(nag: Nag52Diag) -> Self {
Self {
nag,
running: Arc::new(AtomicBool::new(false)),
status: Arc::new(RwLock::new(String::new()))
}
}
}

impl AtfTempCalibrationPage {
fn run_command(&mut self, mode: AtfCommand, ctx: Context) {
let nag_c = self.nag.clone();
let status_c = self.status.clone();
let running_c = self.running.clone();
std::thread::spawn(move|| {
running_c.store(true, Ordering::Relaxed);
*status_c.write().unwrap() = String::new();
ctx.request_repaint();

//let res = nag_c.with_kwp(|kwp| {
// kwp.kwp_set_session(KwpSessionType::ExtendedDiagnostics.into())?;
// kwp.send_byte_array_with_response(&[0x31, 0x33, mode as u8])?;
// kwp.kwp_set_session(KwpSessionType::Normal.into())?;
// Ok(())
//});

//*status_c.write().unwrap() = match res {
// Ok(_) => "Operation completed successfully".into(),
// Err(e) => format!("Operation failed. Error: {e:?}"),
//};

running_c.store(false, Ordering::Relaxed);
ctx.request_repaint();
});
}
}

impl crate::window::InterfacePage for AtfTempCalibrationPage {
fn make_ui(&mut self, ui: &mut eframe::egui::Ui, frame: &eframe::Frame) -> crate::window::PageAction {
ui.heading("ATF Curve calibration");
ui.label("
In order to compensate for variances in PCB to PCB, and ATF temp sensors,
if you are experiencing inconsistent shifting, you can calibrate the curve of the ATF temperature
sensor reading here.
This test MUST ONLY be performed after the car has been off overnight. This allows the temperature
of the engine oil and transmission oil to both settle to ambiant temperature.
Trying to perform this with a warm engine WILL RESULT IN MASSVIELY OUT OF SPEC ATF TEMPERATURE!
");

if !self.running.load(Ordering::Relaxed) {
ui.vertical(|ui| {
if ui.button("Reset calibration (TCU Default)").clicked() {
self.run_command(AtfCommand::ResetCalibration, ui.ctx().clone())
}
if ui.button("Calibrate to match engine oil temperature").clicked() {
self.run_command(AtfCommand::CalibrateToEngineOilTemp, ui.ctx().clone())
}
});
} else {
ui.label("Routine running...");
}
ui.label(self.status.read().unwrap().clone());

PageAction::None
}

fn get_title(&self) -> &'static str {
"ATF Curve calibration"
}

fn should_show_statusbar(&self) -> bool {
true
}
}
14 changes: 13 additions & 1 deletion config_app/src/ui/routine_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ use backend::diag::Nag52Diag;

use crate::window::PageAction;

use self::{solenoid_test::SolenoidTestPage, adaptation::AdaptationViewerPage, tcc_control::TccControlPage, canlogger::CanLoggerPage};
use self::{solenoid_test::SolenoidTestPage, adaptation::AdaptationViewerPage, tcc_control::TccControlPage, canlogger::CanLoggerPage, atf_temp_cal::AtfTempCalibrationPage};

pub mod solenoid_test;
pub mod adaptation;
pub mod tcc_control;
pub mod canlogger;
pub mod atf_temp_cal;

pub struct RoutinePage {
nag: Nag52Diag,
Expand Down Expand Up @@ -72,6 +73,17 @@ impl crate::window::InterfacePage for RoutinePage {
)));
}

ui.label(
"
Calibrate ATF temperature curve to remove board to board variance
",
);
if ui.button("ATF curve calibration").clicked() {
page_action = PageAction::Add(Box::new(AtfTempCalibrationPage::new(
self.nag.clone()
)));
}

if self.nag.has_logger() { // AKA USB connection

ui.label(
Expand Down
Loading

0 comments on commit 485d6e2

Please sign in to comment.