system: refactor build configurations

Namespace build configurations of modules, make more things into constexpr
(not fully finished though)

Unify code using ...Count() to parse IDs

Avoid using unsigned char aka uint8_t as index, prefer size_t
as most code already uses it anyway. Making sure we never accidentally
truncate the value or try to read it as 32bit-wide. Also, simplify
access to built in containers, since those use the wide type as well.

Renames led and button types, more consistent initialization and field access.
This commit is contained in:
Maxim Prokhorov
2021-03-10 15:35:36 +03:00
parent ec220b7dd1
commit f92116341e
24 changed files with 1087 additions and 935 deletions

View File

@@ -11,6 +11,18 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "board.h"
#include "ntp.h"
bool tryParseId(const char* p, TryParseIdFunc limit, size_t& out) {
static_assert(std::numeric_limits<size_t>::max() >= std::numeric_limits<unsigned long>::max(), "");
char* endp { nullptr };
out = strtoul(p, &endp, 10);
if ((endp == p) || (*endp != '\0') || (out >= limit())) {
return false;
}
return true;
}
void setDefaultHostname() {
if (strlen(HOSTNAME) > 0) {
setSetting("hostname", F(HOSTNAME));