-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_config.h
More file actions
207 lines (197 loc) · 6.12 KB
/
Copy pathui_config.h
File metadata and controls
207 lines (197 loc) · 6.12 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
#pragma once
#include <pgmspace.h>
static const char CONFIG_PAGE_HTML[] PROGMEM = R"rawhtml(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>ESP32-CAM Config</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: #0d0d0d;
color: #e0e0e0;
font-family: system-ui, -apple-system, sans-serif;
max-width: 520px;
margin: 0 auto;
padding: 20px 16px 40px;
}
h1 { font-size: 18px; color: #4af; margin-bottom: 20px; }
h2 { font-size: 13px; color: #888; margin: 20px 0 10px; text-transform: uppercase; letter-spacing: 1px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 11px; color: #777; }
input[type=number] {
width: 100%;
padding: 9px 10px;
background: #1a1a1a;
border: 1px solid #2e2e2e;
border-radius: 5px;
color: #e0e0e0;
font-size: 15px;
}
input[type=number]:focus {
outline: none;
border-color: #4af;
}
select {
width: 100%;
padding: 9px 10px;
background: #1a1a1a;
border: 1px solid #2e2e2e;
border-radius: 5px;
color: #e0e0e0;
font-size: 15px;
}
select:focus { outline: none; border-color: #4af; }
.note {
font-size: 10px;
color: #555;
margin-top: 2px;
line-height: 1.4;
}
.note.warn { color: #884; }
.actions { margin-top: 24px; display: flex; flex-direction: column; gap: 8px; }
button {
width: 100%;
padding: 11px;
border: none;
border-radius: 6px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
}
#save-btn { background: #1a4080; color: #fff; }
#save-btn:hover { background: #255aaa; }
#save-btn:disabled { background: #2a2a2a; color: #555; cursor: default; }
#back-btn { background: #1a1a1a; color: #aaa; border: 1px solid #2e2e2e; }
#back-btn:hover { background: #242424; }
#msg {
margin-top: 14px;
padding: 10px 12px;
border-radius: 5px;
font-size: 13px;
display: none;
}
#msg.ok { background: #0a3a0a; color: #4c4; display: block; }
#msg.err { background: #3a0a0a; color: #e55; display: block; }
.divider { border: none; border-top: 1px solid #1e1e1e; margin: 8px 0; }
</style>
</head>
<body>
<h1>⚙ Configuration</h1>
<h2>Serial Pins</h2>
<div class="grid">
<div class="field">
<label>TX Pin (ESP32 → FC)</label>
<input type="number" id="tx_pin" min="0" max="39" value="14">
<div class="note">GPIO 14 = SD_CLK. Not a strapping pin; safe when SD card is not connected.</div>
</div>
<div class="field">
<label>RX Pin (FC → ESP32)</label>
<input type="number" id="rx_pin" min="0" max="39" value="13">
<div class="note">Telemetry from flight controller (optional).</div>
</div>
</div>
<hr class="divider" style="margin-top:20px;">
<h2>Camera</h2>
<div class="field">
<label>Resolution</label>
<select id="resolution">
<option value="1">160×120 (QQVGA — fastest)</option>
<option value="5" selected>320×240 (QVGA — default)</option>
<option value="8">640×480 (VGA — higher detail)</option>
</select>
<div class="note">Takes effect after reboot. Lower resolution = higher frame rate.</div>
</div>
<hr class="divider" style="margin-top:20px;">
<h2>Channel Mapping (1 – 16)</h2>
<div class="grid">
<div class="field">
<label>Roll</label>
<input type="number" id="ch_roll" min="1" max="16" value="1">
</div>
<div class="field">
<label>Pitch</label>
<input type="number" id="ch_pitch" min="1" max="16" value="2">
</div>
<div class="field">
<label>Throttle</label>
<input type="number" id="ch_throttle" min="1" max="16" value="3">
<div class="note">Stick snaps to center (mid = 1500 µs).</div>
</div>
<div class="field">
<label>Yaw</label>
<input type="number" id="ch_yaw" min="1" max="16" value="4">
</div>
<div class="field">
<label>Arm switch</label>
<input type="number" id="ch_arm" min="1" max="16" value="5">
<div class="note">Low = disarmed / High = armed.</div>
</div>
<div class="field">
<label>Flight mode (3-pos)</label>
<input type="number" id="ch_fmode" min="1" max="16" value="6">
<div class="note">STB=low ACRO=mid AUTO=high.</div>
</div>
</div>
<div class="actions">
<button id="save-btn" onclick="saveConfig()">Save & Reboot</button>
<button id="back-btn" onclick="location.href='/'">← Back to Controller</button>
</div>
<div id="msg"></div>
<script>
const fields = ['tx_pin','rx_pin','ch_roll','ch_pitch','ch_throttle','ch_yaw','ch_arm','ch_fmode','resolution'];
async function loadConfig() {
try {
const r = await fetch('/config/data');
if (!r.ok) throw new Error(r.status);
const d = await r.json();
fields.forEach(k => {
const el = document.getElementById(k);
if (el && d[k] !== undefined) el.value = d[k];
});
} catch(e) {
showMsg('Failed to load config: ' + e.message, false);
}
}
async function saveConfig() {
const body = {};
for (const k of fields) {
const v = parseInt(document.getElementById(k).value, 10);
if (isNaN(v)) { showMsg('Invalid value for ' + k, false); return; }
body[k] = v;
}
const btn = document.getElementById('save-btn');
btn.disabled = true;
btn.textContent = 'Saving\u2026';
try {
const r = await fetch('/config/save', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
if (r.ok) {
showMsg('Saved! Device is rebooting\u2026', true);
} else {
showMsg('Server error: ' + r.status, false);
btn.disabled = false;
btn.textContent = 'Save & Reboot';
}
} catch(e) {
// Device will reboot so the request may fail — treat as success
showMsg('Saved! Device is rebooting\u2026', true);
}
}
function showMsg(text, ok) {
const el = document.getElementById('msg');
el.textContent = text;
el.className = ok ? 'ok' : 'err';
}
loadConfig();
</script>
</body>
</html>
)rawhtml";