1
0

settings.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. {% extends "base.html" %} {% block title %}Settings - {{ app_name or 'Dune Weaver' }}{%
  2. endblock %}
  3. {% block additional_styles %}
  4. /* Dark mode styles for settings page */
  5. .dark .bg-white {
  6. background-color: #262626;
  7. }
  8. .dark .text-slate-900 {
  9. color: #ffffff;
  10. }
  11. .dark .text-slate-800 {
  12. color: #f8fafc;
  13. }
  14. .dark .text-slate-700 {
  15. color: #f1f5f9;
  16. }
  17. .dark .text-slate-600 {
  18. color: #e2e8f0;
  19. }
  20. .dark .text-slate-500 {
  21. color: #e2e8f0;
  22. }
  23. /* Label overrides for better visibility */
  24. .dark label {
  25. color: #f1f5f9;
  26. }
  27. .dark .border-slate-200 {
  28. border-color: #404040;
  29. }
  30. .dark .border-slate-300 {
  31. border-color: #404040;
  32. }
  33. .dark .divide-slate-100 {
  34. border-color: #404040;
  35. }
  36. .dark .bg-slate-50 {
  37. background-color: #262626;
  38. }
  39. .dark .hover\:bg-slate-50:hover {
  40. background-color: #404040;
  41. }
  42. .dark .bg-slate-100 {
  43. background-color: #404040;
  44. }
  45. .dark .form-input,
  46. .dark input[type="number"],
  47. .dark input[type="text"] {
  48. background-color: #1f1f1f;
  49. border-color: #404040;
  50. color: #e5e5e5;
  51. }
  52. .dark .form-input::placeholder {
  53. color: #9ca3af;
  54. }
  55. .dark .form-input:focus {
  56. border-color: #0c7ff2;
  57. ring-color: #0c7ff2;
  58. }
  59. .dark .form-select {
  60. background-color: #1f1f1f;
  61. border-color: #404040;
  62. color: #e5e5e5;
  63. }
  64. .dark .form-select:focus {
  65. border-color: #0c7ff2;
  66. ring-color: #0c7ff2;
  67. }
  68. .dark .focus\:ring-sky-500:focus {
  69. ring-color: #0c7ff2;
  70. }
  71. .dark .focus\:border-sky-500:focus {
  72. border-color: #0c7ff2;
  73. }
  74. .dark .hover\:text-gray-700:hover {
  75. color: #e5e5e5;
  76. }
  77. .dark .text-gray-400 {
  78. color: #9ca3af;
  79. }
  80. /* Autocomplete suggestions dark mode */
  81. .dark #clearFromInSuggestions,
  82. .dark #clearFromOutSuggestions {
  83. background-color: #262626;
  84. border-color: #404040;
  85. }
  86. .dark .suggestion-item {
  87. color: #e5e5e5;
  88. }
  89. .dark .suggestion-item:hover {
  90. background-color: #404040;
  91. }
  92. .dark .suggestion-item.selected {
  93. background-color: #0c7ff2;
  94. color: white;
  95. }
  96. /* Light mode autocomplete styles */
  97. .suggestion-item {
  98. padding: 8px 12px;
  99. cursor: pointer;
  100. color: #1f2937;
  101. transition: background-color 0.15s;
  102. }
  103. .suggestion-item:hover {
  104. background-color: #f3f4f6;
  105. }
  106. .suggestion-item.selected {
  107. background-color: #0c7ff2;
  108. color: white;
  109. }
  110. .suggestion-item mark {
  111. background-color: #fef3c7;
  112. font-weight: 600;
  113. }
  114. .dark .suggestion-item mark {
  115. background-color: #92400e;
  116. color: #fef3c7;
  117. }
  118. /* Toggle switch styles */
  119. .switch {
  120. position: relative;
  121. display: inline-block;
  122. width: 60px;
  123. height: 34px;
  124. }
  125. .switch input {
  126. opacity: 0;
  127. width: 0;
  128. height: 0;
  129. }
  130. .slider {
  131. position: absolute;
  132. cursor: pointer;
  133. top: 0;
  134. left: 0;
  135. right: 0;
  136. bottom: 0;
  137. background-color: #ccc;
  138. transition: .4s;
  139. }
  140. .slider:before {
  141. position: absolute;
  142. content: "";
  143. height: 26px;
  144. width: 26px;
  145. left: 4px;
  146. bottom: 4px;
  147. background-color: white;
  148. transition: .4s;
  149. }
  150. input:checked + .slider {
  151. background-color: #0c7ff2;
  152. }
  153. input:focus + .slider {
  154. box-shadow: 0 0 1px #0c7ff2;
  155. }
  156. input:checked + .slider:before {
  157. transform: translateX(26px);
  158. }
  159. .slider.round {
  160. border-radius: 34px;
  161. }
  162. .slider.round:before {
  163. border-radius: 50%;
  164. }
  165. /* Dark mode for switches */
  166. .dark .slider {
  167. background-color: #404040;
  168. }
  169. .dark input:checked + .slider {
  170. background-color: #0c7ff2;
  171. }
  172. /* Spin animation for loading states */
  173. @keyframes spin {
  174. from {
  175. transform: rotate(0deg);
  176. }
  177. to {
  178. transform: rotate(360deg);
  179. }
  180. }
  181. .animate-spin {
  182. animation: spin 1s linear infinite;
  183. }
  184. /* Time slot specific styles */
  185. .time-slot-item {
  186. background-color: #f8fafc;
  187. border: 1px solid #e2e8f0;
  188. border-radius: 8px;
  189. padding: 16px;
  190. transition: all 0.15s;
  191. }
  192. .dark .time-slot-item {
  193. background-color: #1e293b;
  194. border-color: #475569;
  195. }
  196. .time-slot-item:hover {
  197. border-color: #cbd5e1;
  198. }
  199. .dark .time-slot-item:hover {
  200. border-color: #64748b;
  201. }
  202. /* Info box dark mode - grey theme */
  203. .dark .bg-blue-50 {
  204. background-color: #1f1f1f;
  205. }
  206. .dark .border-blue-200 {
  207. border-color: #404040;
  208. }
  209. .dark .text-blue-600 {
  210. color: #e2e8f0;
  211. }
  212. .dark .text-blue-800 {
  213. color: #f1f5f9;
  214. }
  215. .dark .text-blue-700 {
  216. color: #e2e8f0;
  217. }
  218. /* Amber box dark mode - grey theme */
  219. .dark .bg-amber-50 {
  220. background-color: #1f1f1f;
  221. }
  222. .dark .border-amber-200 {
  223. border-color: #404040;
  224. }
  225. .dark .text-amber-600 {
  226. color: #f1f5f9;
  227. }
  228. {% endblock %}
  229. {% block content %}
  230. <div class="layout-content-container flex flex-col w-full max-w-4xl gap-8 pt-2 pb-[75px]">
  231. <div
  232. class="flex flex-wrap justify-between items-center p-4 bg-white rounded-xl shadow-sm mt-2 sm:mt-8"
  233. >
  234. <h1
  235. class="text-slate-900 tracking-tight text-2xl sm:text-3xl font-bold leading-tight"
  236. >
  237. Settings
  238. </h1>
  239. </div>
  240. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  241. <h2
  242. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  243. >
  244. Device Connection
  245. </h2>
  246. <div class="divide-y divide-slate-100">
  247. <div
  248. class="flex items-center gap-4 px-6 py-5 hover:bg-slate-50 transition-colors"
  249. >
  250. <div
  251. class="text-slate-600 flex items-center justify-center rounded-lg bg-slate-100 shrink-0 size-12"
  252. >
  253. <span class="material-icons text-3xl">usb_off</span>
  254. </div>
  255. <div class="flex-1">
  256. <p class="text-slate-800 text-base font-medium leading-normal">
  257. Status
  258. </p>
  259. <p
  260. id="serialStatus"
  261. class="text-red-500 text-sm font-medium leading-normal"
  262. >
  263. Disconnected
  264. </p>
  265. </div>
  266. <button
  267. id="disconnectButton"
  268. class="text-xs font-medium text-slate-600 bg-red-100 hover:bg-red-200 text-red-700 px-3 py-1.5 rounded-md transition-colors"
  269. hidden
  270. >
  271. Disconnect
  272. </button>
  273. </div>
  274. <div id="portSelectionDiv" class="px-6 py-5 space-y-4">
  275. <label class="flex flex-col gap-1.5">
  276. <span class="text-slate-700 text-sm font-medium leading-normal"
  277. >Available Serial Ports</span
  278. >
  279. <div class="flex gap-3 items-center">
  280. <select
  281. id="portSelect"
  282. class="form-select flex-1 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-medium leading-normal transition-colors "
  283. >
  284. <option value="">Select a port...</option>
  285. </select>
  286. <button
  287. id="connectButton"
  288. class="flex items-center justify-center gap-2 min-w-[100px] cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors flex-shrink-0"
  289. >
  290. <span class="material-icons text-lg">cable</span>
  291. <span class="truncate">Connect</span>
  292. </button>
  293. </div>
  294. <p class="text-xs text-slate-500 mt-2">
  295. Select a port and click 'Connect' to establish a connection.
  296. </p>
  297. </label>
  298. </div>
  299. </div>
  300. </section>
  301. <!-- Desert Compass Section (hidden unless advanced calibration enabled) -->
  302. <section id="desertCompassSection" class="bg-white rounded-xl shadow-sm overflow-hidden" style="display: none;">
  303. <h2
  304. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  305. >
  306. Desert Compass
  307. </h2>
  308. <div class="px-6 py-5 space-y-6">
  309. <div class="flex items-center justify-between">
  310. <div class="flex-1">
  311. <h3 class="text-slate-700 text-base font-medium leading-normal flex items-center gap-2">
  312. <span class="material-icons text-slate-600">explore</span>
  313. Enable Desert Compass (Raspberry Pi Only)
  314. </h3>
  315. <p class="text-xs text-slate-500 mt-1">
  316. Use a reed switch and magnet to establish a precise angular reference point for the table's rotation.
  317. </p>
  318. </div>
  319. <label class="switch">
  320. <input type="checkbox" id="angularHomingToggle">
  321. <span class="slider round"></span>
  322. </label>
  323. </div>
  324. <!-- GPIO Pin Selection (shown when Desert Compass is enabled) -->
  325. <div id="gpioSelectionContainer" class="space-y-2" style="display: none;">
  326. <label for="gpioInput" class="text-sm font-medium text-slate-700 flex items-center gap-2">
  327. <span class="material-icons text-slate-600 text-base">settings_input_component</span>
  328. Reed Switch GPIO Pin
  329. </label>
  330. <input
  331. type="number"
  332. id="gpioInput"
  333. min="2"
  334. max="27"
  335. step="1"
  336. value="18"
  337. class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-sky-500 text-sm"
  338. placeholder="18"
  339. />
  340. <p class="text-xs text-slate-500">
  341. GPIO pin number (BCM numbering) where the reed switch is connected. Common pins: 17, 18, 22, 23, 24, 25, 27.
  342. </p>
  343. </div>
  344. <!-- Invert State Toggle (shown when Desert Compass is enabled) -->
  345. <div id="invertStateContainer" class="space-y-2" style="display: none;">
  346. <div class="flex items-center justify-between p-3 bg-slate-50 rounded-lg">
  347. <div class="flex-1">
  348. <label for="invertStateToggle" class="text-sm font-medium text-slate-700 flex items-center gap-2 cursor-pointer">
  349. <span class="material-icons text-slate-600 text-base">swap_vert</span>
  350. Invert Sensor Logic
  351. </label>
  352. <p class="text-xs text-slate-500 mt-1">
  353. Enable if your reed switch is triggered when LOW instead of HIGH (normally closed configuration).
  354. </p>
  355. </div>
  356. <label class="switch">
  357. <input type="checkbox" id="invertStateToggle">
  358. <span class="slider round"></span>
  359. </label>
  360. </div>
  361. </div>
  362. <!-- Compass Calibration (shown when Desert Compass is enabled) -->
  363. <div id="angularOffsetContainer" class="space-y-2" style="display: none;">
  364. <label for="angularOffsetInput" class="text-sm font-medium text-slate-700 flex items-center gap-2">
  365. <span class="material-icons text-slate-600 text-base">straighten</span>
  366. Compass Reference Point (degrees)
  367. </label>
  368. <input
  369. type="number"
  370. id="angularOffsetInput"
  371. min="0"
  372. max="360"
  373. step="0.1"
  374. value="0"
  375. class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-sky-500 text-sm"
  376. placeholder="0.0"
  377. />
  378. <p class="text-xs text-slate-500">
  379. Set the angle (in degrees) where your magnet/sensor is physically mounted. 0° = East, increases clockwise (90° = South, 180° = West, 270° = North).
  380. </p>
  381. </div>
  382. <div id="angularHomingInfo" class="text-xs text-slate-600 bg-blue-50 border border-blue-200 rounded-lg p-3" style="display: none;">
  383. <div class="flex items-start gap-2">
  384. <span class="material-icons text-blue-600 text-base">info</span>
  385. <div>
  386. <p class="font-medium text-blue-800">How Desert Compass Works:</p>
  387. <ul class="mt-1 space-y-1 text-blue-700">
  388. <li>• After radial calibration, the arm moves to the table's edge</li>
  389. <li>• The table rotates until the magnet triggers the reed switch</li>
  390. <li>• This position becomes the angular reference point based on your compass setting</li>
  391. <li>• Requires Raspberry Pi with reed switch connected to selected GPIO pin</li>
  392. <li>• Standard wiring: Reed switch to 3.3V (triggered = HIGH)</li>
  393. <li>• Inverted wiring: Reed switch to ground (triggered = LOW)</li>
  394. <li>• Uses BCM GPIO numbering (not physical pin numbers)</li>
  395. </ul>
  396. </div>
  397. </div>
  398. </div>
  399. <div class="flex justify-end">
  400. <button
  401. id="saveHomingConfig"
  402. class="flex items-center justify-center gap-2 min-w-[140px] cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors"
  403. >
  404. <span class="material-icons text-lg">save</span>
  405. <span class="truncate">Save Compass Config</span>
  406. </button>
  407. </div>
  408. </div>
  409. </section>
  410. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  411. <h2
  412. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  413. >
  414. Application Settings
  415. </h2>
  416. <div class="px-6 py-5 space-y-6">
  417. <label class="flex flex-col gap-1.5">
  418. <span class="text-slate-700 text-sm font-medium leading-normal"
  419. >Application Name</span
  420. >
  421. <div class="flex gap-3 items-center">
  422. <div class="relative flex-1">
  423. <input
  424. id="appNameInput"
  425. class="form-input flex w-full min-w-0 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 pr-10 text-base font-normal leading-normal transition-colors"
  426. placeholder="e.g., Dune Weaver"
  427. value="Dune Weaver"
  428. />
  429. <button
  430. type="button"
  431. onclick="document.getElementById('appNameInput').value='Dune Weaver';"
  432. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700"
  433. aria-label="Reset to default"
  434. title="Reset to default"
  435. >
  436. <span class="material-icons">restart_alt</span>
  437. </button>
  438. </div>
  439. <button
  440. id="saveAppName"
  441. class="flex items-center justify-center gap-2 min-w-[140px] cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors flex-shrink-0"
  442. >
  443. <span class="material-icons text-lg">save</span>
  444. <span class="truncate">Save Name</span>
  445. </button>
  446. </div>
  447. <p class="text-xs text-slate-500 mt-2">
  448. This name will appear in the browser tab and at the top of every page.
  449. </p>
  450. </label>
  451. </div>
  452. </section>
  453. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  454. <h2
  455. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  456. >
  457. Pattern Clearing
  458. </h2>
  459. <div class="px-6 py-5 space-y-6">
  460. <p class="text-sm text-slate-600">
  461. Customize the clearing behavior used when transitioning between patterns. Set custom patterns and speed to control how sand is distributed.
  462. </p>
  463. <!-- Clearing Speed Section -->
  464. <div class="bg-slate-50 rounded-lg p-4 space-y-4">
  465. <h3 class="text-slate-800 text-base font-semibold">Clearing Speed</h3>
  466. <p class="text-sm text-slate-600">
  467. Set a custom speed for clearing patterns. Leave empty to use the default pattern speed. This allows clearing patterns to run at a different speed than regular patterns.
  468. </p>
  469. <div class="flex flex-col gap-1.5">
  470. <label for="clearPatternSpeedInput" class="text-slate-700 text-sm font-medium leading-normal">
  471. Speed (steps per minute)
  472. </label>
  473. <div class="flex gap-3 items-center">
  474. <input
  475. id="clearPatternSpeedInput"
  476. type="number"
  477. min="50"
  478. max="2000"
  479. step="50"
  480. class="form-input flex-1 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-normal leading-normal transition-colors"
  481. placeholder="Default (use pattern speed)"
  482. value=""
  483. />
  484. <button
  485. id="saveClearSpeed"
  486. class="flex items-center justify-center gap-2 min-w-[120px] cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors"
  487. >
  488. <span class="material-icons text-lg">save</span>
  489. <span class="truncate">Save Speed</span>
  490. </button>
  491. </div>
  492. <div id="effectiveClearSpeed" class="text-xs text-slate-500 mt-1"></div>
  493. </div>
  494. </div>
  495. <!-- Custom Patterns Section -->
  496. <div class="bg-slate-50 rounded-lg p-4 space-y-4">
  497. <h3 class="text-slate-800 text-base font-semibold">Custom Clear Patterns</h3>
  498. <p class="text-sm text-slate-600">
  499. Choose specific patterns to use when clearing. Leave empty to use the default clearing behavior.
  500. </p>
  501. <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
  502. <div class="flex flex-col gap-1.5">
  503. <label for="customClearFromInInput" class="text-slate-700 text-sm font-medium leading-normal">Clear From Center Pattern</label>
  504. <div class="relative">
  505. <input
  506. id="customClearFromInInput"
  507. type="text"
  508. class="form-input w-full resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 pr-10 text-base font-normal leading-normal transition-colors"
  509. placeholder="Type to search patterns or leave empty for default"
  510. autocomplete="off"
  511. />
  512. <button
  513. type="button"
  514. id="clearFromInClear"
  515. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hidden"
  516. aria-label="Clear selection"
  517. title="Clear selection"
  518. >
  519. <span class="material-icons text-xl">close</span>
  520. </button>
  521. <div id="clearFromInSuggestions" class="absolute z-10 w-full mt-1 bg-white border border-slate-300 rounded-lg shadow-lg max-h-60 overflow-y-auto hidden"></div>
  522. </div>
  523. <p class="text-xs text-slate-500 mt-1">
  524. Pattern to use when clearing from the center outward.
  525. </p>
  526. </div>
  527. <div class="flex flex-col gap-1.5">
  528. <label for="customClearFromOutInput" class="text-slate-700 text-sm font-medium leading-normal">Clear From Perimeter Pattern</label>
  529. <div class="relative">
  530. <input
  531. id="customClearFromOutInput"
  532. type="text"
  533. class="form-input w-full resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 pr-10 text-base font-normal leading-normal transition-colors"
  534. placeholder="Type to search patterns or leave empty for default"
  535. autocomplete="off"
  536. />
  537. <button
  538. type="button"
  539. id="clearFromOutClear"
  540. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hidden"
  541. aria-label="Clear selection"
  542. title="Clear selection"
  543. >
  544. <span class="material-icons text-xl">close</span>
  545. </button>
  546. <div id="clearFromOutSuggestions" class="absolute z-10 w-full mt-1 bg-white border border-slate-300 rounded-lg shadow-lg max-h-60 overflow-y-auto hidden"></div>
  547. </div>
  548. <p class="text-xs text-slate-500 mt-1">
  549. Pattern to use when clearing from the perimeter inward.
  550. </p>
  551. </div>
  552. </div>
  553. <div class="flex justify-end">
  554. <button
  555. id="saveClearPatterns"
  556. class="flex items-center justify-center gap-2 min-w-[140px] cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors"
  557. >
  558. <span class="material-icons text-lg">save</span>
  559. <span class="truncate">Save Patterns</span>
  560. </button>
  561. </div>
  562. </div>
  563. </div>
  564. </section>
  565. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  566. <h2
  567. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  568. >
  569. LED Controller Configuration
  570. </h2>
  571. <div class="px-6 py-5 space-y-6">
  572. <!-- LED Provider Selection -->
  573. <div class="flex flex-col gap-2">
  574. <span class="text-slate-700 text-sm font-medium leading-normal">LED Provider</span>
  575. <div class="flex gap-3">
  576. <label class="flex items-center gap-2 cursor-pointer">
  577. <input type="radio" name="ledProvider" value="none" id="ledProviderNone" class="w-4 h-4 text-sky-600 border-slate-300 focus:ring-sky-500">
  578. <span class="text-sm text-slate-700">None</span>
  579. </label>
  580. <label class="flex items-center gap-2 cursor-pointer">
  581. <input type="radio" name="ledProvider" value="wled" id="ledProviderWled" class="w-4 h-4 text-sky-600 border-slate-300 focus:ring-sky-500">
  582. <span class="text-sm text-slate-700">WLED</span>
  583. </label>
  584. <label class="flex items-center gap-2 cursor-pointer">
  585. <input type="radio" name="ledProvider" value="dw_leds" id="ledProviderDwLeds" class="w-4 h-4 text-sky-600 border-slate-300 focus:ring-sky-500">
  586. <span class="text-sm text-slate-700">DW LEDs (Local GPIO)</span>
  587. </label>
  588. </div>
  589. <p class="text-xs text-slate-500">
  590. Select your LED control system (settings are mutually exclusive)
  591. </p>
  592. </div>
  593. <!-- WLED Configuration (shown when WLED is selected) -->
  594. <div id="wledConfig" class="flex flex-col gap-4 hidden">
  595. <label class="flex flex-col gap-1.5">
  596. <span class="text-slate-700 text-sm font-medium leading-normal">WLED IP Address</span>
  597. <div class="relative flex-1">
  598. <input
  599. id="wledIpInput"
  600. class="form-input flex w-full min-w-0 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 pr-10 text-base font-normal leading-normal transition-colors"
  601. placeholder="e.g., 192.168.1.100"
  602. value=""
  603. />
  604. <button
  605. type="button"
  606. onclick="document.getElementById('wledIpInput').value='';"
  607. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700"
  608. aria-label="Clear WLED IP"
  609. >
  610. <span class="material-icons">close</span>
  611. </button>
  612. </div>
  613. <p class="text-xs text-slate-500">
  614. Enter the IP address of your WLED controller
  615. </p>
  616. </label>
  617. </div>
  618. <!-- DW LEDs Configuration (shown when DW LEDs is selected) -->
  619. <div id="dwLedsConfig" class="flex flex-col gap-4 hidden">
  620. <div class="bg-blue-50 border border-blue-200 rounded-lg p-3">
  621. <div class="flex items-start gap-2">
  622. <span class="material-icons text-blue-600 text-base">info</span>
  623. <div class="text-xs text-blue-700">
  624. <p class="font-medium text-blue-800">Supported LED Strips: WS281x Only</p>
  625. <p class="mt-1">Compatible with WS2811, WS2812, WS2812B, WS2813, WS2815 (12V), and other WS281x RGB LED strips. RGBW strips (SK6812, SK6812W) are not supported.</p>
  626. </div>
  627. </div>
  628. </div>
  629. <label class="flex flex-col gap-1.5">
  630. <span class="text-slate-700 text-sm font-medium leading-normal">Number of LEDs</span>
  631. <input
  632. id="dwLedNumLeds"
  633. type="number"
  634. class="form-input flex w-full min-w-0 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-normal leading-normal transition-colors"
  635. placeholder="60"
  636. value="60"
  637. min="1"
  638. max="1000"
  639. />
  640. <p class="text-xs text-slate-500">
  641. Total number of LEDs in your WS281x strip
  642. </p>
  643. </label>
  644. <label class="flex flex-col gap-1.5">
  645. <span class="text-slate-700 text-sm font-medium leading-normal">GPIO Pin</span>
  646. <select
  647. id="dwLedGpioPin"
  648. class="form-select flex w-full min-w-0 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 px-4 text-base font-normal leading-normal transition-colors"
  649. >
  650. <option value="12">GPIO 12 (PWM0)</option>
  651. <option value="13">GPIO 13 (PWM1)</option>
  652. <option value="18">GPIO 18 (PWM0)</option>
  653. <option value="19">GPIO 19 (PWM1)</option>
  654. </select>
  655. <p class="text-xs text-slate-500">
  656. Select a PWM-capable GPIO pin for WS281x timing
  657. </p>
  658. </label>
  659. <label class="flex flex-col gap-1.5">
  660. <span class="text-slate-700 text-sm font-medium leading-normal">Pixel Color Order (WS281x)</span>
  661. <select
  662. id="dwLedPixelOrder"
  663. class="form-select flex w-full min-w-0 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 px-4 text-base font-normal leading-normal transition-colors"
  664. >
  665. <option value="GRB" selected>GRB - WS2812/WS2812B (most common)</option>
  666. <option value="RGB">RGB - WS2815/WS2811 and some variants</option>
  667. <option value="BGR">BGR - Some WS2811 variants</option>
  668. <option value="RBG">RBG - Rare variant</option>
  669. <option value="GBR">GBR - Rare variant</option>
  670. <option value="BRG">BRG - Rare variant</option>
  671. </select>
  672. <p class="text-xs text-slate-500">
  673. Most WS2812B and WS2815 strips use GRB. WS2811 often uses RGB. If colors appear wrong, try different orders.
  674. </p>
  675. </label>
  676. </div>
  677. <!-- Save Button -->
  678. <button
  679. id="saveLedConfig"
  680. class="flex items-center justify-center gap-2 w-full sm:w-auto cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors"
  681. >
  682. <span class="material-icons text-lg">save</span>
  683. <span class="truncate">Save LED Configuration</span>
  684. </button>
  685. </div>
  686. </section>
  687. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  688. <h2
  689. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  690. >
  691. Auto-play on Boot
  692. </h2>
  693. <div class="px-6 py-5 space-y-6">
  694. <div class="flex items-center justify-between">
  695. <div class="flex-1">
  696. <h3 class="text-slate-700 text-base font-medium leading-normal">Enable Auto-play on Boot</h3>
  697. <p class="text-xs text-slate-500 mt-1">
  698. Automatically start playing a selected playlist when the system boots up.
  699. </p>
  700. </div>
  701. <label class="switch">
  702. <input type="checkbox" id="auto_playModeToggle">
  703. <span class="slider round"></span>
  704. </label>
  705. </div>
  706. <div id="auto_playSettings" class="space-y-4" style="display: none;">
  707. <label class="flex flex-col gap-1.5">
  708. <span class="text-slate-700 text-sm font-medium leading-normal">Startup Playlist</span>
  709. <select
  710. id="auto_playPlaylistSelect"
  711. class="form-select flex-1 resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-medium leading-normal transition-colors"
  712. >
  713. <option value="">Select a playlist...</option>
  714. </select>
  715. <p class="text-xs text-slate-500 mt-1">
  716. Choose which playlist to automatically play when the system starts.
  717. </p>
  718. </label>
  719. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  720. <label class="flex flex-col gap-1.5">
  721. <span class="text-slate-700 text-sm font-medium leading-normal">Run Mode</span>
  722. <select
  723. id="auto_playRunModeSelect"
  724. class="form-select resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-medium leading-normal transition-colors"
  725. >
  726. <option value="single">Single (play once)</option>
  727. <option value="loop">Loop (repeat forever)</option>
  728. </select>
  729. <p class="text-xs text-slate-500 mt-1">
  730. How to run the playlist when it finishes.
  731. </p>
  732. </label>
  733. <label class="flex flex-col gap-1.5">
  734. <span class="text-slate-700 text-sm font-medium leading-normal">Pause Between Patterns (seconds)</span>
  735. <input
  736. id="auto_playPauseTimeInput"
  737. type="number"
  738. min="0"
  739. step="0.5"
  740. class="form-input resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-normal leading-normal transition-colors"
  741. placeholder="5.0"
  742. />
  743. <p class="text-xs text-slate-500 mt-1">
  744. Time to wait between each pattern (0 or more seconds).
  745. </p>
  746. </label>
  747. </div>
  748. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  749. <label class="flex flex-col gap-1.5">
  750. <span class="text-slate-700 text-sm font-medium leading-normal">Clear Pattern</span>
  751. <select
  752. id="auto_playClearPatternSelect"
  753. class="form-select resize-none overflow-hidden rounded-lg text-slate-900 focus:outline-0 focus:ring-2 focus:ring-sky-500 border border-slate-300 bg-white focus:border-sky-500 h-10 placeholder:text-slate-400 px-4 text-base font-medium leading-normal transition-colors"
  754. >
  755. <option value="none">None</option>
  756. <option value="adaptive">Adaptive</option>
  757. <option value="clear_from_in">Clear From Center</option>
  758. <option value="clear_from_out">Clear From Perimeter</option>
  759. <option value="clear_sideway">Clear Sideway</option>
  760. <option value="random">Random</option>
  761. </select>
  762. <p class="text-xs text-slate-500 mt-1">
  763. Pattern to run before each main pattern.
  764. </p>
  765. </label>
  766. <div class="flex items-center justify-between">
  767. <div class="flex-1">
  768. <h4 class="text-slate-700 text-sm font-medium leading-normal">Shuffle Playlist</h4>
  769. <p class="text-xs text-slate-500 mt-1">
  770. Randomize the order of patterns in the playlist.
  771. </p>
  772. </div>
  773. <label class="switch">
  774. <input type="checkbox" id="auto_playShuffleToggle">
  775. <span class="slider round"></span>
  776. </label>
  777. </div>
  778. </div>
  779. </div>
  780. </div>
  781. </section>
  782. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  783. <h2
  784. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  785. >
  786. Still Sands
  787. </h2>
  788. <div class="px-6 py-5 space-y-6">
  789. <div class="flex items-center justify-between">
  790. <div class="flex-1">
  791. <h3 class="text-slate-700 text-base font-medium leading-normal">Enable Still Sands</h3>
  792. <p class="text-xs text-slate-500 mt-1">
  793. Automatically bring the sands to rest during specified time periods.
  794. </p>
  795. </div>
  796. <label class="switch">
  797. <input type="checkbox" id="scheduledPauseToggle">
  798. <span class="slider round"></span>
  799. </label>
  800. </div>
  801. <div id="scheduledPauseSettings" class="space-y-4" style="display: none;">
  802. <!-- WLED Control Option -->
  803. <div class="bg-amber-50 rounded-lg p-4 border border-amber-200">
  804. <div class="flex items-center justify-between">
  805. <div class="flex-1">
  806. <h4 class="text-slate-800 text-sm font-medium flex items-center gap-2">
  807. <span class="material-icons text-amber-600 text-base">lightbulb</span>
  808. Control WLED Lights
  809. </h4>
  810. <p class="text-xs text-slate-600 mt-1">
  811. Turn off WLED lights during still periods for complete rest
  812. </p>
  813. </div>
  814. <label class="switch">
  815. <input type="checkbox" id="stillSandsWledControl">
  816. <span class="slider round"></span>
  817. </label>
  818. </div>
  819. </div>
  820. <div class="bg-slate-50 rounded-lg p-4 space-y-4">
  821. <div class="flex items-center justify-between">
  822. <h4 class="text-slate-800 text-base font-semibold">Still Periods</h4>
  823. <button
  824. id="addTimeSlotButton"
  825. class="flex items-center justify-center gap-2 cursor-pointer rounded-lg h-9 px-3 bg-sky-600 hover:bg-sky-700 text-white text-xs font-medium leading-normal tracking-[0.015em] transition-colors"
  826. >
  827. <span class="material-icons text-base">add</span>
  828. <span>Add Still Period</span>
  829. </button>
  830. </div>
  831. <p class="text-sm text-slate-600">
  832. Define time periods when the sands should rest in stillness. Patterns will resume automatically when still periods end.
  833. </p>
  834. <div id="timeSlotsContainer" class="space-y-3">
  835. <!-- Time slots will be dynamically added here -->
  836. </div>
  837. <div class="text-xs text-slate-500 bg-blue-50 border border-blue-200 rounded-lg p-3">
  838. <div class="flex items-start gap-2">
  839. <span class="material-icons text-blue-600 text-base">info</span>
  840. <div>
  841. <p class="font-medium text-blue-800">Important Notes:</p>
  842. <ul class="mt-1 space-y-1 text-blue-700">
  843. <li>• Times are based on your system's local time zone</li>
  844. <li>• Currently running patterns will pause immediately when entering a still period</li>
  845. <li>• Patterns will resume automatically when exiting a still period</li>
  846. <li>• Still periods that span midnight (e.g., 22:00 to 06:00) are supported</li>
  847. </ul>
  848. </div>
  849. </div>
  850. </div>
  851. </div>
  852. <div class="flex justify-end">
  853. <button
  854. id="savePauseSettings"
  855. class="flex items-center justify-center gap-2 min-w-[140px] cursor-pointer rounded-lg h-10 px-4 bg-sky-600 hover:bg-sky-700 text-white text-sm font-medium leading-normal tracking-[0.015em] transition-colors"
  856. >
  857. <span class="material-icons text-lg">save</span>
  858. <span class="truncate">Save Still Sands</span>
  859. </button>
  860. </div>
  861. </div>
  862. </div>
  863. </section>
  864. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  865. <h2
  866. class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em] px-6 py-4 border-b border-slate-200"
  867. >
  868. Software Version
  869. </h2>
  870. <div class="divide-y divide-slate-100">
  871. <div class="flex items-center gap-4 px-6 py-5">
  872. <div
  873. class="text-slate-600 flex items-center justify-center rounded-lg bg-slate-100 shrink-0 size-12"
  874. >
  875. <span class="material-icons text-3xl">terminal</span>
  876. </div>
  877. <div class="flex-1">
  878. <p class="text-slate-800 text-base font-medium leading-normal">
  879. Current Version
  880. </p>
  881. <p id="currentVersionText" class="text-slate-500 text-sm font-normal leading-normal">Loading...</p>
  882. </div>
  883. </div>
  884. <div class="flex items-center gap-4 px-6 py-5">
  885. <div
  886. class="text-slate-600 flex items-center justify-center rounded-lg bg-slate-100 shrink-0 size-12"
  887. >
  888. <span class="material-icons text-3xl">system_update</span>
  889. </div>
  890. <div class="flex-1">
  891. <p class="text-slate-800 text-base font-medium leading-normal">
  892. Latest Version
  893. </p>
  894. <p id="latestVersionText" class="text-slate-500 text-sm font-normal leading-normal">Checking...</p>
  895. </div>
  896. <button
  897. id="updateSoftware"
  898. class="flex items-center justify-center gap-1.5 min-w-[84px] cursor-pointer rounded-lg h-9 px-3 bg-gray-400 text-white text-xs font-medium leading-normal tracking-[0.015em] transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
  899. disabled
  900. >
  901. <span id="updateIcon" class="material-icons text-base">download</span>
  902. <span id="updateText" class="truncate">Update</span>
  903. </button>
  904. </div>
  905. </div>
  906. </section>
  907. </div>
  908. {% endblock %} {% block scripts %}
  909. <script src="/static/js/settings.js"></script>
  910. {% endblock %}