pushed some non functioning code

This commit is contained in:
Jonas_Jones 2022-09-04 23:28:01 +02:00
parent 8d85068b48
commit c60e0db035
14 changed files with 2364 additions and 11 deletions

View file

@ -0,0 +1,12 @@
// #include "LcdControl.h"
// #include "LiquidCrystal.h"
// //instance object
// LcdControl::LcdControl(LiquidCrystal lcd) {
// ;
// }
// //when to update a cycle
// LcdControl::update() {
// ;
// }

12
arduino/src/LcdControl.h Normal file
View file

@ -0,0 +1,12 @@
// #ifndef LcdControl_h
// #define LcdControl_h
// class LcdControl {
// private:
// public:
// };
// #endif

View file

@ -0,0 +1,11 @@
#include "SerialHandler.h"
#include "SoftwareSerial.h"
SerialHandler::SerialHandler(uint8_t rx, uint8_t tx) {
update();
}
//Serialhandler loop
SerialHandler::update() {
;
}

View file

@ -0,0 +1,14 @@
//header file with the SerialHandler class
#ifndef SerialHandler_h
#define SerialHandler_h
class SerialHandler {
private:
public:
SerialHandler(uint8_t rx, uint8_t tx);
void update();
};
#endif

2166
desktop/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,25 @@
[package]
name = "desktop"
version = "0.1.0"
authors = "Jonas_Jones"
#authors = ["Jonas_Jones"]
edition = "2021"
description = "The desktop module of the PI-server-rack project."
documentation = "https://github.com/JonasJones/PI-server-rack"
readme = "README.md"
homepage = "https://jonasjones.me/PI-server-rack"
repository = "https://github.com/J-onasJones/PI-server-rack"
license = "MIT OR Apache-2.0"
keywords = ["server", "raspberry pi"]
categories = ["config"]
#description = "The desktop module of the PI-server-rack project."
#documentation = "https://github.com/JonasJones/PI-server-rack"
#readme = "README.md"
#homepage = "https://jonasjones.me/PI-server-rack"
#repository = "https://github.com/J-onasJones/PI-server-rack"
#license = "MIT OR Apache-2.0"
#keywords = ["server", "raspberry pi"]
#categories = ["config"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
eframe = "0.19.0"
try-catch = "0.2.2"
serde = "1.0.144"
serde_json = "1.0.85"
serde_derive = "1.0.144"
config = "0.13.2"
log = "0.4.17"
dirs = "4.0.0"

View file

@ -0,0 +1,38 @@
use std::{fs::File, io::Read};
use try_catch::catch;
use serde_json::from_str;
use defaultconfigs::Mainconfig;
use crate::defaultconfigs::{self, CONFIG_PATH};
extern crate serde;
extern crate serde_json;
pub(crate) fn init() {
catch! {
try {
load()
} catch _error {
create()
}
}
}
fn load() {
// Load the config file
let mut file = File::open(CONFIG_PATH).unwrap();
let mut contents = String::new();
file.read_to_string(&mut contents).unwrap();
let config: Mainconfig = from_str(&contents).unwrap();
println!("{:?}", config);
}
fn create() {
// Create the config file
}
fn save() {
// Save the config file
}

View file

@ -0,0 +1,19 @@
use std::path::{PathBuf};
use serde::{Serialize, Deserialize};
use dirs::config_dir;
const SYSTEM_CONFIG_PATH: Option<PathBuf> = config_dir();
const RELATIVE_CONFIG_PATH: &str = "/pi-server-rack/config.json";
pub(crate) const VERSION: &str = env!("CARGO_PKG_VERSION");
pub(crate) const CONFIG_PATH: PathBuf= SYSTEM_CONFIG_PATH.push(RELATIVE_CONFIG_PATH); //TODO: not die from fucking rust paths
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct Mainconfig {
lang : String,
configpath : String,
customwindowframe : bool,
}

View file

@ -0,0 +1,3 @@
fn load() {
// Load the language file
}

View file

@ -1,3 +1,18 @@
//import ui
mod ui;
pub(crate) mod confighandler;
pub(crate) mod defaultconfigs;
use defaultconfigs::VERSION;
use log::{info};
fn main() {
println!("Hello, world!");
}
info!(target: "[THREAD-MAIN]", "Welcome to PI-Server-Rack v{} !", VERSION);
//initialize config
confighandler::init();
//initialiaze ui
ui::mainloop();
}

53
desktop/src/ui/mod.rs Normal file
View file

@ -0,0 +1,53 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
pub(crate) mod tabs;
extern crate eframe;
use eframe::egui;
pub(crate) fn mainloop() {
let options = eframe::NativeOptions::default();
eframe::run_native(
"Confirm exit",
options,
Box::new(|_cc| Box::new(RootWindow::default())),
);
}
#[derive(Default)]
struct RootWindow {
allowed_to_close: bool,
show_confirmation_dialog: bool,
}
impl eframe::App for RootWindow {
fn on_close_event(&mut self) -> bool {
self.show_confirmation_dialog = true;
self.allowed_to_close
}
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Try to close the window");
});
if self.show_confirmation_dialog {
// Show confirmation dialog:
egui::Window::new("Do you want to quit?")
.collapsible(false)
.resizable(false)
.show(ctx, |ui| {
ui.horizontal(|ui| {
if ui.button("Cancel").clicked() {
self.show_confirmation_dialog = false;
}
if ui.button("Yes!").clicked() {
self.allowed_to_close = true;
frame.close();
}
});
});
}
}
}

View file

@ -0,0 +1,2 @@
pub(crate) mod overview;
pub(crate) mod settings;

View file

View file