ELM model init
This commit is contained in:
@@ -9,7 +9,7 @@ use std::{
|
||||
|
||||
use rkyv::{api::low::deserialize, rancor, Deserialize};
|
||||
|
||||
use data::DataChunk;
|
||||
use data::{ArchivedData, Data, DataChunk};
|
||||
|
||||
mod battery;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ trait Graphable {
|
||||
}
|
||||
|
||||
impl Graphable for SplitData {
|
||||
// Timestamps are unix timestamp (seconds)
|
||||
fn timeframe(&self, start: u64, end: u64) -> Vec<(f64, f64)> {
|
||||
let mut data: Vec<(f64, f64)> = Vec::new();
|
||||
let filtered: Vec<(f64, f64)> = self
|
||||
.chunks
|
||||
.iter()
|
||||
@@ -20,7 +20,7 @@ impl Graphable for SplitData {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
data
|
||||
filtered
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +1,50 @@
|
||||
use std::{process::exit, time::Duration};
|
||||
use std::{error::Error, process::exit, time::Duration};
|
||||
|
||||
use data::{ArchivedData, Data};
|
||||
use ratatui::{
|
||||
layout::{self, Constraint, Layout},
|
||||
prelude::Stylize,
|
||||
widgets::{Block, Borders},
|
||||
Frame,
|
||||
};
|
||||
use rkyv::{deserialize, rancor};
|
||||
mod data_graph;
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct Root {
|
||||
counter: i32,
|
||||
running_state: RunningState,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
enum RunningState {
|
||||
#[default]
|
||||
Running,
|
||||
Done,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum Message {
|
||||
Increment,
|
||||
Decrement,
|
||||
Reset,
|
||||
Quit,
|
||||
}
|
||||
|
||||
impl Root {
|
||||
fn view(&self, f: &mut Frame) {
|
||||
let block = Block::new()
|
||||
.border_type(ratatui::widgets::BorderType::Rounded)
|
||||
.borders(Borders::ALL);
|
||||
f.render_widget(block, f.area());
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut app = Root::default();
|
||||
ratatui::run(|terminal| loop {
|
||||
terminal.draw(|frame| {
|
||||
let layout = frame.area().layout_vec(&Layout::vertical([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
]));
|
||||
let middle = layout[1].layout_vec(&Layout::horizontal([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
]));
|
||||
let widget = Block::new()
|
||||
.border_type(ratatui::widgets::BorderType::Rounded)
|
||||
.borders(Borders::ALL)
|
||||
.title("Mroew");
|
||||
frame.render_widget(widget, middle[1]);
|
||||
app.view(frame);
|
||||
})?;
|
||||
if crossterm::event::read().unwrap().is_key_press() {
|
||||
break Ok(());
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user