Fix Bosch BLE protocol: correct UUIDs, 2-byte data IDs, new dashboard fields
This commit is contained in:
parent
b5dd24544c
commit
6e251d6d36
@ -154,10 +154,18 @@ const app = (() => {
|
|||||||
// Cycle through modes every 15 seconds (30 ticks)
|
// Cycle through modes every 15 seconds (30 ticks)
|
||||||
const modeIndex = Math.floor(demoTick / 30) % DEMO_MODES.length;
|
const modeIndex = Math.floor(demoTick / 30) % DEMO_MODES.length;
|
||||||
|
|
||||||
|
const cadence = speed > 0.5 ? Math.round(speed * 2.8 + (Math.random() - 0.5) * 10) : 0;
|
||||||
|
const humanPower = speed > 0.5 ? Math.round(cadence * 1.3 + (Math.random() - 0.5) * 20) : 0;
|
||||||
|
const modeMultiplier = { OFF: 0, ECO: 0.5, TOUR: 1.0, eMTB: 1.5, TURBO: 2.2 };
|
||||||
|
const motorPower = Math.round(humanPower * (modeMultiplier[DEMO_MODES[modeIndex]] || 1.0));
|
||||||
|
const battery = Math.max(0, 87 - Math.floor(demoTick * 0.02));
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
speed: Math.round(speed * 10) / 10,
|
speed: Math.round(speed * 10) / 10,
|
||||||
torque: torque,
|
cadence: Math.max(0, cadence),
|
||||||
totalKm: Math.round(totalKm * 10) / 10,
|
humanPower: Math.max(0, humanPower),
|
||||||
|
motorPower: Math.max(0, motorPower),
|
||||||
|
battery: battery,
|
||||||
mode: DEMO_MODES[modeIndex]
|
mode: DEMO_MODES[modeIndex]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -227,9 +235,26 @@ const app = (() => {
|
|||||||
* Update dashboard with telemetry data
|
* Update dashboard with telemetry data
|
||||||
*/
|
*/
|
||||||
function updateDashboard(data) {
|
function updateDashboard(data) {
|
||||||
document.getElementById('val-speed').textContent = (data.speed || 0).toFixed(1);
|
if (data.speed !== null && data.speed !== undefined) {
|
||||||
document.getElementById('val-torque').textContent = Math.round(data.torque || 0);
|
document.getElementById('val-speed').textContent = (data.speed || 0).toFixed(1);
|
||||||
document.getElementById('val-totalkm').textContent = (data.totalKm || 0).toFixed(1);
|
}
|
||||||
|
if (data.cadence !== null && data.cadence !== undefined) {
|
||||||
|
document.getElementById('val-cadence').textContent = Math.round(data.cadence || 0);
|
||||||
|
}
|
||||||
|
if (data.humanPower !== null && data.humanPower !== undefined) {
|
||||||
|
document.getElementById('val-humanpower').textContent = Math.round(data.humanPower || 0);
|
||||||
|
}
|
||||||
|
if (data.motorPower !== null && data.motorPower !== undefined) {
|
||||||
|
document.getElementById('val-motorpower').textContent = Math.round(data.motorPower || 0);
|
||||||
|
}
|
||||||
|
if (data.battery !== null && data.battery !== undefined) {
|
||||||
|
document.getElementById('val-battery').textContent = data.battery;
|
||||||
|
const bar = document.getElementById('battery-bar');
|
||||||
|
if (bar) {
|
||||||
|
bar.style.width = data.battery + '%';
|
||||||
|
bar.style.background = data.battery > 50 ? '#4caf50' : data.battery > 20 ? '#ff9800' : '#f44336';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const modeStr = data.mode || 'OFF';
|
const modeStr = data.mode || 'OFF';
|
||||||
document.getElementById('val-mode').textContent = modeStr;
|
document.getElementById('val-mode').textContent = modeStr;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user