Compare commits
18 Commits
81edabee6e
...
main
Author | SHA1 | Date | |
---|---|---|---|
17a3b82d5c | |||
8c087f452e | |||
23431457b7 | |||
3f6ea3a2f1 | |||
ef0c80d099 | |||
6af55a17bf | |||
1a760adcfd | |||
ff7f0f2e96 | |||
b13e97ba6a | |||
3c2053dc85 | |||
13b669ce22 | |||
5ed82d0fca | |||
d713becd68 | |||
9670bed8e8 | |||
ce09220708 | |||
422f4c68c6 | |||
078683b5b2 | |||
dc78ea7426 |
@@ -28,13 +28,10 @@ jobs:
|
||||
- name: install frontend dependencies
|
||||
run: npm install # change this to npm or pnpm depending on which one you use
|
||||
working-directory: ./toos-dashboard
|
||||
- uses: tauri-apps/tauri-action@v0
|
||||
- run: npm run tauri build
|
||||
working-directory: ./toos-dashboard
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
|
||||
releaseName: 'App v__VERSION__'
|
||||
releaseBody: 'See the assets to download this version and install.'
|
||||
releaseDraft: true
|
||||
prerelease: false
|
||||
name: toos-dashboard.AppImage
|
||||
path: toos-dashboard/src-tauri/target/release/bundle/appimage/*.AppImage
|
||||
|
@@ -4,6 +4,7 @@ const int redPin = 4;
|
||||
const int greenPin = 5;
|
||||
const int bluePin = 13;
|
||||
const int whitePin = 14;
|
||||
const int btnPin = 18;
|
||||
|
||||
#define PIN_WS2812B 27
|
||||
#define NUM_PIXELS 68
|
||||
@@ -13,6 +14,12 @@ Adafruit_NeoPixel ws2812b(NUM_PIXELS, PIN_WS2812B, NEO_GRB + NEO_KHZ800);
|
||||
String inputCommand = "";
|
||||
String inputColor = "";
|
||||
|
||||
int buttonState = 0;
|
||||
int lastButtonState = LOW;
|
||||
|
||||
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
|
||||
unsigned long debounceDelay = 50;
|
||||
|
||||
void setup() {
|
||||
ws2812b.begin();
|
||||
Serial.begin(9600);
|
||||
@@ -21,6 +28,7 @@ void setup() {
|
||||
pinMode(greenPin, OUTPUT);
|
||||
pinMode(bluePin, OUTPUT);
|
||||
pinMode(whitePin, OUTPUT);
|
||||
pinMode(btnPin, INPUT);
|
||||
|
||||
analogWrite(redPin, 0);
|
||||
analogWrite(greenPin, 0);
|
||||
@@ -60,6 +68,30 @@ void loop() {
|
||||
inputColor = ""; // Clear the inputColor string
|
||||
}
|
||||
}
|
||||
|
||||
int reading = digitalRead(btnPin);
|
||||
|
||||
if (reading != lastButtonState) {
|
||||
// reset the debouncing timer
|
||||
lastDebounceTime = millis();
|
||||
}
|
||||
|
||||
if ((millis() - lastDebounceTime) > debounceDelay) {
|
||||
// whatever the reading is at, it's been there for longer than the debounce
|
||||
// delay, so take it as the actual current state:
|
||||
|
||||
// if the button state has changed:
|
||||
if (reading != buttonState) {
|
||||
buttonState = reading;
|
||||
|
||||
// only toggle the LED if the new button state is HIGH
|
||||
if (buttonState == HIGH) {
|
||||
Serial.write("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastButtonState = reading;
|
||||
}
|
||||
|
||||
void setLight(int brightnessValue) {
|
||||
|
@@ -13,7 +13,7 @@ edition = "2021"
|
||||
tauri-build = { version = "1.5", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "1.5", features = [ "dialog-all", "shell-open"] }
|
||||
tauri = { version = "1.5", features = ["dialog-all", "shell-open"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serialport = "4.2.2"
|
||||
|
@@ -5,6 +5,7 @@ use std::io::BufReader;
|
||||
use rodio::{Decoder, OutputStream, Sink};
|
||||
use std::sync::Mutex;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::serial;
|
||||
|
||||
@@ -15,19 +16,31 @@ struct Timings {
|
||||
}
|
||||
|
||||
static TIMINGS: Mutex<Lazy<Timings>> = Mutex::new(Lazy::new(|| Timings { charging_start_delay: 1600, charging_delay: 450, charging_end_delay: 400 } ));
|
||||
static PLAYING: Mutex<bool> = Mutex::new(false);
|
||||
pub static AUDIO_PATH: Mutex<Lazy<PathBuf>> = Mutex::new(Lazy::new(|| Path::new("assets/audio.mp3").to_path_buf()));
|
||||
|
||||
#[tauri::command]
|
||||
pub fn start() {
|
||||
let mut playing = PLAYING.lock().unwrap();
|
||||
|
||||
if *playing {
|
||||
return;
|
||||
} else {
|
||||
*playing = true;
|
||||
}
|
||||
thread::spawn(move || {
|
||||
println!("Starting animation...");
|
||||
|
||||
|
||||
play_sound();
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
thread::sleep(Duration::from_millis(800));
|
||||
|
||||
let _ = serial::write_serial(format!("SET_LIGHT:0;").as_str());
|
||||
stage_one();
|
||||
stage_two();
|
||||
|
||||
let mut playing = PLAYING.lock().unwrap();
|
||||
*playing = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,7 +49,9 @@ fn play_sound() {
|
||||
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
||||
let sink = Sink::try_new(&stream_handle).unwrap();
|
||||
|
||||
let file = BufReader::new(File::open("assets/audio.mp3").unwrap());
|
||||
let path = AUDIO_PATH.lock().unwrap();
|
||||
|
||||
let file = BufReader::new(File::open(&**path).unwrap());
|
||||
let source = Decoder::new(file).unwrap();
|
||||
|
||||
sink.append(source);
|
||||
@@ -107,4 +122,7 @@ fn stage_two() {
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
let _ = serial::write_serial(format!("SET_LED_OFF;").as_str());
|
||||
let _ = serial::write_serial(format!("SET_STRIP_COLOR:0,0,0;").as_str());
|
||||
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
let _ = serial::write_serial(format!("SET_LIGHT:255;").as_str());
|
||||
}
|
||||
|
@@ -7,6 +7,17 @@ mod animation;
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![serial::get_serial_ports, serial::write_serial, serial::open_port, serial::close_port, animation::start])
|
||||
.setup(|app| {
|
||||
let resource_path = app.path_resolver()
|
||||
.resolve_resource("assets/audio.mp3")
|
||||
.expect("failed to resolve resource");
|
||||
|
||||
let mut audio_path = animation::AUDIO_PATH.lock().unwrap();
|
||||
|
||||
**audio_path = resource_path;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
"beforeBuildCommand": "npm run build",
|
||||
"devPath": "http://localhost:1420",
|
||||
"devPath": "http://127.0.0.1:1420",
|
||||
"distDir": "../dist",
|
||||
"withGlobalTauri": false
|
||||
},
|
||||
@@ -31,6 +31,9 @@
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": [
|
||||
"assets/audio.mp3"
|
||||
]
|
||||
},
|
||||
"security": {
|
||||
|
Reference in New Issue
Block a user