Compare commits

...

4 Commits

Author SHA1 Message Date
b551082c1a Oops, load values as [1,255] too 2024-12-29 00:51:55 +01:00
c06033d39a BIG LAMP 2024-12-29 00:48:37 +01:00
0d295c6361 Scroll lamps to 255 as they should be 2024-12-29 00:45:24 +01:00
fbffdc40f6 Shift = scroll smaller 2024-12-29 00:43:58 +01:00
4 changed files with 11 additions and 7 deletions

View File

@@ -15,7 +15,8 @@
function handleWheel(event: WheelEvent) { function handleWheel(event: WheelEvent) {
event.preventDefault(); event.preventDefault();
const delta = event.deltaY > 0 ? -4 : 4; const increment = event.shiftKey ? 1 : 4;
const delta = event.deltaY > 0 ? -increment : increment;
const newBrightness = Math.max(0, Math.min(100, brightness + delta)); const newBrightness = Math.max(0, Math.min(100, brightness + delta));
if (newBrightness !== brightness) { if (newBrightness !== brightness) {
brightness = newBrightness; brightness = newBrightness;

View File

@@ -2,16 +2,19 @@
import Lamp from "../../components/Lamp.svelte"; import Lamp from "../../components/Lamp.svelte";
import { GetLamps, SetLampBrightness } from "$wails/main/App"; import { GetLamps, SetLampBrightness } from "$wails/main/App";
// Brightness is actually 1-255 and not 1-100
// But we want the frontend to show 1-100 as in %
let lamps: number[] = [0, 0]; let lamps: number[] = [0, 0];
GetLamps().then(apilamps => { GetLamps().then((apilamps) => {
console.log(apilamps); console.log(apilamps);
for (let i = 0; i < apilamps.length; i++) { for (let i = 0; i < apilamps.length; i++) {
lamps[i] = Number(apilamps[i]); lamps[i] = Number(apilamps[i]);
lamps[i] = Math.round(lamps[i] / 2.55);
} }
}); });
function handleBrightnessChange(lamp: number, brightness: number) { function handleBrightnessChange(lamp: number, brightness: number) {
SetLampBrightness(lamp, brightness); SetLampBrightness(lamp, Math.round(brightness * 2.55));
} }
</script> </script>

2
go.mod
View File

@@ -1,4 +1,4 @@
module wails-template module biglamp
go 1.21 go 1.21

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://wails.io/schemas/config.v2.json", "$schema": "https://wails.io/schemas/config.v2.json",
"name": "wails-template", "name": "biglamp",
"outputfilename": "wails-template", "outputfilename": "biglamp",
"frontend:install": "pnpm install", "frontend:install": "pnpm install",
"frontend:build": "pnpm build", "frontend:build": "pnpm build",
"frontend:dev:watcher": "pnpm dev", "frontend:dev:watcher": "pnpm dev",