UPD: UI LEDs follow IRL Nano

This commit is contained in:
Robert Kossessa
2024-04-16 15:07:02 +02:00
parent 13d4f6431f
commit 9c5af6f1a4
2 changed files with 28 additions and 22 deletions

View File

@@ -24,8 +24,11 @@
</svg> </svg>
</template> </template>
<script setup> <script setup>
import { computed, onMounted, onUnmounted, ref } from 'vue' import { computed, ref, watch } from 'vue'
import Color from 'color' import Color from 'color'
import { useDeviceStore } from '@renderer/deviceStore'
const deviceStore = useDeviceStore()
const props = defineProps({ const props = defineProps({
value: { value: {
@@ -45,24 +48,27 @@ const padding = ref(40)
const size = computed(() => (radius.value + ledRadius.value + padding.value) * 2) const size = computed(() => (radius.value + ledRadius.value + padding.value) * 2)
let interval = null const updateLEDs = (value) => {
for (let i = 0; i < ledCount.value; i++) {
onMounted(() => { if (i / ledCount.value < value / 100) {
interval = setInterval(() => { leds.value[i] = Color(deviceStore.currentProfile?.primary)
const valueIndex = Math.floor((props.value / 100) * ledCount.value) } else if ((i - 1) / ledCount.value < value / 100) {
leds.value.forEach((color, index) => { leds.value[i] = Color(deviceStore.currentProfile?.pointer)
const distance = Math.abs(index - valueIndex) % ledCount.value
if (distance < 1) {
leds.value[index] = Color.hsl(40, 100, 100)
} else if (distance < 2) {
leds.value[index] = Color.hsl(40, 100, 60)
} else { } else {
leds.value[index] = color.mix(Color.hsl(310, 100, 20), 0.03) leds.value[i] = Color(deviceStore.currentProfile?.secondary)
} }
}) }
}) }
onUnmounted(() => {
clearInterval(interval) updateLEDs(props.value)
})
}) watch(
() => [
deviceStore.currentProfile?.primary,
deviceStore.currentProfile?.pointer,
deviceStore.currentProfile?.secondary,
props.value
],
() => updateLEDs(props.value)
)
</script> </script>

View File

@@ -49,7 +49,7 @@
> >
<img :src="LogoMidi" alt="midi-logo" class="h-4 opacity-50" /> <img :src="LogoMidi" alt="midi-logo" class="h-4 opacity-50" />
<h2 class="font-pixellg text-5xl"> <h2 class="font-pixellg text-5xl">
{{ parseInt(barValue - deviceStore.turns * 100) }} {{ parseInt(barValue + deviceStore.turns * 100) }}
</h2> </h2>
<div class="font-pixelsm text-md">HIGH PASS</div> <div class="font-pixelsm text-md">HIGH PASS</div>
<DeviceBar :value="barValue" :count="30" :width="120" /> <DeviceBar :value="barValue" :count="30" :width="120" />
@@ -111,7 +111,7 @@ import Color from 'color'
const appStore = useAppStore() const appStore = useAppStore()
const deviceStore = useDeviceStore() const deviceStore = useDeviceStore()
const barValue = computed(() => 100 - (deviceStore.angle / Math.PI / 2) * 100) const barValue = computed(() => 100 + (deviceStore.angle / Math.PI / 2) * 100)
const previewDeviceImages = { const previewDeviceImages = {
nanoOne: RenderNanoOne, nanoOne: RenderNanoOne,