Skip to content

Commit e317f16

Browse files
author
Hrvoje Cavrak
committed
- Add webconfig change to display the fw version properly.
- Update javascript to support swapped vendor IDs. - Bump version.
1 parent efcefcc commit e317f16

File tree

7 files changed

+37
-13
lines changed

7 files changed

+37
-13
lines changed

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
cmake_minimum_required(VERSION 3.6)
22

3-
## Version Configuration
4-
set(VERSION_MAJOR 00)
5-
set(VERSION_MINOR 170)
3+
## Version Configuration.
4+
## Define e.g. 0.72 as major 0 and minor 72
5+
set(VERSION_MAJOR 0)
6+
set(VERSION_MINOR 73)
67

78
## Release Type Selection
89
option(DH_DEBUG "Build a debug version" OFF)
@@ -107,7 +108,9 @@ add_executable(${binary} ${DISK_ASM})
107108

108109
target_sources(${binary} PUBLIC ${COMMON_SOURCES})
109110
target_compile_definitions(${binary}
110-
PRIVATE
111+
PRIVATE
112+
VERSION_MAJOR=${VERSION_MAJOR}
113+
VERSION_MINOR=${VERSION_MINOR}
111114
PIO_USB_USE_TINYUSB=${PIO_USE_TINYUSB}
112115
PIO_USB_DP_PIN_DEFAULT=${DP_PIN_DEFAULT}
113116
__disk_file_path__="${DISK_BIN}"
@@ -129,10 +132,13 @@ pico_set_linker_script(${binary} ${CMAKE_SOURCE_DIR}/misc/memory_map.ld)
129132
## Build other file formats as well
130133
pico_add_extra_outputs(${binary})
131134

135+
# For internal firmware use, to simplify comparison: 0.72 -> 172
136+
math(EXPR FIRMWARE_VERSION "${VERSION_MAJOR} * 1000 + ${VERSION_MINOR} + 100")
137+
132138
## Post-Build Commands
133139
add_custom_command(
134140
TARGET ${binary} POST_BUILD
135-
COMMAND python3 ${CMAKE_SOURCE_DIR}/misc/crc32.py ${binary}.bin ${binary}.crc ${VERSION_MAJOR}${VERSION_MINOR}
141+
COMMAND python3 ${CMAKE_SOURCE_DIR}/misc/crc32.py ${binary}.bin ${binary}.crc ${FIRMWARE_VERSION}
136142
COMMAND ${CMAKE_OBJCOPY} --update-section .section_metadata=${binary}.crc ${binary}.elf
137143
COMMAND ${CMAKE_OBJCOPY} -O binary ${binary}.elf ${binary}.bin
138144
COMMAND ${CMAKE_BINARY_DIR}/elf2uf2/elf2uf2 ${binary}.elf ${binary}.uf2

disk/disk.img

0 Bytes
Binary file not shown.

webconfig/config-unpacked.htm

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,13 +1650,13 @@ <h3>Device Status</h3>
16501650

16511651

16521652

1653-
1653+
16541654
<label class=""> Running FW version</label>
16551655

1656-
1656+
16571657
<input class="api" type="text" name="name78" data-type="uint16" data-key="78"
16581658
onchange="valueChangedHandler(this)"
1659-
/>
1659+
data-fw-ver readonly />
16601660

16611661

16621662

@@ -1780,7 +1780,7 @@ <h3>Device Status</h3>
17801780
return;
17811781

17821782
var devices = await navigator.hid.requestDevice({
1783-
filters: [{ vendorId: 0x1209, productId: 0xc000, usagePage: 0xff00, usage: 0x10 }]
1783+
filters: [{ vendorId: 0x2e8a, productId: 0x107c, usagePage: 0xff00, usage: 0x10 }]
17841784
});
17851785

17861786
device = devices[0];
@@ -1842,6 +1842,13 @@ <h3>Device Status</h3>
18421842

18431843
if (element.hasAttribute('data-hex'))
18441844
setValue(element, parseInt(value).toString(16));
1845+
1846+
if (element.hasAttribute('data-fw-ver')) {
1847+
/* u16 version = major * 1000 + minor + 100; */
1848+
const major = Math.floor((value - 100) / 1000);
1849+
const minor = (value - 100) % 1000;
1850+
setValue(element, `v${major}.${minor}`);
1851+
}
18451852
}
18461853
}
18471854

webconfig/config.htm

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

webconfig/form.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class FormField:
2222
}
2323

2424
STATUS_ = [
25-
FormField(78, "Running FW version", None, {}, "uint16", elem="uint16"),
25+
FormField(78, "Running FW version", None, {}, "uint16", elem="fw_version"),
2626
FormField(79, "Running FW checksum", None, {}, "uint32", elem="hex_info"),
2727
]
2828

webconfig/templates/form.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
{{ label(item, add=':') }}
1717
{{ input(item, class='content api') }} data-hex readonly />
1818

19+
{% elif item.get("elem") == "fw_version" %}
20+
{{ label(item, class='') }}
21+
{{ input(item) }} data-fw-ver readonly />
22+
1923
{% elif item.get("elem") == "label" %}
2024
{{ label(item, class='') }}
2125

webconfig/templates/script.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async function connectHandler() {
8787
return;
8888

8989
var devices = await navigator.hid.requestDevice({
90-
filters: [{ vendorId: 0x1209, productId: 0xc000, usagePage: 0xff00, usage: 0x10 }]
90+
filters: [{ vendorId: 0x2e8a, productId: 0x107c, usagePage: 0xff00, usage: 0x10 }]
9191
});
9292

9393
device = devices[0];
@@ -149,6 +149,13 @@ function updateElement(key, event) {
149149

150150
if (element.hasAttribute('data-hex'))
151151
setValue(element, parseInt(value).toString(16));
152+
153+
if (element.hasAttribute('data-fw-ver')) {
154+
/* u16 version = major * 1000 + minor + 100; */
155+
const major = Math.floor((value - 100) / 1000);
156+
const minor = (value - 100) % 1000;
157+
setValue(element, `v${major}.${minor}`);
158+
}
152159
}
153160
}
154161

@@ -212,4 +219,4 @@ async function saveHandler() {
212219

213220
async function wipeConfigHandler() {
214221
await sendReport(packetType.wipeConfigMsg, [], true);
215-
}
222+
}

0 commit comments

Comments
 (0)