Ken Van Hoeylandt 3ea02d912f
Merge develop into main (#167)
- WiFi Connect app is now hidden by default, but accessible at the bottom of the WiFi Manage app when WiFi is turned on.
- WiFi service now turns on WiFi when calling connect() and WiFi is not on.
- Removed `blocking` option for `service::loader::startApp()`. This feature was unused and complex.
- Various apps: Moved private headers into Private/ folder.
- Various apps: created start() function for easy starting.
- Added documentation to all TactilityC APIs
- Refactored various `enum` into `class enum`
- Refactor M5Stack `initBoot()` (but VBus is still 0V for some reason)
2025-01-17 19:37:42 +01:00

27 lines
897 B
C++

#include "app/crashdiagnostics/QrHelpers.h"
#include <cstdint>
/**
* Maps QR version (starting at a fictitious 0) to the usable byte size for L(ow) CRC checking QR.
*
* See https://www.qrcode.com/en/about/version.html
*/
uint16_t qr_version_binary_sizes[] = {
0, 17, 32, 53, 78, 106, 134, 154, 192, 230, // 0 - 9
271, 321, 367, 425, 458, 520, 586, 644, 718, 792, // 10-19
858, 929, 1003, 1091, 1171, 1273, 1367, 1465, 1528, 1682, // 20-29
1732, 1840, 1952, 2068, 2188, 2303, 2431, 2563, 2699, 2809, 2953 // 30-40
};
bool getQrVersionForBinaryDataLength(size_t inLength, int& outVersion) {
static_assert(sizeof(qr_version_binary_sizes) == 41 * sizeof(int16_t));
for (int version = 1; version < 41; version++) {
if (inLength <= qr_version_binary_sizes[version]) {
outVersion = version;
return true;
}
}
return false;
}