generated from dave/wails-template
Oops, load values as [1,255] too
This commit is contained in:
@@ -2,17 +2,18 @@
|
|||||||
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) {
|
||||||
// Brightness is actually 1-255 and not 1-100
|
|
||||||
// But we want the frontend to show 1-100 as in %
|
|
||||||
SetLampBrightness(lamp, Math.round(brightness * 2.55));
|
SetLampBrightness(lamp, Math.round(brightness * 2.55));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -22,4 +23,4 @@
|
|||||||
<Lamp lamp={1} brightness={lamps[0]} brightnessChange={handleBrightnessChange} />
|
<Lamp lamp={1} brightness={lamps[0]} brightnessChange={handleBrightnessChange} />
|
||||||
<Lamp lamp={2} brightness={lamps[1]} brightnessChange={handleBrightnessChange} />
|
<Lamp lamp={2} brightness={lamps[1]} brightnessChange={handleBrightnessChange} />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Reference in New Issue
Block a user