Pack STM32WL Companion help while retaining every command
This commit is contained in:
1 parent
9d973d353a
commit
73789a64e8
9 files changed
+211
-31
No files matched your search
@@ -1,9 +1,11 @@
|
||||
#if defined(RAK_4631) && defined(COMPANION_RADIO_FULL)
|
||||
// This is the only Companion translation unit compiled as C++17. Include the
|
||||
#if defined(RAK_4631) && defined(COMPANION_RADIO_FULL) \
|
||||
|| (defined(STM32_PLATFORM) && defined(STM32WLxx))
|
||||
// This is the only selected Companion source compiled as C++17. Include the
|
||||
// same feature/board context as MyMesh before expanding the single help source.
|
||||
#include "MyMesh.h"
|
||||
#include "CompanionHelpWriter.h"
|
||||
|
||||
#if !defined(STM32_PLATFORM) || COMPANION_FEATURE_TEXT_TERMINAL
|
||||
namespace mesh { namespace companion {
|
||||
size_t writePackedCompanionHelp(Stream& output) {
|
||||
// Constant evaluation retains only the exact-sized packed help image.
|
||||
@@ -30,3 +32,4 @@ size_t writePackedCompanionHelp(Stream& output) {
|
||||
}
|
||||
} } // namespace mesh::companion
|
||||
#endif
|
||||
#endif
|
||||
@@ -7,7 +7,7 @@ class Stream;
|
||||
|
||||
namespace mesh { namespace companion {
|
||||
|
||||
// The implementation is isolated in the RAK Full C++17 packing source.
|
||||
// The implementation is isolated in one selected C++17 packing source.
|
||||
size_t writePackedCompanionHelp(Stream& output);
|
||||
|
||||
// Native USB accepts bounded producer writes. Honor partial progress, and stop
|
||||
@@ -33,7 +33,13 @@ namespace help_packing {
|
||||
// ASCII literals retain bit 7 clear. Two-byte references encode a 3..18 byte
|
||||
// match at distance 1..2048. Only the final packed bytes survive evaluation;
|
||||
// the hash chains and original text occupy no runtime storage.
|
||||
#if defined(STM32_PLATFORM) && defined(STM32WLxx)
|
||||
// Small STM32WL Companions retain their 1 KiB minimum stack allowance. A
|
||||
// smaller history preserves every help byte without adding a 2 KiB frame.
|
||||
constexpr size_t WindowSize = 256;
|
||||
#else
|
||||
constexpr size_t WindowSize = 2048;
|
||||
#endif
|
||||
constexpr size_t MaximumMatch = 18;
|
||||
constexpr uint8_t hash(const char* text) {
|
||||
return static_cast<uint8_t>((static_cast<uint8_t>(text[0]) * 31u +
|
||||
@@ -134,7 +140,7 @@ size_t writePackedHelp(Output& output, const uint8_t* packed, size_t length) {
|
||||
if (position == length) return written;
|
||||
distance = ((static_cast<size_t>(next & 7) << 8) | packed[position++]) + 1;
|
||||
remaining = ((next >> 3) & 15) + 3;
|
||||
if (distance > produced) return written;
|
||||
if (distance > produced || distance > help_packing::WindowSize) return written;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10404,7 +10404,8 @@ void MyMesh::handleTerminalCommand(char* command, bool reader_prompt,
|
||||
FIRMWARE_VERSION, (unsigned)FIRMWARE_VER_CODE, FIRMWARE_BUILD_DATE);
|
||||
} else if (strcmp(command, "help") == 0) {
|
||||
auto& output = terminalOutput();
|
||||
#if defined(RAK_4631) && defined(COMPANION_RADIO_FULL)
|
||||
#if defined(RAK_4631) && defined(COMPANION_RADIO_FULL) \
|
||||
|| (defined(STM32_PLATFORM) && defined(STM32WLxx) && COMPANION_FEATURE_TEXT_TERMINAL)
|
||||
mesh::companion::writePackedCompanionHelp(output);
|
||||
#else
|
||||
#define MESH_COMPANION_HELP_BEGIN output.print(
|
||||
|
||||
Reference in new issue
Block a user