Unify optional hardware variants and add runtime R8 TFT rotation
This commit is contained in:
1 parent
3848626702
commit
9c78ccde57
61 files changed
+4853
-2518
No files matched your search
@@ -821,8 +821,10 @@ jobs:
|
||||
node test/test_firmware_picker.js
|
||||
node test/test_t114_picker.js
|
||||
node test/test_optional_display_picker.js
|
||||
node test/test_consolidated_picker.js
|
||||
python3 -B test/test_t114_release_profiles.py -v
|
||||
python3 -B test/test_optional_display_profiles.py -v
|
||||
python3 -B test/test_consolidated_profiles.py -v
|
||||
|
||||
- name: Verify Full logging compiler flags and packaged capabilities
|
||||
run: |
|
||||
@@ -960,6 +962,9 @@ jobs:
|
||||
python3 -B test/test_rc32_display_detection.py -v
|
||||
python3 -B test/test_wireless_tracker_display_detection.py -v
|
||||
python3 -B test/test_heltec_r8_display_detection.py -v
|
||||
python3 -B test/test_heltec_r8_display_rotation.py -v
|
||||
python3 -B test/test_muzi_accessory_detection.py -v
|
||||
python3 -B test/test_techo_lite_display_detection.py -v
|
||||
python3 -B test/test_companion_headless_buttons.py -v
|
||||
python3 -B test/test_st7735_display_wake_profile.py -v
|
||||
python3 -B test/test_legacy_ui_version_bounds.py -v
|
||||
|
||||
+31
-1
@@ -3517,6 +3517,15 @@ declare_build_capability_contract() {
|
||||
&& is_esp32_canonical_full_release_target "$env_name"; then
|
||||
pio_env_name=$(get_exact_identity_full_pio_env "$env_name")
|
||||
fi
|
||||
local consolidation_contract capability marker
|
||||
consolidation_contract=""
|
||||
if [ -n "$PIO_CONFIG_JSON" ]; then
|
||||
consolidation_contract=$(python3 scripts/consolidated_profiles.py expectations "$pio_env_name" <<<"$PIO_CONFIG_JSON") || return 1
|
||||
fi
|
||||
while IFS='=' read -r capability marker; do
|
||||
[ -n "$capability" ] || continue
|
||||
record_application_expectation "$capability" "$marker"
|
||||
done <<<"$consolidation_contract"
|
||||
if is_repeater_role_target "$env_name" \
|
||||
&& { pio_env_option_contains "$env_name" build_flags "WITH_RS232_BRIDGE=" \
|
||||
|| pio_env_option_contains "$pio_env_name" build_flags "WITH_RS232_BRIDGE="; }; then
|
||||
@@ -3552,7 +3561,8 @@ declare_build_capability_contract() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$env_platform" = "ESP32_PLATFORM" ] && ! is_kiss_modem_target "$env_name"; then
|
||||
if { [ "$env_platform" = "ESP32_PLATFORM" ] || [ "$env_platform" = "NRF52_PLATFORM" ]; } \
|
||||
&& ! is_kiss_modem_target "$env_name"; then
|
||||
local optional_display_marker
|
||||
if [ -n "$PIO_CONFIG_JSON" ] \
|
||||
&& optional_display_marker=$(python3 scripts/optional_display_profiles.py "$pio_env_name" <<<"$PIO_CONFIG_JSON"); then
|
||||
@@ -5813,6 +5823,9 @@ is_runtime_setting_alias_target() {
|
||||
if get_t114_display_replacement "$1" >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
if get_consolidated_hardware_replacement "$1" >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
if is_legacy_companion_power_saving_target "$1" \
|
||||
|| is_legacy_companion_femoff_target "$1" \
|
||||
|| is_legacy_radio_gain_profile_target "$1" \
|
||||
@@ -5827,6 +5840,23 @@ is_runtime_setting_alias_target() {
|
||||
return 1
|
||||
}
|
||||
|
||||
get_consolidated_hardware_replacement() {
|
||||
# Configuration proves the new implementation is selected before omitting
|
||||
# an ordinary build. Packaging independently requires its executed marker.
|
||||
# Explicit builds still retain the requested historical OTA identity.
|
||||
case "${1,,}" in
|
||||
picow_companion_radio_usb|picow_companion_radio_ble|picow_companion_radio_wifi|\
|
||||
heltec_v4_expansionkit_repeater|heltec_v4_expansionkit_repeater_observer_mqtt|heltec_v4_expansionkit_room_server_observer_mqtt|\
|
||||
heltec_v4_r8_tft_portrait_repeater_observer_mqtt|heltec_v4_r8_tft_portrait_room_server_observer_mqtt|\
|
||||
heltec_v4_expansionkit_tft_companion_radio_*|heltec_v4_3_expansionkit_tft_companion_radio_*|\
|
||||
muzi_base_duo_superio_companion_radio_*|muzi_base_uno_superio_companion_radio_*|lilygo_t-echo-lite_non_shell_companion_radio_*|\
|
||||
heltec_rc32_without_display_*) ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
[ -n "$PIO_CONFIG_JSON" ] || return 1
|
||||
python3 scripts/consolidated_profiles.py replacement "$1" <<<"$PIO_CONFIG_JSON"
|
||||
}
|
||||
|
||||
is_t114_display_autodetect_build() {
|
||||
local target=$1
|
||||
[ "${PIO_ENV_PLATFORM_BY_NAME[$target]:-}" = NRF52_PLATFORM ] \
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
const MODE_LABELS = Object.freeze({
|
||||
standard: "Standard / no separate bridge",
|
||||
full: "Full Companion transports",
|
||||
combined: "USB + Bluetooth LE + Wi-Fi",
|
||||
ble: "Bluetooth LE",
|
||||
usb: "USB",
|
||||
"usb-ble": "USB + Bluetooth LE",
|
||||
@@ -742,13 +743,73 @@
|
||||
}));
|
||||
}
|
||||
|
||||
function releaseBoundControl(profile, key) {
|
||||
const controls = profile && profile.controls;
|
||||
const source = controls && controls[key + "Source"];
|
||||
return Boolean(controls && controls[key] === true && /^[0-9a-f]{40}$/.test(source || "") &&
|
||||
Array.isArray(profile.files) && profile.files.length && profile.files.every(function (file) {
|
||||
const hash = file.name.match(/-([0-9a-f]{8,40})(?:-merged)?\.(?:bin|hex|uf2|zip)$/i);
|
||||
return hash && source.startsWith(hash[1].toLowerCase());
|
||||
}));
|
||||
}
|
||||
|
||||
function combinedPicoCompanion(profile) {
|
||||
return Boolean(profile && profile.target === "PicoW_companion_radio" &&
|
||||
profile.controls && profile.controls.platform === "RP2040_PLATFORM" &&
|
||||
releaseBoundControl(profile, "combinedCompanion"));
|
||||
}
|
||||
|
||||
function consolidationSuccessor(profile, candidate) {
|
||||
if (!profile || !candidate || profile.role !== candidate.role) return false;
|
||||
if (/^PicoW_companion_radio_(usb|ble|wifi)$/.test(profile.target)) {
|
||||
return combinedPicoCompanion(candidate);
|
||||
}
|
||||
const muzi = /^muzi_base_(uno|duo)_superIO$/i.exec(profile.hardware);
|
||||
if (muzi) {
|
||||
return candidate.hardware.toLowerCase() === "muzi_base_" + muzi[1].toLowerCase() &&
|
||||
isFullCompanion(candidate) && optionalAutoDisplayProfile(candidate);
|
||||
}
|
||||
if (profile.hardware === "LilyGo_T-Echo-Lite_non_shell") {
|
||||
return candidate.hardware === "LilyGo_T-Echo-Lite" && isFullCompanion(candidate) && optionalAutoDisplayProfile(candidate);
|
||||
}
|
||||
if (profile.hardware === "heltec_rc32_without_display") {
|
||||
return candidate.hardware === "heltec_rc32" && optionalAutoDisplayProfile(candidate) &&
|
||||
(!profile.sensorProfile || profile.sensorProfile === candidate.sensorProfile);
|
||||
}
|
||||
if (profile.hardware === "heltec_v4_expansionkit" && ["repeater", "room"].includes(profile.role)) {
|
||||
return candidate.hardware === "heltec_v4" && candidate.feature === profile.feature &&
|
||||
candidate.controls && candidate.controls.platform === "ESP32_PLATFORM" &&
|
||||
releaseBoundControl(candidate, "oledExpansionCompatible");
|
||||
}
|
||||
if (["heltec_v4_expansionkit_tft", "heltec_v4_3_expansionkit_tft"].includes(profile.hardware) && profile.role === "companion") {
|
||||
return candidate.target === "heltec_v4_tft_companion_radio_full_femon" &&
|
||||
isFullCompanion(candidate) && candidate.controls && candidate.controls.platform === "ESP32_PLATFORM" &&
|
||||
releaseBoundControl(candidate, "tftExpansionCompatible");
|
||||
}
|
||||
if (profile.hardware === "heltec_v4_r8_tft_portrait" && ["repeater", "room"].includes(profile.role)) {
|
||||
return candidate.hardware === "heltec_v4_r8_tft" && candidate.feature === profile.feature &&
|
||||
candidate.controls && candidate.controls.platform === "ESP32_PLATFORM" &&
|
||||
releaseBoundControl(candidate, "displayRotation");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function omitConsolidatedProfiles(profiles) {
|
||||
return (profiles || []).filter(function (profile) {
|
||||
return !profiles.some(function (candidate) { return consolidationSuccessor(profile, candidate); });
|
||||
});
|
||||
}
|
||||
|
||||
function optionalAutoDisplayProfile(profile) {
|
||||
const controls = profile && profile.controls;
|
||||
const target = String(profile && profile.target || "").toLowerCase();
|
||||
const controller = /^heltec_rc32_(?!without_display_)/.test(target) ? "nv3001b"
|
||||
: /^heltec_(?:wireless_tracker|tracker_v1_1)_/.test(target) ? "st7735"
|
||||
: /^heltec_v4_r8_tft_/.test(target) ? "st7789" : "";
|
||||
return Boolean(controller && controls && controls.platform === "ESP32_PLATFORM" &&
|
||||
: /^heltec_v4_r8_tft_/.test(target) ? "st7789"
|
||||
: /^muzi_base_(?:uno|duo)_(?:superio_)?companion_radio_/.test(target) ? "sh1107"
|
||||
: /^lilygo_t-echo-lite_(?:non_shell_)?(?:companion_radio_|repeater|room_server)/.test(target) ? "ssd1681" : "";
|
||||
const platform = controller === "sh1107" || controller === "ssd1681" ? "NRF52_PLATFORM" : "ESP32_PLATFORM";
|
||||
return Boolean(controller && controls && controls.platform === platform &&
|
||||
controls.display === true && controls.displayAuto === true && controls.displayController === controller &&
|
||||
/^[0-9a-f]{40}$/.test(controls.displaySource || "") &&
|
||||
(!profile.controlsSource || controls.displaySource === profile.controlsSource) &&
|
||||
@@ -934,6 +995,11 @@
|
||||
}
|
||||
|
||||
function applyReleaseRuntimeCapabilities(profile, controls) {
|
||||
if (combinedPicoCompanion(profile)) {
|
||||
profile.mode = "combined";
|
||||
profile.variant = "default";
|
||||
profile.connectionModes = ["combined", "usb", "ble", "wifi", "standard"];
|
||||
}
|
||||
if (["none", "lora-receiver", "lora-source"].includes(controls.otaRole)) {
|
||||
profile.ota = controls.otaRole;
|
||||
}
|
||||
@@ -1212,7 +1278,7 @@
|
||||
}),
|
||||
// Recommendation filters retain original files and target identities in
|
||||
// the raw catalog, including when a qualified successor replaces them.
|
||||
profiles: omitT114DisplayDuplicates(omitReplacedQspiProfiles(omitStationG3SlotDuplicates(profiles))),
|
||||
profiles: omitConsolidatedProfiles(omitT114DisplayDuplicates(omitReplacedQspiProfiles(omitStationG3SlotDuplicates(profiles)))),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1270,6 +1336,29 @@
|
||||
}).filter(Boolean)));
|
||||
}
|
||||
|
||||
function explicitlyReduced(profiles, filters) {
|
||||
return Boolean(filters && (filters.feature === "standard" ||
|
||||
/(?:^|-)no-external-sensors(?:-|$)/.test(filters.variant || "")) &&
|
||||
(profiles || []).some(function (profile) {
|
||||
return profile.sensorProfile === "reduced" && profileMatchesFacets(profile, filters);
|
||||
}));
|
||||
}
|
||||
|
||||
function recommendedProfiles(profiles, filters, includeReduced) {
|
||||
if (includeReduced || explicitlyReduced(profiles, filters)) return profiles || [];
|
||||
const full = new Map((profiles || []).filter(function (profile) {
|
||||
return profile.sensorProfile === "full" && profile.controls &&
|
||||
/^[0-9a-f]{40}$/.test(profile.controls.sensorProfileSource || "");
|
||||
}).map(function (profile) { return [profile.releaseFamily + ":" + profile.target, profile]; }));
|
||||
return (profiles || []).filter(function (profile) {
|
||||
if (profile.sensorProfile !== "reduced") return true;
|
||||
const successor = full.get(profile.releaseFamily + ":" + profile.target.replace(/-reduced$/, "-full"));
|
||||
// A lone Reduced image remains visible. This default never removes
|
||||
// downloads, exact sensor policies or an unmatched compatibility route.
|
||||
return !successor || successor.controls.sensorProfileSource !== profile.controls.sensorProfileSource;
|
||||
});
|
||||
}
|
||||
|
||||
// Keep the original URL facets, but select the correlated firmware
|
||||
// capabilities together so OTA and its sensor/storage tradeoff take one click.
|
||||
function firmwareProfileValue(filters) {
|
||||
@@ -1525,6 +1614,26 @@
|
||||
FACET_FIELDS.forEach(function (field) {
|
||||
requested[field] = params.get(field) || "";
|
||||
});
|
||||
[
|
||||
["heltec_rc32_without_display", "heltec_rc32", function (profile) { return optionalAutoDisplayProfile(profile); }],
|
||||
["heltec_v4_expansionkit", "heltec_v4", function (profile) { return ["repeater", "room"].includes(profile.role) && releaseBoundControl(profile, "oledExpansionCompatible"); }],
|
||||
["heltec_v4_r8_tft_portrait", "heltec_v4_r8_tft", function (profile) { return ["repeater", "room"].includes(profile.role) && releaseBoundControl(profile, "displayRotation"); }],
|
||||
["heltec_v4_expansionkit_tft", "heltec_v4_tft", function (profile) { return profile.target === "heltec_v4_tft_companion_radio_full_femon" && releaseBoundControl(profile, "tftExpansionCompatible"); }],
|
||||
["heltec_v4_3_expansionkit_tft", "heltec_v4_tft", function (profile) { return profile.target === "heltec_v4_tft_companion_radio_full_femon" && releaseBoundControl(profile, "tftExpansionCompatible"); }],
|
||||
["muzi_base_uno_superIO", "muzi_base_uno", function (profile) { return isFullCompanion(profile) && optionalAutoDisplayProfile(profile); }],
|
||||
["muzi_base_duo_superIO", "muzi_base_duo", function (profile) { return isFullCompanion(profile) && optionalAutoDisplayProfile(profile); }],
|
||||
["LilyGo_T-Echo-Lite_non_shell", "LilyGo_T-Echo-Lite", function (profile) { return isFullCompanion(profile) && optionalAutoDisplayProfile(profile); }],
|
||||
].forEach(function (alias) {
|
||||
if (!profiles.some(function (profile) { return profile.hardware === alias[0] && (!requested.role || profile.role === requested.role); }) &&
|
||||
profiles.some(function (profile) { return profile.hardware === alias[1] && alias[2](profile) && (!requested.role || profile.role === requested.role); })) {
|
||||
["hardware", "hardwareFamily"].forEach(function (field) {
|
||||
if (requested[field] === alias[0]) requested[field] = alias[1];
|
||||
});
|
||||
}
|
||||
});
|
||||
if (requested.hardware === "PicoW" && requested.variant === "radio" && profiles.some(combinedPicoCompanion)) {
|
||||
requested.variant = "default";
|
||||
}
|
||||
if (!profiles.some(function (profile) {
|
||||
return String(profile.hardware).toLowerCase() === "heltec_t114_without_display" &&
|
||||
(!requested.role || profile.role === requested.role);
|
||||
@@ -1774,6 +1883,18 @@
|
||||
const target = profile.target;
|
||||
const info = profile.controls || {};
|
||||
const notes = [];
|
||||
if (combinedPicoCompanion(profile)) {
|
||||
notes.push("This Companion image includes USB, Bluetooth LE and WiFi together. Separate transport firmware is unnecessary; this image does not add a wireless firmware updater.");
|
||||
}
|
||||
if (releaseBoundControl(profile, "oledExpansionCompatible")) {
|
||||
notes.push("The same OLED firmware supports the base Heltec V4 and its OLED expansion kit. Existing expansion-kit OTA identities still require their exact historical update or a local USB migration.");
|
||||
}
|
||||
if (releaseBoundControl(profile, "tftExpansionCompatible")) {
|
||||
notes.push("This Full Companion supports the matching Heltec V4 TFT base and TFT expansion kit. Keep your saved settings; changing an older expansion-kit target to this canonical target requires local USB installation.");
|
||||
}
|
||||
if (releaseBoundControl(profile, "displayRotation")) {
|
||||
notes.push("Portrait and landscape use the same firmware. Choose display.rotation at runtime; the stock expansion kit has no orientation sensor.");
|
||||
}
|
||||
if (t114AutoDisplayProfile(profile)) {
|
||||
notes.push("One T114 image detects the supported ST7789 screen at startup and also runs without a screen.");
|
||||
notes.push("Switching from an older without_display image requires a local USB update; do not use a different target's LoRa OTA package. Keep your existing identity and settings; no erase is required.");
|
||||
@@ -2122,7 +2243,7 @@
|
||||
if (infrastructure && (info.updateMethods || []).includes("bluetooth")) section("Bluetooth firmware update", [
|
||||
{ label: "Start DFU", commands: ["start ota"], text: "Use the exact board's application DFU ZIP with the matching Bluetooth-capable bootloader." },
|
||||
]);
|
||||
if (full && info.display) section("Display rotation", [0, 90, 180, 270].map(function (angle) {
|
||||
if ((full || releaseBoundControl(profile, "displayRotation")) && info.display) section("Display rotation", [0, 90, 180, 270].map(function (angle) {
|
||||
return { label: angle === 0 ? "Board default" : angle + " degrees", commands: ["set display.rotation " + angle] };
|
||||
}), "Use on supported displays; 0 restores the board default. Check with get display.rotation.");
|
||||
return sections;
|
||||
@@ -2349,6 +2470,19 @@
|
||||
let bootloaderCatalog = null;
|
||||
let bootloaderNotice = "Loading the latest bootloader downloads...";
|
||||
const filters = {};
|
||||
let showReducedSensors = false;
|
||||
const sensorOptions = createElement("details");
|
||||
sensorOptions.className = "firmware-picker-chip-family firmware-picker-wide";
|
||||
sensorOptions.hidden = true;
|
||||
sensorOptions.appendChild(createElement("summary", "Advanced: sensor compatibility"));
|
||||
const sensorLabel = createElement("label");
|
||||
const sensorToggle = createElement("input");
|
||||
sensorToggle.type = "checkbox";
|
||||
sensorLabel.appendChild(sensorToggle);
|
||||
sensorLabel.appendChild(document.createTextNode(" Show Reduced sensor images"));
|
||||
sensorOptions.appendChild(sensorLabel);
|
||||
sensorOptions.appendChild(createElement("p", "Full sensor support is recommended. Reduced images omit optional drivers and remain available for existing update routes or recovery."));
|
||||
form.insertBefore(sensorOptions, form.querySelector(".firmware-picker-form-actions"));
|
||||
let automaticChipFamily = false;
|
||||
const groupPrefix = "firmware-picker-" + (++pickerInstanceCount);
|
||||
if (resultLink) {
|
||||
@@ -2406,11 +2540,23 @@
|
||||
global.addEventListener("popstate", restoreSelectionUrl);
|
||||
|
||||
function matchingProfiles(ignoredField) {
|
||||
return catalog.profiles.filter(function (profile) {
|
||||
return selectionProfiles().filter(function (profile) {
|
||||
return profileMatchesFacets(profile, filters, ignoredField);
|
||||
});
|
||||
}
|
||||
|
||||
function selectionProfiles() {
|
||||
return recommendedProfiles(catalog.profiles, filters, showReducedSensors);
|
||||
}
|
||||
|
||||
sensorToggle.addEventListener("change", function () {
|
||||
showReducedSensors = sensorToggle.checked;
|
||||
if (!showReducedSensors && explicitlyReduced(catalog.profiles, filters)) {
|
||||
PROFILE_FIELDS.forEach(function (field) { filters[field] = ""; });
|
||||
}
|
||||
refreshFacets();
|
||||
});
|
||||
|
||||
function setSelectOptions(select, field, values, selected) {
|
||||
select.replaceChildren();
|
||||
const hardwareProfiles = field === "hardware" || field === "hardwareFamily"
|
||||
@@ -2473,7 +2619,7 @@
|
||||
hint.id = groupPrefix + "-" + field + "-hint";
|
||||
fieldset.insertBefore(hint, container);
|
||||
}
|
||||
const same = choicesUseSameFirmware(catalog.profiles, filters, field, options);
|
||||
const same = choicesUseSameFirmware(selectionProfiles(), filters, field, options);
|
||||
badge.hidden = !same;
|
||||
hint.hidden = !same;
|
||||
hint.textContent = same ? "These choices do not narrow the firmware builds." +
|
||||
@@ -2502,7 +2648,7 @@
|
||||
ignored.push("chipFamily");
|
||||
}
|
||||
return facetValues(
|
||||
catalog.profiles,
|
||||
selectionProfiles(),
|
||||
filters,
|
||||
field,
|
||||
ignored
|
||||
@@ -2554,13 +2700,19 @@
|
||||
FACET_FIELDS.forEach(function (field) {
|
||||
setControlOptions(field, valuesForField(field));
|
||||
});
|
||||
const profileChoices = firmwareProfileChoices(catalog.profiles, filters);
|
||||
const selectedProfiles = selectionProfiles();
|
||||
sensorOptions.hidden = !catalog.profiles.some(function (profile) {
|
||||
return profile.sensorProfile === "reduced" && profileMatchesFacets(profile, filters, PROFILE_FIELDS);
|
||||
});
|
||||
sensorToggle.checked = showReducedSensors || explicitlyReduced(catalog.profiles, filters);
|
||||
if (sensorToggle.checked) sensorOptions.open = true;
|
||||
const profileChoices = firmwareProfileChoices(selectedProfiles, filters);
|
||||
const profileControl = controls.firmwareProfile;
|
||||
renderRadioChoices(profileControl, [{ value: "", label: "Any" }].concat(profileChoices),
|
||||
firmwareProfileValue(filters), groupPrefix + "-firmwareProfile", "firmwareProfile");
|
||||
profileControl.closest("fieldset").disabled = profileChoices.length === 0;
|
||||
setRefinementHint(profileControl, "firmwareProfile", profileChoices);
|
||||
const requirements = selectionRequirements(catalog.profiles, filters);
|
||||
const requirements = selectionRequirements(selectedProfiles, filters);
|
||||
["logging", "firmwareProfile", "mode", "install"].forEach(function (field) {
|
||||
const control = controls[field];
|
||||
if (control) control.closest("fieldset").hidden = requirements.hiddenFields.includes(field);
|
||||
@@ -2590,7 +2742,7 @@
|
||||
result.hidden = true;
|
||||
missing.hidden = true;
|
||||
resultList.replaceChildren();
|
||||
const requirements = selectionRequirements(catalog.profiles, filters);
|
||||
const requirements = selectionRequirements(selectionProfiles(), filters);
|
||||
const missingFields = requirements.missingFields;
|
||||
const cardOptions = {
|
||||
runtimeFields: requirements.hiddenFields,
|
||||
@@ -2603,7 +2755,7 @@
|
||||
};
|
||||
const matches = matchingProfiles();
|
||||
if (feedback) {
|
||||
const progress = selectionProgress(catalog.profiles,
|
||||
const progress = selectionProgress(selectionProfiles(),
|
||||
Object.assign({}, filters, { install: requirements.installKind }));
|
||||
feedback.hidden = false;
|
||||
feedback.dataset.state = progress.state;
|
||||
@@ -2789,6 +2941,8 @@
|
||||
event.preventDefault();
|
||||
if (!catalog.profiles.length) return;
|
||||
automaticChipFamily = false;
|
||||
showReducedSensors = false;
|
||||
sensorOptions.open = false;
|
||||
if (linkStatus) linkStatus.textContent = "";
|
||||
FACET_FIELDS.forEach(function (field) {
|
||||
filters[field] = "";
|
||||
@@ -2906,6 +3060,10 @@
|
||||
omitLegacyObserverCompatibilityProfiles,
|
||||
omitStationG3SlotDuplicates: omitStationG3SlotDuplicates,
|
||||
t114AutoDisplayProfile: t114AutoDisplayProfile,
|
||||
combinedPicoCompanion: combinedPicoCompanion,
|
||||
releaseBoundControl: releaseBoundControl,
|
||||
omitConsolidatedProfiles: omitConsolidatedProfiles,
|
||||
recommendedProfiles: recommendedProfiles,
|
||||
optionalAutoDisplayProfile: optionalAutoDisplayProfile,
|
||||
omitT114DisplayDuplicates: omitT114DisplayDuplicates,
|
||||
omitTransportsReplacedByDualCdcFull:
|
||||
|
||||
+34
-3
@@ -1212,6 +1212,37 @@ screen identifies connected USB and Bluetooth clients (or both), and TCP,
|
||||
Ethernet, or serial clients where supported. Actual BLE pairing prompts retain
|
||||
priority over connection status.
|
||||
|
||||
## Set display rotation
|
||||
|
||||
Supported Companion displays and new Heltec V4 R8 TFT Repeater, Room Server,
|
||||
and Sensor images accept a saved rotation:
|
||||
|
||||
```text
|
||||
get display.rotation
|
||||
set display.rotation 0
|
||||
set display.rotation 90
|
||||
set display.rotation 180
|
||||
set display.rotation 270
|
||||
```
|
||||
|
||||
`0` restores the board's compiled orientation. On the R8 TFT, the other values
|
||||
turn clockwise from that default. A quarter turn changes between portrait and
|
||||
landscape, and the observer dashboard adapts to the new screen dimensions.
|
||||
The change applies without rebooting. Changing rotation while the display is
|
||||
off leaves it off; the next wake applies the pending panel rotation without
|
||||
resetting the shared touch controller. WebConfig offers the same choices under
|
||||
**Display → Rotation** when the running image supports rotation.
|
||||
|
||||
The stock [R8 Expansion Kit V2](https://heltec.org/project/v4-r8-ex/) does not
|
||||
include an accelerometer. Its GNSS and touch controllers do not measure the
|
||||
screen's physical orientation, so this firmware offers manual rotation rather
|
||||
than an automatic orientation option. Automatic orientation would require a
|
||||
supported motion sensor and its mounting orientation.
|
||||
|
||||
Companion saves this in its existing node preferences. Infrastructure roles
|
||||
use a separate checked settings file, leaving existing node/MQTT layouts
|
||||
compatible. Old published images retain their original supported commands.
|
||||
|
||||
## Set MQTT observer display flip
|
||||
|
||||
Supported observer displays, including the R8 OLED and ST7789 panels, can also
|
||||
@@ -1224,9 +1255,9 @@ set display.flip on
|
||||
```
|
||||
|
||||
`0` and `1` are accepted aliases for `off` and `on`. This is intentionally
|
||||
different from Full Companion `display.rotation`: observer `display.flip` is a
|
||||
relative 180-degree mounting choice and cannot switch between portrait and
|
||||
landscape. The value is harmless on an observer display driver that does not
|
||||
different from `display.rotation`: observer `display.flip` is an additional
|
||||
relative 180-degree mounting choice. Use `display.rotation` to switch between
|
||||
portrait and landscape on new R8 TFT images. The value is harmless on an observer display driver that does not
|
||||
support flipping.
|
||||
|
||||
Flip survives reboot and firmware updates that preserve the filesystem;
|
||||
|
||||
+27
-1
@@ -9,7 +9,7 @@
|
||||
<div class="firmware-picker-feedback firmware-picker-wide" data-role="filter-feedback" hidden>
|
||||
<div aria-live="polite" aria-atomic="true">
|
||||
<strong data-role="filter-count"></strong>
|
||||
<p data-role="filter-note"></p>
|
||||
<p data-role="filter-note"></p>
|
||||
</div>
|
||||
<a data-role="view-results" hidden>View files</a>
|
||||
</div>
|
||||
@@ -159,6 +159,11 @@ Once the exact board and role are selected, the picker skips logging,
|
||||
connection, and profile choices that all select the same firmware. Logging
|
||||
settings move into **Restore your settings after flashing** beneath the files.
|
||||
Choices that select different images remain visible.
|
||||
For qualified nRF52 sensor pairs, Full is the normal recommendation. Open
|
||||
**Advanced: sensor compatibility → Show Reduced sensor images** to select a Reduced image for
|
||||
an existing update route or its smaller optional-driver set. Shared links
|
||||
that explicitly select Reduced retain that selection. Both downloads remain
|
||||
available; this changes the recommendation, not their OTA identities.
|
||||
The optional chip-family filter (ESP32, nRF52, RP2040, or STM32) can narrow the
|
||||
hardware list first. You can skip it: picking hardware fills it in automatically.
|
||||
Chip family and hardware are the only dropdowns. All remaining choices use
|
||||
@@ -330,6 +335,27 @@ SSD1306 Full Companion builds use `set display.rotation 90|180|270`; `0`
|
||||
restores the board default, so a separate rotated release image is not
|
||||
recommended.
|
||||
|
||||
New Heltec V4 R8 TFT images also support saved rotation in Companion,
|
||||
Repeater, Room Server and Sensor roles. The observer dashboard follows the
|
||||
selected portrait or landscape orientation. Once the canonical image proves
|
||||
this capability, the picker replaces separate portrait recommendations with
|
||||
runtime rotation controls. The stock R8 kit has no accelerometer, so automatic
|
||||
orientation is not offered. See [display rotation](cli_commands.md#set-display-rotation).
|
||||
|
||||
Other new canonical images can replace redundant hardware or transport choices:
|
||||
the Heltec V4 OLED covers its matching OLED expansion kit, Pico W Companion
|
||||
combines USB/Bluetooth/WiFi, and RC32 detects its optional T108 display. The
|
||||
picker requires verified capabilities from the actual downloadable application
|
||||
before replacing an older recommendation. Existing downloads remain available
|
||||
through the advanced filename search; changing target names still requires
|
||||
the matching local migration rather than a cross-target LoRa update.
|
||||
|
||||
Muzi Base Companion also includes the optional SuperIO accessory for its exact
|
||||
Uno or Duo radio, and T-Echo Lite Companion detects its e-paper panel. A new
|
||||
verified canonical image can therefore replace the matching SuperIO or
|
||||
non-shell recommendation. These accessory choices do not change the radio
|
||||
hardware selection. See [optional screens](optional_screens.md).
|
||||
|
||||
Ordinary non-OTA roles also use one artifact for normal operation and USB
|
||||
logging. On ESP32 1.17.1.5, run `set powersaving off` before `set usb.logging on`.
|
||||
Select the saved mode with `set usb.logging off|on`; no `-logging-`
|
||||
|
||||
@@ -148,6 +148,12 @@ environmental/ranging drivers while retaining generic I2C and supported board
|
||||
peripherals. Reduced RAK3401/RAK4631 recipes also retain their supported
|
||||
INA219/INA226/INA260/INA3221 voltage/current drivers.
|
||||
|
||||
The picker recommends Full when both profiles are qualified from the same
|
||||
source. Reduced remains available through its Advanced sensor option and
|
||||
explicit shared links, with both downloads and their update identities
|
||||
retained. An absent sensor does not require a Reduced image; supported sensor
|
||||
discovery already handles missing peripherals.
|
||||
|
||||
Both profiles retain their exact board/role OTA identity and storage layout.
|
||||
Choose the matching storage variant and meet its staging/bootloader
|
||||
requirements. These profiles are LoRa OTA receivers; nRF52 Full Companion
|
||||
|
||||
@@ -28,12 +28,19 @@ add detection to an older download.
|
||||
| iKoka Stick and Handheld | The designer documents an [optional Stick OLED](https://github.com/ndoo/ikoka-stick-meshtastic-device#oled-display-optional) and [optional Handheld OLED](https://github.com/ndoo/ikoka-handheld-meshtastic-device#oled-display-optional). | Existing display-capable images already check presence. Handheld Companion supports the screen; currently headless infrastructure recipes remain headless. |
|
||||
| Original LilyGo T-Beam | [LilyGo](https://lilygo.cc/products/t-beam-v1-1-esp32-lora-module) offers soldered/non-soldered OLED configurations. | Existing display-capable SSD1306 images already check presence. |
|
||||
| XIAO ESP32-S3 with Wio-SX1262 | [Seeed](https://wiki.seeedstudio.com/wio_sx1262_with_xiao_esp32s3_kit/#recommended-accessories) lists the expansion board as an accessory for adding screens and sensors. | Existing display-capable Companion images already check presence. |
|
||||
| Muzi Base Uno/Duo with SuperIO | [SuperIO](https://muzi.works/products/super-io) adds the OLED, GPS, buttons and buzzer to the matching Base radio. | New Companion images probe the SH1107 display, leave its 12 V supply off when absent, and discover GPS independently. Uno and Duo retain their different radio drivers. |
|
||||
| LilyGo T-Echo Lite core/display assembly | [LilyGo](https://lilygo.cc/en-us/products/t-echo-lite) documents the split core/base design. | New Companion images check SSD1681 status readback before e-paper initialization and continue headless when the panel does not respond. The old non-shell target names remain compatibility recipes. |
|
||||
|
||||
The older V4 TFT expansion configuration is also optional, but its current
|
||||
recipe has no verified panel readback connection. Detection is not enabled for
|
||||
that wiring. A touchscreen acknowledgement alone does not establish that the
|
||||
LCD responds. The V4 R8 TFT and older V4 TFT pin mappings are distinct.
|
||||
|
||||
New R8 TFT images support saved `display.rotation` values of `0`, `90`, `180`
|
||||
and `270`, including portrait/landscape dashboard changes without reflashing.
|
||||
The stock R8 expansion board has no accelerometer for automatic orientation.
|
||||
See the [rotation commands](cli_commands.md#set-display-rotation).
|
||||
|
||||
Full Wireless Tracker repeaters retain the board's 50-neighbor capacity, as
|
||||
the V1.1 and V2 Full profiles already do. This preserves RAM for the screen,
|
||||
GPS, MQTT and update services; the RAM admission limits remain unchanged.
|
||||
|
||||
@@ -5095,6 +5095,8 @@ static bool wcCopyValue(char* dest, size_t dest_size, const char* value) {
|
||||
|
||||
void MyMesh::getNodeSnapshot(WebConfigServer::NodeSnapshot& s) {
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.display_rotation_supported = _ui != NULL && _ui->supportsDisplayRotation();
|
||||
s.display_rotation_degrees = _prefs.display_rotation_degrees;
|
||||
#if defined(ESP32_PLATFORM) && defined(WIFI_SSID)
|
||||
if (_management_password_ready) {
|
||||
wcCopyValue(s.admin_password, sizeof(s.admin_password), _management_password);
|
||||
|
||||
@@ -3928,6 +3928,14 @@ void setup() {
|
||||
|
||||
// add usb interface
|
||||
#if defined(RP2040_PLATFORM) && defined(ENABLE_WIFI_INTERFACE)
|
||||
#if defined(PICOW_COMBINED_COMPANION) && PICOW_COMBINED_COMPANION == 1 \
|
||||
&& defined(ENABLE_USB_INTERFACE) && defined(PIO_FRAMEWORK_ARDUINO_ENABLE_BLUETOOTH)
|
||||
// Bind consolidation metadata to the actual combined transport setup path.
|
||||
static const char combined_capability[] =
|
||||
"meshcore.capability.companion.picow.combined.v1";
|
||||
const volatile char* combined_marker = combined_capability;
|
||||
(void)*combined_marker;
|
||||
#endif
|
||||
wifi_interface.setSessionChangedCallback([](void*) {
|
||||
the_mesh.cancelSerialResponseStream(&wifi_interface);
|
||||
the_mesh.cancelSerialOperationsForRoute(&wifi_interface);
|
||||
|
||||
@@ -166,7 +166,9 @@ public:
|
||||
return _display != NULL && _display->supportsRotation();
|
||||
}
|
||||
bool setDisplayRotationDegrees(uint16_t degrees) override {
|
||||
return _display != NULL && _display->setRotationDegrees(degrees);
|
||||
if (_display == NULL || !_display->setRotationDegrees(degrees)) return false;
|
||||
_next_refresh = millis();
|
||||
return true;
|
||||
}
|
||||
bool isButtonPressed() const;
|
||||
|
||||
|
||||
@@ -104,7 +104,9 @@ public:
|
||||
return _display != NULL && _display->supportsRotation();
|
||||
}
|
||||
bool setDisplayRotationDegrees(uint16_t degrees) override {
|
||||
return _display != NULL && _display->setRotationDegrees(degrees);
|
||||
if (_display == NULL || !_display->setRotationDegrees(degrees)) return false;
|
||||
_next_refresh = millis();
|
||||
return true;
|
||||
}
|
||||
void clearMsgPreview();
|
||||
void servicePairingState() override;
|
||||
|
||||
@@ -103,7 +103,9 @@ public:
|
||||
return _display != NULL && _display->supportsRotation();
|
||||
}
|
||||
bool setDisplayRotationDegrees(uint16_t degrees) override {
|
||||
return _display != NULL && _display->setRotationDegrees(degrees);
|
||||
if (_display == NULL || !_display->setRotationDegrees(degrees)) return false;
|
||||
_next_refresh = millis();
|
||||
return true;
|
||||
}
|
||||
bool isButtonPressed() const;
|
||||
void servicePairingState() override;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "MyMesh.h"
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
#endif
|
||||
#if defined(ESP32_PLATFORM)
|
||||
#include <helpers/esp32/BootFileSystem.h>
|
||||
#include <helpers/WiFiNetworkPowerPolicy.h>
|
||||
@@ -11112,6 +11116,11 @@ void MyMesh::clearStats() {
|
||||
#ifdef WITH_WEBCONFIG
|
||||
void MyMesh::getNodeSnapshot(WebConfigServer::NodeSnapshot& s) {
|
||||
memset(&s, 0, sizeof(s));
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
s.display_rotation_supported = true;
|
||||
s.display_rotation_degrees = mesh::ui::displayRotationDegrees();
|
||||
#endif
|
||||
StrHelper::strncpy(s.name, _prefs.node_name, sizeof(s.name));
|
||||
StrHelper::strncpy(s.admin_password, _prefs.password, sizeof(s.admin_password));
|
||||
s.lat = _prefs.node_lat;
|
||||
|
||||
@@ -288,6 +288,24 @@ static inline bool millisReached(unsigned long now, unsigned long deadline) {
|
||||
return (int32_t)((uint32_t)now - (uint32_t)deadline) >= 0;
|
||||
}
|
||||
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
|
||||
void UITask::applyDisplayRotation() {
|
||||
if (_display == nullptr || !_display->supportsRotation()) return;
|
||||
const uint16_t degrees = mesh::ui::displayRotationDegrees();
|
||||
if (degrees == _rotation_seen || !_display->setRotationDegrees(degrees)) return;
|
||||
_rotation_seen = degrees;
|
||||
#ifdef DISPLAY_REDRAW_ON_CHANGE
|
||||
_frame_valid = false;
|
||||
#endif
|
||||
#ifdef DISPLAY_ACTIVITY_DASHBOARD
|
||||
_rows_valid = false;
|
||||
#endif
|
||||
_next_refresh = millis();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Applies `display.flip` when it changes, forcing a complete repaint because
|
||||
// the panel's existing contents are now the wrong way up.
|
||||
void UITask::applyDisplayFlip() {
|
||||
@@ -337,6 +355,9 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
|
||||
resetRadioProfileDisplayPage();
|
||||
#ifdef DISPLAY_ACTIVITY_DASHBOARD
|
||||
ObserverDashboard::applyDarkPalette(); // retunes UIColor for this target only
|
||||
#endif
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
applyDisplayRotation();
|
||||
#endif
|
||||
_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected());
|
||||
applyDisplayFlip();
|
||||
@@ -804,7 +825,7 @@ void UITask::renderDashboard() {
|
||||
memset(&snap, 0, sizeof(snap));
|
||||
}
|
||||
|
||||
const ObserverDashboard::Layout& layout = ObserverDashboard::activeLayout();
|
||||
const ObserverDashboard::Layout& layout = ObserverDashboard::activeLayout(*_display);
|
||||
ObserverDashboard::drawFull(*_display, layout, ctx, snap);
|
||||
ObserverDashboard::allRowSignatures(layout, ctx, snap, _row_signatures);
|
||||
_rows_valid = true;
|
||||
@@ -821,7 +842,7 @@ void UITask::updateActivityRows() {
|
||||
|
||||
RadioActivitySnapshot snap;
|
||||
_activity->snapshot(millis(), &snap);
|
||||
ObserverDashboard::drawChangedRows(*_display, ObserverDashboard::activeLayout(), ctx, snap,
|
||||
ObserverDashboard::drawChangedRows(*_display, ObserverDashboard::activeLayout(*_display), ctx, snap,
|
||||
_row_signatures);
|
||||
}
|
||||
#endif
|
||||
@@ -846,6 +867,9 @@ void UITask::toggleDisplay(const char* source) {
|
||||
#endif
|
||||
|
||||
void UITask::loop() {
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
applyDisplayRotation();
|
||||
#endif
|
||||
// Observe expiry outside display/Morse/input gates; startup is one-shot.
|
||||
if (!_startup_complete && (uint32_t)(millis() - _started_at) >= BOOT_SCREEN_MILLIS) {
|
||||
_startup_complete = true;
|
||||
|
||||
@@ -66,6 +66,10 @@ class UITask {
|
||||
#endif
|
||||
uint8_t _flip_seen = 0xFF; // 0xFF forces the first apply
|
||||
void applyDisplayFlip();
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
uint16_t _rotation_seen = 0xFFFF;
|
||||
void applyDisplayRotation();
|
||||
#endif
|
||||
|
||||
|
||||
void renderCurrScreen();
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "MyMesh.h"
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
#endif
|
||||
#if defined(ESP32_PLATFORM)
|
||||
#include <helpers/esp32/BootFileSystem.h>
|
||||
#include <helpers/WiFiNetworkPowerPolicy.h>
|
||||
@@ -3166,6 +3170,11 @@ void MyMesh::clearStats() {
|
||||
#ifdef WITH_WEBCONFIG
|
||||
void MyMesh::getNodeSnapshot(WebConfigServer::NodeSnapshot& s) {
|
||||
memset(&s, 0, sizeof(s));
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
s.display_rotation_supported = true;
|
||||
s.display_rotation_degrees = mesh::ui::displayRotationDegrees();
|
||||
#endif
|
||||
StrHelper::strncpy(s.name, _prefs.node_name, sizeof(s.name));
|
||||
StrHelper::strncpy(s.admin_password, _prefs.password, sizeof(s.admin_password));
|
||||
s.lat = _prefs.node_lat;
|
||||
|
||||
@@ -85,6 +85,24 @@ static inline bool millisReached(unsigned long now, unsigned long deadline) {
|
||||
return (int32_t)((uint32_t)now - (uint32_t)deadline) >= 0;
|
||||
}
|
||||
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
|
||||
void UITask::applyDisplayRotation() {
|
||||
if (_display == nullptr || !_display->supportsRotation()) return;
|
||||
const uint16_t degrees = mesh::ui::displayRotationDegrees();
|
||||
if (degrees == _rotation_seen || !_display->setRotationDegrees(degrees)) return;
|
||||
_rotation_seen = degrees;
|
||||
#ifdef DISPLAY_REDRAW_ON_CHANGE
|
||||
_frame_valid = false;
|
||||
#endif
|
||||
#ifdef DISPLAY_ACTIVITY_DASHBOARD
|
||||
_rows_valid = false;
|
||||
#endif
|
||||
_next_refresh = millis();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Applies `display.flip` when it changes, forcing a complete repaint because
|
||||
// the panel's existing contents are now the wrong way up.
|
||||
void UITask::applyDisplayFlip() {
|
||||
@@ -136,6 +154,9 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
|
||||
resetRadioProfileDisplayPage();
|
||||
#ifdef DISPLAY_ACTIVITY_DASHBOARD
|
||||
ObserverDashboard::applyDarkPalette(); // retunes UIColor for this target only
|
||||
#endif
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
applyDisplayRotation();
|
||||
#endif
|
||||
_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected());
|
||||
applyDisplayFlip();
|
||||
@@ -455,7 +476,7 @@ void UITask::renderDashboard() {
|
||||
memset(&snap, 0, sizeof(snap));
|
||||
}
|
||||
|
||||
const ObserverDashboard::Layout& layout = ObserverDashboard::activeLayout();
|
||||
const ObserverDashboard::Layout& layout = ObserverDashboard::activeLayout(*_display);
|
||||
ObserverDashboard::drawFull(*_display, layout, ctx, snap);
|
||||
ObserverDashboard::allRowSignatures(layout, ctx, snap, _row_signatures);
|
||||
_rows_valid = true;
|
||||
@@ -472,7 +493,7 @@ void UITask::updateActivityRows() {
|
||||
|
||||
RadioActivitySnapshot snap;
|
||||
_activity->snapshot(millis(), &snap);
|
||||
ObserverDashboard::drawChangedRows(*_display, ObserverDashboard::activeLayout(), ctx, snap,
|
||||
ObserverDashboard::drawChangedRows(*_display, ObserverDashboard::activeLayout(*_display), ctx, snap,
|
||||
_row_signatures);
|
||||
}
|
||||
#endif
|
||||
@@ -497,6 +518,9 @@ void UITask::toggleDisplay(const char* source) {
|
||||
#endif
|
||||
|
||||
void UITask::loop() {
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
applyDisplayRotation();
|
||||
#endif
|
||||
// Observe expiry outside display/Morse/input gates; startup is one-shot.
|
||||
if (!_startup_complete && (uint32_t)(millis() - _started_at) >= BOOT_SCREEN_MILLIS) {
|
||||
_startup_complete = true;
|
||||
|
||||
@@ -63,6 +63,10 @@ class UITask {
|
||||
#endif
|
||||
uint8_t _flip_seen = 0xFF; // 0xFF forces the first apply
|
||||
void applyDisplayFlip();
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
uint16_t _rotation_seen = 0xFFFF;
|
||||
void applyDisplayRotation();
|
||||
#endif
|
||||
|
||||
void resetRadioProfileDisplayPage();
|
||||
bool showingSecondaryRadioProfilePage();
|
||||
|
||||
@@ -78,10 +78,25 @@ static const uint8_t meshcore_logo [] PROGMEM = {
|
||||
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
|
||||
};
|
||||
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
|
||||
void UITask::applyDisplayRotation() {
|
||||
if (_display == nullptr || !_display->supportsRotation()) return;
|
||||
const uint16_t degrees = mesh::ui::displayRotationDegrees();
|
||||
if (degrees == _rotation_seen || !_display->setRotationDegrees(degrees)) return;
|
||||
_rotation_seen = degrees;
|
||||
_last_refresh = uint32_t(millis()) - 1000u;
|
||||
}
|
||||
#endif
|
||||
|
||||
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version) {
|
||||
_prevBtnState = HIGH;
|
||||
_node_prefs = node_prefs;
|
||||
resetRadioProfileDisplayPage();
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
applyDisplayRotation();
|
||||
#endif
|
||||
_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected());
|
||||
#if defined(PIN_USER_BTN) && defined(DISPLAY_CLASS) \
|
||||
&& defined(MOMENTARY_BUTTON_WAKE_FROM_SLEEP) \
|
||||
@@ -211,6 +226,9 @@ void UITask::renderCurrScreen() {
|
||||
}
|
||||
|
||||
void UITask::loop() {
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
applyDisplayRotation();
|
||||
#endif
|
||||
// This UI's splash is relative to boot, not to begin(). Retire it once.
|
||||
if (!_startup_complete && millis() >= BOOT_SCREEN_MILLIS) {
|
||||
_startup_complete = true;
|
||||
|
||||
@@ -13,6 +13,10 @@ class UITask {
|
||||
uint32_t _radio_profile_page_started_at = 0;
|
||||
bool _dual_radio_enabled_seen = false;
|
||||
bool _startup_complete = false;
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) && HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
uint16_t _rotation_seen = 0xFFFF;
|
||||
void applyDisplayRotation();
|
||||
#endif
|
||||
|
||||
void resetRadioProfileDisplayPage();
|
||||
bool showingSecondaryRadioProfilePage();
|
||||
|
||||
@@ -62,6 +62,7 @@ build_src_filter =
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/ui/DisplayDriver.cpp>
|
||||
+<helpers/ui/DisplayPowerSettings.cpp>
|
||||
+<helpers/ui/DisplayRotationSettings.cpp>
|
||||
+<helpers/ota/OtaTinf.c>
|
||||
; MQTT-only sources (need Timezone/NTPClient); observer envs add them back.
|
||||
-<helpers/MQTTMessageBuilder.cpp>
|
||||
|
||||
@@ -21,6 +21,7 @@ from package_cascade_release import (category, collect_artifacts, nrf52_sensor_p
|
||||
omit_retired_onboard_qspi_records)
|
||||
from station_g3_profiles import omit_redundant_slot_records
|
||||
from t114_profiles import omit_legacy_display_records
|
||||
from consolidated_profiles import omit_redundant_records
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -293,6 +294,7 @@ def select_ordinary_full_records(records: list[dict]) -> list[dict]:
|
||||
records = omit_redundant_slot_records(
|
||||
[record for record in records if ordinary_record(record)])
|
||||
records = omit_legacy_display_records(records)
|
||||
records = omit_redundant_records(records)
|
||||
records = omit_retired_onboard_qspi_records(records)
|
||||
|
||||
tower_primary = "heltec_tower_v2_sdcard_repeater_lora_ota_no_external_sensors"
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
"""Consolidation evidence for new applications; historical OTA names stay exact."""
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
from optional_display_profiles import resolved_defines, spec_for_defines
|
||||
|
||||
SPECS = (
|
||||
dict(key="combinedCompanion", capability="companion.picow.combined",
|
||||
marker="meshcore.capability.companion.picow.combined.v1",
|
||||
platform="RP2040_PLATFORM", board="rpipicow", target=r"PicoW_companion_radio",
|
||||
defines={"PICOW_COMBINED_COMPANION": "1", "ENABLE_USB_INTERFACE": "1",
|
||||
"ENABLE_WIFI_INTERFACE": "1", "PIO_FRAMEWORK_ARDUINO_ENABLE_BLUETOOTH": "1"}),
|
||||
dict(key="oledExpansionCompatible", capability="hardware.heltec_v4.oled_kit",
|
||||
marker="meshcore.capability.hardware.heltec_v4.oled_kit.v1",
|
||||
platform="ESP32_PLATFORM", board="heltec_v4",
|
||||
target=r"heltec_v4_(?:repeater|room_server)(?:_observer_mqtt)?",
|
||||
defines={"HELTEC_V4_OLED_KIT_COMPAT": "1", "HELTEC_LORA_V4_OLED": "1",
|
||||
"DISPLAY_CLASS": "SSD1306Display", "ENV_PIN_SDA": "4", "ENV_PIN_SCL": "3"}),
|
||||
dict(key="displayRotation", capability="display.rotation.runtime",
|
||||
marker="meshcore.capability.display.rotation.heltec_r8.v1",
|
||||
platform="ESP32_PLATFORM", board="heltec_v4_r8",
|
||||
target=r"heltec_v4_r8_tft_(?:(?:repeater|room_server)(?:_observer_mqtt)?|sensor|companion_radio_full)",
|
||||
defines={"HELTEC_TFT_RUNTIME_ROTATION": "1", "HELTEC_V4_R8_TFT": "1",
|
||||
"DISPLAY_CLASS": "ST7789LCDDisplay"}),
|
||||
dict(key="tftExpansionCompatible", capability="hardware.heltec_v4.tft_kit",
|
||||
marker="meshcore.capability.hardware.heltec_v4.tft_kit.v1",
|
||||
platform="ESP32_PLATFORM", board="heltec_v4", target=r"heltec_v4_tft_companion_radio_full_femon",
|
||||
defines={"HELTEC_V4_TFT_KIT_COMPAT": "1", "HELTEC_LORA_V4_TFT": "1",
|
||||
"DISPLAY_CLASS": "ST7789LCDDisplay"}),
|
||||
)
|
||||
|
||||
|
||||
def specs_for_config(target, env):
|
||||
defines = resolved_defines(env.get("build_flags", []))
|
||||
return [spec for spec in SPECS if env.get("board") == spec["board"]
|
||||
and re.fullmatch(spec["target"], target, re.I)
|
||||
and all(defines.get(key) == value for key, value in spec["defines"].items())]
|
||||
|
||||
|
||||
def proven(manifest, spec):
|
||||
return (manifest.get("verified") is True and manifest.get("platform") == spec["platform"]
|
||||
and re.fullmatch(spec["target"], manifest.get("target", ""), re.I)
|
||||
and spec["capability"] in manifest.get("capabilities", [])
|
||||
and any(row.get("capability") == spec["capability"] and row.get("present") is True
|
||||
and row.get("source") == "packaged application" and row.get("evidence") == spec["marker"]
|
||||
for row in manifest.get("verification", [])))
|
||||
|
||||
|
||||
def runtime_metadata(manifest, env, release_source):
|
||||
result = {}
|
||||
for spec in SPECS:
|
||||
if spec["capability"] not in manifest.get("capabilities", []):
|
||||
continue
|
||||
if spec not in specs_for_config(manifest["target"], env) or not proven(manifest, spec):
|
||||
raise ValueError(manifest["target"] + ": consolidation requires exact configuration and packaged application proof")
|
||||
source = manifest.get("source_commit", release_source)
|
||||
if not isinstance(source, str) or not re.fullmatch(r"[0-9a-f]{40}", source) or source != release_source:
|
||||
raise ValueError("Consolidation metadata requires the exact release source")
|
||||
result[spec["key"]] = True
|
||||
result[spec["key"] + "Source"] = source
|
||||
return result
|
||||
|
||||
|
||||
def replacements(target):
|
||||
"""Known functionality successors, never aliases for deployed update IDs."""
|
||||
if re.fullmatch(r"PicoW_companion_radio_(?:usb|ble|wifi)", target, re.I):
|
||||
return [("PicoW_companion_radio", "combinedCompanion")]
|
||||
if re.fullmatch(r"heltec_v4(?:_3)?_expansionkit_tft_companion_radio_(?:usb|ble|wifi|full)(?:_ps)?(?:_fem(?:on|off))?", target, re.I):
|
||||
return [("heltec_v4_tft_companion_radio_full_femon", "tftExpansionCompatible")]
|
||||
match = re.fullmatch(r"muzi_base_(uno|duo)_superio_companion_radio_(?:usb|ble|full)", target, re.I)
|
||||
if match:
|
||||
return [("muzi_base_" + match[1].lower() + "_companion_radio_full", "muziAccessories")]
|
||||
if re.fullmatch(r"LilyGo_T-Echo-Lite_non_shell_companion_radio_(?:usb|ble|full)", target, re.I):
|
||||
return [("LilyGo_T-Echo-Lite_companion_radio_full", "techoLiteDisplay")]
|
||||
match = re.fullmatch(r"heltec_v4_expansionkit_(repeater|room_server)(_observer_mqtt)?", target, re.I)
|
||||
if match:
|
||||
base = "heltec_v4_" + match[1].lower()
|
||||
return [(base + (match[2] or ""), "oledExpansionCompatible"), (base, "oledExpansionCompatible")]
|
||||
match = re.fullmatch(r"heltec_v4_r8_tft_portrait_(repeater|room_server)_observer_mqtt", target, re.I)
|
||||
if match:
|
||||
base = "heltec_v4_r8_tft_" + match[1].lower()
|
||||
return [(base + "_observer_mqtt", "displayRotation"), (base, "displayRotation")]
|
||||
match = re.fullmatch(r"heltec_rc32_without_display_(repeater|room_server|sensor|companion_radio_(?:usb|ble|wifi|full))(?:_observer_mqtt)?", target, re.I)
|
||||
if match:
|
||||
return [(target.lower().replace("_without_display_", "_", 1), "displayAuto")]
|
||||
return []
|
||||
|
||||
|
||||
def configuration_replacement(target, envs):
|
||||
def environment(name):
|
||||
# Full nRF52 targets can be generated by build.sh from their exact
|
||||
# USB or BLE base. Never substitute another physical radio variant.
|
||||
for choice in (name, name.replace("_companion_radio_full", "_companion_radio_usb"),
|
||||
name.replace("_companion_radio_full", "_companion_radio_ble")):
|
||||
if "env:" + choice in envs:
|
||||
return envs["env:" + choice]
|
||||
return None
|
||||
for candidate, key in replacements(target):
|
||||
env = environment(candidate)
|
||||
source_env = environment(target)
|
||||
if not env or not source_env or env.get("board") != source_env.get("board"):
|
||||
continue
|
||||
if key in ("displayAuto", "muziAccessories", "techoLiteDisplay"):
|
||||
spec = spec_for_defines(resolved_defines(env.get("build_flags", [])), env.get("board"))
|
||||
expected = {"displayAuto": "rc32", "muziAccessories": "muzi_superio", "techoLiteDisplay": "techo_lite"}[key]
|
||||
qualified = spec and spec["marker"] == expected and re.fullmatch(spec["targets"], candidate.lower())
|
||||
else:
|
||||
qualified = any(spec["key"] == key for spec in specs_for_config(candidate, env))
|
||||
if qualified:
|
||||
return candidate
|
||||
return None
|
||||
|
||||
|
||||
def omit_redundant_records(records):
|
||||
"""Remove resumed alternatives only with an actual qualified successor."""
|
||||
def same_policy(left, right):
|
||||
return (left.get("build_profile") == right.get("build_profile")
|
||||
and sorted(x for x in left.get("capabilities", []) if x.startswith("sensor.profile."))
|
||||
== sorted(x for x in right.get("capabilities", []) if x.startswith("sensor.profile.")))
|
||||
|
||||
def qualified(manifest, key):
|
||||
if key in ("displayAuto", "muziAccessories", "techoLiteDisplay"):
|
||||
from optional_display_profiles import marker, SPECS as displays
|
||||
expected = {"displayAuto": "rc32", "muziAccessories": "muzi_superio", "techoLiteDisplay": "techo_lite"}[key]
|
||||
spec = next((s for s in displays if s["marker"] == expected
|
||||
and re.fullmatch(s["targets"], manifest.get("target", "").lower())), None)
|
||||
if spec is None:
|
||||
return False
|
||||
transport = key == "displayAuto" or (
|
||||
{"companion.usb", "companion.bluetooth"} <= set(manifest.get("capabilities", []))
|
||||
and {"companion.usb", "companion.bluetooth"} <= {
|
||||
row.get("capability") for row in manifest.get("verification", [])
|
||||
if row.get("present") is True and row.get("source") == "linked image" and row.get("evidence")})
|
||||
return (transport and manifest.get("verified") is True
|
||||
and manifest.get("platform") == spec.get("platform", "ESP32_PLATFORM")
|
||||
and "display.autodetect" in manifest.get("capabilities", [])
|
||||
and any(row.get("capability") == "display.autodetect" and row.get("present") is True
|
||||
and row.get("source") == "packaged application" and row.get("evidence") == marker(spec)
|
||||
for row in manifest.get("verification", [])))
|
||||
return any(s["key"] == key and proven(manifest, s) for s in SPECS)
|
||||
|
||||
result = []
|
||||
for record in records:
|
||||
manifest = record["manifest"]
|
||||
alternatives = replacements(manifest["target"])
|
||||
if not any(candidate["manifest"]["target"].lower() == target.lower()
|
||||
and (same_policy(manifest, candidate["manifest"])
|
||||
or key in ("muziAccessories", "techoLiteDisplay")
|
||||
and candidate["manifest"].get("build_profile") == "full"
|
||||
and manifest["target"].lower().endswith(("_usb", "_ble")))
|
||||
and qualified(candidate["manifest"], key)
|
||||
for target, key in alternatives for candidate in records):
|
||||
result.append(record)
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
envs = {name: dict(options) for name, options in json.load(sys.stdin)}
|
||||
mode, target = sys.argv[1:]
|
||||
if mode == "replacement":
|
||||
result = configuration_replacement(target, envs)
|
||||
if result is None:
|
||||
sys.exit(1)
|
||||
print(result)
|
||||
elif mode == "expectations":
|
||||
for spec in specs_for_config(target, envs.get("env:" + target, {})):
|
||||
print(spec["capability"] + "=" + spec["marker"])
|
||||
else:
|
||||
raise SystemExit("Unknown consolidation operation")
|
||||
@@ -13,6 +13,7 @@ from package_esp32_partition_migration import BOARDS
|
||||
from package_cascade_release import nrf52_sensor_profile
|
||||
from station_g3_profiles import runtime_metadata as station_g3_metadata
|
||||
from optional_display_profiles import runtime_metadata as display_metadata
|
||||
from consolidated_profiles import runtime_metadata as consolidation_metadata
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -164,6 +165,7 @@ def generate(stage, config):
|
||||
controls.update(runtime_metadata(manifest, controls['mqtt'], plan['source']))
|
||||
controls.update(station_g3_metadata(manifest, defines, plan['source']))
|
||||
controls.update(display_metadata(manifest, defines, plan['source'], env.get('board')))
|
||||
controls.update(consolidation_metadata(manifest, env, plan['source']))
|
||||
if manifest.get('ota_update_requirements'):
|
||||
controls['updateRequirements'] = manifest['ota_update_requirements']
|
||||
note = capacity_note(manifest.get('reductions', []), defines)
|
||||
|
||||
@@ -19,6 +19,18 @@ SPECS = (
|
||||
dict(flag="HELTEC_TFT_DISPLAY_AUTODETECT", board="heltec_v4_r8",
|
||||
guard="HELTEC_V4_R8_TFT", driver="ST7789LCDDisplay", controller="st7789", marker="heltec_r8",
|
||||
targets=r"heltec_v4_r8_tft_.+"),
|
||||
dict(flag="MUZI_BASE_ACCESSORY_AUTODETECT", board="muzi_base", guard="MUZI_BASE",
|
||||
driver="SH1107Display", controller="sh1107", marker="muzi_superio", platform="NRF52_PLATFORM",
|
||||
defines={"RADIO_CLASS": "CustomLR1121", "USE_LR1121": "1"},
|
||||
targets=r"muzi_base_duo_(?:superio_)?companion_radio_(?:usb|ble|full)"),
|
||||
dict(flag="MUZI_BASE_ACCESSORY_AUTODETECT", board="muzi_base", guard="MUZI_BASE",
|
||||
driver="SH1107Display", controller="sh1107", marker="muzi_superio", platform="NRF52_PLATFORM",
|
||||
defines={"RADIO_CLASS": "CustomSX1262", "USE_SX1262": "1"},
|
||||
targets=r"muzi_base_uno_(?:superio_)?companion_radio_(?:usb|ble|full)"),
|
||||
dict(flag="TECHO_LITE_DISPLAY_AUTODETECT", board="t-echo", guard="LILYGO_TECHO_LITE",
|
||||
driver="GxEPDDisplay", controller="ssd1681", marker="techo_lite", platform="NRF52_PLATFORM",
|
||||
defines={"EINK_DISPLAY_MODEL": "GxEPD2_122_T61"},
|
||||
targets=r"lilygo_t-echo-lite_(?:non_shell_)?(?:companion_radio_(?:usb|ble|full)|(?:repeater|room_server)(?:_lora_ota(?:_no_external_sensors)?)?)"),
|
||||
)
|
||||
|
||||
|
||||
@@ -31,6 +43,7 @@ def spec_for_defines(defines, board=None):
|
||||
if (defines.get(spec["flag"]) == "1"
|
||||
and defines.get(spec["guard"], "0") not in ("0", "false")
|
||||
and defines.get("DISPLAY_CLASS") == spec["driver"]
|
||||
and all(defines.get(key) == value for key, value in spec.get("defines", {}).items())
|
||||
and (board is None or board == spec["board"])):
|
||||
return spec
|
||||
return None
|
||||
@@ -43,7 +56,7 @@ def runtime_metadata(manifest, defines, release_source=None, board=None):
|
||||
return t114_metadata(manifest, defines, release_source)
|
||||
spec = spec_for_defines(defines, board)
|
||||
if (not spec or board is None or manifest.get("verified") is not True
|
||||
or manifest.get("platform") != "ESP32_PLATFORM"
|
||||
or manifest.get("platform") != spec.get("platform", "ESP32_PLATFORM")
|
||||
or not re.fullmatch(spec["targets"], str(manifest.get("target", "")).lower())
|
||||
or not any(row.get("capability") == CAPABILITY and row.get("present") is True
|
||||
and row.get("source") == "packaged application"
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include "PowerSavingDiagnostics.h"
|
||||
#include "HilStartupTrace.h"
|
||||
#include <helpers/ui/DisplayPowerSettings.h>
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
#endif
|
||||
#include <helpers/BatteryChargeCLI.h>
|
||||
#if MESH_ENABLE_CARRIER_TOOLS || MESH_ENABLE_MORSE_RX
|
||||
#include <helpers/MorseCLI.h>
|
||||
@@ -802,6 +806,10 @@ void CommonCLI::loadPrefs(FILESYSTEM* fs) {
|
||||
#endif
|
||||
mesh::hilStartupTrace("prefs_display_begin");
|
||||
const bool display_settings_loaded = mesh::ui::loadDisplayPowerSettings(fs, false);
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
mesh::ui::loadDisplayRotationSettings(fs);
|
||||
#endif
|
||||
mesh::hilStartupTrace("prefs_display_ready");
|
||||
(void)display_settings_loaded;
|
||||
bool is_fresh_install = false;
|
||||
@@ -3006,6 +3014,10 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
return;
|
||||
}
|
||||
if (mesh::ui::handleDisplayPowerCommand(command, reply, 160)) return;
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
if (mesh::ui::handleDisplayRotationCommand(command, reply, 160, true)) return;
|
||||
#endif
|
||||
|
||||
// Observer-only top-level commands (ota check/update, tls.bundletest, alert test)
|
||||
// live in CommonCLI_Observer.cpp.
|
||||
|
||||
@@ -23,7 +23,7 @@ static const char* const WC_ALLOWED_SET_KEYS[] = {
|
||||
"cad", "radio.rxgain", "radio.fem.rxgain", "radio.fem.txgain", "radio.rxps", "powersaving",
|
||||
"repeat",
|
||||
"display.mode", "display.timeout", "display.usb.mode", "display.usb.timeout",
|
||||
"display.inbox",
|
||||
"display.inbox", "display.rotation",
|
||||
"advert.interval", "flood.advert.interval",
|
||||
"flood.max", "flood.max.advert", "flood.max.unscoped", "loop.detect",
|
||||
// MQTTPrefs (WiFi / MQTT / misc observer)
|
||||
|
||||
+2327
-2322
File diff suppressed because it is too large.
Load diff
@@ -2369,6 +2369,10 @@ void WebConfigServer::handleConfigGet(AsyncWebServerRequest* req) {
|
||||
screen["usb_mode"] = mesh::ui::displayModeName(display_prefs.usb.mode);
|
||||
screen["usb_timeout"] = display_prefs.usb.seconds;
|
||||
screen["pairing"] = mesh::ui::displayPairingSupported();
|
||||
screen["rotation_supported"] = node.display_rotation_supported;
|
||||
if (node.display_rotation_supported) {
|
||||
screen["rotation"] = node.display_rotation_degrees;
|
||||
}
|
||||
#endif
|
||||
radio["repeat"] = (bool)node.repeat;
|
||||
radio["flood_max"] = node.flood_max;
|
||||
|
||||
@@ -130,6 +130,8 @@ public:
|
||||
uint32_t rx_ps_rx_us;
|
||||
uint32_t rx_ps_sleep_us;
|
||||
uint8_t power_saving;
|
||||
bool display_rotation_supported;
|
||||
uint16_t display_rotation_degrees;
|
||||
bool mqtt_enabled;
|
||||
uint8_t repeat;
|
||||
uint16_t advert_interval;
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
#include "DisplayRotationSettings.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace mesh { namespace ui {
|
||||
namespace {
|
||||
FILESYSTEM* settings_fs = nullptr;
|
||||
uint16_t degrees = 0;
|
||||
const char* const path = "/display_rotation";
|
||||
const char* const backup = "/display_rotation.bak";
|
||||
const char* const temporary = "/display_rotation.tmp";
|
||||
|
||||
void encode(uint16_t value, uint8_t (&data)[6]) {
|
||||
data[0] = 'D'; data[1] = 'R'; data[2] = 1;
|
||||
data[3] = value & 255; data[4] = value >> 8;
|
||||
data[5] = 0;
|
||||
for (unsigned i = 0; i < 5; ++i) data[5] ^= data[i];
|
||||
}
|
||||
|
||||
bool valid(uint16_t value) { return value <= 270 && value % 90 == 0; }
|
||||
|
||||
bool readPrefs(const char* name, uint16_t& value) {
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
File file(*settings_fs);
|
||||
if (!file.open(name, FILE_O_READ)) return false;
|
||||
#else
|
||||
File file = settings_fs->open(name, "r");
|
||||
if (!file) return false;
|
||||
#endif
|
||||
uint8_t data[6], expected[6];
|
||||
const bool complete = file.size() == sizeof(data)
|
||||
&& file.read(data, sizeof(data)) == sizeof(data);
|
||||
file.close();
|
||||
if (!complete) return false;
|
||||
value = uint16_t(data[3]) | (uint16_t(data[4]) << 8);
|
||||
encode(value, expected);
|
||||
return valid(value) && memcmp(data, expected, sizeof(data)) == 0;
|
||||
}
|
||||
|
||||
bool savePrefs(uint16_t value) {
|
||||
if (!settings_fs) return false;
|
||||
settings_fs->remove(temporary);
|
||||
if (settings_fs->exists(temporary)) return false;
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
File file(*settings_fs);
|
||||
if (!file.open(temporary, FILE_O_WRITE)) return false;
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = settings_fs->open(temporary, "w");
|
||||
if (!file) return false;
|
||||
#else
|
||||
File file = settings_fs->open(temporary, "w", true);
|
||||
if (!file) return false;
|
||||
#endif
|
||||
uint8_t data[6];
|
||||
encode(value, data);
|
||||
const bool written = file.write(data, sizeof(data)) == sizeof(data);
|
||||
file.close();
|
||||
uint16_t checked = 0;
|
||||
if (!written || !readPrefs(temporary, checked) || checked != value) return false;
|
||||
if (settings_fs->exists(backup) && !settings_fs->remove(backup)) return false;
|
||||
if (settings_fs->exists(path) && !settings_fs->rename(path, backup)) return false;
|
||||
if (!settings_fs->rename(temporary, path)) {
|
||||
if (settings_fs->exists(backup)) settings_fs->rename(backup, path);
|
||||
return false;
|
||||
}
|
||||
settings_fs->remove(backup);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool loadDisplayRotationSettings(FILESYSTEM* fs) {
|
||||
settings_fs = fs;
|
||||
degrees = 0;
|
||||
if (!fs) return false;
|
||||
uint16_t loaded = 0;
|
||||
bool found = readPrefs(path, loaded);
|
||||
if (!found && readPrefs(backup, loaded)) {
|
||||
found = true;
|
||||
fs->remove(path);
|
||||
fs->rename(backup, path);
|
||||
}
|
||||
if (found) degrees = loaded;
|
||||
return found;
|
||||
}
|
||||
|
||||
uint16_t displayRotationDegrees() { return degrees; }
|
||||
|
||||
bool handleDisplayRotationCommand(const char* command, char* reply,
|
||||
size_t reply_size, bool supported) {
|
||||
const bool get = strncmp(command, "get ", 4) == 0;
|
||||
const bool set = strncmp(command, "set ", 4) == 0;
|
||||
if (!get && !set) return false;
|
||||
const char* key = command + 4;
|
||||
constexpr size_t key_length = sizeof("display.rotation") - 1;
|
||||
if (strncmp(key, "display.rotation", key_length) != 0
|
||||
|| (key[key_length] != 0 && key[key_length] != ' ')) return false;
|
||||
if (!supported) {
|
||||
snprintf(reply, reply_size, "Error: display rotation unsupported");
|
||||
return true;
|
||||
}
|
||||
const char* value = key + key_length;
|
||||
if (get) {
|
||||
if (*value) snprintf(reply, reply_size, "Error: unexpected argument");
|
||||
else if (degrees == 0) snprintf(reply, reply_size, "display.rotation default");
|
||||
else snprintf(reply, reply_size, "display.rotation %u", unsigned(degrees));
|
||||
return true;
|
||||
}
|
||||
while (*value == ' ') ++value;
|
||||
unsigned candidate = 0;
|
||||
bool parsed = *value != 0;
|
||||
for (const char* p = value; *p && parsed; ++p) {
|
||||
parsed = *p >= '0' && *p <= '9';
|
||||
if (parsed) {
|
||||
candidate = candidate * 10 + unsigned(*p - '0');
|
||||
parsed = candidate <= 270;
|
||||
}
|
||||
}
|
||||
if (!parsed || !valid(candidate)) {
|
||||
snprintf(reply, reply_size, "Error: use set display.rotation <0|90|180|270>");
|
||||
} else if (!savePrefs(uint16_t(candidate))) {
|
||||
snprintf(reply, reply_size, "Error: display rotation save failed");
|
||||
} else {
|
||||
degrees = uint16_t(candidate);
|
||||
if (degrees == 0) snprintf(reply, reply_size, "OK - display rotation reset to board default");
|
||||
else snprintf(reply, reply_size, "OK - display rotation %u", unsigned(degrees));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}} // namespace mesh::ui
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/IdentityStore.h>
|
||||
|
||||
namespace mesh { namespace ui {
|
||||
|
||||
// Infrastructure uses a separate checked file so its existing node/MQTT
|
||||
// preference layouts stay compatible. Companion retains its NodePrefs field.
|
||||
bool loadDisplayRotationSettings(FILESYSTEM* fs);
|
||||
uint16_t displayRotationDegrees();
|
||||
// 0 restores the compiled board orientation; 90/180/270 turn clockwise from it.
|
||||
// The UI observes saved changes on its next loop, even with the display off.
|
||||
bool handleDisplayRotationCommand(const char* command, char* reply,
|
||||
size_t reply_size, bool supported);
|
||||
|
||||
}} // namespace mesh::ui
|
||||
@@ -1,6 +1,13 @@
|
||||
|
||||
#include "GxEPDDisplay.h"
|
||||
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
#include "TechoLiteDisplayProbe.h"
|
||||
extern const char meshcore_capability_display_autodetect_techo_lite[];
|
||||
const char meshcore_capability_display_autodetect_techo_lite[] =
|
||||
"meshcore.capability.display.autodetect.techo_lite.v1";
|
||||
#endif
|
||||
|
||||
#ifdef EXP_PIN_BACKLIGHT
|
||||
#include <PCA9557.h>
|
||||
extern PCA9557 expander;
|
||||
@@ -30,6 +37,16 @@ ColorVal UIColor::popup_txt = GxEPD_BLACK;
|
||||
ColorVal UIColor::corp_blue = GxEPD_BLACK;
|
||||
|
||||
bool GxEPDDisplay::begin() {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_probe_complete) {
|
||||
const volatile char* capability = meshcore_capability_display_autodetect_techo_lite;
|
||||
(void)*capability;
|
||||
_probe_complete = true;
|
||||
_present = mesh::ui::techo_lite::probe();
|
||||
}
|
||||
if (!_present) return false;
|
||||
if (_init) return true;
|
||||
#endif
|
||||
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
#ifdef ESP32
|
||||
SPI1.begin(PIN_DISPLAY_SCLK, PIN_DISPLAY_MISO, PIN_DISPLAY_MOSI, PIN_DISPLAY_CS);
|
||||
@@ -66,7 +83,13 @@ bool GxEPDDisplay::begin() {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOn() {
|
||||
if (!_init) begin();
|
||||
if (!_init) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!begin()) return;
|
||||
#else
|
||||
begin();
|
||||
#endif
|
||||
}
|
||||
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
digitalWrite(DISP_BACKLIGHT, HIGH);
|
||||
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
@@ -78,6 +101,9 @@ void GxEPDDisplay::turnOn() {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOff() {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_init || !_present || !_isOn) return;
|
||||
#endif
|
||||
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
digitalWrite(DISP_BACKLIGHT, LOW);
|
||||
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
@@ -94,12 +120,18 @@ void GxEPDDisplay::turnOff() {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::clear() {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
display.setTextColor(GxEPD_BLACK);
|
||||
display_crc.reset();
|
||||
}
|
||||
|
||||
void GxEPDDisplay::startFrame(ColorVal bkg) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.fillScreen(bkg);
|
||||
display.setTextColor(_curr_color = UIColor::primary_txt);
|
||||
display_crc.reset();
|
||||
@@ -116,6 +148,9 @@ void GxEPDDisplay::startFrame(ColorVal bkg) {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::setTextSize(int sz) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_present || (!_isOn && _init)) return;
|
||||
#endif
|
||||
display_crc.update<int>(sz);
|
||||
switch(sz) {
|
||||
case 1: // Small
|
||||
@@ -140,22 +175,34 @@ void GxEPDDisplay::setTextSize(int sz) {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::setColor(ColorVal c) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display_crc.update<ColorVal> (c);
|
||||
display.setTextColor(_curr_color = c);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::setCursor(int x, int y) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display_crc.update<int>(x);
|
||||
display_crc.update<int>(y);
|
||||
display.setCursor(x, y + _text_ascent);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::print(const char* str) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display_crc.update<char>(str, strlen(str));
|
||||
display.print(str);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display_crc.update<int>(x);
|
||||
display_crc.update<int>(y);
|
||||
display_crc.update<int>(w);
|
||||
@@ -164,6 +211,9 @@ void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display_crc.update<int>(x);
|
||||
display_crc.update<int>(y);
|
||||
display_crc.update<int>(w);
|
||||
@@ -172,6 +222,9 @@ void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
|
||||
}
|
||||
|
||||
void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
if (!bits || w <= 0 || h <= 0) return;
|
||||
display_crc.update<int>(x);
|
||||
display_crc.update<int>(y);
|
||||
@@ -182,6 +235,9 @@ void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
}
|
||||
|
||||
uint16_t GxEPDDisplay::getTextWidth(const char* str) {
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
if (!_present) return 0;
|
||||
#endif
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
#define DISPLAY_ROTATION 3
|
||||
#endif
|
||||
|
||||
#if defined(LILYGO_TECHO_LITE) && defined(TECHO_LITE_DISPLAY_AUTODETECT) \
|
||||
&& TECHO_LITE_DISPLAY_AUTODETECT == 1
|
||||
#define MESHCORE_TECHO_LITE_DISPLAY_DETECTION 1
|
||||
#endif
|
||||
|
||||
class GxEPDDisplay : public DisplayDriver {
|
||||
|
||||
#if defined(EINK_DISPLAY_MODEL)
|
||||
@@ -44,6 +49,10 @@ class GxEPDDisplay : public DisplayDriver {
|
||||
int _line_height = 22;
|
||||
bool _init = false;
|
||||
bool _isOn = false;
|
||||
#ifdef MESHCORE_TECHO_LITE_DISPLAY_DETECTION
|
||||
bool _probe_complete = false;
|
||||
bool _present = false;
|
||||
#endif
|
||||
uint16_t _curr_color;
|
||||
CRC32 display_crc;
|
||||
int last_display_crc_value = 0;
|
||||
|
||||
@@ -118,6 +118,12 @@ inline const Layout& activeLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
inline const Layout& activeLayout(const DisplayDriver& display) {
|
||||
static const Layout portrait = portraitLayout();
|
||||
static const Layout landscape = landscapeLayout();
|
||||
return display.width() < display.height() ? portrait : landscape;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- formatting ---
|
||||
// Every value is formatted from integers. Arguments are widened explicitly so
|
||||
// the same code is correct on a 32-bit target and on a 64-bit host.
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
#define DISPLAY_ROTATION 0
|
||||
#endif
|
||||
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
extern const char meshcore_capability_display_autodetect_muzi_superio[];
|
||||
const char meshcore_capability_display_autodetect_muzi_superio[] =
|
||||
"meshcore.capability.display.autodetect.muzi_superio.v1";
|
||||
#endif
|
||||
|
||||
ColorVal UIColor::window_bkg = SH110X_BLACK;
|
||||
ColorVal UIColor::title_bkg = SH110X_BLACK;
|
||||
ColorVal UIColor::title_txt = SH110X_WHITE;
|
||||
@@ -25,15 +31,46 @@ bool SH1107Display::i2c_probe(TwoWire &wire, uint8_t addr)
|
||||
|
||||
bool SH1107Display::begin()
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (_probe_complete && !_present) return false;
|
||||
if (_isOn && _panel_ready) return true;
|
||||
const volatile char* capability = meshcore_capability_display_autodetect_muzi_superio;
|
||||
(void)*capability;
|
||||
// SuperIO's panel needs its own 12 V boost supply, separate from GPS/radio.
|
||||
digitalWrite(SCREEN_12V_ENABLE, HIGH);
|
||||
pinMode(SCREEN_12V_ENABLE, OUTPUT);
|
||||
delay(250);
|
||||
if (_panel_ready) {
|
||||
// Only OLED VCC is switched; the 3.3 V controller logic retains setup.
|
||||
// Avoid Adafruit_GrayOLED::_init allocating another BusIO adapter on
|
||||
// every wake. Display-off is sent before VCC removal below.
|
||||
display.oled_command(SH110X_DISPLAYON);
|
||||
_isOn = true;
|
||||
return true;
|
||||
}
|
||||
_probe_complete = true;
|
||||
if (!i2c_probe(Wire, DISPLAY_ADDRESS)) {
|
||||
digitalWrite(SCREEN_12V_ENABLE, LOW);
|
||||
_present = _panel_ready = _isOn = false;
|
||||
return false; // No library objects/framebuffer are allocated when absent.
|
||||
}
|
||||
#endif
|
||||
bool result = display.begin(DISPLAY_ADDRESS, true) && i2c_probe(Wire, DISPLAY_ADDRESS);
|
||||
if (result) {
|
||||
display.setRotation(DISPLAY_ROTATION);
|
||||
}
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
_present = _panel_ready = _isOn = result;
|
||||
if (!result) digitalWrite(SCREEN_12V_ENABLE, LOW);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void SH1107Display::turnOn()
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!begin()) return;
|
||||
#endif
|
||||
display.oled_command(SH110X_DISPLAYON);
|
||||
uint8_t cmd[] = {0xD5, 0xF0};
|
||||
display.oled_commandList(cmd, 2);
|
||||
@@ -42,18 +79,30 @@ void SH1107Display::turnOn()
|
||||
|
||||
void SH1107Display::turnOff()
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_panel_ready) return;
|
||||
#endif
|
||||
display.oled_command(SH110X_DISPLAYOFF);
|
||||
_isOn = false;
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
digitalWrite(SCREEN_12V_ENABLE, LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SH1107Display::clear()
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
}
|
||||
|
||||
void SH1107Display::startFrame(ColorVal bkg)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.clearDisplay(); // TODO: apply 'bkg'
|
||||
display.setContrast(120); // 0-127. default setting was causing some flickering.
|
||||
// display.SH110X_SETPRECHARGE(255);
|
||||
@@ -65,42 +114,66 @@ void SH1107Display::startFrame(ColorVal bkg)
|
||||
|
||||
void SH1107Display::setTextSize(int sz)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.setTextSize(sz);
|
||||
}
|
||||
|
||||
void SH1107Display::setColor(ColorVal c)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
_color = (c != 0) ? SH110X_WHITE : SH110X_BLACK;
|
||||
display.setTextColor(_color);
|
||||
}
|
||||
|
||||
void SH1107Display::setCursor(int x, int y)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.setCursor(x, y);
|
||||
}
|
||||
|
||||
void SH1107Display::print(const char *str)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.print(str);
|
||||
}
|
||||
|
||||
void SH1107Display::fillRect(int x, int y, int w, int h)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.fillRect(x, y, w, h, _color);
|
||||
}
|
||||
|
||||
void SH1107Display::drawRect(int x, int y, int w, int h)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.drawRect(x, y, w, h, _color);
|
||||
}
|
||||
|
||||
void SH1107Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.drawBitmap(x, y, bits, w, h, SH110X_WHITE);
|
||||
}
|
||||
|
||||
uint16_t SH1107Display::getTextWidth(const char *str)
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return 0;
|
||||
#endif
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
@@ -109,5 +182,8 @@ uint16_t SH1107Display::getTextWidth(const char *str)
|
||||
|
||||
void SH1107Display::endFrame()
|
||||
{
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
if (!_isOn) return;
|
||||
#endif
|
||||
display.display();
|
||||
}
|
||||
@@ -14,10 +14,20 @@
|
||||
#define DISPLAY_ADDRESS 0x3c
|
||||
#endif
|
||||
|
||||
#if defined(MUZI_BASE) && defined(MUZI_BASE_ACCESSORY_AUTODETECT) \
|
||||
&& MUZI_BASE_ACCESSORY_AUTODETECT == 1
|
||||
#define MESHCORE_MUZI_ACCESSORY_DETECTION 1
|
||||
#endif
|
||||
|
||||
class SH1107Display : public DisplayDriver
|
||||
{
|
||||
Adafruit_SH1107 display;
|
||||
bool _isOn;
|
||||
#ifdef MESHCORE_MUZI_ACCESSORY_DETECTION
|
||||
bool _probe_complete = false;
|
||||
bool _present = false;
|
||||
bool _panel_ready = false;
|
||||
#endif
|
||||
uint8_t _color;
|
||||
|
||||
bool i2c_probe(TwoWire &wire, uint8_t addr);
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#define PIN_TFT_MISO -1
|
||||
#endif
|
||||
|
||||
#ifdef MESHCORE_HELTEC_R8_RUNTIME_ROTATION
|
||||
extern const char meshcore_capability_display_rotation_heltec_r8[] =
|
||||
"meshcore.capability.display.rotation.heltec_r8.v1";
|
||||
#endif
|
||||
|
||||
#ifdef MESHCORE_HELTEC_R8_TFT_DETECTION
|
||||
#include "HeltecR8DisplayProbe.h"
|
||||
extern const char meshcore_capability_display_autodetect_heltec_r8[];
|
||||
@@ -19,25 +24,52 @@ const char meshcore_capability_display_autodetect_heltec_r8[] =
|
||||
#define DISPLAY_WIDTH 240
|
||||
#define DISPLAY_HEIGHT 320
|
||||
|
||||
// The compiled orientation, optionally turned 180 degrees by `display.flip`.
|
||||
// Adding 2 keeps portrait portrait and landscape landscape, so the viewport
|
||||
// geometry below never has to change with it.
|
||||
// display.flip remains an additive 180-degree mounting adjustment, independent
|
||||
// of the selected orientation. Other boards keep their compiled orientation.
|
||||
uint8_t ST7789LCDDisplay::effectiveRotation() const {
|
||||
#ifdef MESHCORE_HELTEC_R8_RUNTIME_ROTATION
|
||||
return (uint8_t)((_base_rotation + (_flipped ? 2 : 0)) & 3);
|
||||
#else
|
||||
return (uint8_t)((DISPLAY_ROTATION + (_flipped ? 2 : 0)) & 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ST7789LCDDisplay::applyRotation() {
|
||||
#ifdef HELTEC_V4_R8_TFT
|
||||
const auto rotation = effectiveRotation();
|
||||
// Layout follows saved intent immediately, including before initialization
|
||||
// and while the backlight is off. Defer all panel traffic until awake.
|
||||
setDimensions((rotation & 1) ? 320 : 240, (rotation & 1) ? 240 : 320);
|
||||
if (!_panel_ready) return;
|
||||
if (!_isOn) {
|
||||
_rotation_pending = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (_panel_ready) display.setRotation(effectiveRotation());
|
||||
}
|
||||
|
||||
bool ST7789LCDDisplay::setRotationDegrees(uint16_t degrees) {
|
||||
#ifdef MESHCORE_HELTEC_R8_RUNTIME_ROTATION
|
||||
const volatile char* capability = meshcore_capability_display_rotation_heltec_r8;
|
||||
(void)*capability;
|
||||
if (degrees > 270 || degrees % 90 != 0) return false;
|
||||
const uint8_t rotation = (DISPLAY_ROTATION + degrees / 90) & 3;
|
||||
if (_base_rotation != rotation) {
|
||||
_base_rotation = rotation;
|
||||
applyRotation();
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
(void)degrees;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ST7789LCDDisplay::setFlipped(bool flipped) {
|
||||
if (_flipped == flipped) return;
|
||||
_flipped = flipped;
|
||||
if (_panel_ready) {
|
||||
#ifdef MESHCORE_HELTEC_R8_TFT_DETECTION
|
||||
if (!_isOn) {
|
||||
_rotation_pending = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
display.setRotation(effectiveRotation());
|
||||
}
|
||||
applyRotation();
|
||||
}
|
||||
|
||||
bool ST7789LCDDisplay::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
@@ -69,14 +101,12 @@ bool ST7789LCDDisplay::begin() {
|
||||
// and stalling the UI loop for ~500 ms of reset delays.
|
||||
if (_panel_ready) {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
#ifdef MESHCORE_HELTEC_R8_TFT_DETECTION
|
||||
// A preference may change while the backlight is off. Apply only that
|
||||
// deferred change; ordinary wakes remain free of SPI/reset work.
|
||||
if (_rotation_pending) {
|
||||
display.setRotation(effectiveRotation());
|
||||
_rotation_pending = false;
|
||||
}
|
||||
#endif
|
||||
if (PIN_TFT_LEDA_CTL != -1) {
|
||||
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
|
||||
}
|
||||
@@ -136,6 +166,9 @@ bool ST7789LCDDisplay::begin() {
|
||||
display.init(DISPLAY_WIDTH, DISPLAY_HEIGHT);
|
||||
display.setRotation(effectiveRotation());
|
||||
setDimensions(display.width(), display.height());
|
||||
#ifdef HELTEC_V4_R8_TFT
|
||||
_rotation_pending = false;
|
||||
#endif
|
||||
|
||||
display.setSPISpeed(40e6);
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
#define MESHCORE_HELTEC_R8_TFT_DETECTION 1
|
||||
#endif
|
||||
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
#define MESHCORE_HELTEC_R8_RUNTIME_ROTATION 1
|
||||
#endif
|
||||
|
||||
class ST7789LCDDisplay : public DisplayDriver {
|
||||
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT) || defined(HELTEC_V4_R8_TFT)
|
||||
SPIClass displaySPI;
|
||||
@@ -26,6 +31,11 @@ class ST7789LCDDisplay : public DisplayDriver {
|
||||
#ifdef MESHCORE_HELTEC_R8_TFT_DETECTION
|
||||
bool _probe_complete = false;
|
||||
bool _present = false;
|
||||
#endif
|
||||
#ifdef HELTEC_V4_R8_TFT
|
||||
#ifdef MESHCORE_HELTEC_R8_RUNTIME_ROTATION
|
||||
uint8_t _base_rotation = DISPLAY_ROTATION & 3;
|
||||
#endif
|
||||
bool _rotation_pending = false;
|
||||
#endif
|
||||
bool _flipped = false;
|
||||
@@ -36,6 +46,7 @@ class ST7789LCDDisplay : public DisplayDriver {
|
||||
static constexpr int kHeight = (DISPLAY_ROTATION & 1) ? 240 : 320;
|
||||
|
||||
uint8_t effectiveRotation() const;
|
||||
void applyRotation();
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
public:
|
||||
#ifdef USE_PIN_TFT
|
||||
@@ -64,6 +75,10 @@ public:
|
||||
bool begin();
|
||||
|
||||
bool isOn() override { return _isOn; }
|
||||
#ifdef MESHCORE_HELTEC_R8_RUNTIME_ROTATION
|
||||
bool supportsRotation() const override { return true; }
|
||||
#endif
|
||||
bool setRotationDegrees(uint16_t degrees) override;
|
||||
void turnOn() override;
|
||||
void turnOff() override;
|
||||
void clear() override;
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace mesh { namespace ui { namespace techo_lite {
|
||||
|
||||
// LilyGo's P1.12 is SCREEN_BS1, the SSD1681 interface-mode strap, not a
|
||||
// switched display supply. LOW selects the 4-wire SPI used by GxEPD2.
|
||||
// SSD1681 Rev 0.13 pp. 10-11/29: 0x2F reads status over bidirectional SDA;
|
||||
// bits 1:0 identify the chip as 01. Bits 5:4 are undefined after reset.
|
||||
inline void writeCommand(uint8_t command) {
|
||||
digitalWrite(DISP_CS, LOW);
|
||||
digitalWrite(DISP_DC, LOW);
|
||||
pinMode(DISP_MOSI, OUTPUT);
|
||||
for (uint8_t mask = 0x80; mask; mask >>= 1) {
|
||||
digitalWrite(DISP_MOSI, command & mask ? HIGH : LOW);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(DISP_SCLK, HIGH);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(DISP_SCLK, LOW);
|
||||
}
|
||||
digitalWrite(DISP_CS, HIGH);
|
||||
}
|
||||
|
||||
inline uint8_t readStatus(uint8_t bias) {
|
||||
digitalWrite(DISP_CS, LOW);
|
||||
digitalWrite(DISP_DC, LOW);
|
||||
pinMode(DISP_MOSI, OUTPUT);
|
||||
for (uint8_t mask = 0x80; mask; mask >>= 1) {
|
||||
digitalWrite(DISP_MOSI, 0x2F & mask ? HIGH : LOW);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(DISP_SCLK, HIGH);
|
||||
delayMicroseconds(5);
|
||||
// The controller drives the first read bit on the last command falling
|
||||
// edge. Release SDA first; there is no dummy read clock on this command.
|
||||
if (mask == 1) {
|
||||
pinMode(DISP_MOSI, bias);
|
||||
digitalWrite(DISP_DC, HIGH);
|
||||
}
|
||||
digitalWrite(DISP_SCLK, LOW);
|
||||
}
|
||||
uint8_t result = 0;
|
||||
for (uint8_t bit = 0; bit < 8; ++bit) {
|
||||
delayMicroseconds(5);
|
||||
result = uint8_t((result << 1) | (digitalRead(DISP_MOSI) ? 1u : 0u));
|
||||
digitalWrite(DISP_SCLK, HIGH);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(DISP_SCLK, LOW);
|
||||
}
|
||||
digitalWrite(DISP_CS, HIGH);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool waitReady() {
|
||||
// A disconnected BUSY line follows this pull-up and fails closed. Do not
|
||||
// equate an idle LOW alone with presence: status readback below is required.
|
||||
pinMode(DISP_BUSY, INPUT_PULLUP);
|
||||
for (uint16_t elapsed = 0; elapsed < 200; ++elapsed) {
|
||||
if (digitalRead(DISP_BUSY) == LOW) return true;
|
||||
delay(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void parkAbsent() {
|
||||
digitalWrite(DISP_RST, LOW);
|
||||
pinMode(DISP_CS, INPUT);
|
||||
pinMode(DISP_DC, INPUT);
|
||||
pinMode(DISP_MOSI, INPUT);
|
||||
pinMode(DISP_SCLK, INPUT);
|
||||
pinMode(DISP_BUSY, INPUT);
|
||||
// Keep BS1 LOW, as the manufacturer requires for the fitted SPI interface.
|
||||
}
|
||||
|
||||
inline bool probe() {
|
||||
digitalWrite(DISP_BS1, LOW);
|
||||
pinMode(DISP_BS1, OUTPUT);
|
||||
digitalWrite(DISP_CS, HIGH);
|
||||
pinMode(DISP_CS, OUTPUT);
|
||||
digitalWrite(DISP_SCLK, LOW);
|
||||
pinMode(DISP_SCLK, OUTPUT);
|
||||
pinMode(DISP_DC, OUTPUT);
|
||||
digitalWrite(DISP_RST, LOW);
|
||||
pinMode(DISP_RST, OUTPUT);
|
||||
|
||||
for (uint8_t attempt = 0; attempt < 2; ++attempt) {
|
||||
digitalWrite(DISP_RST, LOW);
|
||||
delay(2); // Panel application sequence specifies at least 200 us.
|
||||
digitalWrite(DISP_RST, HIGH);
|
||||
delay(10);
|
||||
if (!waitReady()) continue;
|
||||
writeCommand(0x12); // SW RESET, BUSY is HIGH while the command executes.
|
||||
if (!waitReady()) continue;
|
||||
uint8_t status[2];
|
||||
bool stable = true;
|
||||
for (uint8_t bias = 0; bias < 2; ++bias) {
|
||||
const uint8_t mode = bias == 0 ? INPUT_PULLUP : INPUT_PULLDOWN;
|
||||
(void)readStatus(mode);
|
||||
status[bias] = readStatus(mode) & 0xCFu;
|
||||
stable = ((readStatus(mode) & 0xCFu) == status[bias]) && stable;
|
||||
}
|
||||
// Check the chip ID, BUSY=0 and documented reserved-zero bits. Repeated
|
||||
// opposite-pull reads reject floating, stuck and unstable SDA inputs.
|
||||
if (stable && status[0] == 0x01u && status[1] == status[0]) {
|
||||
pinMode(DISP_MOSI, INPUT);
|
||||
pinMode(DISP_BUSY, INPUT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
parkAbsent();
|
||||
return false;
|
||||
}
|
||||
|
||||
}}} // namespace mesh::ui::techo_lite
|
||||
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
const assert = require("assert");
|
||||
const p = require("../docs/_javascript/firmware_picker.js");
|
||||
const source = "a".repeat(40), family = "v1.18.0.1-dev-aaaaaaaa";
|
||||
const targets = [
|
||||
"PicoW_companion_radio", "PicoW_companion_radio_usb", "PicoW_companion_radio_ble", "PicoW_companion_radio_wifi",
|
||||
"heltec_v4_repeater-full-usb-wifi", "heltec_v4_expansionkit_repeater-full-usb-wifi",
|
||||
"heltec_v4_r8_tft_room_server-full-usb-wifi", "heltec_v4_r8_tft_portrait_room_server_observer_mqtt-full-usb-wifi",
|
||||
"heltec_rc32_companion_radio_full", "heltec_rc32_without_display_companion_radio_full",
|
||||
];
|
||||
function asset(target) {
|
||||
const name = target + "-" + family + (target.startsWith("PicoW") ? ".uf2" : ".bin");
|
||||
return {name, size: 500000, browser_download_url: "https://github.com/mikecarper/MeshCore/releases/download/" + family + "/" + name};
|
||||
}
|
||||
function release(names) {
|
||||
return {tag_name: family, name: family, draft: false, published_at: "2026-10-20T00:00:00Z", assets: names.map(asset),
|
||||
html_url: "https://github.com/mikecarper/MeshCore/releases/tag/" + family};
|
||||
}
|
||||
const controls = Object.fromEntries(targets.map(t => [t, {platform: t.startsWith("PicoW") ? "RP2040_PLATFORM" : "ESP32_PLATFORM"}]));
|
||||
const metadata = {familyTag: family, source, profiles: controls};
|
||||
const oldCatalog = p.buildCatalog([release(targets)], metadata);
|
||||
assert.strictEqual(oldCatalog.profiles.length, targets.length, "unqualified historical choices remain exact");
|
||||
controls.PicoW_companion_radio = {platform: "RP2040_PLATFORM", combinedCompanion: true, combinedCompanionSource: source};
|
||||
Object.assign(controls[targets[4]], {oledExpansionCompatible: true, oledExpansionCompatibleSource: source});
|
||||
Object.assign(controls[targets[6]], {display: true, displayRotation: true, displayRotationSource: source});
|
||||
Object.assign(controls[targets[8]], {display: true, displayAuto: true, displayController: "nv3001b", displaySource: source});
|
||||
const releases = [release(targets)], snapshot = JSON.stringify(releases);
|
||||
const catalog = p.buildCatalog(releases, metadata);
|
||||
assert.deepStrictEqual(catalog.profiles.map(x => x.target).sort(), [targets[0], targets[4], targets[6], targets[8]].sort());
|
||||
assert.strictEqual(catalog.rows.length, targets.length);
|
||||
assert.strictEqual(JSON.stringify(releases), snapshot, "no release filename, OTA identity or download is rewritten");
|
||||
const pico = catalog.profiles.find(x => x.target === targets[0]);
|
||||
assert.strictEqual(pico.mode, "combined");
|
||||
assert.strictEqual(pico.ota, "none", "combined transports do not claim Full mOTA support");
|
||||
assert(["usb", "ble", "wifi"].every(mode => p.profileFieldValues(pico, "mode").includes(mode)));
|
||||
assert(p.boardNotes(pico).some(note => note.includes("USB, Bluetooth LE and WiFi")));
|
||||
for (const [oldHardware, newHardware] of [["heltec_v4_expansionkit", "heltec_v4"], ["heltec_v4_r8_tft_portrait", "heltec_v4_r8_tft"], ["heltec_rc32_without_display", "heltec_rc32"]]) {
|
||||
const role = oldHardware.includes("portrait") ? "room" : oldHardware.includes("rc32") ? "companion" : "repeater";
|
||||
const restored = p.selectionFromUrl("https://example.org/?hardware=" + oldHardware + "&role=" + role, catalog.profiles);
|
||||
assert.strictEqual(restored.filters.hardware, newHardware);
|
||||
assert.deepStrictEqual(restored.unavailable, []);
|
||||
}
|
||||
const stale = JSON.parse(JSON.stringify(metadata));
|
||||
for (const entry of Object.values(stale.profiles)) for (const key of Object.keys(entry)) if (key.endsWith("Source")) entry[key] = "b".repeat(40);
|
||||
assert.strictEqual(p.buildCatalog(releases, stale).profiles.length, targets.length, "stale proof never folds old hardware");
|
||||
|
||||
const pairNames = ["Test_repeater_lora_ota_no_external_sensors-full", "Test_repeater_lora_ota_no_external_sensors-reduced"];
|
||||
const sensorMetadata = {familyTag: family, source, profiles: Object.fromEntries(pairNames.map((target, i) => [target, {
|
||||
platform: "NRF52_PLATFORM", sensorProfile: i ? "reduced" : "full", sensorProfileSource: source,
|
||||
otaRole: "lora-receiver", updateMethods: ["lora"],
|
||||
}]))};
|
||||
const pairs = p.buildCatalog([release(pairNames)], sensorMetadata).profiles;
|
||||
assert.strictEqual(pairs.length, 2, "both qualified packages remain in the catalog");
|
||||
assert.deepStrictEqual(p.recommendedProfiles(pairs, {}).map(x => x.sensorProfile), ["full"]);
|
||||
assert.strictEqual(p.recommendedProfiles(pairs, {}, true).length, 2, "Advanced exposes Reduced");
|
||||
const full = pairs.find(x => x.sensorProfile === "full"), reduced = pairs.find(x => x.sensorProfile === "reduced");
|
||||
assert.strictEqual(p.recommendedProfiles([reduced], {}).length, 1, "unmatched Reduced compatibility route stays available");
|
||||
const filters = {hardware: reduced.hardware, role: reduced.role, feature: reduced.feature, variant: reduced.variant, ota: reduced.ota};
|
||||
const url = p.shortSelectionUrl("https://example.org/firmware_picker/", filters, true);
|
||||
const restored = p.selectionFromUrl(url, pairs);
|
||||
assert.deepStrictEqual(restored.unavailable, []);
|
||||
assert(p.recommendedProfiles(pairs, restored.filters).includes(reduced), "explicit Reduced links never select Full");
|
||||
assert.strictEqual(p.recommendedProfiles([full, {...reduced, controls: {...reduced.controls, sensorProfileSource: "b".repeat(40)}}], {}).length, 2, "unmatched source policies are retained");
|
||||
console.log("Qualified hardware/transport consolidation, historical files and Full-default/Advanced-Reduced compatibility passed");
|
||||
|
||||
for (const [legacy, canonical, controller] of [
|
||||
["muzi_base_uno_superIO_companion_radio_ble", "muzi_base_uno_companion_radio_full", "sh1107"],
|
||||
["muzi_base_duo_superIO_companion_radio_ble", "muzi_base_duo_companion_radio_full", "sh1107"],
|
||||
["LilyGo_T-Echo-Lite_non_shell_companion_radio_usb", "LilyGo_T-Echo-Lite_companion_radio_full", "ssd1681"]
|
||||
]) {
|
||||
const proof = {platform: "NRF52_PLATFORM", display: true, displayAuto: true, displayController: controller, displaySource: source};
|
||||
const metadata = {familyTag: family, source, profiles: {[canonical]: proof}};
|
||||
const catalog = p.buildCatalog([release([legacy, canonical])], metadata);
|
||||
assert.deepStrictEqual(catalog.profiles.map(x => x.target), [canonical]);
|
||||
assert.strictEqual(catalog.rows.length, 2);
|
||||
assert(p.optionalAutoDisplayProfile(catalog.profiles[0]));
|
||||
const oldHardware = p.parseTargetProfile(legacy).hardware;
|
||||
const restored = p.selectionFromUrl("https://example.org/?hardware=" + oldHardware + "&role=companion", catalog.profiles);
|
||||
assert.strictEqual(restored.filters.hardware, p.parseTargetProfile(canonical).hardware);
|
||||
assert.deepStrictEqual(restored.unavailable, []);
|
||||
const unqualified = {familyTag: family, source, profiles: {[canonical]: {...proof, displaySource: "b".repeat(40)}}};
|
||||
assert.strictEqual(p.buildCatalog([release([legacy, canonical])], unqualified).profiles.length, 2);
|
||||
const other = canonical.includes("uno") ? canonical.replace("uno", "duo") : canonical.includes("duo") ? canonical.replace("duo", "uno") : canonical.replace("Lite", "Card");
|
||||
assert.strictEqual(p.buildCatalog([release([legacy, other])], {familyTag: family, source, profiles: {[other]: proof}}).profiles.length, 2, "physical radio/panel families cannot substitute");
|
||||
}
|
||||
console.log("Muzi per-radio accessories and T-Echo Lite shell/core folding require exact new display proof");
|
||||
|
||||
{
|
||||
const canonical = "heltec_v4_tft_companion_radio_full_femon";
|
||||
const legacy = "heltec_v4_expansionkit_tft_companion_radio_full_femon";
|
||||
const metadata = {familyTag: family, source, profiles: {[canonical]: {
|
||||
platform: "ESP32_PLATFORM", display: true, tftExpansionCompatible: true, tftExpansionCompatibleSource: source,
|
||||
}}};
|
||||
const catalog = p.buildCatalog([release([legacy, canonical])], metadata);
|
||||
assert.deepStrictEqual(catalog.profiles.map(x => x.target), [canonical]);
|
||||
assert.strictEqual(catalog.rows.length, 2);
|
||||
assert(p.boardNotes(catalog.profiles[0]).some(note => note.includes("TFT expansion kit")));
|
||||
const restored = p.selectionFromUrl("https://example.org/?hardware=heltec_v4_expansionkit_tft&role=companion", catalog.profiles);
|
||||
assert.strictEqual(restored.filters.hardware, "heltec_v4_tft");
|
||||
assert.deepStrictEqual(restored.unavailable, []);
|
||||
delete metadata.profiles[canonical].tftExpansionCompatible;
|
||||
assert.strictEqual(p.buildCatalog([release([legacy, canonical])], metadata).profiles.length, 2);
|
||||
}
|
||||
console.log("V4 TFT base/kit consolidation requires its own exact qualified Full image");
|
||||
@@ -0,0 +1,413 @@
|
||||
"""No-build contracts for evidence-bound firmware choice consolidation."""
|
||||
from copy import deepcopy
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
import consolidated_profiles as consolidated
|
||||
|
||||
|
||||
SOURCE = "a" * 40
|
||||
CASES = (
|
||||
dict(target="PicoW_companion_radio", legacy="PicoW_companion_radio_wifi",
|
||||
board="rpipicow", platform="RP2040_PLATFORM", key="combinedCompanion",
|
||||
capability="companion.picow.combined",
|
||||
marker="meshcore.capability.companion.picow.combined.v1",
|
||||
flags=["-DPICOW_COMBINED_COMPANION=1", "-DENABLE_USB_INTERFACE=1",
|
||||
"-DENABLE_WIFI_INTERFACE=1", "-DPIO_FRAMEWORK_ARDUINO_ENABLE_BLUETOOTH=1"]),
|
||||
dict(target="heltec_v4_repeater", legacy="heltec_v4_expansionkit_repeater",
|
||||
board="heltec_v4", platform="ESP32_PLATFORM", key="oledExpansionCompatible",
|
||||
capability="hardware.heltec_v4.oled_kit",
|
||||
marker="meshcore.capability.hardware.heltec_v4.oled_kit.v1",
|
||||
flags=["-DHELTEC_V4_OLED_KIT_COMPAT=1", "-DHELTEC_LORA_V4_OLED=1",
|
||||
"-DDISPLAY_CLASS=SSD1306Display", "-DENV_PIN_SDA=4", "-DENV_PIN_SCL=3"]),
|
||||
dict(target="heltec_v4_r8_tft_room_server",
|
||||
legacy="heltec_v4_r8_tft_portrait_room_server_observer_mqtt",
|
||||
board="heltec_v4_r8", platform="ESP32_PLATFORM", key="displayRotation",
|
||||
capability="display.rotation.runtime",
|
||||
marker="meshcore.capability.display.rotation.heltec_r8.v1",
|
||||
flags=["-DHELTEC_TFT_RUNTIME_ROTATION=1", "-DHELTEC_V4_R8_TFT=1",
|
||||
"-DDISPLAY_CLASS=ST7789LCDDisplay"]),
|
||||
dict(target="heltec_v4_tft_companion_radio_full_femon",
|
||||
legacy="heltec_v4_expansionkit_tft_companion_radio_full_femon",
|
||||
board="heltec_v4", platform="ESP32_PLATFORM", key="tftExpansionCompatible",
|
||||
capability="hardware.heltec_v4.tft_kit",
|
||||
marker="meshcore.capability.hardware.heltec_v4.tft_kit.v1",
|
||||
flags=["-DHELTEC_V4_TFT_KIT_COMPAT=1", "-DHELTEC_LORA_V4_TFT=1",
|
||||
"-DDISPLAY_CLASS=ST7789LCDDisplay"]),
|
||||
)
|
||||
ACCESSORY_CASES = (
|
||||
dict(base="muzi_base_uno", legacy="muzi_base_uno_superIO", board="muzi_base",
|
||||
marker="muzi_superio", roles=("ble", "full"), flag="MUZI_BASE_ACCESSORY_AUTODETECT",
|
||||
flags=["-DMUZI_BASE=1", "-DMUZI_BASE_ACCESSORY_AUTODETECT=1", "-DDISPLAY_CLASS=SH1107Display",
|
||||
"-DRADIO_CLASS=CustomSX1262", "-DUSE_SX1262=1"]),
|
||||
dict(base="muzi_base_duo", legacy="muzi_base_duo_superIO", board="muzi_base",
|
||||
marker="muzi_superio", roles=("ble", "full"), flag="MUZI_BASE_ACCESSORY_AUTODETECT",
|
||||
flags=["-DMUZI_BASE=1", "-DMUZI_BASE_ACCESSORY_AUTODETECT=1", "-DDISPLAY_CLASS=SH1107Display",
|
||||
"-DRADIO_CLASS=CustomLR1121", "-DUSE_LR1121=1"]),
|
||||
dict(base="LilyGo_T-Echo-Lite", legacy="LilyGo_T-Echo-Lite_non_shell", board="t-echo",
|
||||
marker="techo_lite", roles=("usb", "ble", "full"), flag="TECHO_LITE_DISPLAY_AUTODETECT",
|
||||
flags=["-DLILYGO_TECHO_LITE=1", "-DTECHO_LITE_DISPLAY_AUTODETECT=1",
|
||||
"-DDISPLAY_CLASS=GxEPDDisplay", "-DEINK_DISPLAY_MODEL=GxEPD2_122_T61"]),
|
||||
)
|
||||
|
||||
|
||||
def environment(case):
|
||||
return dict(board=case["board"], build_flags=list(case["flags"]))
|
||||
|
||||
|
||||
def manifest(case, target=None, proof=True):
|
||||
return dict(target=target or case["target"], verified=True,
|
||||
platform=case["platform"], source_commit=SOURCE,
|
||||
build_profile="full", capabilities=[case["capability"]] if proof else [],
|
||||
verification=[dict(capability=case["capability"], present=True,
|
||||
source="packaged application", evidence=case["marker"])] if proof else [])
|
||||
|
||||
|
||||
def record(case, target=None, proof=True):
|
||||
row = manifest(case, target, proof)
|
||||
return dict(manifest=row, files=[row["target"] + ".bin"])
|
||||
|
||||
|
||||
class ConsolidatedProfileTests(unittest.TestCase):
|
||||
def test_r8_rotation_proof_covers_all_four_supported_roles(self):
|
||||
case = next(case for case in CASES if case["key"] == "displayRotation")
|
||||
for role in ("repeater", "room_server", "sensor", "companion_radio_full"):
|
||||
target = "heltec_v4_r8_tft_" + role
|
||||
with self.subTest(target=target):
|
||||
self.assertEqual(consolidated.runtime_metadata(manifest(case, target), environment(case), SOURCE),
|
||||
dict(displayRotation=True, displayRotationSource=SOURCE))
|
||||
for role in ("kiss_modem", "partition_expander", "other", "companion_radio_wifi"):
|
||||
with self.subTest(role=role), self.assertRaises(ValueError):
|
||||
consolidated.runtime_metadata(manifest(case, "heltec_v4_r8_tft_" + role), environment(case), SOURCE)
|
||||
|
||||
def test_original_v4_tft_full_kit_alias_keeps_identical_wiring_and_battery_guard(self):
|
||||
from test_upstream_observer_recipes import Recipes
|
||||
from test_t114_autodisplay_recipes import defines
|
||||
recipes = Recipes()
|
||||
canonical = "env:heltec_v4_tft_companion_radio_full_femon"
|
||||
legacy = "env:heltec_v4_expansionkit_tft_companion_radio_full_femon"
|
||||
flags = defines(recipes.value(canonical, "build_flags"))
|
||||
self.assertEqual(flags, defines(recipes.value(legacy, "build_flags")))
|
||||
for key, value in dict(HELTEC_V4_TFT_KIT_COMPAT="1", DISPLAY_CLASS="ST7789LCDDisplay",
|
||||
AUTO_SHUTDOWN_MILLIVOLTS="3400", MESHCORE_REQUIRES_COMPANION_RADIO_FULL="1",
|
||||
PIN_BOARD_SDA="4", PIN_BOARD_SCL="3", PIN_TFT_RST="18", PIN_TFT_LEDA_CTL="21",
|
||||
PIN_TFT_CS="15", PIN_TFT_DC="16", PIN_TFT_SCL="17", PIN_TFT_SDA="33").items():
|
||||
self.assertEqual(flags.get(key), value, key)
|
||||
for option in ("board", "board_build.partitions", "board_build.flash_mode", "build_src_filter", "lib_deps"):
|
||||
self.assertEqual(recipes.value(canonical, option), recipes.value(legacy, option), option)
|
||||
|
||||
def test_exact_current_configuration_and_packaged_marker_emit_source_bound_metadata(self):
|
||||
for case in CASES:
|
||||
with self.subTest(target=case["target"]):
|
||||
self.assertEqual(consolidated.runtime_metadata(manifest(case), environment(case), SOURCE),
|
||||
{case["key"]: True, case["key"] + "Source": SOURCE})
|
||||
self.assertEqual(consolidated.runtime_metadata(manifest(case, proof=False),
|
||||
environment(case), SOURCE), {},
|
||||
"Current recipes must not relabel a historical application")
|
||||
|
||||
def test_metadata_rejects_unverified_or_wrong_application_evidence(self):
|
||||
for case in CASES:
|
||||
base = manifest(case)
|
||||
invalid_rows = (
|
||||
{"verified": False}, {"platform": "OTHER_PLATFORM"},
|
||||
{"target": "other_board_repeater"}, {"verification": []},
|
||||
{"verification": [{**base["verification"][0], "present": False}]},
|
||||
{"verification": [{**base["verification"][0], "present": 1}]},
|
||||
{"verification": [{**base["verification"][0], "source": "linked image"}]},
|
||||
{"verification": [{**base["verification"][0], "evidence": "a familiar driver name"}]},
|
||||
{"verification": [{**base["verification"][0], "capability": "other.capability"}]},
|
||||
)
|
||||
for changed in invalid_rows:
|
||||
with self.subTest(target=case["target"], changed=changed), self.assertRaises(ValueError):
|
||||
consolidated.runtime_metadata({**base, **changed}, environment(case), SOURCE)
|
||||
|
||||
def test_metadata_requires_full_matching_release_source(self):
|
||||
for case in CASES:
|
||||
for source in (None, "a" * 8, "g" * 40, "A" * 40, "b" * 40):
|
||||
with self.subTest(target=case["target"], source=source), self.assertRaises(ValueError):
|
||||
consolidated.runtime_metadata({**manifest(case), "source_commit": source},
|
||||
environment(case), SOURCE)
|
||||
for release_source in (None, "a" * 8, "b" * 40):
|
||||
with self.subTest(target=case["target"], release_source=release_source), self.assertRaises(ValueError):
|
||||
consolidated.runtime_metadata(manifest(case), environment(case), release_source)
|
||||
|
||||
def test_metadata_rejects_unknown_board_and_later_define_or_undefine_overrides(self):
|
||||
for case in CASES:
|
||||
with self.subTest(target=case["target"], board="unknown"), self.assertRaises(ValueError):
|
||||
consolidated.runtime_metadata(manifest(case), {**environment(case), "board": "unknown"}, SOURCE)
|
||||
for flag in case["flags"]:
|
||||
key = flag[2:].split("=", 1)[0]
|
||||
for override in ("-U" + key, "-D" + key + "=0"):
|
||||
changed = {**environment(case), "build_flags": case["flags"] + [override]}
|
||||
with self.subTest(target=case["target"], override=override), self.assertRaises(ValueError):
|
||||
consolidated.runtime_metadata(manifest(case), changed, SOURCE)
|
||||
|
||||
def test_replacements_are_limited_to_known_exact_legacy_targets(self):
|
||||
for case in CASES:
|
||||
self.assertIn((case["target"], case["key"]), consolidated.replacements(case["legacy"]))
|
||||
self.assertEqual(consolidated.replacements(case["target"]), [])
|
||||
self.assertEqual(consolidated.replacements(case["legacy"] + "_custom"), [])
|
||||
for target in ("other_PicoW_companion_radio_usb", "heltec_v4_expansionkit_sensor",
|
||||
"heltec_v4_r8_tft_portrait_sensor_observer_mqtt", "other_without_display_repeater"):
|
||||
with self.subTest(target=target):
|
||||
self.assertEqual(consolidated.replacements(target), [])
|
||||
|
||||
def test_configuration_replacement_requires_both_known_matching_boards(self):
|
||||
for case in CASES:
|
||||
canonical = "env:" + case["target"]
|
||||
legacy = "env:" + case["legacy"]
|
||||
envs = {canonical: environment(case), legacy: environment(case)}
|
||||
self.assertEqual(consolidated.configuration_replacement(case["legacy"], envs), case["target"])
|
||||
for changed in ({legacy: environment(case)}, {canonical: environment(case)},
|
||||
{canonical: environment(case), legacy: {**environment(case), "board": "other"}},
|
||||
{canonical: {**environment(case), "board": "unknown"},
|
||||
legacy: {**environment(case), "board": "unknown"}}):
|
||||
with self.subTest(target=case["target"], envs=changed):
|
||||
self.assertIsNone(consolidated.configuration_replacement(case["legacy"], changed))
|
||||
|
||||
def test_configuration_replacement_preserves_candidate_flag_overrides(self):
|
||||
for case in CASES:
|
||||
for flag in case["flags"]:
|
||||
key = flag[2:].split("=", 1)[0]
|
||||
for override in ("-U" + key, "-D" + key + "=0"):
|
||||
envs = {"env:" + case["legacy"]: environment(case),
|
||||
"env:" + case["target"]: {**environment(case),
|
||||
"build_flags": case["flags"] + [override]}}
|
||||
with self.subTest(target=case["target"], override=override):
|
||||
self.assertIsNone(consolidated.configuration_replacement(case["legacy"], envs))
|
||||
|
||||
def test_omission_requires_matching_profile_policy_and_real_packaged_successor(self):
|
||||
for case in CASES:
|
||||
legacy = record(case, case["legacy"], proof=False)
|
||||
canonical = record(case)
|
||||
legacy["manifest"]["capabilities"].append("sensor.profile.full")
|
||||
canonical["manifest"]["capabilities"].append("sensor.profile.full")
|
||||
before = deepcopy([legacy, canonical])
|
||||
for inputs in ([legacy, canonical], [canonical, legacy]):
|
||||
with self.subTest(target=case["target"], order=[r["manifest"]["target"] for r in inputs]):
|
||||
self.assertEqual(consolidated.omit_redundant_records(inputs), [canonical])
|
||||
self.assertEqual([legacy, canonical], before)
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy]), [legacy])
|
||||
for changed in (dict(build_profile="reduced"), dict(verified=False), dict(verification=[]),
|
||||
dict(platform="OTHER_PLATFORM"), dict(target=case["target"] + "_custom"),
|
||||
dict(capabilities=[case["capability"], "sensor.profile.reduced"]),
|
||||
dict(verification=[{**canonical["manifest"]["verification"][0], "source": "linked image"}]),
|
||||
dict(verification=[{**canonical["manifest"]["verification"][0], "evidence": "other marker"}])):
|
||||
candidate = {**canonical, "manifest": {**canonical["manifest"], **changed}}
|
||||
with self.subTest(target=case["target"], changed=changed):
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy, candidate]), [legacy, candidate])
|
||||
|
||||
def test_historical_manifests_are_never_relabelled_by_current_recipe_defaults(self):
|
||||
for case in CASES:
|
||||
legacy, current_name_old_image = record(case, case["legacy"], False), record(case, proof=False)
|
||||
inputs = [legacy, current_name_old_image]
|
||||
before = deepcopy(inputs)
|
||||
self.assertEqual(consolidated.omit_redundant_records(inputs), inputs)
|
||||
self.assertEqual(inputs, before)
|
||||
|
||||
def test_rc32_headless_choice_requires_exact_canonical_autodetection_marker(self):
|
||||
target, legacy_target = "heltec_rc32_repeater", "heltec_rc32_without_display_repeater"
|
||||
canonical = dict(manifest=dict(target=target, platform="ESP32_PLATFORM", verified=True,
|
||||
build_profile="full", capabilities=["display.autodetect"], verification=[dict(
|
||||
capability="display.autodetect", present=True, source="packaged application",
|
||||
evidence="meshcore.capability.display.autodetect.rc32.v1")]), files=[target + ".bin"])
|
||||
legacy = dict(manifest=dict(target=legacy_target, platform="ESP32_PLATFORM", verified=True,
|
||||
build_profile="full", capabilities=[], verification=[]), files=[legacy_target + ".bin"])
|
||||
before = deepcopy([legacy, canonical])
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy, canonical]), [canonical])
|
||||
self.assertEqual([legacy, canonical], before)
|
||||
for changed in (dict(verified=False), dict(platform="NRF52_PLATFORM"), dict(capabilities=[]),
|
||||
dict(verification=[]), dict(build_profile="reduced"),
|
||||
dict(capabilities=["display.autodetect", "sensor.profile.reduced"]),
|
||||
dict(verification=[{**canonical["manifest"]["verification"][0], "source": "linked image"}]),
|
||||
dict(verification=[{**canonical["manifest"]["verification"][0], "present": False}]),
|
||||
dict(verification=[{**canonical["manifest"]["verification"][0],
|
||||
"evidence": "meshcore.capability.display.autodetect.heltec_r8.v1"}])):
|
||||
candidate = {**canonical, "manifest": {**canonical["manifest"], **changed}}
|
||||
with self.subTest(changed=changed):
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy, candidate]), [legacy, candidate])
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy]), [legacy])
|
||||
|
||||
def test_rc32_configuration_successor_requires_resolved_auto_display_recipe(self):
|
||||
target, legacy = "heltec_rc32_companion_radio_full", "heltec_rc32_without_display_companion_radio_full"
|
||||
flags = ["-DRC32_DISPLAY_AUTODETECT=1", "-DHELTEC_RC32=1", "-DDISPLAY_CLASS=NV3001BDisplay"]
|
||||
env = dict(board="heltec-rc32", build_flags=flags)
|
||||
envs = {"env:" + target: env, "env:" + legacy: env}
|
||||
self.assertEqual(consolidated.configuration_replacement(legacy, envs), target)
|
||||
for override in ("-URC32_DISPLAY_AUTODETECT", "-DRC32_DISPLAY_AUTODETECT=0",
|
||||
"-UHELTEC_RC32", "-DHELTEC_RC32=0", "-DDISPLAY_CLASS=NullDisplayDriver"):
|
||||
changed = {**envs, "env:" + target: {**env, "build_flags": flags + [override]}}
|
||||
with self.subTest(override=override):
|
||||
self.assertIsNone(consolidated.configuration_replacement(legacy, changed))
|
||||
changed = {key: {**value, "board": "unknown"} for key, value in envs.items()}
|
||||
self.assertIsNone(consolidated.configuration_replacement(legacy, changed))
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Bash release contracts run on Linux/WSL")
|
||||
def test_bulk_shell_wiring_omits_aliases_preserves_direct_identity_and_demands_application_marker(self):
|
||||
config = []
|
||||
setup, checks = [], []
|
||||
for case in CASES:
|
||||
for target in (case["target"], case["legacy"]):
|
||||
config.append(["env:" + target, [["board", case["board"]], ["build_flags", case["flags"]]]])
|
||||
setup.append("SUPPORTED_PIO_ENVS+=(" + shlex.quote(target) + ")")
|
||||
for mapping, value in (("PIO_ENV_PLATFORM_BY_NAME", case["platform"]),
|
||||
("PIO_ENV_BOARD_BY_NAME", case["board"]),
|
||||
("PIO_ENV_BUILD_BASE_BY_NAME", target)):
|
||||
setup.append(mapping + "[" + shlex.quote(target) + "]=" + shlex.quote(value))
|
||||
checks.append("check_choice " + " ".join(shlex.quote(value) for value in (
|
||||
case["legacy"], case["target"], case["platform"],
|
||||
case["capability"] + "=" + case["marker"])))
|
||||
program = r'''
|
||||
set -euo pipefail
|
||||
source build.sh
|
||||
pio() { echo 'PlatformIO must not run in this test' >&2; return 99; }
|
||||
@SETUP@
|
||||
ALL_PIO_ENVS=("${SUPPORTED_PIO_ENVS[@]}")
|
||||
PIO_CONFIG_JSON=@CONFIG@
|
||||
BUILD_PROFILE_FOR_TARGET=full
|
||||
check_choice() {
|
||||
local legacy=$1 canonical=$2 platform=$3 expected=$4
|
||||
[ "$(get_consolidated_hardware_replacement "$legacy")" = "$canonical" ]
|
||||
is_redundant_bulk_build_target "$legacy"
|
||||
is_known_pio_env "$legacy"
|
||||
[ "$(get_pio_build_env "$legacy")" = "$legacy" ]
|
||||
! get_consolidated_hardware_replacement "$canonical"
|
||||
BUILD_APPLICATION_EXPECTATIONS=() BUILD_EXPECTATIONS=() BUILD_CAPABILITIES=() BUILD_REDUCTIONS=()
|
||||
declare_build_capability_contract "$canonical" "$platform"
|
||||
[[ " ${BUILD_APPLICATION_EXPECTATIONS[*]} " == *" $expected "* ]]
|
||||
}
|
||||
@CHECKS@
|
||||
PIO_CONFIG_JSON=@OVERRIDDEN@
|
||||
@OVERRIDE_CHECKS@
|
||||
'''
|
||||
overridden = deepcopy(config)
|
||||
for case in CASES:
|
||||
row = next(row for row in overridden if row[0] == "env:" + case["target"])
|
||||
row[1][1][1].append("-U" + case["flags"][0][2:].split("=", 1)[0])
|
||||
program = program.replace("@SETUP@", "\n".join(setup))
|
||||
program = program.replace("@CHECKS@", "\n".join(checks))
|
||||
program = program.replace("@CONFIG@", shlex.quote(json.dumps(config)))
|
||||
program = program.replace("@OVERRIDDEN@", shlex.quote(json.dumps(overridden)))
|
||||
program = program.replace("@OVERRIDE_CHECKS@", "\n".join(
|
||||
"! get_consolidated_hardware_replacement " + shlex.quote(case["legacy"]) for case in CASES))
|
||||
result = subprocess.run(["bash", "-c", program], cwd=ROOT, capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
def test_actual_controls_generator_requires_packaged_proof_from_its_exact_config(self):
|
||||
import generate_picker_controls as controls
|
||||
|
||||
family = "v1.18.0.1.preview1-aaaaaaaa"
|
||||
with tempfile.TemporaryDirectory(prefix="consolidated-controls-") as folder:
|
||||
stage = Path(folder)
|
||||
(stage / "companion").mkdir()
|
||||
(stage / "release-plan.json").write_text(json.dumps(dict(
|
||||
source=SOURCE, groups=[dict(key="companion", tag=family)])))
|
||||
path = stage / "companion/TARGET-MANIFEST.json"
|
||||
for case in CASES:
|
||||
row = manifest(case)
|
||||
row.update(platformio_env=case["target"], files=[case["target"] + "-" + family + ".bin"])
|
||||
path.write_text(json.dumps([row]))
|
||||
config = [["env:" + case["target"], [["board", case["board"]], ["build_flags", case["flags"]]]]]
|
||||
profile = controls.generate(stage, config)["profiles"][case["target"]]
|
||||
self.assertIs(profile[case["key"]], True)
|
||||
self.assertEqual(profile[case["key"] + "Source"], SOURCE)
|
||||
changed = deepcopy(config)
|
||||
changed[0][1][1][1].append("-U" + case["flags"][0][2:].split("=", 1)[0])
|
||||
with self.subTest(target=case["target"], reason="overridden recipe"), self.assertRaises(ValueError):
|
||||
controls.generate(stage, changed)
|
||||
row["verification"] = []
|
||||
path.write_text(json.dumps([row]))
|
||||
with self.subTest(target=case["target"], reason="missing packaged evidence"), self.assertRaises(ValueError):
|
||||
controls.generate(stage, config)
|
||||
row["capabilities"] = []
|
||||
path.write_text(json.dumps([row]))
|
||||
historical = controls.generate(stage, config)["profiles"][case["target"]]
|
||||
self.assertNotIn(case["key"], historical)
|
||||
self.assertNotIn(case["key"] + "Source", historical)
|
||||
|
||||
def test_generated_accessory_full_targets_require_exact_radio_board_and_optional_display_recipe(self):
|
||||
for case in ACCESSORY_CASES:
|
||||
canonical = case["base"] + "_companion_radio_full"
|
||||
for base_role in ("usb", "ble"):
|
||||
canonical_base = case["base"] + "_companion_radio_" + base_role
|
||||
legacy_base = case["legacy"] + "_companion_radio_" + base_role
|
||||
env = dict(board=case["board"], build_flags=case["flags"])
|
||||
envs = {"env:" + canonical_base: env, "env:" + legacy_base: env}
|
||||
for role in case["roles"]:
|
||||
target = case["legacy"] + "_companion_radio_" + role
|
||||
# A BLE request needs its real BLE source; generated Full
|
||||
# can resolve either attached-transport source recipe.
|
||||
role_envs = {**envs, "env:" + target: env} if role != "full" else envs
|
||||
with self.subTest(target=target, canonical_base=canonical_base):
|
||||
self.assertEqual(consolidated.configuration_replacement(target, role_envs), canonical)
|
||||
for changed in (
|
||||
{**env, "board": "unknown"},
|
||||
{**env, "build_flags": case["flags"] + ["-U" + case["flag"]]},
|
||||
{**env, "build_flags": case["flags"] + ["-D" + case["flag"] + "=0"]},
|
||||
{**env, "build_flags": case["flags"] + ["-DDISPLAY_CLASS=NullDisplayDriver"]}):
|
||||
invalid = {**role_envs, "env:" + canonical_base: changed}
|
||||
with self.subTest(target=target, changed=changed):
|
||||
self.assertIsNone(consolidated.configuration_replacement(target, invalid))
|
||||
if case["base"].startswith("muzi_base_"):
|
||||
other = next(row for row in ACCESSORY_CASES if row["board"] == "muzi_base"
|
||||
and row["base"] != case["base"])
|
||||
wrong_radio = {**envs, "env:" + canonical_base: dict(board=case["board"], build_flags=other["flags"])}
|
||||
with self.subTest(target=canonical, wrong_radio=other["base"]):
|
||||
self.assertIsNone(consolidated.configuration_replacement(
|
||||
case["legacy"] + "_companion_radio_full", wrong_radio))
|
||||
other_name = other["base"] + "_companion_radio_" + base_role
|
||||
different_hardware = {"env:" + other_name: env, "env:" + legacy_base: env}
|
||||
self.assertIsNone(consolidated.configuration_replacement(
|
||||
case["legacy"] + "_companion_radio_full", different_hardware))
|
||||
|
||||
def test_accessory_full_omission_requires_packaged_display_and_both_linked_transports(self):
|
||||
for case in ACCESSORY_CASES:
|
||||
canonical_target = case["base"] + "_companion_radio_full"
|
||||
display = dict(capability="display.autodetect", present=True, source="packaged application",
|
||||
evidence="meshcore.capability.display.autodetect." + case["marker"] + ".v1")
|
||||
transport = [dict(capability=key, present=True, source="linked image", evidence=symbol)
|
||||
for key, symbol in (("companion.usb", "+++MESHCORE-TERM-START"),
|
||||
("companion.bluetooth", "Companion: starting Bluetooth"))]
|
||||
canonical = dict(manifest=dict(target=canonical_target, platform="NRF52_PLATFORM", verified=True,
|
||||
build_profile="full", capabilities=["display.autodetect", "companion.usb", "companion.bluetooth"],
|
||||
verification=[display, *transport]), files=[canonical_target + ".uf2"])
|
||||
for role in case["roles"]:
|
||||
target = case["legacy"] + "_companion_radio_" + role
|
||||
legacy = dict(manifest=dict(target=target, platform="NRF52_PLATFORM", verified=True,
|
||||
build_profile="full" if role == "full" else "standard", capabilities=[], verification=[]),
|
||||
files=[target + ".uf2"])
|
||||
before = deepcopy([legacy, canonical])
|
||||
with self.subTest(target=target):
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy, canonical]), [canonical])
|
||||
self.assertEqual([legacy, canonical], before)
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy]), [legacy])
|
||||
invalid = [dict(verified=False), dict(platform="ESP32_PLATFORM"), dict(verification=[]),
|
||||
dict(capabilities=["companion.usb", "companion.bluetooth"]),
|
||||
dict(verification=[{**display, "source": "linked image"}, *transport]),
|
||||
dict(verification=[{**display, "evidence": "meshcore.capability.display.autodetect.rc32.v1"}, *transport])]
|
||||
for key in ("companion.usb", "companion.bluetooth"):
|
||||
invalid.append(dict(capabilities=[cap for cap in canonical["manifest"]["capabilities"] if cap != key]))
|
||||
for change in (dict(present=False), dict(source="packaged application"), dict(evidence="")):
|
||||
invalid.append(dict(verification=[{**row, **change} if row["capability"] == key else row
|
||||
for row in canonical["manifest"]["verification"]]))
|
||||
if role == "full":
|
||||
invalid.append(dict(build_profile="standard"))
|
||||
if case["base"].startswith("muzi_base_"):
|
||||
other = "muzi_base_duo" if case["base"] == "muzi_base_uno" else "muzi_base_uno"
|
||||
invalid.append(dict(target=other + "_companion_radio_full"))
|
||||
for changed in invalid:
|
||||
candidate = {**canonical, "manifest": {**canonical["manifest"], **changed}}
|
||||
with self.subTest(target=target, changed=changed):
|
||||
self.assertEqual(consolidated.omit_redundant_records([legacy, candidate]), [legacy, candidate])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,239 @@
|
||||
"""Exercise real R8 rotation, atomic saved settings and role redraw hooks."""
|
||||
from pathlib import Path
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from cpp_source import body
|
||||
import test_heltec_r8_display_detection as detection
|
||||
from test_display_power import FS_STUB
|
||||
from test_serial_wifi_sessions import SANITIZER_FLAGS
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
DRIVER_TEST = r'''
|
||||
#include "ST7789LCDDisplay.h"
|
||||
#include <helpers/ui/ObserverDashboard.h>
|
||||
void checkGeometry(ST7789LCDDisplay& d,unsigned degrees,bool flipped,bool initialized_panel) {
|
||||
const unsigned reg=(DISPLAY_ROTATION+degrees/90+(flipped?2:0))&3;
|
||||
assert(d.width()==(reg&1?320:240) && d.height()==(reg&1?240:320));
|
||||
const auto& layout=ObserverDashboard::activeLayout(d);
|
||||
assert(layout.right_x==(d.width()==240?232:310));
|
||||
assert(layout.status_y<d.height() && layout.right_x<d.width());
|
||||
if (initialized_panel) assert(last_rotation==reg);
|
||||
}
|
||||
int main(int argc,char** argv) {
|
||||
assert(argc==2); scenario=argv[1];
|
||||
RefCountedDigitalPin rail(40); rail.begin(); rail.claim();
|
||||
ST7789LCDDisplay d(&rail);
|
||||
#ifndef MESHCORE_HELTEC_R8_RUNTIME_ROTATION
|
||||
assert(!d.supportsRotation());
|
||||
assert(!d.setRotationDegrees(90));
|
||||
return 0;
|
||||
#else
|
||||
assert(d.supportsRotation());
|
||||
const auto before=events;
|
||||
assert(d.setRotationDegrees(90)); checkGeometry(d,90,false,false);
|
||||
assert(events==before && rotations==0 && init_calls==0);
|
||||
assert(!d.setRotationDegrees(45) && !d.setRotationDegrees(360));
|
||||
checkGeometry(d,90,false,false);
|
||||
if (scenario=="floating") {
|
||||
assert(!d.begin());
|
||||
const auto failed_events=events;
|
||||
for (unsigned angle:{0,90,180,270}) {
|
||||
assert(d.setRotationDegrees(angle)); d.setFlipped(true);
|
||||
checkGeometry(d,angle,true,false); d.setFlipped(false);
|
||||
checkGeometry(d,angle,false,false); d.turnOn(); assert(!d.begin());
|
||||
}
|
||||
assert(events==failed_events && rotations==0 && init_calls==0);
|
||||
assert(levels[PIN_TFT_RST]==HIGH);
|
||||
return 0;
|
||||
}
|
||||
assert(d.begin()); checkGeometry(d,90,false,true);
|
||||
const auto reset_count=resets, init_count=init_calls, spi_count=spi_begins;
|
||||
for (bool flipped:{false,true}) {
|
||||
d.setFlipped(flipped);
|
||||
for (unsigned angle:{0,90,180,270}) {
|
||||
assert(d.setRotationDegrees(angle)); checkGeometry(d,angle,flipped,true);
|
||||
const auto count=rotations;
|
||||
assert(d.setRotationDegrees(angle) && rotations==count);
|
||||
assert(resets==reset_count && init_calls==init_count && spi_begins==spi_count);
|
||||
}
|
||||
}
|
||||
d.turnOff(); const auto asleep_draws=draws, asleep_rotations=rotations;
|
||||
// Coalesce several saved changes without waking or touching SPI/reset.
|
||||
assert(d.setRotationDegrees(90)); d.setFlipped(false);
|
||||
assert(d.setRotationDegrees(180)); assert(d.setRotationDegrees(270));
|
||||
checkGeometry(d,270,false,false);
|
||||
assert(draws==asleep_draws && rotations==asleep_rotations && !d.isOn());
|
||||
d.turnOn(); checkGeometry(d,270,false,true);
|
||||
assert(rotations==asleep_rotations+1);
|
||||
assert(resets==reset_count && init_calls==init_count && spi_begins==spi_count);
|
||||
d.turnOff(); d.turnOn();
|
||||
assert(rotations==asleep_rotations+1 && resets==reset_count);
|
||||
assert(d.setRotationDegrees(0)); checkGeometry(d,0,false,true);
|
||||
d.turnOff(); rail.release(); assert(levels[40]==LOW);
|
||||
#endif
|
||||
}
|
||||
'''
|
||||
|
||||
SETTINGS_TEST = r'''
|
||||
#include <cassert>
|
||||
#include <helpers/ui/DisplayRotationSettings.h>
|
||||
using namespace mesh::ui;
|
||||
bool command(const char* text,char* reply,bool supported=true) {
|
||||
return handleDisplayRotationCommand(text,reply,160,supported);
|
||||
}
|
||||
int main() {
|
||||
FakeFS fs; char reply[160];
|
||||
assert(!loadDisplayRotationSettings(&fs) && displayRotationDegrees()==0);
|
||||
assert(!command("get display.rotation.extra",reply));
|
||||
assert(!command("set display.mode on",reply));
|
||||
assert(command("get display.rotation",reply) && strstr(reply,"default"));
|
||||
for (const char* input:{"set display.rotation 45","set display.rotation -90",
|
||||
"set display.rotation 360","set display.rotation 90junk","set display.rotation",
|
||||
"set display.rotation 99999999999999999999999999999999","set display.rotation auto"}) {
|
||||
assert(command(input,reply) && strstr(reply,"Error:"));
|
||||
assert(displayRotationDegrees()==0 && fs.files.empty());
|
||||
}
|
||||
assert(command("set display.rotation 90",reply,false) && strstr(reply,"unsupported"));
|
||||
assert(fs.files.empty());
|
||||
for (unsigned angle:{90,180,270,0}) {
|
||||
char input[80]; snprintf(input,sizeof(input),"set display.rotation %u",angle);
|
||||
assert(command(input,reply) && strstr(reply,"OK"));
|
||||
assert(displayRotationDegrees()==angle && fs.files.size()==1);
|
||||
assert(fs.exists("/display_rotation") && fs.files["/display_rotation"].size()==6);
|
||||
assert(loadDisplayRotationSettings(&fs) && displayRotationDegrees()==angle);
|
||||
}
|
||||
assert(command("set display.rotation 90",reply));
|
||||
const auto original=fs.files["/display_rotation"];
|
||||
fs.fail_write=true;
|
||||
assert(command("set display.rotation 180",reply) && strstr(reply,"save failed"));
|
||||
assert(displayRotationDegrees()==90 && fs.files["/display_rotation"]==original);
|
||||
fs.fail_write=false; fs.fail_publish=true;
|
||||
assert(command("set display.rotation 180",reply) && strstr(reply,"save failed"));
|
||||
assert(displayRotationDegrees()==90 && fs.files["/display_rotation"]==original);
|
||||
fs.fail_publish=false;
|
||||
assert(loadDisplayRotationSettings(&fs) && displayRotationDegrees()==90);
|
||||
// Recover a last complete backup rather than accepting a damaged primary.
|
||||
fs.files["/display_rotation.bak"]=original;
|
||||
fs.files["/display_rotation"][5]^=1;
|
||||
assert(loadDisplayRotationSettings(&fs) && displayRotationDegrees()==90);
|
||||
assert(fs.files["/display_rotation"]==original && !fs.exists("/display_rotation.bak"));
|
||||
// A valid checksum with an invalid angle/version is still rejected.
|
||||
for (bool bad_version:{false,true}) {
|
||||
fs.files["/display_rotation"]=original;
|
||||
auto& data=fs.files["/display_rotation"];
|
||||
if (bad_version) data[2]=2; else data[3]=45;
|
||||
data[5]=0; for (unsigned i=0;i<5;++i) data[5]^=data[i];
|
||||
assert(!loadDisplayRotationSettings(&fs) && displayRotationDegrees()==0);
|
||||
}
|
||||
assert(!loadDisplayRotationSettings(nullptr));
|
||||
assert(command("set display.rotation 90",reply) && strstr(reply,"save failed"));
|
||||
}
|
||||
'''
|
||||
|
||||
ROLE_TEST = r'''
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#define DISPLAY_REDRAW_ON_CHANGE 1
|
||||
#define DISPLAY_ACTIVITY_DASHBOARD 1
|
||||
namespace mesh { namespace ui {
|
||||
unsigned wanted=0;
|
||||
uint16_t displayRotationDegrees() {return wanted;}
|
||||
}}
|
||||
uint32_t now=50;
|
||||
uint32_t millis() {return now;}
|
||||
struct Display {
|
||||
bool supported=true,accept=true;
|
||||
unsigned calls=0,angle=999;
|
||||
bool supportsRotation() {return supported;}
|
||||
bool setRotationDegrees(uint16_t value) {++calls; if(!accept)return false; angle=value; return true;}
|
||||
};
|
||||
class UITask {
|
||||
public:
|
||||
Display* _display;
|
||||
uint16_t _rotation_seen=0xffff;
|
||||
bool _frame_valid=true,_rows_valid=true;
|
||||
uint32_t _next_refresh=1000,_last_refresh=0;
|
||||
void applyDisplayRotation();
|
||||
};
|
||||
@METHOD@
|
||||
int main() {
|
||||
Display display; UITask task{&display};
|
||||
task.applyDisplayRotation(); assert(display.calls==1 && display.angle==0);
|
||||
@INVALIDATION@
|
||||
task.applyDisplayRotation(); assert(display.calls==1);
|
||||
mesh::ui::wanted=90; task._frame_valid=task._rows_valid=true; task._next_refresh=2000;
|
||||
task.applyDisplayRotation(); assert(display.calls==2 && display.angle==90);
|
||||
@INVALIDATION@
|
||||
display.accept=false; mesh::ui::wanted=180; task.applyDisplayRotation();
|
||||
assert(task._rotation_seen==90);
|
||||
display.accept=true; task.applyDisplayRotation(); assert(task._rotation_seen==180);
|
||||
display.supported=false; const auto calls=display.calls; mesh::ui::wanted=270;
|
||||
task.applyDisplayRotation(); assert(display.calls==calls);
|
||||
task._display=nullptr; task.applyDisplayRotation();
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class HeltecR8DisplayRotationTests(unittest.TestCase):
|
||||
def compile_run(self, directory, main, extra=()):
|
||||
cpp=directory/"main.cpp"; binary=directory/"test"
|
||||
cpp.write_text(main)
|
||||
result=subprocess.run([os.environ.get("CXX","g++"),"-std=c++17","-Wall","-Wextra","-Werror",
|
||||
"-Wno-unused-variable",*SANITIZER_FLAGS,"-I"+str(directory),"-I"+str(ROOT/"src"),
|
||||
str(cpp),*map(str,extra),"-o",str(binary)],capture_output=True,text=True,timeout=60)
|
||||
self.assertEqual(result.returncode,0,result.stdout+result.stderr)
|
||||
result=subprocess.run([str(binary)],capture_output=True,text=True,timeout=10)
|
||||
self.assertEqual(result.returncode,0,result.stdout+result.stderr)
|
||||
|
||||
def test_all_board_defaults_quarter_turns_flip_sleep_and_absence(self):
|
||||
fixture=detection.HeltecR8DisplayDetectionTest()
|
||||
with tempfile.TemporaryDirectory(prefix="r8-rotation-") as temporary:
|
||||
for default in range(4):
|
||||
flags=["-DHELTEC_V4_R8_TFT","-DHELTEC_TFT_DISPLAY_AUTODETECT=1",
|
||||
"-DHELTEC_TFT_RUNTIME_ROTATION=1",f"-DDISPLAY_ROTATION={default}"]
|
||||
with patch.object(detection,"MAIN",DRIVER_TEST):
|
||||
binary=fixture.build(Path(temporary)/str(default),flags)
|
||||
self.assertIn(b"meshcore.capability.display.rotation.heltec_r8.v1",binary.read_bytes())
|
||||
for scenario in ("valid","floating"):
|
||||
with self.subTest(default=default,scenario=scenario):fixture.run_case(binary,scenario)
|
||||
|
||||
def test_rotation_is_scoped_to_enabled_r8_firmware(self):
|
||||
fixture=detection.HeltecR8DisplayDetectionTest()
|
||||
with tempfile.TemporaryDirectory(prefix="r8-rotation-guard-") as temporary:
|
||||
for index,flags in enumerate((["-DHELTEC_V4_R8_TFT"],
|
||||
["-DHELTEC_V4_R8_TFT","-DHELTEC_TFT_RUNTIME_ROTATION=0"],
|
||||
["-DHELTEC_LORA_V4_TFT","-DHELTEC_TFT_RUNTIME_ROTATION=1"],
|
||||
["-DLILYGO_TDECK","-DHELTEC_TFT_RUNTIME_ROTATION=1"])):
|
||||
with patch.object(detection,"MAIN",DRIVER_TEST):
|
||||
binary=fixture.build(Path(temporary)/str(index),flags)
|
||||
fixture.run_case(binary,"valid")
|
||||
self.assertNotIn(b"meshcore.capability.display.rotation.heltec_r8.v1",binary.read_bytes())
|
||||
|
||||
def test_saved_rotation_reboots_validation_and_atomic_failure_recovery(self):
|
||||
with tempfile.TemporaryDirectory(prefix="r8-rotation-settings-") as temporary:
|
||||
directory=Path(temporary); (directory/"helpers").mkdir()
|
||||
(directory/"helpers/IdentityStore.h").write_text(FS_STUB.replace("/display_prefs.tmp","/display_rotation.tmp"))
|
||||
self.compile_run(directory,SETTINGS_TEST,[ROOT/"src/helpers/ui/DisplayRotationSettings.cpp"])
|
||||
|
||||
def test_every_infrastructure_role_observes_changes_and_invalidates_its_frame(self):
|
||||
with tempfile.TemporaryDirectory(prefix="r8-rotation-ui-") as temporary:
|
||||
for role in ("simple_repeater","simple_room_server","simple_sensor"):
|
||||
source=(ROOT/"examples"/role/"UITask.cpp").read_text()
|
||||
method=body(source,"void UITask::applyDisplayRotation()")
|
||||
invalidation=("assert(uint32_t(now-task._last_refresh)>=1000u);" if role=="simple_sensor"
|
||||
else "assert(!task._frame_valid && !task._rows_valid && task._next_refresh==now);")
|
||||
main=ROLE_TEST.replace("@METHOD@",method).replace("@INVALIDATION@",invalidation)
|
||||
self.compile_run(Path(temporary),main)
|
||||
# A setting change while asleep must be observed before power
|
||||
# servicing can wake and repaint the display.
|
||||
loop=body(source,"void UITask::loop()")
|
||||
self.assertLess(loop.index("applyDisplayRotation();"),loop.index("servicePower("))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,213 @@
|
||||
"""Actual Muzi optional OLED lifecycle, GPS/button integration and recipe aliases."""
|
||||
from pathlib import Path
|
||||
import configparser
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from test_replay_reset_integration import extract_braced
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
UI = ROOT / "src/helpers/ui"
|
||||
SAN = ["-fsanitize=address,undefined", "-fno-sanitize-recover=all", "-fno-pie", "-no-pie"] if sys.platform.startswith("linux") else []
|
||||
|
||||
ARDUINO = r'''
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#define LOW 0
|
||||
#define HIGH 1
|
||||
#define INPUT 0
|
||||
#define OUTPUT 1
|
||||
#define INPUT_PULLDOWN 3
|
||||
#define SCREEN_12V_ENABLE 23
|
||||
inline unsigned now_ms=0, events=0, probes=0, initializations=0, draws=0, allocations=0;
|
||||
inline int levels[64]={}, modes[64]={};
|
||||
inline bool initialized=false, allocated=false;
|
||||
inline std::string scenario;
|
||||
inline bool automatic() {
|
||||
#if defined(MUZI_BASE) && defined(MUZI_BASE_ACCESSORY_AUTODETECT) && MUZI_BASE_ACCESSORY_AUTODETECT == 1
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
inline void pinMode(int pin,int mode) { assert(pin==23); modes[pin]=mode; ++events; }
|
||||
inline void digitalWrite(int pin,int value) { assert(pin==23); levels[pin]=value; ++events; }
|
||||
inline void delay(unsigned ms) { now_ms+=ms; }
|
||||
'''
|
||||
WIRE = r'''
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
class TwoWire {
|
||||
public:
|
||||
void beginTransmission(uint8_t addr) { assert(addr==0x3c); if(automatic()) assert(levels[23]==HIGH && now_ms>=250); }
|
||||
uint8_t endTransmission() { ++probes; return scenario=="absent" ? 2 : 0; }
|
||||
};
|
||||
inline TwoWire Wire;
|
||||
'''
|
||||
PANEL = r'''
|
||||
#pragma once
|
||||
#include <Wire.h>
|
||||
#define SH110X_BLACK 0
|
||||
#define SH110X_WHITE 1
|
||||
#define SH110X_DISPLAYON 0xaf
|
||||
#define SH110X_DISPLAYOFF 0xae
|
||||
class Adafruit_SH1107 {
|
||||
public:
|
||||
template<class... T> Adafruit_SH1107(T...) {}
|
||||
bool begin(uint8_t,bool) {
|
||||
if(automatic()) assert(probes>0 && "probe before library allocation");
|
||||
++initializations;
|
||||
if(!allocated) { allocated=true; ++allocations; }
|
||||
initialized=scenario!="init-fail";
|
||||
return initialized;
|
||||
}
|
||||
void setRotation(int) { assert(initialized); ++draws; }
|
||||
void oled_command(int command) { assert(initialized); if(automatic()) assert(levels[23]==HIGH); ++draws; }
|
||||
void oled_commandList(uint8_t*,int) { assert(initialized); ++draws; }
|
||||
void clearDisplay() { assert(initialized); ++draws; }
|
||||
void display() { assert(initialized); ++draws; }
|
||||
void setContrast(int) { assert(initialized); ++draws; }
|
||||
void setTextColor(int) { assert(initialized); ++draws; }
|
||||
void setTextSize(int) { assert(initialized); ++draws; }
|
||||
void cp437(bool) { assert(initialized); ++draws; }
|
||||
void setCursor(int,int) { assert(initialized); ++draws; }
|
||||
void print(const char*) { assert(initialized); ++draws; }
|
||||
void fillRect(int,int,int,int,int) { assert(initialized); ++draws; }
|
||||
void drawRect(int,int,int,int,int) { assert(initialized); ++draws; }
|
||||
void drawBitmap(int,int,const uint8_t*,int,int,int) { assert(initialized); ++draws; }
|
||||
void getTextBounds(const char* s,int,int,int16_t* x,int16_t* y,uint16_t* w,uint16_t* h) {
|
||||
assert(initialized); ++draws; *x=*y=0; *w=strlen(s)*6; *h=8;
|
||||
}
|
||||
};
|
||||
'''
|
||||
MAIN = r'''
|
||||
#include "SH1107Display.h"
|
||||
void frame(SH1107Display& d) {
|
||||
const uint8_t bitmap[]={0x80};
|
||||
d.clear(); d.startFrame(); d.setTextSize(1); d.setColor(1); d.setCursor(0,0); d.print("a");
|
||||
d.fillRect(0,0,1,1); d.drawRect(0,0,1,1); d.drawXbm(0,0,bitmap,1,1); (void)d.getTextWidth("a"); d.endFrame();
|
||||
}
|
||||
int main(int argc,char** argv) {
|
||||
assert(argc==2); scenario=argv[1]; SH1107Display d;
|
||||
if(!automatic()) { assert(d.begin()); d.turnOn(); frame(d); assert(initializations==1 && probes==1 && events==0); return 0; }
|
||||
frame(d); assert(events==0 && draws==0 && initializations==0);
|
||||
bool result=d.begin();
|
||||
if(scenario=="absent" || scenario=="init-fail") {
|
||||
assert(!result && !d.isOn() && levels[23]==LOW);
|
||||
assert(initializations==(scenario=="absent" ? 0u : 1u));
|
||||
auto before=events, inits=initializations; d.turnOn(); d.turnOff(); frame(d); assert(!d.begin());
|
||||
assert(events==before && initializations==inits && draws==0 && now_ms<300);
|
||||
return 0;
|
||||
}
|
||||
assert(result && d.isOn() && levels[23]==HIGH && initializations==1);
|
||||
frame(d); auto painted=draws;
|
||||
for(unsigned i=0;i<100;++i) {
|
||||
d.turnOff(); assert(!d.isOn() && levels[23]==LOW);
|
||||
painted=draws; frame(d); assert(draws==painted);
|
||||
d.turnOn(); assert(d.isOn() && levels[23]==HIGH);
|
||||
}
|
||||
assert(initializations==1 && allocations==1 && "wake must not leak repeated GrayOLED adapters");
|
||||
frame(d); assert(draws>painted);
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class MuziAccessoryDetectionTest(unittest.TestCase):
|
||||
def compile(self, work, source, flags=(), files=None):
|
||||
work.mkdir()
|
||||
for name, value in (files or {}).items(): (work / name).write_text(value)
|
||||
(work / "main.cpp").write_text(source)
|
||||
binary = work / "native"
|
||||
command = [os.environ.get("CXX", "g++"), "-std=c++17", "-Wall", "-Wextra", "-Werror",
|
||||
"-Wno-unused-parameter", *SAN, *flags, "-I"+str(work), "-I"+str(UI), "-I"+str(ROOT/"src"), str(work/"main.cpp")]
|
||||
if files: command.append(str(work/"SH1107Display.cpp"))
|
||||
result = subprocess.run(command + ["-o", str(binary)], text=True, capture_output=True, timeout=60)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
return binary
|
||||
|
||||
def test_real_oled_absence_init_failure_and_power_sleep_cycles(self):
|
||||
with tempfile.TemporaryDirectory(prefix="muzi-accessories-") as temp:
|
||||
for index, flags in enumerate((["-DMUZI_BASE", "-DMUZI_BASE_ACCESSORY_AUTODETECT=1"],
|
||||
["-DMUZI_BASE"], ["-DMUZI_BASE_ACCESSORY_AUTODETECT=1"])):
|
||||
files = {name:(UI/name).read_text() for name in ("SH1107Display.h", "SH1107Display.cpp")}
|
||||
files.update({"Arduino.h":ARDUINO, "Wire.h":WIRE, "Adafruit_SH110X.h":PANEL,
|
||||
"Adafruit_GFX.h":"#pragma once\n", "Adafruit_GrayOLED.h":"#pragma once\n"})
|
||||
binary = self.compile(Path(temp)/str(index), MAIN, flags, files)
|
||||
for scenario in (("absent", "init-fail", "valid") if index==0 else ("valid",)):
|
||||
result = subprocess.run([str(binary), scenario], text=True, capture_output=True, timeout=10)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertEqual(b"meshcore.capability.display.autodetect.muzi_superio.v1" in binary.read_bytes(), index==0)
|
||||
|
||||
def test_real_switch_paths_do_not_enable_an_absent_gps_and_keep_power_button(self):
|
||||
source = (ROOT/"variants/muzi_base/target.cpp").read_text()
|
||||
methods = "\n".join(extract_braced(source, signature) for signature in
|
||||
("bool MuziBaseSensorManager::begin()", "void MuziBaseSensorManager::loop()"))
|
||||
harness = r'''
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#define ENV_INCLUDE_GPS 1
|
||||
#define PIN_GPS_SWITCH 12
|
||||
#define INPUT_PULLDOWN 3
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
#define BUTTON_EVENT_CLICK 1
|
||||
#define USER_BTN_POWER_OFF_CLICKS 5
|
||||
unsigned now=0, starts=0, stops=0, shutdowns=0; int switch_mode=-1, switch_level=0, click=0;
|
||||
unsigned long millis() { return now; }
|
||||
void pinMode(int pin,int mode) { assert(pin==12); switch_mode=mode; }
|
||||
int digitalRead(int pin) { assert(pin==12 && switch_mode==INPUT_PULLDOWN); return switch_level; }
|
||||
struct Button { void begin() {} int check() { int value=click; click=0; return value; } } pwr_btn;
|
||||
void muziPowerOff() { ++shutdowns; }
|
||||
struct EnvironmentSensorManager {
|
||||
bool gps_detected=false, requested=false;
|
||||
bool begin() { return true; } void loop() {}
|
||||
bool setSettingValue(const char* name,const char* value) { assert(strcmp(name,"gps")==0); requested=*value=='1'; return true; }
|
||||
void start_gps() { ++starts; } void stop_gps() { ++stops; }
|
||||
};
|
||||
struct MuziBaseSensorManager : EnvironmentSensorManager {
|
||||
unsigned long _pwr_last_click=0, _next_sw_check=0; unsigned _pwr_clicks=0; int _last_gps_sw=-1;
|
||||
bool begin(); void loop();
|
||||
};
|
||||
'''
|
||||
harness += methods + r'''
|
||||
int main() {
|
||||
MuziBaseSensorManager m; switch_level=HIGH;
|
||||
assert(m.begin() && m.requested && starts==0 && "a switch cannot prove GPS presence");
|
||||
switch_level=LOW; now=1001; m.loop(); assert(!m.requested && starts==0 && stops==0);
|
||||
switch_level=HIGH; now=2002; m.loop(); assert(m.requested && starts==0 && !m.gps_detected);
|
||||
m.gps_detected=true; switch_level=LOW; now=3003; m.loop(); assert(stops==1);
|
||||
switch_level=HIGH; now=4004; m.loop(); assert(starts==1);
|
||||
for(unsigned i=0;i<5;++i) { click=BUTTON_EVENT_CLICK; now+=100; m.loop(); }
|
||||
assert(shutdowns==1 && "five-click power-off survives accessory consolidation");
|
||||
}
|
||||
'''
|
||||
with tempfile.TemporaryDirectory(prefix="muzi-gps-") as temp:
|
||||
binary=self.compile(Path(temp)/"native", harness)
|
||||
result=subprocess.run([str(binary)], capture_output=True, text=True, timeout=10)
|
||||
self.assertEqual(result.returncode, 0, result.stdout+result.stderr)
|
||||
|
||||
def test_recipe_aliases_preserve_radio_and_remove_forced_gps_presence(self):
|
||||
config=configparser.ConfigParser(interpolation=None, inline_comment_prefixes=(";",))
|
||||
config.read(ROOT/"variants/muzi_base/platformio.ini")
|
||||
common=config["muzi_companion_accessories"]
|
||||
self.assertIn("MUZI_BASE_ACCESSORY_AUTODETECT=1", common["build_flags"])
|
||||
self.assertNotIn("ENV_SKIP_GPS_DETECT", (ROOT/"variants/muzi_base/platformio.ini").read_text())
|
||||
for radio in ("uno", "duo"):
|
||||
for transport in ("usb", "ble"):
|
||||
section=config[f"env:muzi_base_{radio}_companion_radio_{transport}"]
|
||||
self.assertIn("${muzi_companion_accessories.build_flags}", section["build_flags"])
|
||||
self.assertIn("${muzi_companion_accessories.build_src_filter}", section["build_src_filter"])
|
||||
self.assertEqual(dict(config[f"env:muzi_base_{radio}_superIO_companion_radio_ble"]),
|
||||
{"extends":f"env:muzi_base_{radio}_companion_radio_ble"})
|
||||
self.assertIn("USE_LR1121", config["muzi_base_duo"]["build_flags"])
|
||||
self.assertIn("USE_SX1262", config["muzi_base_uno"]["build_flags"])
|
||||
|
||||
|
||||
if __name__ == "__main__": unittest.main()
|
||||
@@ -57,6 +57,8 @@ class NativeDisplaysTest(unittest.TestCase):
|
||||
if cls == "ST7789LCDDisplay":
|
||||
source += f"void {cls}::setFlipped(bool) {{}}\n"
|
||||
names = ["setTextSize", "setColor", "setCursor", "print", "fillRect", "drawRect", "drawXbm", "getTextWidth"]
|
||||
if cls == "ST7789LCDDisplay":
|
||||
names += ["setRotationDegrees"]
|
||||
if cls == "ST7789Display":
|
||||
names += ["printWordWrap"]
|
||||
source += "\n".join(method(driver, cls, name) for name in names)
|
||||
|
||||
@@ -75,6 +75,23 @@ bool insideRect(const MockDisplay::Op& op, int x, int y, int w, int h) {
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(ObserverDashboardLayout, LiveViewportSelectsPortraitAndLandscape) {
|
||||
class RotatingViewport : public MockDisplay {
|
||||
public:
|
||||
RotatingViewport() : MockDisplay(LANDSCAPE) {}
|
||||
void resize(int width, int height) { setDimensions(width, height); }
|
||||
} display;
|
||||
for (unsigned turn = 0; turn < 12; ++turn) {
|
||||
const bool portrait = (turn & 1) != 0;
|
||||
display.resize(portrait ? 240 : 320, portrait ? 320 : 240);
|
||||
const auto& layout = activeLayout(display);
|
||||
EXPECT_EQ(layout.right_x, portrait ? 232 : 310);
|
||||
EXPECT_EQ(layout.graph_h, portrait ? 92 : 50);
|
||||
EXPECT_LT(layout.status_y + layout.text_h, display.height());
|
||||
EXPECT_LT(layout.right_x, display.width());
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- formatting ---
|
||||
|
||||
TEST(ObserverDashboardFormat, CompactCountsStayShortAtEveryMagnitude) {
|
||||
|
||||
@@ -26,6 +26,39 @@ def manifest(spec, target):
|
||||
|
||||
|
||||
class OptionalDisplayProfilesTest(unittest.TestCase):
|
||||
def test_nrf52_accessories_require_the_exact_radio_panel_and_packaged_marker(self):
|
||||
recipes = Recipes()
|
||||
for target in ("muzi_base_duo_companion_radio_ble", "muzi_base_uno_companion_radio_ble",
|
||||
"LilyGo_T-Echo-Lite_companion_radio_ble"):
|
||||
flags = defines(recipes.value("env:" + target, "build_flags"))
|
||||
board = recipes.value("env:" + target, "board")
|
||||
spec = displays.spec_for_defines(flags, board)
|
||||
self.assertIsNotNone(spec)
|
||||
row = {**manifest(spec, target), "platform": "NRF52_PLATFORM"}
|
||||
result = displays.runtime_metadata(row, flags, SOURCE, board)
|
||||
self.assertEqual(result, dict(displayAuto=True, displayController=spec["controller"], displaySource=SOURCE))
|
||||
for change in ({spec["flag"]: "0"}, {spec["guard"]: "0"},
|
||||
{"DISPLAY_CLASS": "NullDisplayDriver"},
|
||||
{key: "unrelated" for key in spec.get("defines", {})}):
|
||||
with self.subTest(target=target, change=change), self.assertRaises(ValueError):
|
||||
displays.runtime_metadata(row, {**flags, **change}, SOURCE, board)
|
||||
for change in ({"platform": "ESP32_PLATFORM"}, {"verification": []},
|
||||
{"target": target.replace("duo", "uno") if "duo" in target else "other_companion_radio_ble"}):
|
||||
with self.subTest(target=target, change=change), self.assertRaises(ValueError):
|
||||
displays.runtime_metadata({**row, **change}, flags, SOURCE, board)
|
||||
self.assertEqual(displays.runtime_metadata({**row, "capabilities": []}, flags, SOURCE, board), {})
|
||||
|
||||
def test_lite_explicit_compatibility_roles_keep_their_own_display_proof(self):
|
||||
recipes = Recipes()
|
||||
for role in ("repeater", "room_server"):
|
||||
target = "LilyGo_T-Echo-Lite_" + role + "_lora_ota"
|
||||
flags = defines(recipes.value("env:" + target, "build_flags"))
|
||||
board = recipes.value("env:" + target, "board")
|
||||
spec = displays.spec_for_defines(flags, board)
|
||||
legacy = target + "_no_external_sensors"
|
||||
row = {**manifest(spec, legacy), "platform": "NRF52_PLATFORM"}
|
||||
self.assertTrue(displays.runtime_metadata(row, flags, SOURCE, board)["displayAuto"])
|
||||
|
||||
def test_all_tracker_full_repeaters_keep_the_measured_safe_neighbor_capacity(self):
|
||||
script = r'''
|
||||
set -euo pipefail
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
"""Actual Lite SSD1681 readback, GPIO lifecycle and canonical recipe aliases."""
|
||||
from pathlib import Path
|
||||
import configparser
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
UI=ROOT/"src/helpers/ui"
|
||||
SAN=["-fsanitize=address,undefined","-fno-sanitize-recover=all","-fno-pie","-no-pie"] if sys.platform.startswith("linux") else []
|
||||
|
||||
ARDUINO=r'''
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#define LOW 0
|
||||
#define HIGH 1
|
||||
#define INPUT 0
|
||||
#define OUTPUT 1
|
||||
#define INPUT_PULLUP 2
|
||||
#define INPUT_PULLDOWN 3
|
||||
#define DISP_CS 22
|
||||
#define DISP_DC 21
|
||||
#define DISP_MOSI 20
|
||||
#define DISP_SCLK 19
|
||||
#define DISP_RST 28
|
||||
#define DISP_BUSY 3
|
||||
#define DISP_BS1 44
|
||||
#define PIN_DISPLAY_CS DISP_CS
|
||||
#define PIN_DISPLAY_DC DISP_DC
|
||||
#define PIN_DISPLAY_RST DISP_RST
|
||||
#define PIN_DISPLAY_BUSY DISP_BUSY
|
||||
inline int modes[64]={},levels[64]={};
|
||||
inline uint64_t now_us=0,reset_low_at=0,reset_high_at=0,busy_until=0;
|
||||
inline unsigned events=0,resets=0,commands=0,status_reads=0,spi_begins=0,inits=0,draws=0;
|
||||
inline unsigned bits=0,clocks=0,data_bits=0,command=0; inline uint8_t response=0;
|
||||
inline bool transaction=false,initialized=false;
|
||||
inline std::string scenario;
|
||||
inline bool automatic() {
|
||||
#if defined(LILYGO_TECHO_LITE) && defined(TECHO_LITE_DISPLAY_AUTODETECT) && TECHO_LITE_DISPLAY_AUTODETECT == 1
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
inline void checkPin(int pin) {
|
||||
assert(pin==DISP_CS || pin==DISP_DC || pin==DISP_MOSI || pin==DISP_SCLK || pin==DISP_RST || pin==DISP_BUSY || pin==DISP_BS1);
|
||||
}
|
||||
inline void pinMode(int pin,int mode) {
|
||||
checkPin(pin); modes[pin]=mode; ++events;
|
||||
if(pin==DISP_BS1) assert(mode==OUTPUT && levels[pin]==LOW && "BS1 is a LOW mode strap, not switched power");
|
||||
if(pin==DISP_MOSI && (mode==INPUT_PULLUP || mode==INPUT_PULLDOWN)) {
|
||||
assert(transaction && bits==8 && command==0x2f);
|
||||
++status_reads; unsigned within=(status_reads-1)%6;
|
||||
response=0x01;
|
||||
if(scenario=="floating") response=mode==INPUT_PULLUP ? 0xff : 0;
|
||||
if(scenario=="high") response=0xff;
|
||||
if(scenario=="low" || scenario=="busy-low") response=0;
|
||||
if(scenario=="wrong-id") response=0x02;
|
||||
if(scenario=="reserved") response=0x09;
|
||||
if(scenario=="flags") response=0x31;
|
||||
if(scenario=="biased") response=mode==INPUT_PULLUP ? 0x01 : 0x05;
|
||||
if(scenario=="noise" && within==2) response=0x05;
|
||||
if(scenario=="prime" && within%3==0) response=0xff;
|
||||
if(scenario=="recover" && status_reads<=6) response=0;
|
||||
}
|
||||
}
|
||||
inline void digitalWrite(int pin,int value) {
|
||||
checkPin(pin); ++events;
|
||||
if(pin==DISP_BS1) assert(value==LOW && "never drive the SPI-mode strap as a power enable");
|
||||
if(pin==DISP_RST) {
|
||||
if(value==LOW) reset_low_at=now_us;
|
||||
if(value==HIGH && levels[pin]==LOW) { assert(now_us-reset_low_at>=2000); reset_high_at=now_us; ++resets; }
|
||||
}
|
||||
if(pin==DISP_CS && value==LOW && levels[pin]==HIGH && automatic() && spi_begins==0) {
|
||||
assert(now_us-reset_high_at>=10000 && "reset settle before commands");
|
||||
transaction=true; bits=clocks=data_bits=command=0; ++commands;
|
||||
}
|
||||
if(pin==DISP_SCLK && value==HIGH && transaction) {
|
||||
++clocks;
|
||||
if(bits<8) { assert(modes[DISP_MOSI]==OUTPUT && levels[DISP_DC]==LOW); command=(command<<1)|levels[DISP_MOSI]; ++bits; }
|
||||
}
|
||||
if(pin==DISP_SCLK && value==LOW && transaction && clocks==8 && command==0x2f)
|
||||
assert(modes[DISP_MOSI]!=OUTPUT && "release SDA before controller read falling edge");
|
||||
if(pin==DISP_CS && value==HIGH && transaction) {
|
||||
assert(bits==8);
|
||||
if(command==0x12) { assert(data_bits==0 && clocks==8); busy_until=now_us+3000; }
|
||||
else assert(command==0x2f && data_bits==8 && clocks==16);
|
||||
transaction=false;
|
||||
}
|
||||
levels[pin]=value;
|
||||
}
|
||||
inline int digitalRead(int pin) {
|
||||
checkPin(pin);
|
||||
if(pin==DISP_BUSY) {
|
||||
assert(modes[pin]==INPUT_PULLUP);
|
||||
if(scenario=="busy-high" || scenario=="busy-floating") return HIGH;
|
||||
return now_us<busy_until ? HIGH : LOW;
|
||||
}
|
||||
assert(pin==DISP_MOSI && transaction && command==0x2f && levels[DISP_DC]==HIGH);
|
||||
assert(modes[pin]==((status_reads-1)%6<3 ? INPUT_PULLUP : INPUT_PULLDOWN));
|
||||
assert(clocks==8+data_bits && data_bits<8 && levels[DISP_SCLK]==LOW && "status has no dummy read clock");
|
||||
return (response>>(7-data_bits++))&1;
|
||||
}
|
||||
inline void delay(unsigned ms) { now_us+=uint64_t(ms)*1000; }
|
||||
inline void delayMicroseconds(unsigned us) { now_us+=us; }
|
||||
'''
|
||||
|
||||
SPI=r'''
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#define MSBFIRST 1
|
||||
#define SPI_MODE0 0
|
||||
struct SPISettings { SPISettings(int,int,int) {} };
|
||||
struct SPIClass { void begin() { if(automatic()) assert(status_reads>=6); ++spi_begins; } };
|
||||
inline SPIClass SPI1;
|
||||
'''
|
||||
|
||||
PANEL=r'''
|
||||
#pragma once
|
||||
#include <SPI.h>
|
||||
#define GxEPD_BLACK 0
|
||||
#define GxEPD_WHITE 1
|
||||
struct GxEPD2_122_T61 {
|
||||
static constexpr int WIDTH=176,HEIGHT=192;
|
||||
template<class... T> GxEPD2_122_T61(T...) {}
|
||||
void selectSPI(SPIClass&,SPISettings) {}
|
||||
};
|
||||
using GxEPD2_150_BN=GxEPD2_122_T61;
|
||||
template<class T,int Height> class GxEPD2_BW {
|
||||
int w=T::WIDTH,h=T::HEIGHT;
|
||||
public:
|
||||
T epd2;
|
||||
explicit GxEPD2_BW(T model):epd2(model) {}
|
||||
void init(int,bool,int,bool) { assert(spi_begins==1); ++inits; initialized=true; }
|
||||
void setRotation(int r) { assert(initialized); w=(r&1)?T::HEIGHT:T::WIDTH; h=(r&1)?T::WIDTH:T::HEIGHT; }
|
||||
int width() const { return w; } int height() const { return h; }
|
||||
void setTextWrap(bool) { assert(initialized); }
|
||||
void setFullWindow() { assert(initialized); }
|
||||
void setPartialWindow(int,int,int,int) { assert(initialized); }
|
||||
void setFont(const int*) { assert(initialized); }
|
||||
void setTextColor(int) { assert(initialized); }
|
||||
void setCursor(int,int) { assert(initialized); }
|
||||
void print(const char*) { assert(initialized); ++draws; }
|
||||
void fillScreen(int) { assert(initialized); ++draws; }
|
||||
void display(bool) { assert(initialized); ++draws; }
|
||||
void clearScreen(uint8_t) { assert(initialized); ++draws; }
|
||||
void writeScreenBuffer(uint8_t) { assert(initialized); ++draws; }
|
||||
void hibernate() { assert(initialized); ++draws; }
|
||||
void fillRect(int,int,int,int,int) { assert(initialized); ++draws; }
|
||||
void drawRect(int,int,int,int,int) { assert(initialized); ++draws; }
|
||||
void drawBitmap(int,int,const uint8_t*,int,int,int) { assert(initialized); ++draws; }
|
||||
void getTextBounds(const char* s,int,int,int16_t* x,int16_t* y,uint16_t* ww,uint16_t* hh) {
|
||||
assert(initialized); *x=0; *y=-8; *ww=strlen(s)*6; *hh=12;
|
||||
}
|
||||
};
|
||||
'''
|
||||
|
||||
MAIN=r'''
|
||||
#include "GxEPDDisplay.h"
|
||||
void frame(GxEPDDisplay& d) {
|
||||
const uint8_t bitmap[]={0x80}; d.clear(); d.startFrame(); d.setTextSize(1); d.setColor(1); d.setCursor(0,0); d.print("a");
|
||||
d.fillRect(0,0,1,1); d.drawRect(0,0,1,1); d.drawXbm(0,0,bitmap,1,1); (void)d.getTextWidth("a"); d.endFrame();
|
||||
}
|
||||
int main(int argc,char** argv) {
|
||||
assert(argc==2); scenario=argv[1]; GxEPDDisplay d;
|
||||
if(!automatic()) { assert(d.begin()); frame(d); assert(commands==0 && inits==1); return 0; }
|
||||
frame(d); assert(events==0 && draws==0 && inits==0);
|
||||
bool invalid=scenario=="floating" || scenario=="high" || scenario=="low" || scenario=="wrong-id"
|
||||
|| scenario=="reserved" || scenario=="biased" || scenario=="noise" || scenario=="busy-high"
|
||||
|| scenario=="busy-low" || scenario=="busy-floating";
|
||||
bool result=d.begin();
|
||||
if(invalid) {
|
||||
assert(!result && !d.isOn() && "invalid SSD1681 must remain headless");
|
||||
assert(inits==0 && spi_begins==0 && draws==0 && levels[DISP_RST]==LOW && levels[DISP_BS1]==LOW);
|
||||
for(int pin:{DISP_CS,DISP_DC,DISP_MOSI,DISP_SCLK,DISP_BUSY}) assert(modes[pin]==INPUT);
|
||||
auto count=events; d.turnOn(); d.turnOff(); frame(d); assert(!d.begin());
|
||||
assert(events==count && inits==0 && draws==0 && now_us<500000);
|
||||
return 0;
|
||||
}
|
||||
assert(result && d.isOn() && inits==1 && spi_begins==1 && initialized);
|
||||
assert(status_reads==(scenario=="recover" ? 12u : 6u));
|
||||
auto count=commands,reset_count=resets;
|
||||
frame(d); d.turnOff(); auto painted=draws; frame(d); assert(draws==painted);
|
||||
d.turnOn(); frame(d); assert(draws>painted);
|
||||
assert(inits==1 && spi_begins==1 && commands==count && resets==reset_count);
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class TechoLiteDisplayDetectionTest(unittest.TestCase):
|
||||
def build(self, work, flags=(), mutation=None):
|
||||
work.mkdir(); (work/"Fonts").mkdir()
|
||||
for name in ("GxEPDDisplay.h","GxEPDDisplay.cpp","TechoLiteDisplayProbe.h"):
|
||||
source=(UI/name).read_text()
|
||||
if mutation and name=="TechoLiteDisplayProbe.h":
|
||||
old,new=mutation; self.assertIn(old,source); source=source.replace(old,new)
|
||||
(work/name).write_text(source)
|
||||
files={"Arduino.h":ARDUINO,"SPI.h":SPI,"Wire.h":"#pragma once\n", "GxEPD2_BW.h":PANEL,
|
||||
"CRC32.h":"#pragma once\n#include <cstdint>\n#include <cstddef>\nstruct CRC32 { template<class T> void update(T) {} template<class T> void update(const T*,size_t) {} void reset() {} uint32_t finalize() { return 1; } };\n",
|
||||
"main.cpp":MAIN}
|
||||
for name in ("GxEPD2_3C.h","GxEPD2_4C.h","GxEPD2_7C.h"): files[name]="#pragma once\n"
|
||||
for font in ("FreeSans9pt7b","FreeSansBold12pt7b","FreeSans18pt7b"):
|
||||
files[f"Fonts/{font}.h"]=f"#pragma once\ninline const int {font}=8;\n"
|
||||
for name,source in files.items(): (work/name).write_text(source)
|
||||
binary=work/"native"
|
||||
result=subprocess.run([os.environ.get("CXX","g++"),"-std=c++17","-Wall","-Wextra","-Werror",
|
||||
"-Wno-unused-parameter","-Wno-sign-compare", *SAN,*flags,"-DEINK_DISPLAY_MODEL=GxEPD2_122_T61","-DDISPLAY_ROTATION=4",
|
||||
"-I"+str(work),"-I"+str(UI),"-I"+str(ROOT/"src"),str(work/"main.cpp"),str(work/"GxEPDDisplay.cpp"),"-o",str(binary)],
|
||||
capture_output=True,text=True,timeout=60)
|
||||
self.assertEqual(result.returncode,0,result.stdout+result.stderr)
|
||||
return binary
|
||||
|
||||
def run_case(self,binary,scenario,negative=None):
|
||||
result=subprocess.run([str(binary),scenario],capture_output=True,text=True,timeout=10)
|
||||
if negative:
|
||||
self.assertNotEqual(result.returncode,0); self.assertIn(negative,result.stderr)
|
||||
else:self.assertEqual(result.returncode,0,result.stdout+result.stderr)
|
||||
|
||||
def test_actual_status_readback_and_headless_failure_paths(self):
|
||||
with tempfile.TemporaryDirectory(prefix="techo-lite-detect-") as temp:
|
||||
binary=self.build(Path(temp)/"auto",["-DLILYGO_TECHO_LITE=1","-DTECHO_LITE_DISPLAY_AUTODETECT=1"])
|
||||
self.assertIn(b"meshcore.capability.display.autodetect.techo_lite.v1",binary.read_bytes())
|
||||
for scenario in ("valid","flags","prime","recover","floating","high","low","wrong-id","reserved","biased","noise","busy-high","busy-low","busy-floating"):
|
||||
with self.subTest(scenario=scenario):self.run_case(binary,scenario)
|
||||
|
||||
def test_other_eink_boards_and_disabled_optin_keep_existing_behavior(self):
|
||||
with tempfile.TemporaryDirectory(prefix="techo-lite-detect-") as temp:
|
||||
for index,flags in enumerate(([],["-DLILYGO_TECHO_LITE=1","-DTECHO_LITE_DISPLAY_AUTODETECT=0"],["-DTECHO_LITE_DISPLAY_AUTODETECT=1"])):
|
||||
binary=self.build(Path(temp)/str(index),flags);self.run_case(binary,"valid")
|
||||
self.assertNotIn(b"meshcore.capability.display.autodetect.techo_lite.v1",binary.read_bytes())
|
||||
|
||||
def test_negative_controls_catch_turnaround_id_and_reset_errors(self):
|
||||
flags=["-DLILYGO_TECHO_LITE=1","-DTECHO_LITE_DISPLAY_AUTODETECT=1"]
|
||||
with tempfile.TemporaryDirectory(prefix="techo-lite-detect-") as temp:
|
||||
cases=[("id",("status[0] == 0x01u","status[0] == 0x02u"),"wrong-id","invalid SSD1681 must remain headless"),
|
||||
("settle",("delay(10);","delay(0);"),"valid","reset settle before commands"),
|
||||
("turnaround",("pinMode(DISP_MOSI, bias);","pinMode(DISP_MOSI, OUTPUT);"),"valid","release SDA before controller read falling edge")]
|
||||
for name,mutation,scenario,message in cases:
|
||||
binary=self.build(Path(temp)/name,flags,mutation); self.run_case(binary,scenario,negative=message)
|
||||
|
||||
def test_legacy_core_aliases_share_auto_display_and_exact_usb_transport(self):
|
||||
config=configparser.ConfigParser(interpolation=None,inline_comment_prefixes=(";",));config.read(ROOT/"variants/lilygo_techo_lite/platformio.ini")
|
||||
self.assertIn("TECHO_LITE_DISPLAY_AUTODETECT=1",config["LilyGo_T-Echo-Lite"]["build_flags"])
|
||||
self.assertIn("ENABLE_USB_INTERFACE=1",config["env:LilyGo_T-Echo-Lite_companion_radio_usb"]["build_flags"])
|
||||
for transport in ("usb","ble"):
|
||||
self.assertEqual(dict(config[f"env:LilyGo_T-Echo-Lite_non_shell_companion_radio_{transport}"]),
|
||||
{"extends":f"env:LilyGo_T-Echo-Lite_companion_radio_{transport}"})
|
||||
pins=(ROOT/"variants/lilygo_techo_lite/variant.h").read_text()
|
||||
self.assertIn("#define DISP_POWER DISP_BS1",pins)
|
||||
|
||||
|
||||
if __name__=="__main__":unittest.main()
|
||||
@@ -15,6 +15,7 @@ TEST(WebConfigKeys, AllowsKnownScalarKeys) {
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("radio.rxps"));
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("powersaving"));
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("repeat"));
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("display.rotation"));
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("radio.fem.rxgain")); // Board::handleCommand(), not CommonCLI
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("radio.fem.txgain"));
|
||||
EXPECT_TRUE(wcIsAllowedSetKey("wifi.ssid"));
|
||||
@@ -39,6 +40,7 @@ TEST(WebConfigKeys, RejectsDangerousOrUnknownKeys) {
|
||||
EXPECT_FALSE(wcIsAllowedSetKey("password"));
|
||||
EXPECT_FALSE(wcIsAllowedSetKey("reboot"));
|
||||
EXPECT_FALSE(wcIsAllowedSetKey("bogus"));
|
||||
EXPECT_FALSE(wcIsAllowedSetKey("display.rotation.extra"));
|
||||
EXPECT_FALSE(wcIsAllowedSetKey("bluetooth.stealth.extra"));
|
||||
EXPECT_FALSE(wcIsAllowedSetKey("mqtt1.bogus")); // unknown slot field
|
||||
EXPECT_FALSE(wcIsAllowedSetKey(""));
|
||||
|
||||
@@ -122,7 +122,7 @@ class WebConfigUiRuntimeTest(unittest.TestCase):
|
||||
("config-after", "1"), ("password-cleared", "true")):
|
||||
self.assertIn('data-test-recovery-%s="%s"' % (attribute, value), dom)
|
||||
|
||||
def test_four_display_controls_and_pairing_capability(self):
|
||||
def test_display_power_controls_and_pairing_capability(self):
|
||||
status, config = self.setup_values()
|
||||
config["display"] = {
|
||||
"mode": "button", "timeout": 23,
|
||||
@@ -143,6 +143,8 @@ window.addEventListener("load",function(){
|
||||
body.setAttribute("data-test-usb-timeout",card.querySelector('[data-k="display.usb.timeout"]').value);
|
||||
body.setAttribute("data-test-usb-disabled",card.querySelector('[data-k="display.usb.timeout"]').disabled);
|
||||
body.setAttribute("data-test-pairing-disabled",card.querySelector('option[value="pairing"]').disabled);
|
||||
body.setAttribute("data-test-rotation-hidden",document.getElementById("display-rotation-setting").classList.contains("hide"));
|
||||
body.setAttribute("data-test-rotation-disabled",card.querySelector('[data-k="display.rotation"]').disabled);
|
||||
var mode=card.querySelector('[data-k="display.mode"]');
|
||||
mode.value="off";mode.dispatchEvent(new Event("input",{bubbles:true}));
|
||||
body.setAttribute("data-test-battery-disabled",card.querySelector('[data-k="display.timeout"]').disabled);
|
||||
@@ -152,13 +154,45 @@ window.addEventListener("load",function(){
|
||||
</script>''' % (json.dumps(status), json.dumps(config))
|
||||
dom = self.run_page(prelude)
|
||||
for attribute, value in (
|
||||
("display-visible", "true"), ("display-count", "4"),
|
||||
("display-visible", "true"), ("display-count", "5"),
|
||||
("battery-timeout", "23"), ("usb-timeout", "55"),
|
||||
("usb-disabled", "true"), ("pairing-disabled", "true"),
|
||||
("rotation-hidden", "true"), ("rotation-disabled", "true"),
|
||||
("battery-disabled", "true"), ("dirty-display", "off"),
|
||||
):
|
||||
self.assertIn('data-test-%s="%s"' % (attribute, value), dom)
|
||||
|
||||
def test_supported_rotation_loads_saved_value_and_can_be_changed(self):
|
||||
status, config = self.setup_values()
|
||||
config["display"] = {
|
||||
"mode": "button", "timeout": 15, "usb_mode": "on",
|
||||
"usb_timeout": 15, "pairing": False,
|
||||
"rotation_supported": True, "rotation": 270,
|
||||
}
|
||||
prelude = r'''<script>
|
||||
window.fetch=function(path){
|
||||
var value=path==="/api/status"?%s:%s;
|
||||
return Promise.resolve({ok:true,status:200,json:function(){return Promise.resolve(value)}});
|
||||
};
|
||||
window.addEventListener("load",function(){
|
||||
setTimeout(function(){enterApp()},50);
|
||||
setTimeout(function(){
|
||||
var select=document.querySelector('[data-k="display.rotation"]'),body=document.body;
|
||||
body.setAttribute("data-test-rotation-visible",!document.getElementById("display-rotation-setting").classList.contains("hide"));
|
||||
body.setAttribute("data-test-rotation-enabled",!select.disabled);
|
||||
body.setAttribute("data-test-rotation-loaded",select.value);
|
||||
body.setAttribute("data-test-rotation-values",Array.from(select.options).map(function(o){return o.value}).join(","));
|
||||
select.value="90";select.dispatchEvent(new Event("input",{bubbles:true}));
|
||||
body.setAttribute("data-test-rotation-dirty",st.dirty["display.rotation"]);
|
||||
},650);
|
||||
});
|
||||
</script>''' % (json.dumps(status), json.dumps(config))
|
||||
dom = self.run_page(prelude)
|
||||
for attribute, value in (("visible", "true"), ("enabled", "true"),
|
||||
("loaded", "270"), ("values", "0,90,180,270"),
|
||||
("dirty", "90")):
|
||||
self.assertIn('data-test-rotation-%s="%s"' % (attribute, value), dom)
|
||||
|
||||
def setup_values(self):
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
try:
|
||||
|
||||
@@ -56,6 +56,7 @@ extends = Heltec_lora32_v4
|
||||
build_flags =
|
||||
${Heltec_lora32_v4.build_flags}
|
||||
-D HELTEC_LORA_V4_OLED
|
||||
-D HELTEC_V4_OLED_KIT_COMPAT=1
|
||||
-D PIN_BOARD_SDA=17
|
||||
-D PIN_BOARD_SCL=18
|
||||
; The OLED uses Wire above; the expansion/general sensor connector is 4/3.
|
||||
@@ -70,6 +71,7 @@ extends = Heltec_lora32_v4
|
||||
build_flags =
|
||||
${Heltec_lora32_v4.build_flags}
|
||||
-D HELTEC_LORA_V4_TFT
|
||||
-D HELTEC_V4_TFT_KIT_COMPAT=1
|
||||
-D PIN_BOARD_SDA=4
|
||||
-D PIN_BOARD_SCL=3
|
||||
-D PIN_TFT_RST=18
|
||||
@@ -774,15 +776,11 @@ build_flags =
|
||||
[env:heltec_v4_expansionkit_tft_companion_radio_ble_ps]
|
||||
extends = env:heltec_v4_expansionkit_tft_companion_radio_ble_femon
|
||||
|
||||
; The expansion-kit layout has different I2C ownership from the base TFT. Its
|
||||
; Full image retains that exact hardware recipe while using the common
|
||||
; Arduino-ESP32 2.x single-TTY policy.
|
||||
; The original TFT expansion kit has the same TFT and GPIO4/3 sensor wiring.
|
||||
; Keep its published environment/OTA identity as an exact hardware alias of
|
||||
; the canonical Full recipe, including its low-battery protection.
|
||||
[env:heltec_v4_expansionkit_tft_companion_radio_full_femon]
|
||||
extends = env:heltec_v4_expansionkit_tft_companion_radio_ble_femon
|
||||
board_build.flash_mode = ${esp32_s3_full.board_build.flash_mode}
|
||||
build_flags =
|
||||
${env:heltec_v4_expansionkit_tft_companion_radio_ble_femon.build_flags}
|
||||
-D MESHCORE_REQUIRES_COMPANION_RADIO_FULL=1
|
||||
extends = env:heltec_v4_tft_companion_radio_full_femon
|
||||
|
||||
[env:heltec_v4_tft_companion_radio_wifi_femon]
|
||||
extends = heltec_v4_tft
|
||||
@@ -821,14 +819,14 @@ extends = env:heltec_v4_tft_companion_radio_wifi_femon
|
||||
board_build.flash_mode = ${esp32_s3_full.board_build.flash_mode}
|
||||
build_flags =
|
||||
${env:heltec_v4_tft_companion_radio_wifi_femon.build_flags}
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3400
|
||||
-D MESHCORE_REQUIRES_COMPANION_RADIO_FULL=1
|
||||
|
||||
[env:heltec_v4_3_tft_companion_radio_full_femoff]
|
||||
extends = env:heltec_v4_3_tft_companion_radio_wifi_femoff
|
||||
board_build.flash_mode = ${esp32_s3_full.board_build.flash_mode}
|
||||
extends = env:heltec_v4_tft_companion_radio_full_femon
|
||||
build_flags =
|
||||
${env:heltec_v4_3_tft_companion_radio_wifi_femoff.build_flags}
|
||||
-D MESHCORE_REQUIRES_COMPANION_RADIO_FULL=1
|
||||
${env:heltec_v4_tft_companion_radio_full_femon.build_flags}
|
||||
-D RADIO_FEM_RXGAIN=0 ; undefined (default on), 1=on, 0=off
|
||||
|
||||
[env:heltec_v4_tft_sensor]
|
||||
extends = heltec_v4_tft
|
||||
|
||||
@@ -9,6 +9,29 @@
|
||||
|
||||
HeltecV4Board board;
|
||||
|
||||
#if defined(HELTEC_V4_OLED_KIT_COMPAT) && HELTEC_V4_OLED_KIT_COMPAT == 1
|
||||
extern const char meshcore_capability_heltec_v4_oled_kit[];
|
||||
const char meshcore_capability_heltec_v4_oled_kit[] =
|
||||
"meshcore.capability.hardware.heltec_v4.oled_kit.v1";
|
||||
#endif
|
||||
|
||||
#if defined(HELTEC_V4_TFT_KIT_COMPAT) && HELTEC_V4_TFT_KIT_COMPAT == 1 \
|
||||
&& defined(HELTEC_LORA_V4_TFT) && defined(DISPLAY_CLASS) \
|
||||
&& defined(PIN_BOARD_SDA) && PIN_BOARD_SDA == 4 \
|
||||
&& defined(PIN_BOARD_SCL) && PIN_BOARD_SCL == 3 \
|
||||
&& defined(PIN_TFT_RST) && PIN_TFT_RST == 18 \
|
||||
&& defined(PIN_TFT_LEDA_CTL) && PIN_TFT_LEDA_CTL == 21 \
|
||||
&& defined(PIN_TFT_CS) && PIN_TFT_CS == 15 \
|
||||
&& defined(PIN_TFT_DC) && PIN_TFT_DC == 16 \
|
||||
&& defined(PIN_TFT_SCL) && PIN_TFT_SCL == 17 \
|
||||
&& defined(PIN_TFT_SDA) && PIN_TFT_SDA == 33
|
||||
#define MESHCORE_HELTEC_V4_TFT_KIT_COMPAT 1
|
||||
#include <type_traits>
|
||||
extern const char meshcore_capability_heltec_v4_tft_kit[];
|
||||
const char meshcore_capability_heltec_v4_tft_kit[] =
|
||||
"meshcore.capability.hardware.heltec_v4.tft_kit.v1";
|
||||
#endif
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
static SPIClass spi;
|
||||
#if defined(MC_SX1262_BUFFERED_RADIO_HAL) && MC_SX1262_BUFFERED_RADIO_HAL
|
||||
@@ -40,6 +63,16 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
#if defined(HELTEC_V4_OLED_KIT_COMPAT) && HELTEC_V4_OLED_KIT_COMPAT == 1
|
||||
const volatile char* capability = meshcore_capability_heltec_v4_oled_kit;
|
||||
(void)*capability;
|
||||
#endif
|
||||
#if defined(MESHCORE_HELTEC_V4_TFT_KIT_COMPAT)
|
||||
if (std::is_same<DISPLAY_CLASS, ST7789LCDDisplay>::value) {
|
||||
const volatile char* capability = meshcore_capability_heltec_v4_tft_kit;
|
||||
(void)*capability;
|
||||
}
|
||||
#endif
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ extends = Heltec_v4_r8
|
||||
build_flags =
|
||||
${Heltec_v4_r8.build_flags}
|
||||
-D HELTEC_V4_R8_TFT
|
||||
-D HELTEC_TFT_RUNTIME_ROTATION=1
|
||||
-D HELTEC_TFT_DISPLAY_AUTODETECT=1
|
||||
-D PIN_BOARD_SDA=17
|
||||
-D PIN_BOARD_SCL=18
|
||||
|
||||
@@ -8,6 +8,8 @@ build_flags = ${rak4631_hw.build_flags}
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-D LILYGO_TECHO
|
||||
-D LILYGO_TECHO_LITE=1
|
||||
-D TECHO_LITE_DISPLAY_AUTODETECT=1
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
@@ -132,6 +134,7 @@ build_flags =
|
||||
${LilyGo_T-Echo-Lite.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D ENABLE_USB_INTERFACE=1
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
@@ -147,91 +150,9 @@ lib_deps =
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:LilyGo_T-Echo-Lite_non_shell_companion_radio_ble]
|
||||
extends = LilyGo_T-Echo-Lite
|
||||
upload_protocol = nrfutil
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${rak4631_hw.build_flags}
|
||||
-I variants/lilygo_techo_lite
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D LILYGO_TECHO
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=30
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D GPS_BAUD_RATE=9600
|
||||
-D PIN_GPS_EN=GPS_EN
|
||||
-D AUTO_OFF_MILLIS=0
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D UI_RECENT_LIST_SIZE=9
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
build_src_filter = ${rak4631_hw.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<TechoBoard.cpp>
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../variants/lilygo_techo_lite>
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_T-Echo-Lite.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
; Legacy core-only name: the canonical image detects the fitted SSD1681 panel.
|
||||
extends = env:LilyGo_T-Echo-Lite_companion_radio_ble
|
||||
|
||||
[env:LilyGo_T-Echo-Lite_non_shell_companion_radio_usb]
|
||||
extends = LilyGo_T-Echo-Lite
|
||||
upload_protocol = nrfutil
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${rak4631_hw.build_flags}
|
||||
-I variants/lilygo_techo_lite
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D LILYGO_TECHO
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=30
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D GPS_BAUD_RATE=9600
|
||||
-D PIN_GPS_EN=GPS_EN
|
||||
-D AUTO_OFF_MILLIS=0
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D UI_RECENT_LIST_SIZE=9
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
-D ENABLE_USB_INTERFACE
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${rak4631_hw.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<TechoBoard.cpp>
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../variants/lilygo_techo_lite>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_T-Echo-Lite.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
; Legacy core-only name: the canonical image detects the fitted SSD1681 panel.
|
||||
extends = env:LilyGo_T-Echo-Lite_companion_radio_usb
|
||||
@@ -30,8 +30,8 @@ void initVariant() {
|
||||
// pinMode(PIN_TXCO, OUTPUT);
|
||||
// digitalWrite(PIN_TXCO, HIGH);
|
||||
|
||||
pinMode(DISP_POWER, OUTPUT);
|
||||
digitalWrite(DISP_POWER, LOW);
|
||||
digitalWrite(DISP_BS1, LOW);
|
||||
pinMode(DISP_BS1, OUTPUT); // SSD1681 interface selection, not panel power.
|
||||
|
||||
// shutdown gps
|
||||
pinMode(GPS_EN, OUTPUT);
|
||||
|
||||
@@ -136,7 +136,8 @@ extern const int SCK;
|
||||
#define DISP_DC _PINNUM(0, 21)
|
||||
#define DISP_RST _PINNUM(0, 28)
|
||||
#define DISP_BUSY _PINNUM(0, 3)
|
||||
#define DISP_POWER _PINNUM(1, 12)
|
||||
#define DISP_BS1 _PINNUM(1, 12) // LOW = SSD1681 4-wire SPI; not a power switch
|
||||
#define DISP_POWER DISP_BS1 // Legacy name kept for GPIO reservation compatibility
|
||||
// #define DISP_BACKLIGHT (0) // Display has no backlight, 0 maps to 0xff on this device which is NRFX_SPIM_PIN_NOT_USED
|
||||
|
||||
#define PIN_DISPLAY_CS DISP_CS
|
||||
|
||||
@@ -36,7 +36,11 @@ void MuziBaseBoard::begin() {
|
||||
digitalWrite(PIN_GPS_EN, LOW);
|
||||
// 12V rail is only needed for the superIO display
|
||||
pinMode(SCREEN_12V_ENABLE, OUTPUT);
|
||||
#ifdef MUZI_BASE_SUPERIO
|
||||
#if defined(MUZI_BASE_ACCESSORY_AUTODETECT) && MUZI_BASE_ACCESSORY_AUTODETECT
|
||||
// A bare Base must not run the optional OLED's boost converter. The
|
||||
// display driver owns the bounded probe and powers it down on absence.
|
||||
digitalWrite(SCREEN_12V_ENABLE, LOW);
|
||||
#elif defined(MUZI_BASE_SUPERIO)
|
||||
digitalWrite(SCREEN_12V_ENABLE, HIGH); // Enable 12V power for SH1107 display
|
||||
delay(250);
|
||||
#else
|
||||
|
||||
@@ -45,6 +45,25 @@ lib_deps =
|
||||
; Radio selection (Duo = LR1121, Uno = SX1262). The matching radio pins / TCXO
|
||||
; / RF-switch defines are picked up in variant.h via USE_LR1121 / USE_SX1262.
|
||||
; ---------------------------------------------------------------------------
|
||||
[muzi_companion_accessories]
|
||||
build_flags =
|
||||
-D MUZI_BASE_SUPERIO=1
|
||||
-D MUZI_BASE_ACCESSORY_AUTODETECT=1
|
||||
-D UI_HAS_JOYSTICK=1
|
||||
-D DISPLAY_CLASS=SH1107Display
|
||||
-D DISPLAY_ROTATION=2
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D PIN_BUZZER=22
|
||||
build_src_filter =
|
||||
+<helpers/ui/SH1107Display.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
lib_deps =
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
adafruit/Adafruit SH110X@^2.1.14
|
||||
artronshop/ArtronShop_RX8130CE@1.0.0
|
||||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
|
||||
[muzi_base_duo]
|
||||
extends = muzi_base_common
|
||||
build_flags = ${muzi_base_common.build_flags}
|
||||
@@ -145,18 +164,20 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags = ${muzi_base_duo.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D ENABLE_USB_INTERFACE=1
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
${muzi_companion_accessories.build_flags}
|
||||
build_src_filter = ${muzi_base_duo.build_src_filter}
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
${muzi_companion_accessories.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps = ${muzi_base_duo.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
${muzi_companion_accessories.lib_deps}
|
||||
|
||||
[env:muzi_base_duo_companion_radio_ble]
|
||||
extends = muzi_base_duo
|
||||
@@ -172,16 +193,17 @@ build_flags = ${muzi_base_duo.build_flags}
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
${muzi_companion_accessories.build_flags}
|
||||
; -D ADVERT_NAME='"@@MAC"'
|
||||
build_src_filter = ${muzi_base_duo.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/sensors>
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
${muzi_companion_accessories.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps = ${muzi_base_duo.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
${muzi_companion_accessories.lib_deps}
|
||||
|
||||
[muzi_base_duo_superIO]
|
||||
extends = muzi_base_duo
|
||||
@@ -194,7 +216,7 @@ build_flags = ${muzi_base_duo.build_flags}
|
||||
-D DISPLAY_CLASS=SH1107Display
|
||||
-D DISPLAY_ROTATION=2
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D ENV_SKIP_GPS_DETECT
|
||||
-D MUZI_BASE_ACCESSORY_AUTODETECT=1
|
||||
-D PIN_BUZZER=22
|
||||
build_src_filter = ${muzi_base_duo.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
@@ -213,25 +235,8 @@ debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:muzi_base_duo_superIO_companion_radio_ble]
|
||||
extends = muzi_base_duo_superIO
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags = ${muzi_base_duo_superIO.build_flags}
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-I examples/companion_radio/ui-new
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D QSPIFLASH=1
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${muzi_base_duo_superIO.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${muzi_base_duo_superIO.lib_deps}
|
||||
; Legacy accessory name: the canonical image detects the fitted OLED/GPS.
|
||||
extends = env:muzi_base_duo_companion_radio_ble
|
||||
|
||||
; ===========================================================================
|
||||
; Uno (SX1262) environments
|
||||
@@ -308,18 +313,20 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags = ${muzi_base_uno.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D ENABLE_USB_INTERFACE=1
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
${muzi_companion_accessories.build_flags}
|
||||
build_src_filter = ${muzi_base_uno.build_src_filter}
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
${muzi_companion_accessories.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps = ${muzi_base_uno.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
${muzi_companion_accessories.lib_deps}
|
||||
|
||||
[env:muzi_base_uno_companion_radio_ble]
|
||||
extends = muzi_base_uno
|
||||
@@ -335,16 +342,17 @@ build_flags = ${muzi_base_uno.build_flags}
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
${muzi_companion_accessories.build_flags}
|
||||
; -D ADVERT_NAME='"@@MAC"'
|
||||
build_src_filter = ${muzi_base_uno.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/sensors>
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
${muzi_companion_accessories.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps = ${muzi_base_uno.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
${muzi_companion_accessories.lib_deps}
|
||||
|
||||
[muzi_base_uno_superIO]
|
||||
extends = muzi_base_uno
|
||||
@@ -357,7 +365,7 @@ build_flags = ${muzi_base_uno.build_flags}
|
||||
-D DISPLAY_CLASS=SH1107Display
|
||||
-D DISPLAY_ROTATION=2
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D ENV_SKIP_GPS_DETECT
|
||||
-D MUZI_BASE_ACCESSORY_AUTODETECT=1
|
||||
-D PIN_BUZZER=22
|
||||
build_src_filter = ${muzi_base_uno.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
@@ -376,22 +384,5 @@ debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:muzi_base_uno_superIO_companion_radio_ble]
|
||||
extends = muzi_base_uno_superIO
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags = ${muzi_base_uno_superIO.build_flags}
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-I examples/companion_radio/ui-new
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D QSPIFLASH=1
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${muzi_base_uno_superIO.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${muzi_base_uno_superIO.lib_deps}
|
||||
; Legacy accessory name: the canonical image detects the fitted OLED/GPS.
|
||||
extends = env:muzi_base_uno_companion_radio_ble
|
||||
@@ -38,11 +38,19 @@ static void muziPowerOff() {
|
||||
|
||||
bool MuziBaseSensorManager::begin() {
|
||||
pwr_btn.begin();
|
||||
#if ENV_INCLUDE_GPS
|
||||
// The accessory's mode-switch connector is open on a bare Base. A fixed
|
||||
// pulldown prevents that open input from requesting GPS or claiming it is
|
||||
// present; the shared manager still requires real UART discovery.
|
||||
pinMode(PIN_GPS_SWITCH, INPUT_PULLDOWN);
|
||||
_last_gps_sw = digitalRead(PIN_GPS_SWITCH); // initial gps state from the switch
|
||||
#endif
|
||||
bool ok = EnvironmentSensorManager::begin();
|
||||
#if ENV_INCLUDE_GPS
|
||||
pinMode(PIN_GPS_SWITCH, INPUT);
|
||||
_last_gps_sw = digitalRead(PIN_GPS_SWITCH); // initial gps state from the switch
|
||||
if (_last_gps_sw == HIGH) start_gps(); else stop_gps();
|
||||
setSettingValue("gps", _last_gps_sw == HIGH ? "1" : "0");
|
||||
if (gps_detected) {
|
||||
if (_last_gps_sw == HIGH) start_gps(); else stop_gps();
|
||||
}
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
@@ -62,7 +70,12 @@ void MuziBaseSensorManager::loop() {
|
||||
int sw = digitalRead(PIN_GPS_SWITCH);
|
||||
if (sw != _last_gps_sw) {
|
||||
_last_gps_sw = sw;
|
||||
if (sw == HIGH) start_gps(); else stop_gps();
|
||||
setSettingValue("gps", sw == HIGH ? "1" : "0");
|
||||
// An absent optional receiver must never become active merely because
|
||||
// a switch moved. Discovery owns the pending UART/power transition.
|
||||
if (gps_detected) {
|
||||
if (sw == HIGH) start_gps(); else stop_gps();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -89,6 +89,7 @@ lib_deps = ${rpi_picow.lib_deps}
|
||||
[env:PicoW_companion_radio]
|
||||
extends = rpi_picow
|
||||
build_flags = ${rpi_picow.build_flags}
|
||||
-D PICOW_COMBINED_COMPANION=1
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D ENABLE_USB_INTERFACE
|
||||
|
||||
@@ -402,6 +402,7 @@ body.tab-cli{padding-bottom:0}
|
||||
</div>
|
||||
<div class="card hide" id="display-settings">
|
||||
<h2>Display</h2>
|
||||
<div class="f hide" id="display-rotation-setting"><label>Rotation</label><select data-k="display.rotation"><option value="0">Board default</option><option value="90">90 degrees</option><option value="180">180 degrees</option><option value="270">270 degrees</option></select></div>
|
||||
<div class="row">
|
||||
<div class="f"><label>On battery</label><select data-k="display.mode"><option value="off">Off</option><option value="on">On</option><option value="button">Button</option><option value="pairing">Pairing only</option><option value="button-pairing">Button + pairing</option><option value="automatic">Automatic</option></select></div>
|
||||
<div class="f"><label>Timeout (seconds)</label><input type="number" data-k="display.timeout" min="1" max="3600" step="1"></div>
|
||||
@@ -910,6 +911,7 @@ function cfgVal(k){ // map a `set` key to its current value string, from st.cfg
|
||||
case"radio.rxps":return rxpsCfgValue(r);
|
||||
case"powersaving":return r.powersaving?"on":"off";
|
||||
case"display.mode":return (st.cfg.display||{}).mode||"button";
|
||||
case"display.rotation":return String((st.cfg.display||{}).rotation||0);
|
||||
case"display.timeout":return String((st.cfg.display||{}).timeout||15);
|
||||
case"display.usb.mode":return (st.cfg.display||{}).usb_mode||"button";
|
||||
case"display.usb.timeout":return String((st.cfg.display||{}).usb_timeout||15);
|
||||
@@ -1060,6 +1062,9 @@ function loadConfig(loadCapture){
|
||||
$$("[data-cfm]").forEach(function(el){el.value=""});
|
||||
$$("[data-rg]").forEach(function(el){el.value=String(c.radio[el.dataset.rg]);el.classList.remove("dirty")});
|
||||
$("#display-settings").classList.toggle("hide",!c.display);
|
||||
var rotationSupported=!!(c.display&&c.display.rotation_supported);
|
||||
$("#display-rotation-setting").classList.toggle("hide",!rotationSupported);
|
||||
$('[data-k="display.rotation"]').disabled=!rotationSupported;
|
||||
$$('#display-settings option[value="pairing"],#display-settings option[value="button-pairing"]').forEach(function(el){el.hidden=!(c.display&&c.display.pairing);el.disabled=el.hidden});
|
||||
syncDisplayTimeouts();
|
||||
loadRxps(c.radio);
|
||||
@@ -2013,6 +2018,7 @@ var CLI_VERBS=[
|
||||
mode: 0 = get and set, 1 = get only, 2 = set only
|
||||
values: enum offered as value completions after `set <key> ` */
|
||||
var CLI_KEYS=[
|
||||
["display.rotation","Display rotation on supported hardware (0 restores the board default)",0,"0|90|180|270"],
|
||||
["display.inbox","Companion inbox behavior",0,"history|pending|unread"],
|
||||
["display.mode","Display on battery",0,"off|on|button|pairing|button-pairing|automatic"],
|
||||
["display.timeout","Battery display timeout in seconds (1-3600)",0],
|
||||
|
||||
Reference in new issue
Block a user