Compare commits

...

18 Commits

Author SHA1 Message Date
17a3b82d5c Update toos-dashboard/src-tauri/src/animation.rs
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m18s
2023-10-28 08:43:55 +02:00
8c087f452e Update toos-dashboard/src-tauri/src/animation.rs
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m16s
2023-10-27 20:49:37 +02:00
23431457b7 Update toos-dashboard/src-tauri/src/animation.rs
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m16s
2023-10-27 20:39:31 +02:00
3f6ea3a2f1 Changed localhost to 127.0.0.1
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m29s
2023-10-27 15:11:20 +02:00
ef0c80d099 merge
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m21s
2023-10-27 15:03:38 +02:00
6af55a17bf Merge branch 'main' of https://gitea.xeovalyte.dev/xeovalyte/toos-halloween 2023-10-27 15:03:04 +02:00
1a760adcfd Update .gitea/workflows/workflow.yml
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m37s
2023-10-27 14:22:38 +02:00
ff7f0f2e96 Update .gitea/workflows/workflow.yml
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m17s
2023-10-27 14:04:28 +02:00
b13e97ba6a Update .gitea/workflows/workflow.yml
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 3m59s
2023-10-27 13:22:23 +02:00
3c2053dc85 Update .gitea/workflows/workflow.yml
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m6s
2023-10-27 13:16:43 +02:00
13b669ce22 Update .gitea/workflows/workflow.yml
Some checks failed
publish / publish-tauri (ubuntu-20.04) (push) Failing after 4m18s
2023-10-27 13:02:08 +02:00
5ed82d0fca Update .gitea/workflows/workflow.yml
Some checks failed
publish / publish-tauri (ubuntu-20.04) (push) Failing after 3m55s
2023-10-27 12:52:02 +02:00
d713becd68 Update .gitea/workflows/workflow.yml 2023-10-27 12:51:45 +02:00
9670bed8e8 Update .gitea/workflows/workflow.yml
All checks were successful
publish / publish-tauri (ubuntu-20.04) (push) Successful in 4m3s
2023-10-27 12:45:30 +02:00
ce09220708 Update .gitea/workflows/workflow.yml
Some checks failed
publish / publish-tauri (ubuntu-20.04) (push) Failing after 1m36s
2023-10-27 10:40:29 +02:00
422f4c68c6 feat: Added relative audio path 2023-10-27 10:34:47 +02:00
078683b5b2 feat: Added button
Some checks failed
publish / publish-tauri (ubuntu-20.04) (push) Failing after 4m8s
2023-10-26 15:31:07 +02:00
dc78ea7426 feat: Added button 2023-10-26 15:30:53 +02:00
6 changed files with 73 additions and 12 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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());
}

View File

@@ -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");
}

View File

@@ -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": {