1
0

settings.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  302. <h2
  303. 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"
  304. >
  305. Desert Compass
  306. </h2>
  307. <div class="px-6 py-5 space-y-6">
  308. <div class="flex items-center justify-between">
  309. <div class="flex-1">
  310. <h3 class="text-slate-700 text-base font-medium leading-normal flex items-center gap-2">
  311. <span class="material-icons text-slate-600">explore</span>
  312. Enable Desert Compass (Raspberry Pi Only)
  313. </h3>
  314. <p class="text-xs text-slate-500 mt-1">
  315. Use a reed switch and magnet to establish a precise angular reference point for the table's rotation.
  316. </p>
  317. </div>
  318. <label class="switch">
  319. <input type="checkbox" id="angularHomingToggle">
  320. <span class="slider round"></span>
  321. </label>
  322. </div>
  323. <!-- GPIO Pin Selection (shown when Desert Compass is enabled) -->
  324. <div id="gpioSelectionContainer" class="space-y-2" style="display: none;">
  325. <label for="gpioInput" class="text-sm font-medium text-slate-700 flex items-center gap-2">
  326. <span class="material-icons text-slate-600 text-base">settings_input_component</span>
  327. Reed Switch GPIO Pin
  328. </label>
  329. <input
  330. type="number"
  331. id="gpioInput"
  332. min="2"
  333. max="27"
  334. step="1"
  335. value="18"
  336. 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"
  337. placeholder="18"
  338. />
  339. <p class="text-xs text-slate-500">
  340. GPIO pin number (BCM numbering) where the reed switch is connected. Common pins: 17, 18, 22, 23, 24, 25, 27.
  341. </p>
  342. </div>
  343. <!-- Invert State Toggle (shown when Desert Compass is enabled) -->
  344. <div id="invertStateContainer" class="space-y-2" style="display: none;">
  345. <div class="flex items-center justify-between p-3 bg-slate-50 rounded-lg">
  346. <div class="flex-1">
  347. <label for="invertStateToggle" class="text-sm font-medium text-slate-700 flex items-center gap-2 cursor-pointer">
  348. <span class="material-icons text-slate-600 text-base">swap_vert</span>
  349. Invert Sensor Logic
  350. </label>
  351. <p class="text-xs text-slate-500 mt-1">
  352. Enable if your reed switch is triggered when LOW instead of HIGH (normally closed configuration).
  353. </p>
  354. </div>
  355. <label class="switch">
  356. <input type="checkbox" id="invertStateToggle">
  357. <span class="slider round"></span>
  358. </label>
  359. </div>
  360. </div>
  361. <!-- Compass Calibration (shown when Desert Compass is enabled) -->
  362. <div id="angularOffsetContainer" class="space-y-2" style="display: none;">
  363. <label for="angularOffsetInput" class="text-sm font-medium text-slate-700 flex items-center gap-2">
  364. <span class="material-icons text-slate-600 text-base">straighten</span>
  365. Compass Reference Point (degrees)
  366. </label>
  367. <input
  368. type="number"
  369. id="angularOffsetInput"
  370. min="0"
  371. max="360"
  372. step="0.1"
  373. value="0"
  374. 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"
  375. placeholder="0.0"
  376. />
  377. <p class="text-xs text-slate-500">
  378. Set the angle (in degrees) where your magnet/sensor is physically mounted. 0° = East, increases clockwise (90° = South, 180° = West, 270° = North).
  379. </p>
  380. </div>
  381. <div id="angularHomingInfo" class="text-xs text-slate-600 bg-blue-50 border border-blue-200 rounded-lg p-3" style="display: none;">
  382. <div class="flex items-start gap-2">
  383. <span class="material-icons text-blue-600 text-base">info</span>
  384. <div>
  385. <p class="font-medium text-blue-800">How Desert Compass Works:</p>
  386. <ul class="mt-1 space-y-1 text-blue-700">
  387. <li>• After radial calibration, the arm moves to the table's edge</li>
  388. <li>• The table rotates until the magnet triggers the reed switch</li>
  389. <li>• This position becomes the angular reference point based on your compass setting</li>
  390. <li>• Requires Raspberry Pi with reed switch connected to selected GPIO pin</li>
  391. <li>• Standard wiring: Reed switch to 3.3V (triggered = HIGH)</li>
  392. <li>• Inverted wiring: Reed switch to ground (triggered = LOW)</li>
  393. <li>• Uses BCM GPIO numbering (not physical pin numbers)</li>
  394. </ul>
  395. </div>
  396. </div>
  397. </div>
  398. <div class="flex justify-end">
  399. <button
  400. id="saveHomingConfig"
  401. 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"
  402. >
  403. <span class="material-icons text-lg">save</span>
  404. <span class="truncate">Save Compass Config</span>
  405. </button>
  406. </div>
  407. </div>
  408. </section>
  409. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  410. <h2
  411. 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"
  412. >
  413. Application Settings
  414. </h2>
  415. <div class="px-6 py-5 space-y-6">
  416. <label class="flex flex-col gap-1.5">
  417. <span class="text-slate-700 text-sm font-medium leading-normal"
  418. >Application Name</span
  419. >
  420. <div class="flex gap-3 items-center">
  421. <div class="relative flex-1">
  422. <input
  423. id="appNameInput"
  424. 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"
  425. placeholder="e.g., Dune Weaver"
  426. value="Dune Weaver"
  427. />
  428. <button
  429. type="button"
  430. onclick="document.getElementById('appNameInput').value='Dune Weaver';"
  431. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700"
  432. aria-label="Reset to default"
  433. title="Reset to default"
  434. >
  435. <span class="material-icons">restart_alt</span>
  436. </button>
  437. </div>
  438. <button
  439. id="saveAppName"
  440. 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"
  441. >
  442. <span class="material-icons text-lg">save</span>
  443. <span class="truncate">Save Name</span>
  444. </button>
  445. </div>
  446. <p class="text-xs text-slate-500 mt-2">
  447. This name will appear in the browser tab and at the top of every page.
  448. </p>
  449. </label>
  450. </div>
  451. </section>
  452. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  453. <h2
  454. 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"
  455. >
  456. Pattern Clearing
  457. </h2>
  458. <div class="px-6 py-5 space-y-6">
  459. <p class="text-sm text-slate-600">
  460. Customize the clearing behavior used when transitioning between patterns. Set custom patterns and speed to control how sand is distributed.
  461. </p>
  462. <!-- Clearing Speed Section -->
  463. <div class="bg-slate-50 rounded-lg p-4 space-y-4">
  464. <h3 class="text-slate-800 text-base font-semibold">Clearing Speed</h3>
  465. <p class="text-sm text-slate-600">
  466. 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.
  467. </p>
  468. <div class="flex flex-col gap-1.5">
  469. <label for="clearPatternSpeedInput" class="text-slate-700 text-sm font-medium leading-normal">
  470. Speed (steps per minute)
  471. </label>
  472. <div class="flex gap-3 items-center">
  473. <input
  474. id="clearPatternSpeedInput"
  475. type="number"
  476. min="50"
  477. max="2000"
  478. step="50"
  479. 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"
  480. placeholder="Default (use pattern speed)"
  481. value=""
  482. />
  483. <button
  484. id="saveClearSpeed"
  485. 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"
  486. >
  487. <span class="material-icons text-lg">save</span>
  488. <span class="truncate">Save Speed</span>
  489. </button>
  490. </div>
  491. <div id="effectiveClearSpeed" class="text-xs text-slate-500 mt-1"></div>
  492. </div>
  493. </div>
  494. <!-- Custom Patterns Section -->
  495. <div class="bg-slate-50 rounded-lg p-4 space-y-4">
  496. <h3 class="text-slate-800 text-base font-semibold">Custom Clear Patterns</h3>
  497. <p class="text-sm text-slate-600">
  498. Choose specific patterns to use when clearing. Leave empty to use the default clearing behavior.
  499. </p>
  500. <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
  501. <div class="flex flex-col gap-1.5">
  502. <label for="customClearFromInInput" class="text-slate-700 text-sm font-medium leading-normal">Clear From Center Pattern</label>
  503. <div class="relative">
  504. <input
  505. id="customClearFromInInput"
  506. type="text"
  507. 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"
  508. placeholder="Type to search patterns or leave empty for default"
  509. autocomplete="off"
  510. />
  511. <button
  512. type="button"
  513. id="clearFromInClear"
  514. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hidden"
  515. aria-label="Clear selection"
  516. title="Clear selection"
  517. >
  518. <span class="material-icons text-xl">close</span>
  519. </button>
  520. <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>
  521. </div>
  522. <p class="text-xs text-slate-500 mt-1">
  523. Pattern to use when clearing from the center outward.
  524. </p>
  525. </div>
  526. <div class="flex flex-col gap-1.5">
  527. <label for="customClearFromOutInput" class="text-slate-700 text-sm font-medium leading-normal">Clear From Perimeter Pattern</label>
  528. <div class="relative">
  529. <input
  530. id="customClearFromOutInput"
  531. type="text"
  532. 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"
  533. placeholder="Type to search patterns or leave empty for default"
  534. autocomplete="off"
  535. />
  536. <button
  537. type="button"
  538. id="clearFromOutClear"
  539. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hidden"
  540. aria-label="Clear selection"
  541. title="Clear selection"
  542. >
  543. <span class="material-icons text-xl">close</span>
  544. </button>
  545. <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>
  546. </div>
  547. <p class="text-xs text-slate-500 mt-1">
  548. Pattern to use when clearing from the perimeter inward.
  549. </p>
  550. </div>
  551. </div>
  552. <div class="flex justify-end">
  553. <button
  554. id="saveClearPatterns"
  555. 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"
  556. >
  557. <span class="material-icons text-lg">save</span>
  558. <span class="truncate">Save Patterns</span>
  559. </button>
  560. </div>
  561. </div>
  562. </div>
  563. </section>
  564. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  565. <h2
  566. 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"
  567. >
  568. LED Controller Configuration
  569. </h2>
  570. <div class="px-6 py-5 space-y-6">
  571. <!-- LED Provider Selection -->
  572. <div class="flex flex-col gap-2">
  573. <span class="text-slate-700 text-sm font-medium leading-normal">LED Provider</span>
  574. <div class="flex gap-3">
  575. <label class="flex items-center gap-2 cursor-pointer">
  576. <input type="radio" name="ledProvider" value="none" id="ledProviderNone" class="w-4 h-4 text-sky-600 border-slate-300 focus:ring-sky-500">
  577. <span class="text-sm text-slate-700">None</span>
  578. </label>
  579. <label class="flex items-center gap-2 cursor-pointer">
  580. <input type="radio" name="ledProvider" value="wled" id="ledProviderWled" class="w-4 h-4 text-sky-600 border-slate-300 focus:ring-sky-500">
  581. <span class="text-sm text-slate-700">WLED</span>
  582. </label>
  583. <label class="flex items-center gap-2 cursor-pointer">
  584. <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">
  585. <span class="text-sm text-slate-700">DW LEDs (Local GPIO)</span>
  586. </label>
  587. </div>
  588. <p class="text-xs text-slate-500">
  589. Select your LED control system (settings are mutually exclusive)
  590. </p>
  591. </div>
  592. <!-- WLED Configuration (shown when WLED is selected) -->
  593. <div id="wledConfig" class="flex flex-col gap-4 hidden">
  594. <label class="flex flex-col gap-1.5">
  595. <span class="text-slate-700 text-sm font-medium leading-normal">WLED IP Address</span>
  596. <div class="relative flex-1">
  597. <input
  598. id="wledIpInput"
  599. 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"
  600. placeholder="e.g., 192.168.1.100"
  601. value=""
  602. />
  603. <button
  604. type="button"
  605. onclick="document.getElementById('wledIpInput').value='';"
  606. class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700"
  607. aria-label="Clear WLED IP"
  608. >
  609. <span class="material-icons">close</span>
  610. </button>
  611. </div>
  612. <p class="text-xs text-slate-500">
  613. Enter the IP address of your WLED controller
  614. </p>
  615. </label>
  616. </div>
  617. <!-- DW LEDs Configuration (shown when DW LEDs is selected) -->
  618. <div id="dwLedsConfig" class="flex flex-col gap-4 hidden">
  619. <div class="bg-blue-50 border border-blue-200 rounded-lg p-3">
  620. <div class="flex items-start gap-2">
  621. <span class="material-icons text-blue-600 text-base">info</span>
  622. <div class="text-xs text-blue-700">
  623. <p class="font-medium text-blue-800">Supported LED Strips: WS281x Only</p>
  624. <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>
  625. </div>
  626. </div>
  627. </div>
  628. <label class="flex flex-col gap-1.5">
  629. <span class="text-slate-700 text-sm font-medium leading-normal">Number of LEDs</span>
  630. <input
  631. id="dwLedNumLeds"
  632. type="number"
  633. 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"
  634. placeholder="60"
  635. value="60"
  636. min="1"
  637. max="1000"
  638. />
  639. <p class="text-xs text-slate-500">
  640. Total number of LEDs in your WS281x strip
  641. </p>
  642. </label>
  643. <label class="flex flex-col gap-1.5">
  644. <span class="text-slate-700 text-sm font-medium leading-normal">GPIO Pin</span>
  645. <select
  646. id="dwLedGpioPin"
  647. 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"
  648. >
  649. <option value="12">GPIO 12 (PWM0)</option>
  650. <option value="13">GPIO 13 (PWM1)</option>
  651. <option value="18">GPIO 18 (PWM0)</option>
  652. <option value="19">GPIO 19 (PWM1)</option>
  653. </select>
  654. <p class="text-xs text-slate-500">
  655. Select a PWM-capable GPIO pin for WS281x timing
  656. </p>
  657. </label>
  658. <label class="flex flex-col gap-1.5">
  659. <span class="text-slate-700 text-sm font-medium leading-normal">Pixel Color Order (WS281x)</span>
  660. <select
  661. id="dwLedPixelOrder"
  662. 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"
  663. >
  664. <option value="GRB" selected>GRB - WS2812/WS2812B (most common)</option>
  665. <option value="RGB">RGB - WS2815/WS2811 and some variants</option>
  666. <option value="BGR">BGR - Some WS2811 variants</option>
  667. <option value="RBG">RBG - Rare variant</option>
  668. <option value="GBR">GBR - Rare variant</option>
  669. <option value="BRG">BRG - Rare variant</option>
  670. </select>
  671. <p class="text-xs text-slate-500">
  672. Most WS2812B and WS2815 strips use GRB. WS2811 often uses RGB. If colors appear wrong, try different orders.
  673. </p>
  674. </label>
  675. </div>
  676. <!-- Save Button -->
  677. <button
  678. id="saveLedConfig"
  679. 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"
  680. >
  681. <span class="material-icons text-lg">save</span>
  682. <span class="truncate">Save LED Configuration</span>
  683. </button>
  684. </div>
  685. </section>
  686. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  687. <h2
  688. 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"
  689. >
  690. Auto-play on Boot
  691. </h2>
  692. <div class="px-6 py-5 space-y-6">
  693. <div class="flex items-center justify-between">
  694. <div class="flex-1">
  695. <h3 class="text-slate-700 text-base font-medium leading-normal">Enable Auto-play on Boot</h3>
  696. <p class="text-xs text-slate-500 mt-1">
  697. Automatically start playing a selected playlist when the system boots up.
  698. </p>
  699. </div>
  700. <label class="switch">
  701. <input type="checkbox" id="auto_playModeToggle">
  702. <span class="slider round"></span>
  703. </label>
  704. </div>
  705. <div id="auto_playSettings" class="space-y-4" style="display: none;">
  706. <label class="flex flex-col gap-1.5">
  707. <span class="text-slate-700 text-sm font-medium leading-normal">Startup Playlist</span>
  708. <select
  709. id="auto_playPlaylistSelect"
  710. 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"
  711. >
  712. <option value="">Select a playlist...</option>
  713. </select>
  714. <p class="text-xs text-slate-500 mt-1">
  715. Choose which playlist to automatically play when the system starts.
  716. </p>
  717. </label>
  718. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  719. <label class="flex flex-col gap-1.5">
  720. <span class="text-slate-700 text-sm font-medium leading-normal">Run Mode</span>
  721. <select
  722. id="auto_playRunModeSelect"
  723. 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"
  724. >
  725. <option value="single">Single (play once)</option>
  726. <option value="loop">Loop (repeat forever)</option>
  727. </select>
  728. <p class="text-xs text-slate-500 mt-1">
  729. How to run the playlist when it finishes.
  730. </p>
  731. </label>
  732. <label class="flex flex-col gap-1.5">
  733. <span class="text-slate-700 text-sm font-medium leading-normal">Pause Between Patterns (seconds)</span>
  734. <input
  735. id="auto_playPauseTimeInput"
  736. type="number"
  737. min="0"
  738. step="0.5"
  739. 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"
  740. placeholder="5.0"
  741. />
  742. <p class="text-xs text-slate-500 mt-1">
  743. Time to wait between each pattern (0 or more seconds).
  744. </p>
  745. </label>
  746. </div>
  747. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  748. <label class="flex flex-col gap-1.5">
  749. <span class="text-slate-700 text-sm font-medium leading-normal">Clear Pattern</span>
  750. <select
  751. id="auto_playClearPatternSelect"
  752. 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"
  753. >
  754. <option value="none">None</option>
  755. <option value="adaptive">Adaptive</option>
  756. <option value="clear_from_in">Clear From Center</option>
  757. <option value="clear_from_out">Clear From Perimeter</option>
  758. <option value="clear_sideway">Clear Sideway</option>
  759. <option value="random">Random</option>
  760. </select>
  761. <p class="text-xs text-slate-500 mt-1">
  762. Pattern to run before each main pattern.
  763. </p>
  764. </label>
  765. <div class="flex items-center justify-between">
  766. <div class="flex-1">
  767. <h4 class="text-slate-700 text-sm font-medium leading-normal">Shuffle Playlist</h4>
  768. <p class="text-xs text-slate-500 mt-1">
  769. Randomize the order of patterns in the playlist.
  770. </p>
  771. </div>
  772. <label class="switch">
  773. <input type="checkbox" id="auto_playShuffleToggle">
  774. <span class="slider round"></span>
  775. </label>
  776. </div>
  777. </div>
  778. </div>
  779. </div>
  780. </section>
  781. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  782. <h2
  783. 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"
  784. >
  785. Still Sands
  786. </h2>
  787. <div class="px-6 py-5 space-y-6">
  788. <div class="flex items-center justify-between">
  789. <div class="flex-1">
  790. <h3 class="text-slate-700 text-base font-medium leading-normal">Enable Still Sands</h3>
  791. <p class="text-xs text-slate-500 mt-1">
  792. Automatically bring the sands to rest during specified time periods.
  793. </p>
  794. </div>
  795. <label class="switch">
  796. <input type="checkbox" id="scheduledPauseToggle">
  797. <span class="slider round"></span>
  798. </label>
  799. </div>
  800. <div id="scheduledPauseSettings" class="space-y-4" style="display: none;">
  801. <!-- WLED Control Option -->
  802. <div class="bg-amber-50 rounded-lg p-4 border border-amber-200">
  803. <div class="flex items-center justify-between">
  804. <div class="flex-1">
  805. <h4 class="text-slate-800 text-sm font-medium flex items-center gap-2">
  806. <span class="material-icons text-amber-600 text-base">lightbulb</span>
  807. Control WLED Lights
  808. </h4>
  809. <p class="text-xs text-slate-600 mt-1">
  810. Turn off WLED lights during still periods for complete rest
  811. </p>
  812. </div>
  813. <label class="switch">
  814. <input type="checkbox" id="stillSandsWledControl">
  815. <span class="slider round"></span>
  816. </label>
  817. </div>
  818. </div>
  819. <div class="bg-slate-50 rounded-lg p-4 space-y-4">
  820. <div class="flex items-center justify-between">
  821. <h4 class="text-slate-800 text-base font-semibold">Still Periods</h4>
  822. <button
  823. id="addTimeSlotButton"
  824. 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"
  825. >
  826. <span class="material-icons text-base">add</span>
  827. <span>Add Still Period</span>
  828. </button>
  829. </div>
  830. <p class="text-sm text-slate-600">
  831. Define time periods when the sands should rest in stillness. Patterns will resume automatically when still periods end.
  832. </p>
  833. <div id="timeSlotsContainer" class="space-y-3">
  834. <!-- Time slots will be dynamically added here -->
  835. </div>
  836. <div class="text-xs text-slate-500 bg-blue-50 border border-blue-200 rounded-lg p-3">
  837. <div class="flex items-start gap-2">
  838. <span class="material-icons text-blue-600 text-base">info</span>
  839. <div>
  840. <p class="font-medium text-blue-800">Important Notes:</p>
  841. <ul class="mt-1 space-y-1 text-blue-700">
  842. <li>• Times are based on your system's local time zone</li>
  843. <li>• Currently running patterns will pause immediately when entering a still period</li>
  844. <li>• Patterns will resume automatically when exiting a still period</li>
  845. <li>• Still periods that span midnight (e.g., 22:00 to 06:00) are supported</li>
  846. </ul>
  847. </div>
  848. </div>
  849. </div>
  850. </div>
  851. <div class="flex justify-end">
  852. <button
  853. id="savePauseSettings"
  854. 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"
  855. >
  856. <span class="material-icons text-lg">save</span>
  857. <span class="truncate">Save Still Sands</span>
  858. </button>
  859. </div>
  860. </div>
  861. </div>
  862. </section>
  863. <section class="bg-white rounded-xl shadow-sm overflow-hidden">
  864. <h2
  865. 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"
  866. >
  867. Software Version
  868. </h2>
  869. <div class="divide-y divide-slate-100">
  870. <div class="flex items-center gap-4 px-6 py-5">
  871. <div
  872. class="text-slate-600 flex items-center justify-center rounded-lg bg-slate-100 shrink-0 size-12"
  873. >
  874. <span class="material-icons text-3xl">terminal</span>
  875. </div>
  876. <div class="flex-1">
  877. <p class="text-slate-800 text-base font-medium leading-normal">
  878. Current Version
  879. </p>
  880. <p id="currentVersionText" class="text-slate-500 text-sm font-normal leading-normal">Loading...</p>
  881. </div>
  882. </div>
  883. <div class="flex items-center gap-4 px-6 py-5">
  884. <div
  885. class="text-slate-600 flex items-center justify-center rounded-lg bg-slate-100 shrink-0 size-12"
  886. >
  887. <span class="material-icons text-3xl">system_update</span>
  888. </div>
  889. <div class="flex-1">
  890. <p class="text-slate-800 text-base font-medium leading-normal">
  891. Latest Version
  892. </p>
  893. <p id="latestVersionText" class="text-slate-500 text-sm font-normal leading-normal">Checking...</p>
  894. </div>
  895. <button
  896. id="updateSoftware"
  897. 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"
  898. disabled
  899. >
  900. <span id="updateIcon" class="material-icons text-base">download</span>
  901. <span id="updateText" class="truncate">Update</span>
  902. </button>
  903. </div>
  904. </div>
  905. </section>
  906. </div>
  907. {% endblock %} {% block scripts %}
  908. <script src="/static/js/settings.js"></script>
  909. {% endblock %}