mirror of
https://github.com/4yn/slidershim.git
synced 2024-11-12 00:40:49 +01:00
add slower led update option
This commit is contained in:
parent
ff6e971f62
commit
748a76cf06
@ -38,6 +38,7 @@ impl Config {
|
|||||||
"keyboardSensitivity": 20,
|
"keyboardSensitivity": 20,
|
||||||
"outputPolling": "100",
|
"outputPolling": "100",
|
||||||
"outputWebsocketUrl": "localhost:3000",
|
"outputWebsocketUrl": "localhost:3000",
|
||||||
|
"ledFaster": false,
|
||||||
"ledSensitivity": 20,
|
"ledSensitivity": 20,
|
||||||
"ledWebsocketUrl": "localhost:3001",
|
"ledWebsocketUrl": "localhost:3001",
|
||||||
"ledSerialPort": "COM5"
|
"ledSerialPort": "COM5"
|
||||||
|
@ -11,14 +11,19 @@ pub enum ReactiveLayout {
|
|||||||
pub enum LightsMode {
|
pub enum LightsMode {
|
||||||
None,
|
None,
|
||||||
Reactive {
|
Reactive {
|
||||||
|
faster: bool,
|
||||||
layout: ReactiveLayout,
|
layout: ReactiveLayout,
|
||||||
sensitivity: u8,
|
sensitivity: u8,
|
||||||
},
|
},
|
||||||
Attract,
|
Attract {
|
||||||
|
faster: bool,
|
||||||
|
},
|
||||||
Websocket {
|
Websocket {
|
||||||
|
faster: bool,
|
||||||
url: String,
|
url: String,
|
||||||
},
|
},
|
||||||
Serial {
|
Serial {
|
||||||
|
faster: bool,
|
||||||
port: String,
|
port: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -28,30 +33,39 @@ impl LightsMode {
|
|||||||
Some(match v["ledMode"].as_str()? {
|
Some(match v["ledMode"].as_str()? {
|
||||||
"none" => LightsMode::None,
|
"none" => LightsMode::None,
|
||||||
"reactive-4" => LightsMode::Reactive {
|
"reactive-4" => LightsMode::Reactive {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
layout: ReactiveLayout::Even { splits: 4 },
|
layout: ReactiveLayout::Even { splits: 4 },
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
},
|
},
|
||||||
"reactive-8" => LightsMode::Reactive {
|
"reactive-8" => LightsMode::Reactive {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
layout: ReactiveLayout::Even { splits: 8 },
|
layout: ReactiveLayout::Even { splits: 8 },
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
},
|
},
|
||||||
"reactive-16" => LightsMode::Reactive {
|
"reactive-16" => LightsMode::Reactive {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
layout: ReactiveLayout::Even { splits: 16 },
|
layout: ReactiveLayout::Even { splits: 16 },
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
},
|
},
|
||||||
"reactive-rainbow" => LightsMode::Reactive {
|
"reactive-rainbow" => LightsMode::Reactive {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
layout: ReactiveLayout::Rainbow,
|
layout: ReactiveLayout::Rainbow,
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
},
|
},
|
||||||
"reactive-voltex" => LightsMode::Reactive {
|
"reactive-voltex" => LightsMode::Reactive {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
layout: ReactiveLayout::Voltex,
|
layout: ReactiveLayout::Voltex,
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
},
|
},
|
||||||
"attract" => LightsMode::Attract,
|
"attract" => LightsMode::Attract {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
|
},
|
||||||
"websocket" => LightsMode::Websocket {
|
"websocket" => LightsMode::Websocket {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
url: v["ledWebsocketUrl"].as_str()?.to_string(),
|
url: v["ledWebsocketUrl"].as_str()?.to_string(),
|
||||||
},
|
},
|
||||||
"serial" => LightsMode::Serial {
|
"serial" => LightsMode::Serial {
|
||||||
|
faster: v["ledFaster"].as_bool()?,
|
||||||
port: v["ledSerialPort"].as_str()?.to_string(),
|
port: v["ledSerialPort"].as_str()?.to_string(),
|
||||||
},
|
},
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
@ -30,7 +30,15 @@ impl LightsJob {
|
|||||||
mode: mode.clone(),
|
mode: mode.clone(),
|
||||||
serial_port: None,
|
serial_port: None,
|
||||||
started: Instant::now(),
|
started: Instant::now(),
|
||||||
timer: interval(Duration::from_micros(33333)),
|
timer: match match mode {
|
||||||
|
LightsMode::Attract { faster, .. } => *faster,
|
||||||
|
LightsMode::Websocket { faster, .. } => *faster,
|
||||||
|
LightsMode::Serial { faster, .. } => *faster,
|
||||||
|
_ => false,
|
||||||
|
} {
|
||||||
|
false => interval(Duration::from_micros(66666)),
|
||||||
|
true => interval(Duration::from_micros(33333)),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +153,7 @@ impl LightsJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LightsMode::Attract => {
|
LightsMode::Attract { .. } => {
|
||||||
let theta = self
|
let theta = self
|
||||||
.started
|
.started
|
||||||
.elapsed()
|
.elapsed()
|
||||||
@ -187,7 +195,7 @@ impl LightsJob {
|
|||||||
impl AsyncJob for LightsJob {
|
impl AsyncJob for LightsJob {
|
||||||
async fn setup(&mut self) -> bool {
|
async fn setup(&mut self) -> bool {
|
||||||
match &self.mode {
|
match &self.mode {
|
||||||
LightsMode::Serial { port } => {
|
LightsMode::Serial { port, .. } => {
|
||||||
info!(
|
info!(
|
||||||
"Serial port for led opening at {} {:?}",
|
"Serial port for led opening at {} {:?}",
|
||||||
port.as_str(),
|
port.as_str(),
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
let keyboardSensitivity = 20;
|
let keyboardSensitivity = 20;
|
||||||
let outputPolling = "100";
|
let outputPolling = "100";
|
||||||
let outputWebsocketUrl = "http://localhost:3000";
|
let outputWebsocketUrl = "http://localhost:3000";
|
||||||
|
let ledFaster = false;
|
||||||
let ledSensitivity = 20;
|
let ledSensitivity = 20;
|
||||||
let ledWebsocketUrl = "http://localhost:3001";
|
let ledWebsocketUrl = "http://localhost:3001";
|
||||||
let ledSerialPort = "COM5";
|
let ledSerialPort = "COM5";
|
||||||
@ -66,6 +67,7 @@
|
|||||||
outputPolling = payload.outputPolling || "100";
|
outputPolling = payload.outputPolling || "100";
|
||||||
outputWebsocketUrl =
|
outputWebsocketUrl =
|
||||||
payload.outputWebsocketUrl || "http://localhost:3000/";
|
payload.outputWebsocketUrl || "http://localhost:3000/";
|
||||||
|
ledFaster = payload.ledFaster || false;
|
||||||
ledSensitivity = payload.ledSensitivity || 20;
|
ledSensitivity = payload.ledSensitivity || 20;
|
||||||
ledWebsocketUrl = payload.ledWebsocketUrl || "http://localhost:3001";
|
ledWebsocketUrl = payload.ledWebsocketUrl || "http://localhost:3001";
|
||||||
ledSerialPort = payload.ledSerialPort || "COM5";
|
ledSerialPort = payload.ledSerialPort || "COM5";
|
||||||
@ -116,6 +118,7 @@
|
|||||||
keyboardSensitivity,
|
keyboardSensitivity,
|
||||||
outputPolling,
|
outputPolling,
|
||||||
outputWebsocketUrl,
|
outputWebsocketUrl,
|
||||||
|
ledFaster,
|
||||||
ledSensitivity,
|
ledSensitivity,
|
||||||
ledWebsocketUrl,
|
ledWebsocketUrl,
|
||||||
ledSerialPort,
|
ledSerialPort,
|
||||||
@ -298,7 +301,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if outputMode.slice(0, 2) === "kb" && deviceMode.slice(0, 10) !== "brokenithm"}
|
{#if (outputMode.slice(0, 2) === "kb" || outputMode.slice(0, 7) === "gamepad") && deviceMode.slice(0, 10) !== "brokenithm"}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="label" title="Larger means harder to trigger">
|
<div class="label" title="Larger means harder to trigger">
|
||||||
Sensitivity
|
Sensitivity
|
||||||
@ -357,6 +360,23 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{#if ledMode !== "none"}
|
||||||
|
<div class="row">
|
||||||
|
<div class="label" />
|
||||||
|
<div class="input">
|
||||||
|
<span>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="led-faster"
|
||||||
|
style="width: unset;"
|
||||||
|
bind:checked={ledFaster}
|
||||||
|
on:change={markDirty}
|
||||||
|
/>
|
||||||
|
<label for="led-faster">Update LED data faster</label>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{#if ledMode.slice(0, 8) === "reactive" && deviceMode.slice(0, 10) !== "brokenithm"}
|
{#if ledMode.slice(0, 8) === "reactive" && deviceMode.slice(0, 10) !== "brokenithm"}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="label" title="Larger means harder to trigger">
|
<div class="label" title="Larger means harder to trigger">
|
||||||
|
Loading…
Reference in New Issue
Block a user