Wemos D1 Mini Frimware zur Steuerung einer RGBW-LED-Lampe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  2. * HtmlPage.h
  3. *
  4. * Created on: 08.06.2026
  5. * Author: FSmilari
  6. */
  7. #ifndef HTMLPAGES_H_
  8. #define HTMLPAGES_H_
  9. #include <WString.h>
  10. const String getSetupPage(String macAddress) {
  11. String html =
  12. R"rawliteral(
  13. <!DOCTYPE html>
  14. <html>
  15. <script>
  16. function togglePassword() {
  17. const pass = document.getElementById("pass");
  18. const eye = document.querySelector(".toggle-eye");
  19. if (pass.type === "password") {
  20. pass.type = "text";
  21. eye.textContent = "❌";
  22. } else {
  23. pass.type = "password";
  24. eye.textContent = "👁";
  25. }
  26. }
  27. </script>
  28. <head>
  29. <meta name="viewport" content="width=device-width, initial-scale=1">
  30. <title>Wemos LEDLamp Setup</title>
  31. <style>
  32. body {
  33. margin: 0;
  34. font-family: Arial, sans-serif;
  35. background: linear-gradient(135deg, #1e1e2f, #2b5876);
  36. color: white;
  37. display: flex;
  38. justify-content: center;
  39. align-items: center;
  40. height: 100vh;
  41. }
  42. * {
  43. box-sizing: border-box;
  44. }
  45. .card {
  46. background: rgba(255,255,255,0.08);
  47. backdrop-filter: blur(10px);
  48. padding: 25px;
  49. border-radius: 16px;
  50. width: 90%;
  51. max-width: 360px;
  52. box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  53. animation: fadeIn 0.8s ease;
  54. }
  55. h2 {
  56. margin-top: 0;
  57. text-align: center;
  58. }
  59. .info {
  60. font-size: 12px;
  61. opacity: 0.8;
  62. margin-top: 8px;
  63. margin-bottom: 15px;
  64. text-align: center;
  65. }
  66. input {
  67. width: 100%;
  68. padding: 12px;
  69. margin: 8px 0px;
  70. border-radius: 10px;
  71. border: none;
  72. outline: none;
  73. font-size: 14px;
  74. transition: 0.2s;
  75. }
  76. input:focus {
  77. transform: scale(1.02);
  78. }
  79. button {
  80. width: 100%;
  81. padding: 12px;
  82. margin-top: 10px;
  83. border: none;
  84. border-radius: 10px;
  85. background: #00c6ff;
  86. color: white;
  87. font-size: 16px;
  88. cursor: pointer;
  89. transition: 0.3s;
  90. }
  91. button:hover {
  92. background: #0072ff;
  93. transform: translateY(-2px);
  94. }
  95. .mac {
  96. font-size: 11px;
  97. text-align: center;
  98. margin-bottom: 15px;
  99. opacity: 0.7;
  100. word-break: break-all;
  101. }
  102. .pw-wrapper {
  103. position: relative;
  104. width: 100%;
  105. margin: 8px 0;
  106. }
  107. .pw-wrapper input {
  108. width: 100%;
  109. padding: 12px 40px 12px 12px; /* Platz für Icon rechts */
  110. border-radius: 10px;
  111. border: none;
  112. outline: none;
  113. font-size: 14px;
  114. box-sizing: border-box;
  115. }
  116. .toggle-eye {
  117. position: absolute;
  118. right: 12px;
  119. top: 50%;
  120. transform: translateY(-50%);
  121. cursor: pointer;
  122. font-size: 16px;
  123. opacity: 0.6;
  124. user-select: none;
  125. transition: 0.2s;
  126. }
  127. .toggle-eye:hover {
  128. opacity: 1;
  129. }
  130. .bar_white {
  131. background: white;
  132. width: 100%;
  133. height: 3px;
  134. margin-bottom: 20px;
  135. }
  136. .bar_red {
  137. background: red;
  138. width: 100%;
  139. height: 3px;
  140. margin-bottom: 20px;
  141. }
  142. .bar_green {
  143. background: green;
  144. width: 100%;
  145. height: 3px;
  146. margin-bottom: 20px;
  147. }
  148. .bar_blue {
  149. background: blue;
  150. width: 100%;
  151. height: 3px;
  152. margin-bottom: 20px;
  153. }
  154. @keyframes fadeIn {
  155. from {opacity: 0; transform: translateY(10px);}
  156. to {opacity: 1; transform: translateY(0);}
  157. }
  158. </style>
  159. </head>
  160. <body>
  161. <div class="card">
  162. <div style="display: flex">
  163. <div class="bar_green"></div>
  164. <div class="bar_white"></div>
  165. <div class="bar_red"></div>
  166. <div class="bar_blue"></div>
  167. </div>
  168. <h2>Wemos LEDLamp Setup</h2>
  169. <div class="mac">Device: )rawliteral"
  170. + macAddress
  171. + R"rawliteral(</div>
  172. <form action="/save" method="POST">
  173. <input name="ssid" placeholder="WLAN Name (SSID)">
  174. <div class="pw-wrapper">
  175. <input id="pass" name="pass" type="password" placeholder="Passwort">
  176. <span class="toggle-eye" onclick="togglePassword()">👁</span>
  177. </div>
  178. <button type="submit">Speichern & Verbinden</button>
  179. </form>
  180. <div class="info">Verbinde den LEDLamp Wemos mit einem WLAN Netzwerk</div>
  181. </div>
  182. </body>
  183. </html>
  184. )rawliteral";
  185. return html;
  186. }
  187. const String getSTAControlPage(String macAddress) {
  188. String html =
  189. R"rawliteral(
  190. <!DOCTYPE html>
  191. <html>
  192. <head>
  193. <meta charset="UTF-8">
  194. <meta name="viewport" content="width=device-width, initial-scale=1">
  195. <title>Wemos LEDLamp Control</title>
  196. <style>
  197. body {
  198. margin: 0;
  199. font-family: Arial, sans-serif;
  200. background: linear-gradient(135deg, #1e1e2f, #2b5876);
  201. color: white;
  202. display: flex;
  203. justify-content: center;
  204. align-items: center;
  205. height: 100vh;
  206. }
  207. * {
  208. box-sizing: border-box;
  209. }
  210. .card {
  211. background: rgba(255,255,255,0.08);
  212. backdrop-filter: blur(10px);
  213. padding: 25px;
  214. border-radius: 16px;
  215. width: 90%;
  216. max-width: 360px;
  217. box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  218. animation: fadeIn 0.8s ease;
  219. }
  220. h2 {
  221. margin-top: 0;
  222. text-align: center;
  223. }
  224. .info {
  225. font-size: 12px;
  226. opacity: 0.8;
  227. margin-top: 8px;
  228. margin-bottom: 15px;
  229. text-align: center;
  230. }
  231. input {
  232. width: 100%;
  233. padding: 12px;
  234. margin: 8px 0;
  235. border-radius: 10px;
  236. border: none;
  237. outline: none;
  238. font-size: 14px;
  239. transition: 0.2s;
  240. }
  241. input:focus {
  242. transform: scale(1.02);
  243. }
  244. button {
  245. width: 100%;
  246. padding: 12px;
  247. border: none;
  248. border-radius: 10px;
  249. background: #00c6ff;
  250. color: white;
  251. font-size: 16px;
  252. cursor: pointer;
  253. transition: 0.3s;
  254. }
  255. button:hover {
  256. background: #0072ff;
  257. transform: translateY(-1px) translateX(1px);
  258. }
  259. .btn-row {
  260. display: flex;
  261. gap: 10px;
  262. align-items: center;
  263. margin-top: 10px;
  264. }
  265. .mac {
  266. font-size: 11px;
  267. text-align: center;
  268. margin-bottom: 15px;
  269. opacity: 0.7;
  270. word-break: break-all;
  271. }
  272. .bar_white {
  273. background: white;
  274. width: 100%;
  275. height: 3px;
  276. margin-bottom: 20px;
  277. }
  278. .bar_red {
  279. background: red;
  280. width: 100%;
  281. height: 3px;
  282. margin-bottom: 20px;
  283. }
  284. .bar_green {
  285. background: green;
  286. width: 100%;
  287. height: 3px;
  288. margin-bottom: 20px;
  289. }
  290. .bar_blue {
  291. background: blue;
  292. width: 100%;
  293. height: 3px;
  294. margin-bottom: 20px;
  295. }
  296. @keyframes fadeIn {
  297. from {opacity: 0; transform: translateY(10px);}
  298. to {opacity: 1; transform: translateY(0);}
  299. }
  300. </style>
  301. </head>
  302. <body>
  303. <div class="card">
  304. <div style="display: flex">
  305. <div class="bar_green"></div>
  306. <div class="bar_white"></div>
  307. <div class="bar_red"></div>
  308. <div class="bar_blue"></div>
  309. </div>
  310. <h2>Wemos LEDLamp Control</h2>
  311. <div class="mac">Device: )rawliteral"
  312. + macAddress
  313. + R"rawliteral(</div>
  314. <div class="btn-row">
  315. <button type="button" onclick="ledOn()">LED EIN</button>
  316. <div id="led_status">⚫</div>
  317. <button type="button" onclick="ledOff()">LED AUS</button>
  318. </div>
  319. <div class="btn-row">
  320. <button type="button" onclick="resetWifiCfg()">Wifi-Konfiguration löschen</button>
  321. </div>
  322. <div id="reset_status" class="info">-</div>
  323. </div>
  324. <script>
  325. let ws;
  326. function connectWS() {
  327. ws = new WebSocket("ws://" + location.hostname + ":81/");
  328. ws.onopen = () => {
  329. console.log("WebSocket connected");
  330. };
  331. ws.onmessage = (e) => {
  332. console.log("ESP:", e.data);
  333. if (e.data === "LED ON") {
  334. document.getElementById("led_status").innerHTML = "🟢";
  335. }
  336. if (e.data === "LED OFF") {
  337. document.getElementById("led_status").innerHTML = "⚫";
  338. }
  339. if (e.data === "Wifi_Reset_Success") {
  340. document.getElementById("reset_status").innerHTML = "Die Wifi-Konfiguration wurde erfolgreich zurückgesetzt.";
  341. }
  342. };
  343. ws.onclose = () => {
  344. console.log("WS disconnected → reconnect");
  345. setTimeout(connectWS, 1000);
  346. };
  347. }
  348. connectWS();
  349. function ledOn() {
  350. if (ws && ws.readyState === 1) {
  351. ws.send("{\"cmd\":\"SWITCH_LED\",\"val\":\"on\"}");
  352. }
  353. }
  354. function ledOff() {
  355. if (ws && ws.readyState === 1) {
  356. ws.send("{\"cmd\":\"SWITCH_LED\",\"val\":\"off\"}");
  357. }
  358. }
  359. function resetWifiCfg() {
  360. if (ws && ws.readyState === 1) {
  361. ws.send("{\"cmd\":\"RESET_WIFI_CFG\",\"val\":\"\"}");
  362. }
  363. }
  364. </script>
  365. </body>
  366. </html>
  367. )rawliteral";
  368. return html;
  369. }
  370. const String getConnectionSuccessPage() {
  371. String html =
  372. R"rawliteral(
  373. <!DOCTYPE html>
  374. <html>
  375. <head>
  376. <meta charset="UTF-8">
  377. <meta name="viewport" content="width=device-width, initial-scale=1">
  378. <title>Wemos LEDLamp Setup</title>
  379. <style>
  380. body {
  381. margin: 0;
  382. font-family: Arial, sans-serif;
  383. background: linear-gradient(135deg, #1e1e2f, #2b5876);
  384. color: white;
  385. display: flex;
  386. justify-content: center;
  387. align-items: center;
  388. height: 100vh;
  389. }
  390. * {
  391. box-sizing: border-box;
  392. }
  393. .card {
  394. background: rgba(255,255,255,0.08);
  395. backdrop-filter: blur(10px);
  396. padding: 25px;
  397. border-radius: 16px;
  398. width: 90%;
  399. max-width: 360px;
  400. box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  401. animation: fadeIn 0.8s ease;
  402. }
  403. h2 {
  404. margin-top: 0;
  405. text-align: center;
  406. }
  407. .info {
  408. font-size: 12px;
  409. opacity: 0.8;
  410. margin-top: 8px;
  411. margin-bottom: 15px;
  412. text-align: center;
  413. }
  414. .bar_white {
  415. background: white;
  416. width: 100%;
  417. height: 3px;
  418. margin-bottom: 20px;
  419. }
  420. .bar_red {
  421. background: red;
  422. width: 100%;
  423. height: 3px;
  424. margin-bottom: 20px;
  425. }
  426. .bar_green {
  427. background: green;
  428. width: 100%;
  429. height: 3px;
  430. margin-bottom: 20px;
  431. }
  432. .bar_blue {
  433. background: blue;
  434. width: 100%;
  435. height: 3px;
  436. margin-bottom: 20px;
  437. }
  438. @keyframes fadeIn {
  439. from {opacity: 0; transform: translateY(10px);}
  440. to {opacity: 1; transform: translateY(0);}
  441. }
  442. </style>
  443. </head>
  444. <body>
  445. <div class="card">
  446. <div style="display: flex">
  447. <div class="bar_green"></div>
  448. <div class="bar_white"></div>
  449. <div class="bar_red"></div>
  450. <div class="bar_blue"></div>
  451. </div>
  452. <h2>Wemos LEDLamp Setup gespeichert!</h2>
  453. <div class="info">Wemos startet neu...</div>
  454. </div>
  455. </body>
  456. </html>
  457. )rawliteral";
  458. return html;
  459. }
  460. #endif /* HTMLPAGES_H_ */