Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/preBuildConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def preBuildConfigFun():
else:
cpp.write(',\n')

if item['type'] == 'char':
if (item['type'] == 'char' or item['type'] == 'color'):
cpp.write("\t\"" + item['value'] + "\"")
h.write("\tchar " + item['name'] + "[" + str(item['length']) + "];\n")
elif item['type'] == 'bool':
Expand Down
13 changes: 11 additions & 2 deletions html/js/comp/ConfigPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const DefaultTypeAttributes = {
max: 3.4028235E+38,
step: "any",
},
color: {
type: "color",
},
};

export function ConfigPage(props) {
Expand Down Expand Up @@ -90,9 +93,9 @@ export function ConfigPage(props) {
continue;
}

let value;
let value;
if (typeof state[Config[i].name] !== "undefined") {value = state[Config[i].name];} else {value = "";}

const configInputAttributes = DefaultTypeAttributes[Config[i].type] || {};
const inputType = DefaultTypeAttributes[Config[i].type].type || "text";

Expand All @@ -117,6 +120,12 @@ export function ConfigPage(props) {
<Grey>({conditionalAttributes.min} &ndash; {conditionalAttributes.max})</Grey>
</>;
break;

case "color":
inputType = "color";
conditionalAttributes.value = value;
break;

}

confItems = <>{confItems}
Expand Down
8 changes: 7 additions & 1 deletion html/js/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"length": 32,
"value": "Generic ESP8266 Firmware"
},
{
"name": "dummyColor",
"type": "color",
"length": 32,
"value": "#ffffff"
},
{
"name": "dummyInt",
"type": "uint16_t",
Expand All @@ -15,7 +21,7 @@
"name": "dummyBool",
"type": "bool",
"value": true
},
},
{
"name": "dummyFloat",
"type": "float",
Expand Down
2 changes: 2 additions & 0 deletions html/js/functions/configHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function obj2bin(obj, binSize) {
for (let i = 0; i < Config.length; i++) {
switch (Config[i].type) {
case "char":
case "color":
for (let j = 0; j < obj[Config[i].name].length; j++) {
binDataView.setUint8(n, (new TextEncoder).encode(obj[Config[i].name][j])[0]);
n++;
Expand Down Expand Up @@ -70,6 +71,7 @@ export function bin2obj(rawData) {
for (let i = 0; i < Config.length; i++) {
switch (Config[i].type) {
case "char":
case "color":
parsedData[Config[i].name] = utf8decoder.decode(rawData.slice(n, n + Config[i].length)).split("\0").shift();
n = n + Config[i].length;
break;
Expand Down