mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
Bot: DM+channel modes with separate replies; buzzer auto-mute; UX fixes
- Bot redesign: DM bot active for all private messages (no pubkey filter), channel bot optional with separate enable flag; both can run simultaneously - Bot: one shared trigger, separate reply texts for DM and channel - Buzzer: add Auto mode (mutes when BT connected, unmutes on disconnect); per-channel force-on overrides still work as intended - Settings: defer flash writes to menu exit (only when dirty) - Settings: add Seconds toggle (hide clock seconds, refresh drops 1s→60s) - Fullscreen msg preview: fix truncation (fmsg buf 79→140 chars) - RingtoneEditor: fix melody playback cut after first note (RTTTL lib holds pointer — moved play buffer to member variable) - BotScreen: remove key hint footer - .gitattributes: protect README.md from upstream merge conflicts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
README.md merge=ours
|
||||||
@@ -255,12 +255,16 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
|
|||||||
file.read((uint8_t *)&_prefs.home_pages_mask, sizeof(_prefs.home_pages_mask));
|
file.read((uint8_t *)&_prefs.home_pages_mask, sizeof(_prefs.home_pages_mask));
|
||||||
if (file.available()) {
|
if (file.available()) {
|
||||||
file.read((uint8_t *)&_prefs.bot_enabled, sizeof(_prefs.bot_enabled));
|
file.read((uint8_t *)&_prefs.bot_enabled, sizeof(_prefs.bot_enabled));
|
||||||
|
file.read((uint8_t *)&_prefs.bot_channel_enabled, sizeof(_prefs.bot_channel_enabled));
|
||||||
file.read((uint8_t *)&_prefs.bot_channel_idx, sizeof(_prefs.bot_channel_idx));
|
file.read((uint8_t *)&_prefs.bot_channel_idx, sizeof(_prefs.bot_channel_idx));
|
||||||
file.read((uint8_t *)_prefs.bot_trigger, sizeof(_prefs.bot_trigger));
|
file.read((uint8_t *)_prefs.bot_trigger, sizeof(_prefs.bot_trigger));
|
||||||
file.read((uint8_t *)_prefs.bot_reply, sizeof(_prefs.bot_reply));
|
file.read((uint8_t *)_prefs.bot_reply_dm, sizeof(_prefs.bot_reply_dm));
|
||||||
|
file.read((uint8_t *)_prefs.bot_reply_ch, sizeof(_prefs.bot_reply_ch));
|
||||||
if (file.available()) {
|
if (file.available()) {
|
||||||
file.read((uint8_t *)&_prefs.bot_target_type, sizeof(_prefs.bot_target_type));
|
file.read((uint8_t *)&_prefs.clock_hide_seconds, sizeof(_prefs.clock_hide_seconds));
|
||||||
file.read((uint8_t *)_prefs.bot_dm_pubkey, sizeof(_prefs.bot_dm_pubkey));
|
if (file.available()) {
|
||||||
|
file.read((uint8_t *)&_prefs.buzzer_auto, sizeof(_prefs.buzzer_auto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,11 +327,13 @@ void DataStore::savePrefs(const NodePrefs& _prefs, double node_lat, double node_
|
|||||||
file.write((uint8_t *)_prefs.ringtone_notes, sizeof(_prefs.ringtone_notes));
|
file.write((uint8_t *)_prefs.ringtone_notes, sizeof(_prefs.ringtone_notes));
|
||||||
file.write((uint8_t *)&_prefs.home_pages_mask, sizeof(_prefs.home_pages_mask));
|
file.write((uint8_t *)&_prefs.home_pages_mask, sizeof(_prefs.home_pages_mask));
|
||||||
file.write((uint8_t *)&_prefs.bot_enabled, sizeof(_prefs.bot_enabled));
|
file.write((uint8_t *)&_prefs.bot_enabled, sizeof(_prefs.bot_enabled));
|
||||||
|
file.write((uint8_t *)&_prefs.bot_channel_enabled, sizeof(_prefs.bot_channel_enabled));
|
||||||
file.write((uint8_t *)&_prefs.bot_channel_idx, sizeof(_prefs.bot_channel_idx));
|
file.write((uint8_t *)&_prefs.bot_channel_idx, sizeof(_prefs.bot_channel_idx));
|
||||||
file.write((uint8_t *)_prefs.bot_trigger, sizeof(_prefs.bot_trigger));
|
file.write((uint8_t *)_prefs.bot_trigger, sizeof(_prefs.bot_trigger));
|
||||||
file.write((uint8_t *)_prefs.bot_reply, sizeof(_prefs.bot_reply));
|
file.write((uint8_t *)_prefs.bot_reply_dm, sizeof(_prefs.bot_reply_dm));
|
||||||
file.write((uint8_t *)&_prefs.bot_target_type, sizeof(_prefs.bot_target_type));
|
file.write((uint8_t *)_prefs.bot_reply_ch, sizeof(_prefs.bot_reply_ch));
|
||||||
file.write((uint8_t *)_prefs.bot_dm_pubkey, sizeof(_prefs.bot_dm_pubkey));
|
file.write((uint8_t *)&_prefs.clock_hide_seconds, sizeof(_prefs.clock_hide_seconds));
|
||||||
|
file.write((uint8_t *)&_prefs.buzzer_auto, sizeof(_prefs.buzzer_auto));
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -876,11 +876,11 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
|||||||
_prefs.ringtone_len = 0; // no custom ringtone by default
|
_prefs.ringtone_len = 0; // no custom ringtone by default
|
||||||
_prefs.home_pages_mask = 0x01FF; // all pages visible
|
_prefs.home_pages_mask = 0x01FF; // all pages visible
|
||||||
_prefs.bot_enabled = 0;
|
_prefs.bot_enabled = 0;
|
||||||
|
_prefs.bot_channel_enabled = 0;
|
||||||
_prefs.bot_channel_idx = 0;
|
_prefs.bot_channel_idx = 0;
|
||||||
_prefs.bot_trigger[0] = '\0';
|
_prefs.bot_trigger[0] = '\0';
|
||||||
_prefs.bot_reply[0] = '\0';
|
_prefs.bot_reply_dm[0] = '\0';
|
||||||
_prefs.bot_target_type = 0;
|
_prefs.bot_reply_ch[0] = '\0';
|
||||||
memset(_prefs.bot_dm_pubkey, 0, sizeof(_prefs.bot_dm_pubkey));
|
|
||||||
_prefs.auto_off_secs = 15; // 15 seconds auto-off by default
|
_prefs.auto_off_secs = 15; // 15 seconds auto-off by default
|
||||||
_prefs.tz_offset_hours = 0; // UTC by default
|
_prefs.tz_offset_hours = 0; // UTC by default
|
||||||
_prefs.low_batt_mv = 3400; // auto-shutdown at 3.4V by default
|
_prefs.low_batt_mv = 3400; // auto-shutdown at 3.4V by default
|
||||||
|
|||||||
@@ -3,17 +3,10 @@
|
|||||||
// Included at the bottom of MyMesh.cpp after all class definitions.
|
// Included at the bottom of MyMesh.cpp after all class definitions.
|
||||||
|
|
||||||
void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
||||||
if (!(_prefs.bot_enabled && _prefs.bot_target_type == 1 &&
|
if (!(_prefs.bot_enabled && _prefs.bot_trigger[0] && _prefs.bot_reply_dm[0] &&
|
||||||
_prefs.bot_trigger[0] && _prefs.bot_reply[0] &&
|
|
||||||
millis() - _bot_last_reply_ms > 10000UL))
|
millis() - _bot_last_reply_ms > 10000UL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// all-zero pubkey = any sender; otherwise match first 4 bytes
|
|
||||||
bool key_ok = (_prefs.bot_dm_pubkey[0] == 0 && _prefs.bot_dm_pubkey[1] == 0 &&
|
|
||||||
_prefs.bot_dm_pubkey[2] == 0 && _prefs.bot_dm_pubkey[3] == 0) ||
|
|
||||||
memcmp(from.id.pub_key, _prefs.bot_dm_pubkey, 4) == 0;
|
|
||||||
if (!key_ok) return;
|
|
||||||
|
|
||||||
const char* tr = _prefs.bot_trigger;
|
const char* tr = _prefs.bot_trigger;
|
||||||
int tlen = strlen(tr);
|
int tlen = strlen(tr);
|
||||||
bool matched = false;
|
bool matched = false;
|
||||||
@@ -26,7 +19,7 @@ void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
|||||||
|
|
||||||
uint32_t ts = getRTCClock()->getCurrentTime();
|
uint32_t ts = getRTCClock()->getCurrentTime();
|
||||||
char expanded[200];
|
char expanded[200];
|
||||||
expandMsg(_prefs.bot_reply, expanded, sizeof(expanded),
|
expandMsg(_prefs.bot_reply_dm, expanded, sizeof(expanded),
|
||||||
sensors.node_lat, sensors.node_lon,
|
sensors.node_lat, sensors.node_lon,
|
||||||
sensors.node_lat != 0.0 || sensors.node_lon != 0.0,
|
sensors.node_lat != 0.0 || sensors.node_lon != 0.0,
|
||||||
ts, _prefs.tz_offset_hours);
|
ts, _prefs.tz_offset_hours);
|
||||||
@@ -36,8 +29,7 @@ void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text) {
|
void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text) {
|
||||||
if (!(_prefs.bot_enabled && _prefs.bot_target_type == 0 &&
|
if (!(_prefs.bot_channel_enabled && _prefs.bot_trigger[0] && _prefs.bot_reply_ch[0] &&
|
||||||
_prefs.bot_trigger[0] && _prefs.bot_reply[0] &&
|
|
||||||
channel_idx == _prefs.bot_channel_idx &&
|
channel_idx == _prefs.bot_channel_idx &&
|
||||||
millis() - _bot_last_reply_ms > 10000UL))
|
millis() - _bot_last_reply_ms > 10000UL))
|
||||||
return;
|
return;
|
||||||
@@ -57,7 +49,7 @@ void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text) {
|
|||||||
|
|
||||||
uint32_t ts = getRTCClock()->getCurrentTime();
|
uint32_t ts = getRTCClock()->getCurrentTime();
|
||||||
char expanded[200];
|
char expanded[200];
|
||||||
expandMsg(_prefs.bot_reply, expanded, sizeof(expanded),
|
expandMsg(_prefs.bot_reply_ch, expanded, sizeof(expanded),
|
||||||
sensors.node_lat, sensors.node_lon,
|
sensors.node_lat, sensors.node_lon,
|
||||||
sensors.node_lat != 0.0 || sensors.node_lon != 0.0,
|
sensors.node_lat != 0.0 || sensors.node_lon != 0.0,
|
||||||
ts, _prefs.tz_offset_hours);
|
ts, _prefs.tz_offset_hours);
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ struct NodePrefs { // persisted to file
|
|||||||
uint8_t ringtone_len; // number of notes in custom ringtone (0 = use default)
|
uint8_t ringtone_len; // number of notes in custom ringtone (0 = use default)
|
||||||
uint8_t ringtone_notes[32]; // packed: bits0-2=pitch, bits3-4=octave-4, bits5-6=dur_idx
|
uint8_t ringtone_notes[32]; // packed: bits0-2=pitch, bits3-4=octave-4, bits5-6=dur_idx
|
||||||
uint16_t home_pages_mask; // bitmask of visible home pages (bit0=Clock..bit8=Shutdown); 0=all visible
|
uint16_t home_pages_mask; // bitmask of visible home pages (bit0=Clock..bit8=Shutdown); 0=all visible
|
||||||
uint8_t bot_enabled; // 0=disabled, 1=enabled
|
uint8_t bot_enabled; // 0=disabled, 1=DM bot active (responds to all DMs)
|
||||||
uint8_t bot_channel_idx; // channel index to monitor (when bot_target_type==0)
|
uint8_t bot_channel_enabled; // 0=disabled, 1=channel bot active for bot_channel_idx
|
||||||
|
uint8_t bot_channel_idx; // channel index for channel bot
|
||||||
char bot_trigger[64]; // trigger phrase (case-insensitive contains match)
|
char bot_trigger[64]; // trigger phrase (case-insensitive contains match)
|
||||||
char bot_reply[140]; // auto-reply text
|
char bot_reply_dm[140]; // auto-reply text for DM
|
||||||
uint8_t bot_target_type; // 0=channel (default), 1=DM contact
|
char bot_reply_ch[140]; // auto-reply text for channel
|
||||||
uint8_t bot_dm_pubkey[4]; // pubkey prefix of DM target; all-zero = any DM sender
|
uint8_t clock_hide_seconds; // 0=show HH:MM:SS/refresh 1s (default), 1=hide/refresh 60s
|
||||||
|
uint8_t buzzer_auto; // 0=manual (default), 1=auto-mute when BT connected
|
||||||
};
|
};
|
||||||
@@ -6,11 +6,14 @@ class BotScreen : public UIScreen {
|
|||||||
UITask* _task;
|
UITask* _task;
|
||||||
NodePrefs* _prefs;
|
NodePrefs* _prefs;
|
||||||
|
|
||||||
static const int ITEM_COUNT = 4;
|
// Items: 0=Enable(DM), 1=Channel, 2=Trigger, 3=Reply DM, 4=Reply Ch
|
||||||
|
static const int ITEM_COUNT = 5;
|
||||||
static const int ITEM_H = 11;
|
static const int ITEM_H = 11;
|
||||||
static const int START_Y = 12;
|
static const int START_Y = 12;
|
||||||
static const int VAL_X = 70;
|
static const int VAL_X = 70;
|
||||||
|
|
||||||
|
int _sel;
|
||||||
|
|
||||||
// keyboard state (reused for trigger and reply fields)
|
// keyboard state (reused for trigger and reply fields)
|
||||||
int _kb_field; // -1=off, 2=trigger, 3=reply
|
int _kb_field; // -1=off, 2=trigger, 3=reply
|
||||||
char _kb_buf[KB_MAX_LEN + 1];
|
char _kb_buf[KB_MAX_LEN + 1];
|
||||||
@@ -21,18 +24,10 @@ class BotScreen : public UIScreen {
|
|||||||
bool _kb_ph_mode;
|
bool _kb_ph_mode;
|
||||||
int _kb_ph_sel;
|
int _kb_ph_sel;
|
||||||
|
|
||||||
int _sel;
|
// channel cache (refreshed on enter)
|
||||||
|
|
||||||
// channel + DM contact caches (refreshed on enter)
|
|
||||||
static const int MAX_BOT_DM = 16;
|
|
||||||
|
|
||||||
int _num_channels;
|
int _num_channels;
|
||||||
uint8_t _channel_indices[MAX_GROUP_CHANNELS];
|
uint8_t _channel_indices[MAX_GROUP_CHANNELS];
|
||||||
|
|
||||||
int _num_dm;
|
|
||||||
uint8_t _dm_pubkeys[MAX_BOT_DM][4];
|
|
||||||
char _dm_names[MAX_BOT_DM][32];
|
|
||||||
|
|
||||||
void refreshChannels() {
|
void refreshChannels() {
|
||||||
_num_channels = 0;
|
_num_channels = 0;
|
||||||
ChannelDetails ch;
|
ChannelDetails ch;
|
||||||
@@ -42,33 +37,12 @@ class BotScreen : public UIScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void refreshContacts() {
|
// Returns index into _channel_indices[] for current bot_channel_idx, or -1 if not found/disabled.
|
||||||
_num_dm = 0;
|
int currentChannelListIdx() const {
|
||||||
ContactInfo ci;
|
if (!_prefs->bot_channel_enabled) return -1;
|
||||||
int n = the_mesh.getNumContacts();
|
|
||||||
for (int i = 0; i < n && _num_dm < MAX_BOT_DM; i++) {
|
|
||||||
if (!the_mesh.getContactByIdx(i, ci)) continue;
|
|
||||||
if (ci.type != ADV_TYPE_CHAT) continue;
|
|
||||||
if (!(ci.flags & 0x01)) continue; // favourites only
|
|
||||||
memcpy(_dm_pubkeys[_num_dm], ci.id.pub_key, 4);
|
|
||||||
strncpy(_dm_names[_num_dm], ci.name, sizeof(_dm_names[0]) - 1);
|
|
||||||
_dm_names[_num_dm][sizeof(_dm_names[0]) - 1] = '\0';
|
|
||||||
_num_dm++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns combined index in [channels..., DM contacts...]
|
|
||||||
int currentTargetIdx() const {
|
|
||||||
if (_prefs->bot_target_type == 0) {
|
|
||||||
for (int i = 0; i < _num_channels; i++)
|
for (int i = 0; i < _num_channels; i++)
|
||||||
if (_channel_indices[i] == _prefs->bot_channel_idx) return i;
|
if (_channel_indices[i] == _prefs->bot_channel_idx) return i;
|
||||||
return 0;
|
return -1;
|
||||||
} else {
|
|
||||||
for (int i = 0; i < _num_dm; i++)
|
|
||||||
if (memcmp(_dm_pubkeys[i], _prefs->bot_dm_pubkey, 4) == 0)
|
|
||||||
return _num_channels + i;
|
|
||||||
return _num_channels; // fallback: first DM
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -78,7 +52,6 @@ public:
|
|||||||
_sel = 0;
|
_sel = 0;
|
||||||
_kb_field = -1;
|
_kb_field = -1;
|
||||||
refreshChannels();
|
refreshChannels();
|
||||||
refreshContacts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int render(DisplayDriver& display) override {
|
int render(DisplayDriver& display) override {
|
||||||
@@ -86,7 +59,6 @@ public:
|
|||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
|
|
||||||
if (_kb_field >= 0) {
|
if (_kb_field >= 0) {
|
||||||
// keyboard mode — uses same layout as global keyboard
|
|
||||||
const char* label = (_kb_field == 2) ? "Trigger:" : "Reply:";
|
const char* label = (_kb_field == 2) ? "Trigger:" : "Reply:";
|
||||||
const char* disp_start = _kb_buf;
|
const char* disp_start = _kb_buf;
|
||||||
int disp_len = _kb_len;
|
int disp_len = _kb_len;
|
||||||
@@ -97,7 +69,6 @@ public:
|
|||||||
display.print(preview);
|
display.print(preview);
|
||||||
display.fillRect(0, KB_SEP_Y, display.width(), 1);
|
display.fillRect(0, KB_SEP_Y, display.width(), 1);
|
||||||
|
|
||||||
// char rows
|
|
||||||
for (int row = 0; row < KB_ROWS_CHAR; row++) {
|
for (int row = 0; row < KB_ROWS_CHAR; row++) {
|
||||||
int y = KB_CHARS_Y + row * KB_CELL_H;
|
int y = KB_CHARS_Y + row * KB_CELL_H;
|
||||||
for (int col = 0; col < KB_COLS_CHAR; col++) {
|
for (int col = 0; col < KB_COLS_CHAR; col++) {
|
||||||
@@ -118,7 +89,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// special row: [^] [Sp] [Del] [{}] [OK] — 5 buttons at 25px each
|
|
||||||
const char* spec[] = { "[^]", "[Sp]", "[Del]", "[{}]", "[OK]" };
|
const char* spec[] = { "[^]", "[Sp]", "[Del]", "[{}]", "[OK]" };
|
||||||
for (int i = 0; i < KB_SPECIAL; i++) {
|
for (int i = 0; i < KB_SPECIAL; i++) {
|
||||||
bool sel = (_kb_row == KB_ROWS_CHAR && _kb_col == i);
|
bool sel = (_kb_row == KB_ROWS_CHAR && _kb_col == i);
|
||||||
@@ -136,7 +106,6 @@ public:
|
|||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// placeholder picker overlay
|
|
||||||
if (_kb_ph_mode) {
|
if (_kb_ph_mode) {
|
||||||
display.setColor(DisplayDriver::DARK);
|
display.setColor(DisplayDriver::DARK);
|
||||||
display.fillRect(20, 20, 88, 12 + KB_PH_COUNT * 10);
|
display.fillRect(20, 20, 88, 12 + KB_PH_COUNT * 10);
|
||||||
@@ -165,7 +134,7 @@ public:
|
|||||||
display.drawTextCentered(display.width() / 2, 0, "AUTO-REPLY BOT");
|
display.drawTextCentered(display.width() / 2, 0, "AUTO-REPLY BOT");
|
||||||
display.fillRect(0, 10, display.width(), 1);
|
display.fillRect(0, 10, display.width(), 1);
|
||||||
|
|
||||||
static const char* labels[] = { "Enable", NULL, "Trigger", "Reply" };
|
static const char* labels[] = { "Enable", "Channel", "Trigger", "Reply DM", "Reply Ch" };
|
||||||
for (int i = 0; i < ITEM_COUNT; i++) {
|
for (int i = 0; i < ITEM_COUNT; i++) {
|
||||||
int y = START_Y + i * ITEM_H;
|
int y = START_Y + i * ITEM_H;
|
||||||
bool sel = (i == _sel);
|
bool sel = (i == _sel);
|
||||||
@@ -174,46 +143,33 @@ public:
|
|||||||
display.setColor(DisplayDriver::DARK);
|
display.setColor(DisplayDriver::DARK);
|
||||||
}
|
}
|
||||||
display.setCursor(2, y);
|
display.setCursor(2, y);
|
||||||
if (i == 1)
|
|
||||||
display.print(_prefs->bot_target_type == 0 ? "Channel" : "Contact");
|
|
||||||
else
|
|
||||||
display.print(labels[i]);
|
display.print(labels[i]);
|
||||||
display.setCursor(VAL_X, y);
|
display.setCursor(VAL_X, y);
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
display.print(_prefs->bot_enabled ? "ON" : "OFF");
|
display.print(_prefs->bot_enabled ? "ON" : "OFF");
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
int total = _num_channels + _num_dm;
|
if (!_prefs->bot_channel_enabled || _num_channels == 0) {
|
||||||
if (total == 0) {
|
display.print("OFF");
|
||||||
display.print("none");
|
} else {
|
||||||
} else if (_prefs->bot_target_type == 0) {
|
|
||||||
ChannelDetails ch;
|
ChannelDetails ch;
|
||||||
if (_num_channels > 0 && the_mesh.getChannel(_prefs->bot_channel_idx, ch) && ch.name[0])
|
if (the_mesh.getChannel(_prefs->bot_channel_idx, ch) && ch.name[0])
|
||||||
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, ch.name);
|
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, ch.name);
|
||||||
else
|
else
|
||||||
display.print("?");
|
display.print("?");
|
||||||
} else {
|
|
||||||
bool found = false;
|
|
||||||
for (int j = 0; j < _num_dm && !found; j++) {
|
|
||||||
if (memcmp(_dm_pubkeys[j], _prefs->bot_dm_pubkey, 4) == 0) {
|
|
||||||
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, _dm_names[j]);
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) display.print("?");
|
|
||||||
}
|
}
|
||||||
} else if (i == 2) {
|
} else if (i == 2) {
|
||||||
const char* tr = _prefs->bot_trigger;
|
const char* tr = _prefs->bot_trigger;
|
||||||
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, tr[0] ? tr : "(none)");
|
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, tr[0] ? tr : "(none)");
|
||||||
|
} else if (i == 3) {
|
||||||
|
const char* rp = _prefs->bot_reply_dm;
|
||||||
|
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, rp[0] ? rp : "(none)");
|
||||||
} else {
|
} else {
|
||||||
const char* rp = _prefs->bot_reply;
|
const char* rp = _prefs->bot_reply_ch;
|
||||||
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, rp[0] ? rp : "(none)");
|
display.drawTextEllipsized(VAL_X, y, display.width() - VAL_X - 1, rp[0] ? rp : "(none)");
|
||||||
}
|
}
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
display.setCursor(0, 54);
|
|
||||||
display.print("ENT:edit CANCEL:save");
|
|
||||||
return 300;
|
return 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +182,6 @@ public:
|
|||||||
bool cancel = (c == KEY_CANCEL || c == KEY_CONTEXT_MENU);
|
bool cancel = (c == KEY_CANCEL || c == KEY_CONTEXT_MENU);
|
||||||
|
|
||||||
if (_kb_field >= 0) {
|
if (_kb_field >= 0) {
|
||||||
// placeholder picker overlay takes priority
|
|
||||||
if (_kb_ph_mode) {
|
if (_kb_ph_mode) {
|
||||||
if (c == KEY_UP && _kb_ph_sel > 0) { _kb_ph_sel--; return true; }
|
if (c == KEY_UP && _kb_ph_sel > 0) { _kb_ph_sel--; return true; }
|
||||||
if (c == KEY_DOWN && _kb_ph_sel < KB_PH_COUNT - 1) { _kb_ph_sel++; return true; }
|
if (c == KEY_DOWN && _kb_ph_sel < KB_PH_COUNT - 1) { _kb_ph_sel++; return true; }
|
||||||
@@ -249,7 +204,7 @@ public:
|
|||||||
if (up) {
|
if (up) {
|
||||||
if (_kb_row > 0) {
|
if (_kb_row > 0) {
|
||||||
_kb_row--;
|
_kb_row--;
|
||||||
if (_kb_row == KB_ROWS_CHAR - 1) // leaving special row upward
|
if (_kb_row == KB_ROWS_CHAR - 1)
|
||||||
_kb_col = _kb_col * KB_COLS_CHAR / KB_SPECIAL;
|
_kb_col = _kb_col * KB_COLS_CHAR / KB_SPECIAL;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -257,15 +212,12 @@ public:
|
|||||||
if (down) {
|
if (down) {
|
||||||
if (_kb_row < KB_ROWS_CHAR) {
|
if (_kb_row < KB_ROWS_CHAR) {
|
||||||
_kb_row++;
|
_kb_row++;
|
||||||
if (_kb_row == KB_ROWS_CHAR) // entering special row
|
if (_kb_row == KB_ROWS_CHAR)
|
||||||
_kb_col = _kb_col * KB_SPECIAL / KB_COLS_CHAR;
|
_kb_col = _kb_col * KB_SPECIAL / KB_COLS_CHAR;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (left) {
|
if (left) { if (_kb_col > 0) _kb_col--; return true; }
|
||||||
if (_kb_col > 0) _kb_col--;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (right) {
|
if (right) {
|
||||||
int max_col = (_kb_row == KB_ROWS_CHAR) ? KB_SPECIAL - 1 : KB_COLS_CHAR - 1;
|
int max_col = (_kb_row == KB_ROWS_CHAR) ? KB_SPECIAL - 1 : KB_COLS_CHAR - 1;
|
||||||
if (_kb_col < max_col) _kb_col++;
|
if (_kb_col < max_col) _kb_col++;
|
||||||
@@ -293,13 +245,15 @@ public:
|
|||||||
_kb_ph_sel = 0;
|
_kb_ph_sel = 0;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// OK — commit to prefs
|
|
||||||
if (_kb_field == 2) {
|
if (_kb_field == 2) {
|
||||||
strncpy(_prefs->bot_trigger, _kb_buf, sizeof(_prefs->bot_trigger) - 1);
|
strncpy(_prefs->bot_trigger, _kb_buf, sizeof(_prefs->bot_trigger) - 1);
|
||||||
_prefs->bot_trigger[sizeof(_prefs->bot_trigger) - 1] = '\0';
|
_prefs->bot_trigger[sizeof(_prefs->bot_trigger) - 1] = '\0';
|
||||||
|
} else if (_kb_field == 3) {
|
||||||
|
strncpy(_prefs->bot_reply_dm, _kb_buf, sizeof(_prefs->bot_reply_dm) - 1);
|
||||||
|
_prefs->bot_reply_dm[sizeof(_prefs->bot_reply_dm) - 1] = '\0';
|
||||||
} else {
|
} else {
|
||||||
strncpy(_prefs->bot_reply, _kb_buf, sizeof(_prefs->bot_reply) - 1);
|
strncpy(_prefs->bot_reply_ch, _kb_buf, sizeof(_prefs->bot_reply_ch) - 1);
|
||||||
_prefs->bot_reply[sizeof(_prefs->bot_reply) - 1] = '\0';
|
_prefs->bot_reply_ch[sizeof(_prefs->bot_reply_ch) - 1] = '\0';
|
||||||
}
|
}
|
||||||
_kb_field = -1;
|
_kb_field = -1;
|
||||||
break;
|
break;
|
||||||
@@ -323,24 +277,28 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_sel == 1) {
|
if (_sel == 1) {
|
||||||
int total = _num_channels + _num_dm;
|
if (_num_channels == 0) return false;
|
||||||
if (total == 0) return false;
|
// Cycle: OFF → ch[0] → ch[1] → ... → OFF
|
||||||
int idx = currentTargetIdx();
|
int idx = currentChannelListIdx(); // -1 = OFF
|
||||||
if (right || enter) idx = (idx + 1) % total;
|
if (right || enter) {
|
||||||
if (left) idx = (idx + total - 1) % total;
|
idx++;
|
||||||
|
if (idx >= _num_channels) idx = -1; // wrap to OFF
|
||||||
|
}
|
||||||
|
if (left) {
|
||||||
|
idx--;
|
||||||
|
if (idx < -1) idx = _num_channels - 1;
|
||||||
|
}
|
||||||
if (left || right || enter) {
|
if (left || right || enter) {
|
||||||
if (idx < _num_channels) {
|
if (idx < 0) {
|
||||||
_prefs->bot_target_type = 0;
|
_prefs->bot_channel_enabled = 0;
|
||||||
_prefs->bot_channel_idx = _channel_indices[idx];
|
|
||||||
} else {
|
} else {
|
||||||
int di = idx - _num_channels;
|
_prefs->bot_channel_enabled = 1;
|
||||||
_prefs->bot_target_type = 1;
|
_prefs->bot_channel_idx = _channel_indices[idx];
|
||||||
memcpy(_prefs->bot_dm_pubkey, _dm_pubkeys[di], 4);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((_sel == 2 || _sel == 3) && enter) {
|
if ((_sel == 2 || _sel == 3 || _sel == 4) && enter) {
|
||||||
_kb_field = _sel;
|
_kb_field = _sel;
|
||||||
_kb_row = 0;
|
_kb_row = 0;
|
||||||
_kb_col = 0;
|
_kb_col = 0;
|
||||||
@@ -350,9 +308,12 @@ public:
|
|||||||
if (_sel == 2) {
|
if (_sel == 2) {
|
||||||
strncpy(_kb_buf, _prefs->bot_trigger, sizeof(_kb_buf) - 1);
|
strncpy(_kb_buf, _prefs->bot_trigger, sizeof(_kb_buf) - 1);
|
||||||
_kb_maxlen = sizeof(_prefs->bot_trigger) - 1;
|
_kb_maxlen = sizeof(_prefs->bot_trigger) - 1;
|
||||||
|
} else if (_sel == 3) {
|
||||||
|
strncpy(_kb_buf, _prefs->bot_reply_dm, sizeof(_kb_buf) - 1);
|
||||||
|
_kb_maxlen = sizeof(_prefs->bot_reply_dm) - 1;
|
||||||
} else {
|
} else {
|
||||||
strncpy(_kb_buf, _prefs->bot_reply, sizeof(_kb_buf) - 1);
|
strncpy(_kb_buf, _prefs->bot_reply_ch, sizeof(_kb_buf) - 1);
|
||||||
_kb_maxlen = sizeof(_prefs->bot_reply) - 1;
|
_kb_maxlen = sizeof(_prefs->bot_reply_ch) - 1;
|
||||||
}
|
}
|
||||||
_kb_buf[sizeof(_kb_buf) - 1] = '\0';
|
_kb_buf[sizeof(_kb_buf) - 1] = '\0';
|
||||||
_kb_len = strlen(_kb_buf);
|
_kb_len = strlen(_kb_buf);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class RingtoneEditorScreen : public UIScreen {
|
|||||||
bool _menu_open;
|
bool _menu_open;
|
||||||
int _menu_sel;
|
int _menu_sel;
|
||||||
int _menu_scroll;
|
int _menu_scroll;
|
||||||
|
char _play_buf[220]; // persistent RTTTL buffer — library holds a pointer into it
|
||||||
|
|
||||||
enum MenuOpt {
|
enum MenuOpt {
|
||||||
M_PLAY_STOP, M_DURATION, M_BPM_UP, M_BPM_DOWN,
|
M_PLAY_STOP, M_DURATION, M_BPM_UP, M_BPM_DOWN,
|
||||||
@@ -46,28 +47,27 @@ class RingtoneEditorScreen : public UIScreen {
|
|||||||
if (_scroll < 0) _scroll = 0;
|
if (_scroll < 0) _scroll = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildRTTTL(char* buf, int buf_len) {
|
void buildRTTTL() {
|
||||||
uint16_t bpm = BPM_OPTS[_bpm_idx < 5 ? _bpm_idx : 2];
|
uint16_t bpm = BPM_OPTS[_bpm_idx < 5 ? _bpm_idx : 2];
|
||||||
int pos = snprintf(buf, buf_len, "Ring:d=8,o=5,b=%u:", bpm);
|
int pos = snprintf(_play_buf, sizeof(_play_buf), "Ring:d=8,o=5,b=%u:", bpm);
|
||||||
for (int i = 0; i < _len && pos < buf_len - 8; i++) {
|
for (int i = 0; i < _len && pos < (int)sizeof(_play_buf) - 8; i++) {
|
||||||
if (i > 0 && pos < buf_len - 1) buf[pos++] = ',';
|
if (i > 0 && pos < (int)sizeof(_play_buf) - 1) _play_buf[pos++] = ',';
|
||||||
uint8_t pitch = notePitch(_notes[i]);
|
uint8_t pitch = notePitch(_notes[i]);
|
||||||
uint8_t octave = noteOctave(_notes[i]);
|
uint8_t octave = noteOctave(_notes[i]);
|
||||||
uint8_t dur_val = DUR_VALS[noteDurIdx(_notes[i])];
|
uint8_t dur_val = DUR_VALS[noteDurIdx(_notes[i])];
|
||||||
if (pitch == 0)
|
if (pitch == 0)
|
||||||
pos += snprintf(buf + pos, buf_len - pos, "%dp", dur_val);
|
pos += snprintf(_play_buf + pos, sizeof(_play_buf) - pos, "%dp", dur_val);
|
||||||
else
|
else
|
||||||
pos += snprintf(buf + pos, buf_len - pos, "%d%c%d", dur_val, PITCH_NAMES[pitch], octave);
|
pos += snprintf(_play_buf + pos, sizeof(_play_buf) - pos, "%d%c%d", dur_val, PITCH_NAMES[pitch], octave);
|
||||||
}
|
}
|
||||||
if (pos < buf_len) buf[pos] = '\0';
|
if (pos < (int)sizeof(_play_buf)) _play_buf[pos] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void previewNote(uint8_t note_byte) {
|
void previewNote(uint8_t note_byte) {
|
||||||
uint8_t pitch = notePitch(note_byte);
|
uint8_t pitch = notePitch(note_byte);
|
||||||
if (pitch == 0) { _task->stopMelody(); return; }
|
if (pitch == 0) { _task->stopMelody(); return; }
|
||||||
char buf[28];
|
snprintf(_play_buf, sizeof(_play_buf), "P:d=16,o=5,b=240:%c%d", PITCH_NAMES[pitch], noteOctave(note_byte));
|
||||||
snprintf(buf, sizeof(buf), "P:d=16,o=5,b=240:%c%d", PITCH_NAMES[pitch], noteOctave(note_byte));
|
_task->playMelody(_play_buf);
|
||||||
_task->playMelody(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -211,9 +211,8 @@ public:
|
|||||||
if (_task->isMelodyPlaying()) {
|
if (_task->isMelodyPlaying()) {
|
||||||
_task->stopMelody();
|
_task->stopMelody();
|
||||||
} else if (_len > 0) {
|
} else if (_len > 0) {
|
||||||
char buf[220];
|
buildRTTTL();
|
||||||
buildRTTTL(buf, sizeof(buf));
|
_task->playMelody(_play_buf);
|
||||||
_task->playMelody(buf);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case M_DURATION:
|
case M_DURATION:
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class SettingsScreen : public UIScreen {
|
|||||||
BRIGHTNESS,
|
BRIGHTNESS,
|
||||||
AUTO_OFF,
|
AUTO_OFF,
|
||||||
BATT_DISPLAY,
|
BATT_DISPLAY,
|
||||||
|
CLOCK_SECONDS,
|
||||||
// Sound section
|
// Sound section
|
||||||
SECTION_SOUND,
|
SECTION_SOUND,
|
||||||
BUZZER,
|
BUZZER,
|
||||||
@@ -350,7 +351,9 @@ class SettingsScreen : public UIScreen {
|
|||||||
display.print("Buzzer");
|
display.print("Buzzer");
|
||||||
display.setCursor(VAL_X, y);
|
display.setCursor(VAL_X, y);
|
||||||
#ifdef PIN_BUZZER
|
#ifdef PIN_BUZZER
|
||||||
display.print(_task->isBuzzerQuiet() ? "OFF" : "ON");
|
{ static const char* labels[] = { "ON", "OFF", "Auto" };
|
||||||
|
int m = _task->getBuzzerMode();
|
||||||
|
display.print(labels[m < 3 ? m : 0]); }
|
||||||
#else
|
#else
|
||||||
display.print("N/A");
|
display.print("N/A");
|
||||||
#endif
|
#endif
|
||||||
@@ -399,6 +402,10 @@ class SettingsScreen : public UIScreen {
|
|||||||
display.setCursor(VAL_X, y);
|
display.setCursor(VAL_X, y);
|
||||||
uint8_t mode = p ? p->batt_display_mode : 0;
|
uint8_t mode = p ? p->batt_display_mode : 0;
|
||||||
display.print(BATT_DISPLAY_LABELS[mode < BATT_DISPLAY_COUNT ? mode : 0]);
|
display.print(BATT_DISPLAY_LABELS[mode < BATT_DISPLAY_COUNT ? mode : 0]);
|
||||||
|
} else if (item == CLOCK_SECONDS) {
|
||||||
|
display.print("Seconds");
|
||||||
|
display.setCursor(VAL_X, y);
|
||||||
|
display.print((p && p->clock_hide_seconds) ? "OFF" : "ON");
|
||||||
} else if (item == DM_FILTER) {
|
} else if (item == DM_FILTER) {
|
||||||
display.print("DM");
|
display.print("DM");
|
||||||
display.setCursor(VAL_X, y);
|
display.setCursor(VAL_X, y);
|
||||||
@@ -615,11 +622,11 @@ public:
|
|||||||
_edit_ph_mode = true;
|
_edit_ph_mode = true;
|
||||||
_edit_ph_sel = 0;
|
_edit_ph_sel = 0;
|
||||||
} else {
|
} else {
|
||||||
// OK — save
|
// OK — commit to prefs, save deferred to settings exit
|
||||||
if (p) {
|
if (p) {
|
||||||
strncpy(p->custom_msgs[_edit_slot], _edit_buf, sizeof(p->custom_msgs[0]) - 1);
|
strncpy(p->custom_msgs[_edit_slot], _edit_buf, sizeof(p->custom_msgs[0]) - 1);
|
||||||
p->custom_msgs[_edit_slot][sizeof(p->custom_msgs[0]) - 1] = '\0';
|
p->custom_msgs[_edit_slot][sizeof(p->custom_msgs[0]) - 1] = '\0';
|
||||||
the_mesh.savePrefs();
|
_dirty = true;
|
||||||
}
|
}
|
||||||
_edit_slot = -1;
|
_edit_slot = -1;
|
||||||
}
|
}
|
||||||
@@ -666,7 +673,8 @@ public:
|
|||||||
return right || left;
|
return right || left;
|
||||||
}
|
}
|
||||||
if (_selected == BUZZER && (left || right || enter)) {
|
if (_selected == BUZZER && (left || right || enter)) {
|
||||||
_task->toggleBuzzer(); // saves immediately internally
|
_task->cycleBuzzerMode();
|
||||||
|
_dirty = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_selected == BUZZER_VOLUME) {
|
if (_selected == BUZZER_VOLUME) {
|
||||||
@@ -721,6 +729,11 @@ public:
|
|||||||
if (left) idx = (idx + BATT_DISPLAY_COUNT - 1) % BATT_DISPLAY_COUNT;
|
if (left) idx = (idx + BATT_DISPLAY_COUNT - 1) % BATT_DISPLAY_COUNT;
|
||||||
if (left || right) { p->batt_display_mode = idx; _dirty = true; return true; }
|
if (left || right) { p->batt_display_mode = idx; _dirty = true; return true; }
|
||||||
}
|
}
|
||||||
|
if (_selected == CLOCK_SECONDS && p && (left || right || enter)) {
|
||||||
|
p->clock_hide_seconds ^= 1;
|
||||||
|
_dirty = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (_selected == DM_FILTER && p && (left || right || enter)) {
|
if (_selected == DM_FILTER && p && (left || right || enter)) {
|
||||||
p->dm_show_all = p->dm_show_all ? 0 : 1;
|
p->dm_show_all = p->dm_show_all ? 0 : 1;
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
@@ -1237,7 +1250,7 @@ public:
|
|||||||
if (ring_pos >= 0) {
|
if (ring_pos >= 0) {
|
||||||
const char* ftext = _hist[ring_pos].text;
|
const char* ftext = _hist[ring_pos].text;
|
||||||
const char* fsep = strstr(ftext, ": ");
|
const char* fsep = strstr(ftext, ": ");
|
||||||
char fsender[22], fmsg[79];
|
char fsender[22], fmsg[140];
|
||||||
if (fsep) {
|
if (fsep) {
|
||||||
int nl = fsep - ftext; if (nl > 21) nl = 21;
|
int nl = fsep - ftext; if (nl > 21) nl = 21;
|
||||||
strncpy(fsender, ftext, nl); fsender[nl] = '\0';
|
strncpy(fsender, ftext, nl); fsender[nl] = '\0';
|
||||||
@@ -1992,7 +2005,11 @@ public:
|
|||||||
char buf[24];
|
char buf[24];
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
display.setTextSize(2);
|
display.setTextSize(2);
|
||||||
|
bool show_sec = !_node_prefs || !_node_prefs->clock_hide_seconds;
|
||||||
|
if (show_sec)
|
||||||
sprintf(buf, "%02d:%02d:%02d", ti->tm_hour, ti->tm_min, ti->tm_sec);
|
sprintf(buf, "%02d:%02d:%02d", ti->tm_hour, ti->tm_min, ti->tm_sec);
|
||||||
|
else
|
||||||
|
sprintf(buf, "%02d:%02d", ti->tm_hour, ti->tm_min);
|
||||||
display.drawTextCentered(display.width() / 2, 18, buf);
|
display.drawTextCentered(display.width() / 2, 18, buf);
|
||||||
|
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
@@ -2209,7 +2226,11 @@ public:
|
|||||||
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate:" PRESS_LABEL);
|
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate:" PRESS_LABEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (_page == HomePage::CLOCK) ? 1000 : 5000;
|
if (_page == HomePage::CLOCK) {
|
||||||
|
bool show_sec = !_node_prefs || !_node_prefs->clock_hide_seconds;
|
||||||
|
return show_sec ? 1000 : 60000;
|
||||||
|
}
|
||||||
|
return 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleInput(char c) override {
|
bool handleInput(char c) override {
|
||||||
@@ -2604,6 +2625,13 @@ void UITask::loop() {
|
|||||||
userLedHandler();
|
userLedHandler();
|
||||||
|
|
||||||
#ifdef PIN_BUZZER
|
#ifdef PIN_BUZZER
|
||||||
|
if (_node_prefs && _node_prefs->buzzer_auto) {
|
||||||
|
bool should_quiet = hasConnection();
|
||||||
|
if (buzzer.isQuiet() != should_quiet) {
|
||||||
|
buzzer.quiet(should_quiet);
|
||||||
|
_next_refresh = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (buzzer.isPlaying()) buzzer.loop();
|
if (buzzer.isPlaying()) buzzer.loop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2776,17 +2804,41 @@ void UITask::setBuzzerVolumeLevel(uint8_t level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UITask::toggleBuzzer() {
|
void UITask::toggleBuzzer() {
|
||||||
// Toggle buzzer quiet mode
|
|
||||||
#ifdef PIN_BUZZER
|
#ifdef PIN_BUZZER
|
||||||
|
if (_node_prefs) _node_prefs->buzzer_auto = 0; // exit auto mode
|
||||||
if (buzzer.isQuiet()) {
|
if (buzzer.isQuiet()) {
|
||||||
buzzer.quiet(false);
|
buzzer.quiet(false);
|
||||||
notify(UIEventType::ack);
|
notify(UIEventType::ack);
|
||||||
} else {
|
} else {
|
||||||
buzzer.quiet(true);
|
buzzer.quiet(true);
|
||||||
}
|
}
|
||||||
_node_prefs->buzzer_quiet = buzzer.isQuiet();
|
if (_node_prefs) _node_prefs->buzzer_quiet = buzzer.isQuiet();
|
||||||
the_mesh.savePrefs();
|
the_mesh.savePrefs();
|
||||||
showAlert(buzzer.isQuiet() ? "Buzzer: OFF" : "Buzzer: ON", 800);
|
showAlert(buzzer.isQuiet() ? "Buzzer: OFF" : "Buzzer: ON", 800);
|
||||||
_next_refresh = 0; // trigger refresh
|
_next_refresh = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UITask::getBuzzerMode() {
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
if (_node_prefs && _node_prefs->buzzer_auto) return 2;
|
||||||
|
return buzzer.isQuiet() ? 1 : 0;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::cycleBuzzerMode() {
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
if (!_node_prefs) return;
|
||||||
|
int mode = getBuzzerMode();
|
||||||
|
mode = (mode + 1) % 3; // ON(0) → OFF(1) → Auto(2) → ON
|
||||||
|
_node_prefs->buzzer_auto = (mode == 2) ? 1 : 0;
|
||||||
|
if (mode == 0) { buzzer.quiet(false); _node_prefs->buzzer_quiet = 0; notify(UIEventType::ack); }
|
||||||
|
if (mode == 1) { buzzer.quiet(true); _node_prefs->buzzer_quiet = 1; }
|
||||||
|
if (mode == 2) { buzzer.quiet(hasConnection()); }
|
||||||
|
static const char* labels[] = { "Buzzer: ON", "Buzzer: OFF", "Buzzer: Auto" };
|
||||||
|
showAlert(labels[mode], 800);
|
||||||
|
_next_refresh = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void toggleBuzzer();
|
void toggleBuzzer();
|
||||||
|
void cycleBuzzerMode(); // ON → OFF → Auto → ON
|
||||||
|
int getBuzzerMode(); // 0=ON, 1=OFF, 2=Auto
|
||||||
bool getGPSState();
|
bool getGPSState();
|
||||||
void toggleGPS();
|
void toggleGPS();
|
||||||
void applyBrightness();
|
void applyBrightness();
|
||||||
|
|||||||
Reference in New Issue
Block a user