* refactored buzzer concept to UITask
* moved buzzer.h/cpp to helpers/ui
This commit is contained in:
@@ -53,6 +53,18 @@ void UITask::begin(DisplayDriver* display, NodePrefs* node_prefs, const char* bu
|
|||||||
|
|
||||||
// v1.2.3 (1 Jan 2025)
|
// v1.2.3 (1 Jan 2025)
|
||||||
sprintf(_version_info, "%s (%s)", version, build_date);
|
sprintf(_version_info, "%s (%s)", version, build_date);
|
||||||
|
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
buzzer.begin();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::soundBuzzer() {
|
||||||
|
#if defined(PIN_BUZZER)
|
||||||
|
// gemini's pick
|
||||||
|
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
|
||||||
|
//Serial.println("DBG: Buzzzzzz");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::msgRead(int msgcount) {
|
void UITask::msgRead(int msgcount) {
|
||||||
@@ -248,6 +260,10 @@ void UITask::loop() {
|
|||||||
buttonHandler();
|
buttonHandler();
|
||||||
userLedHandler();
|
userLedHandler();
|
||||||
|
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
if (buzzer.isPlaying()) buzzer.loop();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_display != NULL && _display->isOn()) {
|
if (_display != NULL && _display->isOn()) {
|
||||||
static bool _firstBoot = true;
|
static bool _firstBoot = true;
|
||||||
if(_firstBoot && millis() >= BOOT_SCREEN_MILLIS) {
|
if(_firstBoot && millis() >= BOOT_SCREEN_MILLIS) {
|
||||||
|
|||||||
@@ -4,11 +4,18 @@
|
|||||||
#include <helpers/ui/DisplayDriver.h>
|
#include <helpers/ui/DisplayDriver.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
#include <helpers/ui/buzzer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "NodePrefs.h"
|
#include "NodePrefs.h"
|
||||||
|
|
||||||
class UITask {
|
class UITask {
|
||||||
DisplayDriver* _display;
|
DisplayDriver* _display;
|
||||||
mesh::MainBoard* _board;
|
mesh::MainBoard* _board;
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
genericBuzzer buzzer;
|
||||||
|
#endif
|
||||||
unsigned long _next_refresh, _auto_off;
|
unsigned long _next_refresh, _auto_off;
|
||||||
bool _connected;
|
bool _connected;
|
||||||
uint32_t _pin_code;
|
uint32_t _pin_code;
|
||||||
@@ -37,5 +44,6 @@ public:
|
|||||||
void clearMsgPreview();
|
void clearMsgPreview();
|
||||||
void msgRead(int msgcount);
|
void msgRead(int msgcount);
|
||||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
|
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
|
||||||
|
void soundBuzzer();
|
||||||
void loop();
|
void loop();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,11 +66,6 @@
|
|||||||
static UITask ui_task(&board);
|
static UITask ui_task(&board);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_BUZZER
|
|
||||||
#include "buzzer.h"
|
|
||||||
genericBuzzer buzzer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Believe it or not, this std C function is busted on some platforms!
|
// Believe it or not, this std C function is busted on some platforms!
|
||||||
static uint32_t _atoi(const char* sp) {
|
static uint32_t _atoi(const char* sp) {
|
||||||
uint32_t n = 0;
|
uint32_t n = 0;
|
||||||
@@ -488,15 +483,6 @@ class MyMesh : public BaseChatMesh {
|
|||||||
return 0; // queue is empty
|
return 0; // queue is empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void soundBuzzer() {
|
|
||||||
#if defined(PIN_BUZZER)
|
|
||||||
// gemini's pick
|
|
||||||
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
|
|
||||||
//Serial.println("DBG: Buzzzzzz");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float getAirtimeBudgetFactor() const override {
|
float getAirtimeBudgetFactor() const override {
|
||||||
return _prefs.airtime_factor;
|
return _prefs.airtime_factor;
|
||||||
@@ -533,7 +519,9 @@ protected:
|
|||||||
_serial->writeFrame(out_frame, 1 + PUB_KEY_SIZE);
|
_serial->writeFrame(out_frame, 1 + PUB_KEY_SIZE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
soundBuzzer();
|
#ifdef DISPLAY_CLASS
|
||||||
|
ui_task.soundBuzzer();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
saveContacts();
|
saveContacts();
|
||||||
@@ -594,7 +582,9 @@ protected:
|
|||||||
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
||||||
_serial->writeFrame(frame, 1);
|
_serial->writeFrame(frame, 1);
|
||||||
} else {
|
} else {
|
||||||
soundBuzzer();
|
#ifdef DISPLAY_CLASS
|
||||||
|
ui_task.soundBuzzer();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
ui_task.newMsg(path_len, from.name, text, offline_queue_len);
|
ui_task.newMsg(path_len, from.name, text, offline_queue_len);
|
||||||
@@ -645,7 +635,9 @@ protected:
|
|||||||
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
||||||
_serial->writeFrame(frame, 1);
|
_serial->writeFrame(frame, 1);
|
||||||
} else {
|
} else {
|
||||||
soundBuzzer();
|
#ifdef DISPLAY_CLASS
|
||||||
|
ui_task.soundBuzzer();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
ui_task.newMsg(path_len, "Public", text, offline_queue_len);
|
ui_task.newMsg(path_len, "Public", text, offline_queue_len);
|
||||||
@@ -1563,10 +1555,6 @@ public:
|
|||||||
ui_task.setHasConnection(_serial->isConnected());
|
ui_task.setHasConnection(_serial->isConnected());
|
||||||
ui_task.loop();
|
ui_task.loop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_BUZZER
|
|
||||||
if (buzzer.isPlaying()) buzzer.loop();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1634,10 +1622,6 @@ void setup() {
|
|||||||
|
|
||||||
board.begin();
|
board.begin();
|
||||||
|
|
||||||
#ifdef PIN_BUZZER
|
|
||||||
buzzer.begin();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
DisplayDriver* disp = NULL;
|
DisplayDriver* disp = NULL;
|
||||||
if (display.begin()) {
|
if (display.begin()) {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ build_flags = ${t1000-e.build_flags}
|
|||||||
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
|
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
|
||||||
build_src_filter = ${t1000-e.build_src_filter}
|
build_src_filter = ${t1000-e.build_src_filter}
|
||||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||||
|
+<helpers/ui/buzzer.cpp>
|
||||||
+<../examples/companion_radio/*.cpp>
|
+<../examples/companion_radio/*.cpp>
|
||||||
lib_deps = ${t1000-e.lib_deps}
|
lib_deps = ${t1000-e.lib_deps}
|
||||||
densaugeo/base64 @ ~1.4.0
|
densaugeo/base64 @ ~1.4.0
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Buzzer
|
// Buzzer
|
||||||
|
|
||||||
#define PIN_BUZZER (46)
|
// #define PIN_BUZZER (46)
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user