Wemos D1 Mini Frimware zur Steuerung einer RGBW-LED-Lampe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

HtmlPages.h 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. @keyframes fadeIn {
  131. from {opacity: 0; transform: translateY(10px);}
  132. to {opacity: 1; transform: translateY(0);}
  133. }
  134. </style>
  135. </head>
  136. <body>
  137. <div class="card">
  138. <h2>Wemos LEDLamp Setup</h2>
  139. <div class="mac">Device: )rawliteral"
  140. + macAddress
  141. + R"rawliteral(</div>
  142. <form action="/save" method="POST">
  143. <input name="ssid" placeholder="WLAN Name (SSID)">
  144. <div class="pw-wrapper">
  145. <input id="pass" name="pass" type="password" placeholder="Passwort">
  146. <span class="toggle-eye" onclick="togglePassword()">👁</span>
  147. </div>
  148. <button type="submit">Speichern & Verbinden</button>
  149. </form>
  150. <div class="info">Verbinde den LEDLamp Wemos mit einem WLAN Netzwerk</div>
  151. </body>
  152. </html>
  153. )rawliteral";
  154. return html;
  155. }
  156. const String getSTAControlPage(String macAddress) {
  157. String html =
  158. R"rawliteral(
  159. <!DOCTYPE html>
  160. <html>
  161. <head>
  162. <meta name="viewport" content="width=device-width, initial-scale=1">
  163. <title>Wemos LEDLamp Control</title>
  164. <style>
  165. body {
  166. margin: 0;
  167. font-family: Arial, sans-serif;
  168. background: linear-gradient(135deg, #1e1e2f, #2b5876);
  169. color: white;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. height: 100vh;
  174. }
  175. * {
  176. box-sizing: border-box;
  177. }
  178. .card {
  179. background: rgba(255,255,255,0.08);
  180. backdrop-filter: blur(10px);
  181. padding: 25px;
  182. border-radius: 16px;
  183. width: 90%;
  184. max-width: 360px;
  185. box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  186. animation: fadeIn 0.8s ease;
  187. }
  188. h2 {
  189. margin-top: 0;
  190. text-align: center;
  191. }
  192. .info {
  193. font-size: 12px;
  194. opacity: 0.8;
  195. margin-bottom: 15px;
  196. text-align: center;
  197. }
  198. input {
  199. width: 100%;
  200. padding: 12px;
  201. margin: 8px 0;
  202. border-radius: 10px;
  203. border: none;
  204. outline: none;
  205. font-size: 14px;
  206. transition: 0.2s;
  207. }
  208. input:focus {
  209. transform: scale(1.02);
  210. }
  211. button {
  212. width: 100%;
  213. padding: 12px;
  214. margin-top: 10px;
  215. border: none;
  216. border-radius: 10px;
  217. background: #00c6ff;
  218. color: white;
  219. font-size: 16px;
  220. cursor: pointer;
  221. transition: 0.3s;
  222. }
  223. button:hover {
  224. background: #0072ff;
  225. transform: translateY(-2px);
  226. }
  227. .mac {
  228. font-size: 11px;
  229. text-align: center;
  230. margin-bottom: 15px;
  231. opacity: 0.7;
  232. word-break: break-all;
  233. }
  234. @keyframes fadeIn {
  235. from {opacity: 0; transform: translateY(10px);}
  236. to {opacity: 1; transform: translateY(0);}
  237. }
  238. </style>
  239. </head>
  240. <body>
  241. <div class="card">
  242. <h2>Wemos LEDLamp Control</h2>
  243. <div class="mac">Device: )rawliteral"
  244. + macAddress
  245. + R"rawliteral(</div>
  246. <div class="btn-row">
  247. <button type="button" onclick="ledOn()">LED EIN</button>
  248. <button type="button" onclick="ledOff()">LED AUS</button>
  249. </div>
  250. <script>
  251. let ws;
  252. function connectWS() {
  253. ws = new WebSocket("ws://" + location.hostname + ":81/");
  254. ws.onopen = () => {
  255. console.log("WebSocket connected");
  256. };
  257. ws.onmessage = (e) => {
  258. console.log("ESP:", e.data);
  259. };
  260. ws.onclose = () => {
  261. console.log("WS disconnected → reconnect");
  262. setTimeout(connectWS, 1000);
  263. };
  264. }
  265. connectWS();
  266. function ledOn() {
  267. if (ws && ws.readyState === 1) {
  268. ws.send("/ledOn");
  269. }
  270. }
  271. function ledOff() {
  272. if (ws && ws.readyState === 1) {
  273. ws.send("/ledOff");
  274. }
  275. }
  276. </script>
  277. </body>
  278. </html>
  279. )rawliteral";
  280. return html;
  281. }
  282. #endif /* HTMLPAGES_H_ */