-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathsettings.html
More file actions
840 lines (806 loc) · 38.1 KB
/
settings.html
File metadata and controls
840 lines (806 loc) · 38.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="data:," />
<title x-text="header"></title>
<style>
[x-cloak] {
display: none !important;
}
</style>
<link rel="stylesheet" href="index.css" />
<script defer src="index.js" type="module"></script>
</head>
<body
x-data="Object.assign(page('Settings'), { showAdvanced: false }, {
showHelp: false,
helpTitle: '',
helpContent: '',
showHelpModal(title, content) {
this.helpTitle = title;
this.helpContent = content;
this.showHelp = true;
}
})"
class="flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-gray-100"
>
<div
class="flex flex-col items-center justify-center bg-neutral-800 shadow-[0_0_30px_10px_#222] p-6 m-6 rounded-lg max-w-lg w-11/12 text-center"
>
<a
href="index.html"
class="text-gray-400 hover:text-amber-600 transition-colors self-end"
title="Back to Home"
>
<!-- Heroicon: X Mark -->
<svg
xmlns="http://www.w3.org/2000/svg"
class="w-6 h-6"
fill="none"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</a>
<h2
class="text-xl font-semibold text-left w-full border-b border-gray-600 pb-2 mb-4 relative flex justify-between"
>
General Settings
</h2>
<div class="flex gap-2 flex-wrap">
<div class="grow">
<label for="name" class="block text-left text-lg mt-4">
Display Name
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="name"
x-model="settings.name"
placeholder="Enter a name for this display"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'name'"
x-text="errors.message"
></div>
</div>
<div class="grow">
<label for="mdns" class="block text-left text-lg mt-4">
mDNS Hostname
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="mdns"
x-model="settings.mdns"
placeholder="Enter mDNS hostname"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'mdns'"
x-text="errors.message"
></div>
</div>
</div>
<label for="timezone" class="block text-left text-lg mt-4">
Timezone
</label>
<div class="relative w-full mt-2">
<select
class="w-full p-3 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
x-model="settings.timezone"
id="timezone"
>
<template x-for="(name, zone) in timezones" :key="zone">
<option
:value="zone"
x-text="zone"
:selected="zone === settings.timezone"
></option>
</template>
</select>
<div
x-show="loading.timezones"
class="absolute inset-0 flex justify-center items-center rounded-md"
>
<svg
class="animate-spin h-5 w-5 text-gray-100"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
class="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
stroke-width="4"
></circle>
<path
class="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
></path>
</svg>
</div>
</div>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'timezone'"
x-text="errors.message"
></div>
<div class="grid grid-cols-2 gap-2 w-full">
<div>
<label
class="flex text-lg mt-4 justify-between"
for="date_format"
>
Date Format
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="date_format"
x-model="settings.dateFormat"
placeholder="e.g. {dd}-{mm}-{yy}"
/>
</div>
<div>
<label
class="flex text-lg mt-4 justify-between"
for="time_format"
>Time Format
<button
type="button"
class="ml-1 text-sm text-gray-400 hover:text-white cursor-pointer transition-colors"
@click="$dispatch('open-help', {
title: 'Date & Time Format Help',
content: `
<p><strong>Date Tokens:</strong></p>
<ul class='list-disc list-inside pl-2'>
<li><code>{dd}</code> – Day of month (01–31)</li>
<li><code>{d}</code> – Day of month (1–31, no leading 0)</li>
<li><code>{mmm}</code> – Abbreviated month name (e.g. Apr)</li>
<li><code>{mm}</code> – Month as number (01–12)</li>
<li><code>{yy}</code> – Two-digit year (e.g. 24)</li>
<li><code>{yyyy}</code> – Full year (e.g. 2024)</li>
<li><code>{ddd}</code> – Weekday abbreviation (e.g. Mon)</li>
<li><code>{dddd}</code> – Full weekday (e.g. Monday)</li>
<li><code>{ww}</code> – Week number (ISO)</li>
<li><code>{D}</code> – Day of the year (001–366)</li>
</ul>
<p class='mt-2'><strong>Time Tokens:</strong></p>
<ul class='list-disc list-inside pl-2'>
<li><code>{HH}</code> – Hour (00–23)</li>
<li><code>{hh}</code> – Hour (01–12)</li>
<li><code>{mm}</code> – Minutes (00–59)</li>
<li><code>{ss}</code> – Seconds divided by 10 (0–5)</li>
<li><code>{AM}</code> – AM/PM (uppercase)</li>
</ul>
<p class='mt-2 text-xs italic text-gray-400'>
Tokens are case-sensitive. You can mix with literal text,
like <code>{ddd}{dd}-{mm}</code> → “Mon08-04”.
You can also mix date and time tokens but you have to select the corresponding mode from the dropdown.
</p>
`
})"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"
/>
</svg>
</button>
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="time_format"
x-model="settings.timeFormat"
placeholder="e.g. {HH}:{mm}"
/>
</div>
</div>
<h2
class="text-xl font-semibold text-left w-full border-b border-gray-600 pb-2 mt-10 mb-2"
>
Wi-Fi Settings
</h2>
<div class="flex gap-2 flex-wrap">
<div class="grow">
<label for="ssid" class="block text-left text-lg mt-4">
Wi-Fi SSID
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="ssid"
x-model="settings.ssid"
placeholder="WiFi SSID"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'ssid'"
x-text="errors.message"
></div>
</div>
<div class="grow">
<label for="password" class="block text-left text-lg mt-4">
Wi-Fi Password
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="password"
id="password"
x-model="settings.password"
placeholder="WiFi Password"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'password'"
x-text="errors.message"
></div>
</div>
</div>
<div class="relative w-full">
<label for="otaPass" class="block text-lg mt-4">
OTA Password
<button
type="button"
class="ml-1 text-sm absolute right-0 text-gray-400 hover:text-white cursor-pointer transition-colors"
@click="$dispatch('open-help', {
title: 'OTA Password Help',
content: `
<p><strong>What is OTA?</strong></p>
<p>OTA (Over-the-Air) allows you to wirelessly upload new firmware or filesystem updates to your Split Flap Display.</p>
<p class='mt-2'><strong>What is the OTA Password?</strong></p>
<p>This password secures your device by requiring authentication before accepting any OTA updates. Without it, anyone on the same network could potentially push firmware to your device.</p>
<p class='mt-2'><strong>How to Use:</strong></p>
<ul class='list-disc list-inside pl-2'>
<li>Set a password in the <code>OTA Password</code> field.</li>
<li>Add the password to your <code>platformio.ini</code> as the <code>--auth</code> flag for OTA uploads.</li>
<li>Use the appropriate OTA environment (e.g. <code>esp32_s3_ota</code>) when uploading firmware or filesystem updates.</li>
</ul>
`
})"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"
/>
</svg>
</button>
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="password"
id="otaPass"
x-model="settings.otaPass"
placeholder="Enter OTA Password"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'otaPass'"
x-text="errors.message"
></div>
</div>
<h2
class="text-xl font-semibold text-left w-full border-b border-gray-600 pb-2 mt-10 mb-2 flex justify-between"
>
MQTT Settings
<button
type="button"
class="ml-1 text-sm text-gray-400 hover:text-white cursor-pointer transition-colors"
@click="$dispatch('open-help', {
title: 'Home Assistant MQTT Help',
content: `
<p><strong>Home Assistant Integration:</strong></p>
<ul class='list-disc list-inside pl-2'>
<li>Make sure MQTT is enabled in Home Assistant and a broker (like Mosquitto) is installed and running.</li>
<li>Use your Home Assistant MQTT broker settings for <strong>Server</strong>, <strong>Port</strong>, <strong>Username</strong>, and <strong>Password</strong>.</li>
<li>After saving settings, the display will automatically connect and publish state to the MQTT topic you’ve configured.</li>
</ul>
<p class='mt-2'><strong>Auto-Discovery:</strong></p>
<ul class='list-disc list-inside pl-2'>
<li>This device supports Home Assistant MQTT auto-discovery.</li>
<li>Entities will appear automatically under <em>Settings → Devices & Services → MQTT</em>.</li>
<li>If you change the display name or topic, entities may be re-created with new IDs in Home Assistant.</li>
</ul>
<p class='mt-2 text-xs italic text-gray-400'>
If entities don't appear, restart Home Assistant or verify the MQTT integration is correctly configured with discovery enabled.
</p>
`
})"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"
/>
</svg>
</button>
</h2>
<div class="gap-2 grid grid-cols-2">
<div>
<label
class="block text-left text-lg mt-4"
for="mqtt_server"
>MQTT Server</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="mqtt_server"
x-model="settings.mqtt_server"
placeholder="e.g. 192.168.1.10"
/>
</div>
<div>
<label class="block text-left text-lg mt-4" for="mqtt_port"
>MQTT Port</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="mqtt_port"
x-model="settings.mqtt_port"
placeholder="1883"
/>
</div>
</div>
<div class="gap-2 grid grid-cols-2">
<div>
<label class="block text-left text-lg mt-4" for="mqtt_user">
MQTT Username
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="text"
id="mqtt_user"
x-model="settings.mqtt_user"
placeholder="optional"
/>
</div>
<div>
<label class="block text-left text-lg mt-4" for="mqtt_pass">
MQTT Password
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="password"
id="mqtt_pass"
x-model="settings.mqtt_pass"
placeholder="optional"
/>
</div>
</div>
<h2
class="text-xl font-semibold text-left w-full border-b border-gray-600 pb-2 mt-10 mb-2 flex justify-between"
>
Hardware Settings
<button
type="button"
class="ml-1 text-sm text-gray-400 hover:text-white cursor-pointer transition-colors"
@click="$dispatch('open-help', {
title: 'Hardware Settings Help',
content: `
<ul class='list-disc list-inside pl-2'>
<li><strong>Number of modules:</strong> How many split-flap modules are connected.</li>
<li><strong>Character Set:</strong> 37 = standard (A-Z 0-9), 48 = extended (includes symbols).</li>
<li><strong>Customise Characters:</strong> Specify your custom characters and symbols.</li>
<li><strong>Addresses:</strong> I²C address for each module. Typically starts at 32 and increases per module.</li>
<li><strong>Offsets:</strong> Fine-tune each module’s zero position if flaps are misaligned.</li>
</ul>
<p class='mt-2'><strong>Advanced Settings:</strong></p>
<ul class='list-disc list-inside pl-2'>
<li><strong>Magnet Position:</strong> Step where the home sensor is triggered. Usually 730 (37) or 615 (48).</li>
<li><strong>SDA / SCL Pin:</strong> GPIO pins on the Esp32 used for I²C communication to modules.</li>
<li><strong>Steps Per Rotation:</strong> Total steps to rotate one full cycle across all flaps.</li>
<li><strong>Max Velocity:</strong> Controls how fast the motor moves (too high may skip steps).</li>
</ul>
<p class='mt-2 text-xs italic text-gray-400'>
For the Advanced Settings you should be able to go with the defaults unless you're building custom hardware.
</p>
`
})"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"
/>
</svg>
</button>
</h2>
<div class="gap-2 grid grid-cols-2 w-full">
<div>
<label
for="moduleCount"
class="block text-left text-lg mt-4"
>
Number of Modules
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="moduleCount"
x-model="settings.moduleCount"
min="1"
max="8"
placeholder="1-8"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'moduleCount'"
x-text="errors.message"
></div>
</div>
<div>
<label for="charset" class="block text-left text-lg mt-4">
Character Set
</label>
<select
class="w-full p-3.5 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-white"
x-model.number="settings.charset"
id="charset"
@change="
if (settings.charset === 37) {
settings.magnetPosition = 730;
} else if (settings.charset === 48) {
settings.magnetPosition = 615;
}
"
>
<option value="37">Standard (37)</option>
<option value="48">Extended (48)</option>
</select>
</div>
<div class="col-span-2">
<label
for="customCharset"
class="block text-left text-lg mt-4"
>
Customise Characters
</label>
<div class="relative">
<input
id="customCharset"
type="text"
x-model="settings.custom_charset"
class="w-full p-3 pr-16 text-lg border rounded-md text-center bg-neutral-700 text-gray-100"
:class="{
'border-red-600': settings.custom_charset.length !== settings.charset,
'border-green-500': settings.custom_charset.length === settings.charset
}"
placeholder=" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789':?!.-/@$#%"
/>
<span
class="absolute right-3 top-1/2 transform -translate-y-1/2 text-sm"
:class="{
'text-red-600': settings.custom_charset.length !== settings.charset,
'text-green-500': settings.custom_charset.length === settings.charset
}"
x-text="`${settings.custom_charset.length}/${settings.charset}`"
></span>
</div>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'custom_charset'"
x-text="errors.message"
></div>
</div>
</div>
<label class="block text-left text-lg mt-4">
Module Addresses
</label>
<div class="grid grid-cols-4 md:grid-cols-8 gap-2 mt-2 w-full">
<template
x-for="(val, i) in Array.from({ length: settings.moduleCount })"
:key="`addr-${i}-${addressArray[i]}`"
>
<input
type="number"
class="no-buttons w-full p-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
:value="addressArray[i]"
@input="setAddress(i, $event.target.value)"
:placeholder="`e.g. ${32 + i}`"
/>
</template>
</div>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'moduleAddresses'"
x-text="errors.message"
></div>
<label class="block text-left text-lg mt-4"> Module Offsets </label>
<div class="grid grid-cols-4 md:grid-cols-8 gap-2 mt-2 w-full">
<template
x-for="(val, i) in Array.from({ length: settings.moduleCount })"
:key="`off-${i}-${offsetArray[i]}`"
>
<input
type="number"
class="no-buttons w-full p-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
:value="offsetArray[i]"
@input="setOffset(i, $event.target.value)"
placeholder="e.g. 0"
/>
</template>
</div>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'moduleOffsets'"
x-text="errors.message"
></div>
<a
href="#"
class="block w-full text-center text-sm hover:underline mt-6 mb-2"
x-on:click.prevent="showAdvanced = !showAdvanced"
x-text="showAdvanced ? 'Hide Advanced Settings ▲' : 'Show Advanced Settings ▼'"
></a>
<div x-show="showAdvanced" x-cloak>
<div class="grid grid-cols-3 gap-2 w-full">
<div>
<label
for="magnetPosition"
class="block text-left text-lg mt-4"
>
Magnet Position
</label>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="magnetPosition"
x-model="settings.magnetPosition"
placeholder="730"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'magnetPosition'"
x-text="errors.message"
></div>
</div>
<div>
<label for="sdaPin" class="block text-left text-lg mt-4"
>SDA Pin</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="sdaPin"
x-model="settings.sdaPin"
placeholder="Enter SDA pin"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'sdaPin'"
x-text="errors.message"
></div>
</div>
<div>
<label for="sclPin" class="block text-left text-lg mt-4"
>SCL Pin</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="sclPin"
x-model="settings.sclPin"
placeholder="Enter SCL pin"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'sclPin'"
x-text="errors.message"
></div>
</div>
<div>
<label
for="displayOffset"
class="block text-left text-lg mt-4"
>Display Offset</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="displayOffset"
x-model="settings.displayOffset"
placeholder="Enter display offset"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'displayOffset'"
x-text="errors.message"
></div>
</div>
<div>
<label
for="stepsPerRot"
class="block text-left text-lg mt-4"
>Steps Per Rotation</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="stepsPerRot"
x-model="settings.stepsPerRot"
placeholder="Enter steps per rotation"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'stepsPerRot'"
x-text="errors.message"
></div>
</div>
<div>
<label for="maxVel" class="block text-left text-lg mt-4"
>Max Velocity</label
>
<input
class="w-full p-3 mt-2 text-lg border border-gray-600 rounded-md text-center bg-neutral-700 text-gray-100"
type="number"
id="maxVel"
step="0.1"
x-model="settings.maxVel"
placeholder="Enter max velocity"
/>
<div
class="w-full p-3 mt-2 text-sm text-white bg-red-700 rounded-md"
x-cloak
x-show="errors.key === 'maxVel'"
x-text="errors.message"
></div>
</div>
</div>
<button
class="w-full p-3 mt-4 text-lg font-semibold text-white bg-red-600 rounded-md hover:bg-red-500 transition-colors"
x-on:click.prevent="reset()"
:disabled="processing"
:class="{'opacity-50 cursor-not-allowed': processing}"
>
Reset to Defaults
</button>
<div class="w-full mt-4" x-data="{ showDebug: false }">
<a
href="#"
class="w-full p-3 text-xs font-semibold text-white bg-neutral-600 rounded-md hover:bg-neutral-500 transition-colors flex justify-between items-center"
x-on:click.prevent="showDebug = !showDebug"
>
<span class="flex-1 text-left">Debugging Info</span>
<span
class="flex-none"
x-text="showDebug ? '▲' : '▼'"
></span>
</a>
<div x-show="showDebug" class="mt-2">
<pre
class="w-full p-3 text-sm bg-neutral-700 text-gray-100 rounded-md overflow-auto text-left"
x-text="JSON.stringify(settings, null, 2)"
></pre>
</div>
</div>
</div>
<div class="flex items-center justify-between w-full my-6">
<a
href="index.html"
class="p-3 w-1/3 text-lg font-semibold text-white hover:text-amber-600 transition-colors"
>
Back
</a>
<button
class="w-2/3 p-3 text-lg font-semibold text-white bg-green-600 rounded-md hover:bg-green-500 transition-colors"
x-on:click.prevent="save()"
disabled
:disabled="processing"
:class="{'opacity-50 cursor-not-allowed': processing}"
>
Save Settings
</button>
</div>
</div>
<div
class="fixed top-4 left-1/2 transform -translate-x-1/2 p-4 text-white rounded-md transition duration-300"
:class="{'bg-green-600': dialog.type === 'success', 'bg-red-600': dialog.type === 'error'}"
x-show="dialog.show"
x-text="dialog.message"
x-cloak
></div>
<!-- Help Modal -->
<div
x-data="helpModal"
x-show="visible"
@open-help.window="open($event.detail)"
x-cloak
class="fixed inset-0 z-50 flex items-center justify-center backdrop-blur bg-black/50 shadow-[0_0_30px_10px_#222]"
>
<div
class="bg-neutral-800 text-white rounded-lg shadow-lg p-6 max-w-md w-full relative"
@click.outside="close()"
>
<h2 class="text-xl font-bold mb-4" x-text="title"></h2>
<div
class="text-sm leading-relaxed space-y-1"
x-html="content"
></div>
<button
class="absolute top-2 right-2 text-gray-400 hover:text-white"
@click="close()"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="w-5 h-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
</div>
</div>
</body>
</html>