simplify tones_ config key

This commit is contained in:
my 2026-09-15 16:41:27 +02:00
parent 815f79bc0b
commit 02df479896
4 changed files with 17 additions and 8 deletions

View file

@ -1,8 +1,8 @@
#nick=your nick, picked randomly on first run
brightness=200
tones_msg=T300 O4 l8 D l4 A+
tones_sys=T300 O4 l8 A l4 D+
tones_msg=t300 d8 a+4
tones_sys=t300 a8 d+4
touch_threshold=300

View file

@ -404,9 +404,9 @@ void handleCommand(const char* in) {
} else {
*sp = '\0';
size_t klen = strlen(args);
bool is_tones = klen > 6 && !strcmp(args + klen - 6, "_tones");
bool is_tones = klen > 6 && strncmp(args, "tones_", 6) == 0;
bool ok = is_tones ? settings_set_tones(args, sp + 1)
: settings_set_color(args, sp + 1);
: settings_set_color(args, sp + 1);
if (ok)
ui_push_message("", "Saved. Restart to apply.", false, true);
else if (is_tones)
@ -657,7 +657,7 @@ static void go_to_sleep() {
snprintf(m, sizeof(m), "%s left the chat!", currentNick);
// broadcastChatMessage("System", m); // same here, only show don't broadcasst
ui_push_message("", m, false, true);
delay(200); // let the packet fly
// Hold the backlight OFF pin through deep sleep so the screen stays dark.

9
src/meshberry/compat.h Normal file
View file

@ -0,0 +1,9 @@
#pragma once
#include <string.h>
// Replace the calls that MMLMusic makes to the
// AVR function strchr_P to strchr
#ifndef strchr_P
#define strchr_P strchr
#endif

View file

@ -8,8 +8,8 @@ settings_t g_settings;
static const settings_t DEFAULTS = {
.nick = NICK_DEFAULT_PREFIX,
.brightness = 200,
.tones_msg = "T140 G",
.tones_sys = "T140 A",
.tones_msg = "t300 d8 a+4",
.tones_sys = "t300 a8 d+4",
.touch_threshold = TOUCH_THRESHOLD,
.color_bg = {.blue = 0x11, .green = 0x11, .red = 0x11},
.color_header_bg = {.blue = 0x1e, .green = 0x1e, .red = 0x1e},
@ -178,7 +178,7 @@ bool settings_set_color(const char* key, const char* hex) {
bool settings_set_tones(const char* key, const char* tones) {
if (strlen(key) <= 6 || strcmp(key + strlen(key) - 6, "_tones") != 0) {
if (strlen(key) <= 6 || strncmp(key, "tones_", 6) != 0) {
return false;
}
if (!apply_kv(key, tones)) return false; // unknown key or bad tones