Wemos D1 Mini Frimware zur Steuerung einer RGBW-LED-Lampe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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-top: 10px;
  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. .rowTop {
  266. margin-top: 20px;
  267. }
  268. .mac {
  269. font-size: 11px;
  270. text-align: center;
  271. margin-bottom: 15px;
  272. opacity: 0.7;
  273. word-break: break-all;
  274. }
  275. .bar_white {
  276. background: white;
  277. width: 100%;
  278. height: 3px;
  279. margin-bottom: 20px;
  280. }
  281. .bar_red {
  282. background: red;
  283. width: 100%;
  284. height: 3px;
  285. margin-bottom: 20px;
  286. }
  287. .bar_green {
  288. background: green;
  289. width: 100%;
  290. height: 3px;
  291. margin-bottom: 20px;
  292. }
  293. .bar_blue {
  294. background: blue;
  295. width: 100%;
  296. height: 3px;
  297. margin-bottom: 20px;
  298. }
  299. @keyframes fadeIn {
  300. from {opacity: 0; transform: translateY(10px);}
  301. to {opacity: 1; transform: translateY(0);}
  302. }
  303. </style>
  304. </head>
  305. <body>
  306. <div class="card">
  307. <div style="display: flex">
  308. <div class="bar_green"></div>
  309. <div class="bar_white"></div>
  310. <div class="bar_red"></div>
  311. <div class="bar_blue"></div>
  312. </div>
  313. <h2>Wemos LEDLamp Control</h2>
  314. <div class="mac">Device: )rawliteral"
  315. + macAddress
  316. + R"rawliteral(</div>
  317. <div class="btn-row">
  318. <div id="led_status">⚫</div>
  319. <button type="button" onclick="ledOn()">LED EIN</button>
  320. <button type="button" onclick="ledOff()">LED AUS</button>
  321. </div>
  322. <input id="id_cmd" class="rowTop" placeholder="Commad...">
  323. <div class="btn-row">
  324. <button type="button" onclick="sendCommand()">Command senden</button>
  325. </div>
  326. <div class="btn-row rowTop">
  327. <button type="button" onclick="resetWifiCfg()">Wifi-Konfiguration löschen</button>
  328. </div>
  329. <div id="reset_status" class="info">-</div>
  330. </div>
  331. <script>
  332. let ws;
  333. function connectWS() {
  334. ws = new WebSocket("ws://" + location.hostname + ":81/");
  335. ws.onopen = () => {
  336. console.log("WebSocket connected");
  337. };
  338. ws.onmessage = (e) => {
  339. console.log("ESP:", e.data);
  340. if (e.data === "LED ON") {
  341. document.getElementById("led_status").innerHTML = "🟢";
  342. }
  343. if (e.data === "LED OFF") {
  344. document.getElementById("led_status").innerHTML = "⚫";
  345. }
  346. if (e.data === "Wifi_Reset_Success") {
  347. document.getElementById("reset_status").innerHTML = "Die Wifi-Konfiguration wurde erfolgreich zurückgesetzt.";
  348. }
  349. };
  350. ws.onclose = () => {
  351. console.log("WS disconnected → reconnect");
  352. setTimeout(connectWS, 1000);
  353. };
  354. }
  355. connectWS();
  356. function ledOn() {
  357. if (ws && ws.readyState === 1) {
  358. ws.send("{\"cmd\":\"SWITCH_LED\",\"val\":\"on\"}");
  359. }
  360. }
  361. function ledOff() {
  362. if (ws && ws.readyState === 1) {
  363. ws.send("{\"cmd\":\"SWITCH_LED\",\"val\":\"off\"}");
  364. }
  365. }
  366. function resetWifiCfg() {
  367. if (ws && ws.readyState === 1) {
  368. ws.send("{\"cmd\":\"RESET_WIFI_CFG\",\"val\":\"\"}");
  369. }
  370. }
  371. function sendCommand() {
  372. if (ws && ws.readyState === 1) {
  373. cmd = document.getElementById('id_cmd').value
  374. ws.send(cmd);
  375. }
  376. }
  377. </script>
  378. </body>
  379. </html>
  380. )rawliteral";
  381. return html;
  382. }
  383. const String getConnectionSuccessPage() {
  384. String html =
  385. R"rawliteral(
  386. <!DOCTYPE html>
  387. <html>
  388. <head>
  389. <meta charset="UTF-8">
  390. <meta name="viewport" content="width=device-width, initial-scale=1">
  391. <title>Wemos LEDLamp Setup</title>
  392. <style>
  393. body {
  394. margin: 0;
  395. font-family: Arial, sans-serif;
  396. background: linear-gradient(135deg, #1e1e2f, #2b5876);
  397. color: white;
  398. display: flex;
  399. justify-content: center;
  400. align-items: center;
  401. height: 100vh;
  402. }
  403. * {
  404. box-sizing: border-box;
  405. }
  406. .card {
  407. background: rgba(255,255,255,0.08);
  408. backdrop-filter: blur(10px);
  409. padding: 25px;
  410. border-radius: 16px;
  411. width: 90%;
  412. max-width: 360px;
  413. box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  414. animation: fadeIn 0.8s ease;
  415. }
  416. h2 {
  417. margin-top: 0;
  418. text-align: center;
  419. }
  420. .info {
  421. font-size: 12px;
  422. opacity: 0.8;
  423. margin-top: 8px;
  424. margin-bottom: 15px;
  425. text-align: center;
  426. }
  427. .bar_white {
  428. background: white;
  429. width: 100%;
  430. height: 3px;
  431. margin-bottom: 20px;
  432. }
  433. .bar_red {
  434. background: red;
  435. width: 100%;
  436. height: 3px;
  437. margin-bottom: 20px;
  438. }
  439. .bar_green {
  440. background: green;
  441. width: 100%;
  442. height: 3px;
  443. margin-bottom: 20px;
  444. }
  445. .bar_blue {
  446. background: blue;
  447. width: 100%;
  448. height: 3px;
  449. margin-bottom: 20px;
  450. }
  451. @keyframes fadeIn {
  452. from {opacity: 0; transform: translateY(10px);}
  453. to {opacity: 1; transform: translateY(0);}
  454. }
  455. </style>
  456. </head>
  457. <body>
  458. <div class="card">
  459. <div style="display: flex">
  460. <div class="bar_green"></div>
  461. <div class="bar_white"></div>
  462. <div class="bar_red"></div>
  463. <div class="bar_blue"></div>
  464. </div>
  465. <h2>Wemos LEDLamp Setup gespeichert!</h2>
  466. <div class="info">Wemos startet neu...</div>
  467. </div>
  468. </body>
  469. </html>
  470. )rawliteral";
  471. return html;
  472. }
  473. #endif /* HTMLPAGES_H_ */