-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpage-modules.html
More file actions
455 lines (438 loc) · 22.3 KB
/
Copy pathpage-modules.html
File metadata and controls
455 lines (438 loc) · 22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Модули • ESP-HACK</title>
<link rel="stylesheet" href="css/style.css" />
<script src="js/site-nav.js?v=5" defer></script>
</head>
<body>
<div class="lang-switch lang-switch--ru" role="navigation" aria-label="Язык">
<div class="lang-switch__track">
<span class="lang-switch__thumb" aria-hidden="true"></span>
<span class="lang-switch__opt lang-switch__opt--current" aria-current="page">RU</span>
<a href="en/page-modules.html" class="lang-switch__opt">EN</a>
</div>
</div>
<div class="shell shell--nav-left">
<aside class="sidebar" aria-label="Навигация по разделам">
<div class="sidebar__inner">
<a class="sidebar__brand" href="https://github.com/Teapot174/ESP-HACK" aria-label="ESP-HACK GitHub">ESP-HACK</a>
<nav aria-label="Разделы вики">
<div id="site-nav-container"></div>
</nav>
</div>
</aside>
<main class="content">
<div class="content__wrap">
<h1>Модули</h1>
<div class="table-wrap">
<table class="module-table">
<thead>
<tr>
<th scope="col">Module</th>
<th scope="col">Pin</th>
<th scope="col">Pin</th>
<th scope="col">Pin</th>
<th scope="col">Pin</th>
<th scope="col">Pin</th>
<th scope="col">Pin</th>
<th scope="col">Pin</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<span class="module-name">
<span class="module-name__icon" aria-hidden="true">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M2 3.5A1.5 1.5 0 013.5 2h9A1.5 1.5 0 0114 3.5v6A1.5 1.5 0 0112.5 11h-9A1.5 1.5 0 012 9.5v-6z"
stroke="currentColor"
stroke-width="1.2"
/>
<path d="M6 13h4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
<path d="M8 11v2" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
</svg>
</span>
Display
</span>
</th>
<td data-pinout-module="display" data-pinout-col="0" data-pinout-slot="VCC">VCC → 3V3</td>
<td data-pinout-module="display" data-pinout-col="1" data-pinout-slot="GND">GND → GND</td>
<td data-pinout-module="display" data-pinout-col="2" data-pinout-slot="SCL">SCL → G22</td>
<td data-pinout-module="display" data-pinout-col="3" data-pinout-slot="SDA">SDA → G21</td>
<td class="cell-empty" data-pinout-module="display" data-pinout-col="4" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="display" data-pinout-col="5" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="display" data-pinout-col="6" data-pinout-slot="">—</td>
</tr>
<tr>
<th scope="row">
<span class="module-name">
<span class="module-name__icon" aria-hidden="true">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="5" cy="8" r="2" stroke="currentColor" stroke-width="1.2" />
<circle cx="11" cy="8" r="2" stroke="currentColor" stroke-width="1.2" />
</svg>
</span>
Buttons
</span>
</th>
<td data-pinout-module="buttons" data-pinout-col="0" data-pinout-slot="UP">UP → G27</td>
<td data-pinout-module="buttons" data-pinout-col="1" data-pinout-slot="DOWN">DOWN → G26</td>
<td data-pinout-module="buttons" data-pinout-col="2" data-pinout-slot="OK">OK → G33</td>
<td data-pinout-module="buttons" data-pinout-col="3" data-pinout-slot="BACK">BACK → G32</td>
<td class="cell-empty" data-pinout-module="buttons" data-pinout-col="4" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="buttons" data-pinout-col="5" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="buttons" data-pinout-col="6" data-pinout-slot="">—</td>
</tr>
<tr>
<th scope="row">
<span class="module-name">
<span class="module-name__icon" aria-hidden="true">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="5" width="10" height="7" rx="1" stroke="currentColor" stroke-width="1.2" />
<path d="M5 12v1.5M8 12v1.5M11 12v1.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
</svg>
</span>
CC1101
</span>
</th>
<td data-pinout-module="cc1101" data-pinout-col="0" data-pinout-slot="1">1 → GND</td>
<td data-pinout-module="cc1101" data-pinout-col="1" data-pinout-slot="2">2 → 3V3</td>
<td data-pinout-module="cc1101" data-pinout-col="2" data-pinout-slot="3">3 → G4</td>
<td data-pinout-module="cc1101" data-pinout-col="3" data-pinout-slot="4">4 → G5</td>
<td data-pinout-module="cc1101" data-pinout-col="4" data-pinout-slot="5">5 → G18</td>
<td data-pinout-module="cc1101" data-pinout-col="5" data-pinout-slot="6">6 → G23</td>
<td data-pinout-module="cc1101" data-pinout-col="6" data-pinout-slot="7">7 → G19</td>
</tr>
<tr>
<th scope="row">
<span class="module-name">
<span class="module-name__icon" aria-hidden="true">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M8 2v3M6 5h4M5 14c0-2 1.5-3 3-3s3 1 3 3"
stroke="currentColor"
stroke-width="1.2"
stroke-linecap="round"
/>
<circle cx="8" cy="10" r="3" stroke="currentColor" stroke-width="1.2" />
</svg>
</span>
IR
</span>
</th>
<td data-pinout-module="ir" data-pinout-col="0" data-pinout-slot="IR-TX">IR-TX → G16</td>
<td data-pinout-module="ir" data-pinout-col="1" data-pinout-slot="IR-RX">IR-RX → G35</td>
<td class="cell-empty" data-pinout-module="ir" data-pinout-col="2" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="ir" data-pinout-col="3" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="ir" data-pinout-col="4" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="ir" data-pinout-col="5" data-pinout-slot="">—</td>
<td class="cell-empty" data-pinout-module="ir" data-pinout-col="6" data-pinout-slot="">—</td>
</tr>
<tr>
<th scope="row">
<span class="module-name">
<span class="module-name__icon" aria-hidden="true">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 3v10M8 3v10M12 3v10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
<path d="M3 6h10M3 10h10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
</svg>
</span>
GPIO
</span>
</th>
<td data-pinout-module="gpio" data-pinout-col="0" data-pinout-slot="A">A → G16</td>
<td data-pinout-module="gpio" data-pinout-col="1" data-pinout-slot="B">B → G2</td>
<td data-pinout-module="gpio" data-pinout-col="2" data-pinout-slot="C">C → G18</td>
<td data-pinout-module="gpio" data-pinout-col="3" data-pinout-slot="D">D → G23</td>
<td data-pinout-module="gpio" data-pinout-col="4" data-pinout-slot="E">E → G19</td>
<td data-pinout-module="gpio" data-pinout-col="5" data-pinout-slot="F">F → G25</td>
<td class="cell-empty" data-pinout-module="gpio" data-pinout-col="6" data-pinout-slot="">—</td>
</tr>
<tr>
<th scope="row">
<span class="module-name">
<span class="module-name__icon" aria-hidden="true">
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M4 4.5h7l2 2v7a1 1 0 01-1 1H4a1 1 0 01-1-1v-8a1 1 0 011-1z"
stroke="currentColor"
stroke-width="1.2"
stroke-linejoin="round"
/>
<path d="M11 4.5v2h2" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" />
</svg>
</span>
SD Card
</span>
</th>
<td data-pinout-module="sdcard" data-pinout-col="0" data-pinout-slot="3v3">3v3 → 3v3</td>
<td data-pinout-module="sdcard" data-pinout-col="1" data-pinout-slot="CS">CS → G15</td>
<td data-pinout-module="sdcard" data-pinout-col="2" data-pinout-slot="MOSI">MOSI → G13</td>
<td data-pinout-module="sdcard" data-pinout-col="3" data-pinout-slot="CLK">CLK → G14</td>
<td data-pinout-module="sdcard" data-pinout-col="4" data-pinout-slot="MISO">MISO → G17</td>
<td data-pinout-module="sdcard" data-pinout-col="5" data-pinout-slot="GND">GND → GND</td>
<td class="cell-empty" data-pinout-module="sdcard" data-pinout-col="6" data-pinout-slot="">—</td>
</tr>
</tbody>
</table>
</div>
<h2 id="errors">Ошибки</h2>
<div class="nrf-pin-table-wrap nrf-card">
<div class="nrf-card__head">
<div class="nrf-card__titles">
<span class="nrf-card__title">Таблица ошибок</span>
</div>
<button type="button" class="nrf-card__copy" aria-label="Копировать таблицу ошибок">
Копировать
</button>
</div>
<div class="nrf-card__body">
<table class="nrf-table errors-table" data-copy-format="markdown" data-copy-locale="ru">
<colgroup>
<col class="errors-table__code" />
<col class="errors-table__desc" />
<col class="errors-table__fix" />
</colgroup>
<thead>
<tr>
<th scope="col">ERROR</th>
<th scope="col">Описание ошибки</th>
<th scope="col">Возможное решение</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">0x000</th>
<td>Ошибка инициализации SD-Карты</td>
<td>Отформатируйте SD-карту в FAT32 либо замените её.</td>
</tr>
<tr>
<th scope="row">0x001</th>
<td>Ошибка инициализации CC1101</td>
<td>Проверьте подключение и работоспособность модуля.</td>
</tr>
<tr>
<th scope="row">0x002</th>
<td>Ошибка инициализации NRF24</td>
<td>Проверьте правильность выбора пинов, соединений и перезагрузите устройство.</td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 id="nrf24">Как подключить NRF24</h2>
<p>Посмотрите распиновку GPIO, после чего следуйте этой распиновке:</p>
<div class="nrf-pin-table-wrap nrf-card">
<div class="nrf-card__head">
<div class="nrf-card__titles">
<span class="nrf-card__title">Подключение NRF24</span>
</div>
<button type="button" class="nrf-card__copy" aria-label="Копировать таблицу">
Копировать
</button>
</div>
<div class="nrf-card__body">
<table class="nrf-table">
<thead>
<tr>
<th scope="col">NRF24</th>
<th scope="col">ESP-HACK</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1 (GND)</th>
<td data-nrf-pin="1">GND</td>
</tr>
<tr>
<th scope="row">2 (VCC)</th>
<td data-nrf-pin="2">3V3</td>
</tr>
<tr>
<th scope="row">3 (CE)</th>
<td data-nrf-pin="3">A (G16)</td>
</tr>
<tr>
<th scope="row">4 (CSN)</th>
<td data-nrf-pin="4">B (G2)</td>
</tr>
<tr>
<th scope="row">5 (SCK)</th>
<td data-nrf-pin="5">C (G18)</td>
</tr>
<tr>
<th scope="row">6 (MOSI)</th>
<td data-nrf-pin="6">D (G23)</td>
</tr>
<tr>
<th scope="row">7 (MISO)</th>
<td data-nrf-pin="7">E (G19)</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<script>
(function () {
var DEFAULT_PINOUT = {
modules: {
display: { targets: ["3V3", "GND", "G22", "G21", null, null, null] },
buttons: { targets: ["G27", "G26", "G33", "G32", null, null, null] },
cc1101: { targets: ["GND", "3V3", "G4", "G5", "G18", "G23", "G19"] },
ir: { targets: ["G16", "G35", null, null, null, null, null] },
gpio: { targets: ["G16", "G2", "G18", "G23", "G19", "G25", null] },
sdcard: { targets: ["3V3", "G15", "G13", "G14", "G17", "GND", null] },
},
nrfWiring: ["GND", "3V3", "A", "B", "C", "D", "E"],
};
var dataBase = location.pathname.indexOf("/en/") !== -1 ? "../" : "";
function renderModules(pinout) {
var modules = (pinout && pinout.modules) || {};
document
.querySelectorAll("td[data-pinout-module][data-pinout-col]")
.forEach(function (td) {
var moduleId = td.getAttribute("data-pinout-module") || "";
var col = parseInt(td.getAttribute("data-pinout-col") || "0", 10);
var slotLabel = td.getAttribute("data-pinout-slot") || "";
var target =
modules[moduleId] &&
Array.isArray(modules[moduleId].targets) &&
modules[moduleId].targets.length > col
? modules[moduleId].targets[col]
: null;
var hasTarget = target != null && String(target).trim() !== "";
if (slotLabel && hasTarget) {
td.textContent = slotLabel + " → " + target;
td.classList.remove("cell-empty");
} else {
td.textContent = "—";
td.classList.add("cell-empty");
}
});
}
function renderNrf(pinout) {
var nrfWiring = Array.isArray(pinout && pinout.nrfWiring) ? pinout.nrfWiring : DEFAULT_PINOUT.nrfWiring;
var gpioTargets =
pinout &&
pinout.modules &&
pinout.modules.gpio &&
Array.isArray(pinout.modules.gpio.targets)
? pinout.modules.gpio.targets
: [];
var gpioIndex = { A: 0, B: 1, C: 2, D: 3, E: 4 };
document.querySelectorAll("td[data-nrf-pin]").forEach(function (td) {
var pin = parseInt(td.getAttribute("data-nrf-pin") || "0", 10); // 1..7
var token = nrfWiring[pin - 1];
if (token === "GND" || token === "3V3") {
td.textContent = token;
return;
}
if (gpioIndex[token] != null) {
var gp = gpioTargets[gpioIndex[token]];
td.textContent = token + " (" + (gp ? gp : "—") + ")";
return;
}
td.textContent = "—";
});
}
function bindCopy() {
document
.querySelectorAll(".code-block__copy, .nrf-card__copy")
.forEach(function (btn) {
btn.addEventListener("click", function () {
var text;
var nrfWrap = btn.closest(".nrf-pin-table-wrap");
if (nrfWrap) {
var table = nrfWrap.querySelector("table");
if (!table) return;
var lines;
if (table.getAttribute("data-copy-format") === "markdown") {
if (table.getAttribute("data-copy-locale") === "ru") {
lines = [
"| Код ошибки | Описание ошибки | Возможное решение |",
"|------------|-----------|------------------|",
"| **0x000** | Ошибка инициализации SD-Карты | Отформатируйте SD-карту в FAT32 либо замените её. |",
"| **0x001** | Ошибка инициализации CC1101 | Проверьте подключение и работоспособность модуля. |",
"| **0x002** | Ошибка инициализации NRF24 | Проверьте правильность выбора пинов, соединений и перезагрузите устройство. |",
];
} else {
lines = [
"| Error code | Problem | Possible fix |",
"|------------|-----------|------------------|",
];
table.querySelectorAll("tbody tr").forEach(function (tr) {
var cells = tr.querySelectorAll("th, td");
if (cells.length === 3) {
lines.push(
"| " +
cells[0].textContent.trim() +
" | " +
cells[1].textContent.trim() +
" | " +
cells[2].textContent.trim() +
" |"
);
}
});
}
} else {
lines = ["NRF24 | ESP-HACK"];
table.querySelectorAll("tbody tr").forEach(function (tr) {
var th = tr.querySelector('th[scope="row"]');
var td = tr.querySelector("td");
if (th && td) {
lines.push(th.textContent.trim() + " > " + td.textContent.trim());
}
});
}
text = lines.join("\n");
} else {
var block = btn.closest(".code-block");
var code = block && block.querySelector("pre code");
if (!code) return;
text = code.textContent;
}
var label = btn.textContent;
var copied = location.pathname.indexOf("/en/") !== -1 ? "Copied" : "Скопировано";
function done() {
btn.textContent = copied;
setTimeout(function () {
btn.textContent = label;
}, 1400);
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(done).catch(function () {});
}
});
});
}
function fetchAndRender() {
var url = dataBase + "data/pinout-modules.json";
return fetch(url, { cache: "no-store" })
.then(function (r) {
if (!r.ok) throw new Error("pinout fetch HTTP " + r.status);
return r.json();
})
.then(function (pinout) {
renderModules(pinout);
renderNrf(pinout);
})
.catch(function () {
// If JSON missing - keep current HTML (already filled) and just render defaults.
renderModules(DEFAULT_PINOUT);
renderNrf(DEFAULT_PINOUT);
});
}
// Render pinouts first, then bind UI handlers.
fetchAndRender().then(bindCopy).catch(bindCopy);
})();
</script>
</body>
</html>