Skip to content

Commit c77ac62

Browse files
committed
UII cleanup, bug fixing
1 parent 51e2e45 commit c77ac62

12 files changed

Lines changed: 153 additions & 122 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ It comes with the hardware schematics, production files and the Megahub firmware
2323
- **Web-based Interface**: Configure and program your hub through an intuitive Web UI
2424
- **ROS(Robot Operating System)**: Micro ROS support is comming soon...
2525
- **MQTT**: MQTT support is comming soon...
26+
- **Gamepad**: Bluetooth Gamepad support is comming soon...
27+
- **BT/WiFi switch**: Allow configuration over Bluetooth API instead of Restful HTTP API
2628

2729
## How It Differs from Existing Solutions
2830

frontend/src/components/blockly/component.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,26 @@ const customBlocks = {
689689
return "ui.showvalue(\"" + labelCode + "\", " + styleCode + ", " + valueCode + ")\n";
690690
}
691691
},
692+
693+
"mh_debug_free_heap": {
694+
category: 'Debug',
695+
colour: 230,
696+
blockdefinition: {
697+
"type": "mh_debug_free_heap",
698+
"message0": "Get free HEAP memory",
699+
"args0": [
700+
],
701+
"output": null,
702+
"colour": 230,
703+
"tooltip": "Get free HEAP memory",
704+
"helpUrl": ""
705+
},
706+
generator: (block, generator) => {
707+
const command = "deb.freeHeap()";
708+
709+
return [command, 0];
710+
}
711+
},
692712
};
693713

694714
function generateToolbox(definitions) {

frontend/src/components/logger/component.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import template from './component.html?raw';
2+
import styleSheet from './style.css?raw';
23

34
const MAX_LOG_ENTRIES = 50;
45

@@ -7,23 +8,32 @@ class LoggerHTMLElement extends HTMLElement {
78
logCount = 0;
89

910
connectedCallback() {
10-
this.innerHTML = template;
11+
const shadow = this.attachShadow({ mode: 'open' })
12+
13+
// Create adoptable stylesheet
14+
const sheet = new CSSStyleSheet()
15+
sheet.replaceSync(styleSheet)
16+
shadow.adoptedStyleSheets = [sheet]
17+
18+
shadow.innerHTML = template
1119
};
1220

1321
addToLog(message) {
1422
const logEntry = document.createElement('div');
1523
logEntry.className = 'log-entry';
1624

1725
logEntry.textContent = `${message}`;
18-
26+
27+
const container = this.shadowRoot;
28+
1929
// Add new entry at the top
20-
this.insertBefore(logEntry, this.firstChild);
30+
container.insertBefore(logEntry, container.firstChild);
2131
this.logCount++;
2232

2333
// Remove oldest entry if limit exceeded
2434
if (this.logCount > MAX_LOG_ENTRIES) {
25-
this.removeChild(this.lastChild);
26-
logCount--;
35+
container.removeChild(container.lastChild);
36+
this.logCount--;
2737
}
2838
};
2939
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
:host {
2+
background-color: #252526;
3+
border: 1px solid #3e3e42;
4+
border-radius: 4px;
5+
padding: 10px;
6+
overflow-y: auto;
7+
font-size: 12px;
8+
line-height: 1.4;
9+
color: #d4d4d4;
10+
font-family: 'Courier New', monospace;
11+
grid-area: log;
12+
13+
&::-webkit-scrollbar {
14+
width: 10px;
15+
}
16+
17+
&::-webkit-scrollbar-track {
18+
background: #1e1e1e;
19+
}
20+
21+
&::-webkit-scrollbar-thumb {
22+
background: #424242;
23+
border-radius: 5px;
24+
}
25+
26+
&::-webkit-scrollbar-thumb:hover {
27+
background: #4e4e4e;
28+
}
29+
}
30+
31+
.log-entry {
32+
padding: 4px 0;
33+
border-bottom: 1px solid #2d2d30;
34+
}
35+
36+
.log-entry:first-child {
37+
color: #4ec9b0;
38+
}
39+
40+
.log-entry:last-child {
41+
border-bottom: none;
42+
}

frontend/src/components/luapreview/component.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers'
66
import 'prismjs/themes/prism-tomorrow.css'
77
import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
88

9-
109
class LuaPreviewHTMLElement extends HTMLElement {
1110

1211
connectedCallback() {

frontend/src/components/ui/component.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import template from './component.html?raw';
2+
import styleSheet from './style.css?raw';
23

34
class UIHTMLElement extends HTMLElement {
45

56
connectedCallback() {
6-
this.innerHTML = template;
7+
const shadow = this.attachShadow({ mode: 'open' })
8+
9+
// Create adoptable stylesheet
10+
const sheet = new CSSStyleSheet()
11+
sheet.replaceSync(styleSheet)
12+
shadow.adoptedStyleSheets = [sheet]
13+
14+
shadow.innerHTML = template
715
};
816

917
processUIEvent(event) {
@@ -12,15 +20,17 @@ class UIHTMLElement extends HTMLElement {
1220
const format = event.format || "FORMAT_SIMPLE";
1321
const value = event.value || 0;
1422

15-
var element = this.querySelector('[data-label="' + label + '"]');
23+
const container = this.shadowRoot;
24+
25+
var element = container.querySelector('[data-label="' + label + '"]');
1626
if (element === null) {
1727
// Create new element
1828
element = document.createElement('div');
1929
element.className = 'ui-value-entry';
2030
element.setAttribute('data-label', label);
2131
element.innerHTML = `${value}`;
2232

23-
this.appendChild(element);
33+
container.appendChild(element);
2434
} else {
2535
element.innerHTML = `${value}`;
2636
}
@@ -29,7 +39,7 @@ class UIHTMLElement extends HTMLElement {
2939
};
3040

3141
clear() {
32-
this.innerHTML = template;
42+
this.shadowRoot.innerHTML = template;
3343
}
3444
};
3545

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:host {
2+
display: flex;
3+
flex-direction: column;
4+
flex-wrap: nowrap;
5+
justify-content: flex-start;
6+
align-items: stretch;
7+
align-content: stretch;
8+
}
9+
10+
.ui-value-entry {
11+
flex: 0 1 auto;
12+
}
13+
14+
.ui-value-entry::before {
15+
content: attr(data-label) ": ";
16+
font-weight: bold;
17+
}

frontend/src/project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function saveToLocalStorage(key) {
103103
},
104104
})
105105
.then((response) => {
106-
console.log("Got response from backend : " + response);
106+
console.log("Got response from backend : " + JSON.stringify(response));
107107
});
108108

109109
const luaCode = generateCode();
@@ -116,7 +116,7 @@ function saveToLocalStorage(key) {
116116
},
117117
})
118118
.then((response) => {
119-
console.log("Got response from backend : " + response);
119+
console.log("Got response from backend : " + JSON.stringify(response));
120120
});
121121
}
122122

0 commit comments

Comments
 (0)