[ai] memory optimizations, wifi reset, battery
This commit is contained in:
@@ -13,7 +13,10 @@
|
||||
<h1>HannaBox</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status" id="state">—</div>
|
||||
<div class="header-status-group">
|
||||
<div id="batteryStatus" class="battery-status" title="Battery"></div>
|
||||
<div class="status" id="state">—</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
@@ -148,6 +151,11 @@
|
||||
</div>
|
||||
<button type="button" class="action-btn" style="grid-column: 1 / -1;" onclick="deleteFileOnServer()">Delete</button>
|
||||
</form>
|
||||
|
||||
<h4>System</h4>
|
||||
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
|
||||
<button class="action-btn" style="background-color: #ef4444;" onclick="resetWifi()">Reset WiFi Settings</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</main>
|
||||
|
||||
@@ -115,6 +115,24 @@ function loadDirectory() {
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function resetWifi() {
|
||||
if (!confirm('Are you sure you want to reset WiFi settings? The device will restart and create an access point.')) {
|
||||
return;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/reset_wifi', true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
alert('WiFi settings reset. Device is restarting...');
|
||||
} else {
|
||||
alert('Reset failed: ' + (xhr.responseText || 'Unknown error'));
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function loadMapping() {
|
||||
var el = document.getElementById('mappingList');
|
||||
if (!el) return;
|
||||
@@ -241,6 +259,25 @@ function displayState(state) {
|
||||
var voltageEl = document.getElementById("voltage");
|
||||
if (voltageEl) voltageEl.innerHTML = (state['voltage'] || '') + ' mV';
|
||||
|
||||
// Update header battery indicator
|
||||
var headerBattery = document.getElementById("batteryStatus");
|
||||
if (headerBattery) {
|
||||
var mv = state['voltage'] || 0;
|
||||
if (mv > 0) {
|
||||
// Estimate percentage for single cell LiPo (approx 3.3V - 4.2V)
|
||||
var pct = Math.round((mv - 3300) / (4200 - 3300) * 100);
|
||||
if (pct < 0) pct = 0;
|
||||
if (pct > 100) pct = 100;
|
||||
|
||||
headerBattery.innerHTML =
|
||||
'<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" style="opacity:0.7"><path d="M16 4h-1V2a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"/></svg>' +
|
||||
'<span>' + pct + '%</span>';
|
||||
headerBattery.title = mv + ' mV';
|
||||
} else {
|
||||
headerBattery.innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
var heapEl = document.getElementById("heap");
|
||||
if (heapEl) heapEl.innerHTML = (state['heap'] || '') + ' bytes free heap';
|
||||
|
||||
|
||||
@@ -62,6 +62,19 @@ a { color: var(--accent); text-decoration: none; }
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.battery-status {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: rgba(255,255,255,0.5);
|
||||
padding: 4px 8px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
/* Status (current song) */
|
||||
.status {
|
||||
color: var(--muted);
|
||||
|
||||
Reference in New Issue
Block a user