Skip to content

Commit 2bd8bc7

Browse files
committed
Bug fixing / LPF2 Mode detection
1 parent 83f93d5 commit 2bd8bc7

9 files changed

Lines changed: 228 additions & 131 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ It comes with the hardware schematics, production files and the Megahub firmware
2323
- **Built-in IMU**: Integrated MPU6050 6-axis accelerometer and gyroscope for motion sensing
2424
- **FastLED/NeoPixel Support**: Built-in support for addressable RGB LED strips
2525
- **Flexible GPIO**: Additional GPIO pins available for custom sensors, buttons, and peripherals
26+
- **Gamepad**: Can be paired with Bluetooth Classic HID compatible Gamepads (8BitDo M30, ...)
27+
- **BT/WiFi switch**: Allow configuration over Bluetooth API instead of Restful HTTP API is comming soon...
2628
- **ROS(Robot Operating System)**: Micro ROS support is comming soon...
2729
- **MQTT**: MQTT support is comming soon...
28-
- **Gamepad**: Bluetooth Gamepad support is comming soon...
29-
- **BT/WiFi switch**: Allow configuration over Bluetooth API instead of Restful HTTP API is comming soon...
3030

3131
## Why not Micropython on existing hardware?
3232

docs/devicemodes/coloranddistancesensor.json

Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"type": "BOOST Color and Distance Sensor",
3+
"deviceId": 37,
4+
"icon": "⚙️",
5+
"modes": [
6+
{
7+
"id": 0,
8+
"name": "COLOR",
9+
"units": "IDX",
10+
"datasets": 1,
11+
"figures": 3,
12+
"decimals": 0,
13+
"type": "DATA8"
14+
},
15+
{
16+
"id": 1,
17+
"name": "PROX",
18+
"units": "DIS",
19+
"datasets": 1,
20+
"figures": 3,
21+
"decimals": 0,
22+
"type": "DATA8"
23+
},
24+
{
25+
"id": 2,
26+
"name": "COUNT",
27+
"units": "CNT",
28+
"datasets": 1,
29+
"figures": 4,
30+
"decimals": 0,
31+
"type": "DATA32"
32+
},
33+
{
34+
"id": 3,
35+
"name": "REFLT",
36+
"units": "PCT",
37+
"datasets": 1,
38+
"figures": 3,
39+
"decimals": 0,
40+
"type": "DATA8"
41+
},
42+
{
43+
"id": 4,
44+
"name": "AMBI",
45+
"units": "PCT",
46+
"datasets": 1,
47+
"figures": 3,
48+
"decimals": 0,
49+
"type": "DATA8"
50+
},
51+
{
52+
"id": 5,
53+
"name": "COL O",
54+
"units": "IDX",
55+
"datasets": 1,
56+
"figures": 3,
57+
"decimals": 0,
58+
"type": "DATA8"
59+
},
60+
{
61+
"id": 6,
62+
"name": "RGB I",
63+
"units": "RAW",
64+
"datasets": 3,
65+
"figures": 5,
66+
"decimals": 0,
67+
"type": "DATA16"
68+
},
69+
{
70+
"id": 7,
71+
"name": "IR Tx",
72+
"units": "N/A",
73+
"datasets": 1,
74+
"figures": 5,
75+
"decimals": 0,
76+
"type": "DATA16"
77+
},
78+
{
79+
"id": 8,
80+
"name": "SPEC 1",
81+
"units": "N/A"
82+
},
83+
{
84+
"id": 9,
85+
"name": "DEBUG",
86+
"units": "N/A"
87+
},
88+
{
89+
"id": 10,
90+
"name": "CALIB",
91+
"units": "N/A"
92+
}
93+
]
94+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"type": "BOOST Interactive Motor",
3+
"deviceId": 38,
4+
"icon": "⚙️",
5+
"modes": [
6+
{
7+
"id": 0,
8+
"name": "POWER",
9+
"units": "PCT",
10+
"datasets": 1,
11+
"figures": 4,
12+
"decimals": 0,
13+
"type": "DATA8"
14+
},
15+
{
16+
"id": 1,
17+
"name": "SPEED",
18+
"units": "PCT",
19+
"datasets": 1,
20+
"figures": 4,
21+
"decimals": 0,
22+
"type": "DATA8"
23+
},
24+
{
25+
"id": 2,
26+
"name": "POS",
27+
"units": "DEG",
28+
"datasets": 1,
29+
"figures": 6,
30+
"decimals": 0,
31+
"type": "DATA32"
32+
},
33+
{
34+
"id": 3,
35+
"name": "TEST",
36+
"units": "TST",
37+
"datasets": 5,
38+
"figures": 6,
39+
"decimals": 0,
40+
"type": "DATA16"
41+
}
42+
]
43+
}

frontend/src/index.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ var connectionLostNotification = null; // Reference to "Connection Lost" notific
4747
// ===== Notification System =====
4848

4949
const NotificationIcons = {
50-
success: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`,
51-
error: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>`,
52-
warning: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>`,
53-
info: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`
50+
success : `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`,
51+
error : `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>`,
52+
warning : `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>`,
53+
info : `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`
5454
};
5555

5656
/**
@@ -62,7 +62,8 @@ const NotificationIcons = {
6262
*/
6363
function showNotification(type, title, message = '', duration = 4000) {
6464
const container = document.getElementById('notificationContainer');
65-
if (!container) return;
65+
if (!container)
66+
return;
6667

6768
const notification = document.createElement('div');
6869
notification.className = `notification ${type}`;
@@ -113,7 +114,8 @@ function showConfirmDialog(title, message, options = {}) {
113114
confirmText = 'Confirm',
114115
cancelText = 'Cancel',
115116
destructive = true
116-
} = options;
117+
}
118+
= options;
117119

118120
return new Promise((resolve) => {
119121
const overlay = document.getElementById('confirmDialog');
@@ -160,7 +162,8 @@ function initConfirmDialog() {
160162
const confirmBtn = document.getElementById('confirmDialogConfirm');
161163
const cancelBtn = document.getElementById('confirmDialogCancel');
162164

163-
if (!overlay || !confirmBtn || !cancelBtn) return;
165+
if (!overlay || !confirmBtn || !cancelBtn)
166+
return;
164167

165168
confirmBtn.addEventListener('click', () => closeConfirmDialog(true));
166169
cancelBtn.addEventListener('click', () => closeConfirmDialog(false));
@@ -191,7 +194,8 @@ window.showConfirmDialog = showConfirmDialog;
191194
*/
192195
function showBluetoothUnsupportedMessage() {
193196
const welcomeDiv = document.querySelector('.layout-content.welcome');
194-
if (!welcomeDiv) return;
197+
if (!welcomeDiv)
198+
return;
195199

196200
welcomeDiv.innerHTML = `
197201
<div class="bt-unsupported">
@@ -507,7 +511,7 @@ window.Application = {
507511
showNotification('success', 'Program Stopped', 'Execution has been halted');
508512
});
509513
}
510-
blocklyEditor.removeAllProfilingOverlays();
514+
blocklyEditor.removeAllProfilingOverlays();
511515
// clang-format on
512516
},
513517

@@ -599,7 +603,9 @@ function setupEventListeners() {
599603
});
600604

601605
bleClient.addEventListener(APP_EVENT_TYPE_PORTSTATUS, (data) => {
602-
const status = JSON.parse(new TextDecoder().decode(data));
606+
const portstatustext = new TextDecoder().decode(data);
607+
console.log("Got Portstatus : " + portstatustext);
608+
const status = JSON.parse(portstatustext);
603609
portstatus.updateStatus(status);
604610
});
605611

@@ -642,9 +648,9 @@ async function attemptReconnection() {
642648
// Attempts: 1=2s, 2=4s, 3=8s, 4=16s, 5=30s, 6+=30s (capped)
643649
const delayMs = Math.min(2000 * Math.pow(2, reconnectAttempts - 1), 30000);
644650

645-
console.log(`Reconnection attempt ${reconnectAttempts}/${maxReconnectAttempts} in ${delayMs/1000}s...`);
651+
console.log(`Reconnection attempt ${reconnectAttempts}/${maxReconnectAttempts} in ${delayMs / 1000}s...`);
646652
// Notification duration proportional to delay time (90% of delay)
647-
showNotification('info', 'Reconnecting', `Attempt ${reconnectAttempts}/${maxReconnectAttempts} in ${delayMs/1000}s...`, Math.floor(delayMs * 0.9));
653+
showNotification('info', 'Reconnecting', `Attempt ${reconnectAttempts}/${maxReconnectAttempts} in ${delayMs / 1000}s...`, Math.floor(delayMs * 0.9));
648654

649655
await new Promise(resolve => setTimeout(resolve, delayMs));
650656

@@ -815,8 +821,7 @@ document.addEventListener('DOMContentLoaded', () => {
815821
const confirmed = await showConfirmDialog(
816822
'Load Workspace',
817823
`This will replace your current workspace with ${file.name}. Continue?`,
818-
{ confirmText: 'Load', cancelText: 'Cancel', destructive: true }
819-
);
824+
{confirmText : 'Load', cancelText : 'Cancel', destructive : true});
820825

821826
if (confirmed) {
822827
const success = blocklyEditor.loadXML(fileContent);
@@ -958,8 +963,7 @@ document.addEventListener('DOMContentLoaded', () => {
958963
const confirmed = await showConfirmDialog(
959964
'Reset Workspace',
960965
'Are you sure you want to reset the workspace? All unsaved changes to your Blockly program will be lost.',
961-
{ confirmText: 'Reset', cancelText: 'Cancel', destructive: true }
962-
);
966+
{confirmText : 'Reset', cancelText : 'Cancel', destructive : true});
963967
if (confirmed) {
964968
blocklyEditor.clearWorkspace();
965969
showNotification('success', 'Workspace Reset', 'All blocks have been cleared');
@@ -1018,8 +1022,7 @@ document.addEventListener('DOMContentLoaded', () => {
10181022
const confirmed = await showConfirmDialog(
10191023
'Paste Project',
10201024
'This will replace your current workspace with the project from clipboard. Continue?',
1021-
{ confirmText: 'Paste', cancelText: 'Cancel', destructive: true }
1022-
);
1025+
{confirmText : 'Paste', cancelText : 'Cancel', destructive : true});
10231026

10241027
if (confirmed) {
10251028
const success = blocklyEditor.loadXML(clipboardText);

0 commit comments

Comments
 (0)