kopia lustrzana https://github.com/meshtastic/firmware
Merge branch 'master' into create-pull-request/patch
commit
54bf02352f
|
@ -8,8 +8,13 @@ void playBeep(){};
|
|||
void playStartMelody(){};
|
||||
void playShutdownMelody(){};
|
||||
|
||||
#else
|
||||
#ifdef M5STACK
|
||||
#include "Speaker.h"
|
||||
TONE Tone;
|
||||
#else
|
||||
#include "Tone.h"
|
||||
#endif
|
||||
|
||||
extern "C" void delay(uint32_t dwMs);
|
||||
|
||||
|
@ -38,13 +43,26 @@ const int DURATION_1_4 = 250; // 1/4 note
|
|||
void playTones(const ToneDuration *tone_durations, int size) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
const auto &tone_duration = tone_durations[i];
|
||||
#ifdef M5STACK
|
||||
Tone.tone(tone_duration.frequency_khz);
|
||||
delay(tone_duration.duration_ms);
|
||||
Tone.mute();
|
||||
#else
|
||||
tone(PIN_BUZZER, tone_duration.frequency_khz, tone_duration.duration_ms);
|
||||
#endif
|
||||
// to distinguish the notes, set a minimum time between them.
|
||||
delay(1.3 * tone_duration.duration_ms);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef M5STACK
|
||||
void playBeep() {
|
||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4}};
|
||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||
}
|
||||
#else
|
||||
void playBeep() { tone(PIN_BUZZER, NOTE_B3, DURATION_1_4); }
|
||||
#endif
|
||||
|
||||
void playStartMelody() {
|
||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4},
|
||||
|
|
|
@ -269,6 +269,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
|
||||
|
||||
#elif defined(M5STACK)
|
||||
|
||||
#define HW_VENDOR HardwareModel_M5STACK
|
||||
|
||||
#elif NRF52_SERIES
|
||||
|
||||
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#include "Speaker.h"
|
||||
|
||||
TONE::TONE(void) {
|
||||
_volume = 5;
|
||||
_begun = false;
|
||||
}
|
||||
|
||||
void TONE::begin() {
|
||||
_begun = true;
|
||||
ledcSetup(TONE_PIN_CHANNEL, 0, 13);
|
||||
ledcAttachPin(PIN_BUZZER, TONE_PIN_CHANNEL);
|
||||
}
|
||||
|
||||
void TONE::end() {
|
||||
mute();
|
||||
ledcDetachPin(PIN_BUZZER);
|
||||
_begun = false;
|
||||
}
|
||||
|
||||
void TONE::tone(uint16_t frequency) {
|
||||
if(!_begun) begin();
|
||||
ledcWriteTone(TONE_PIN_CHANNEL, frequency);
|
||||
ledcWrite(TONE_PIN_CHANNEL, 0x400 >> _volume);
|
||||
}
|
||||
|
||||
void TONE::setVolume(uint8_t volume) {
|
||||
_volume = 11 - volume;
|
||||
}
|
||||
|
||||
void TONE::mute() {
|
||||
ledcWriteTone(TONE_PIN_CHANNEL, 0);
|
||||
digitalWrite(PIN_BUZZER, 0);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef _SPEAKER_H_
|
||||
#define _SPEAKER_H_
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
#include "esp32-hal-dac.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
class TONE {
|
||||
public:
|
||||
TONE(void);
|
||||
|
||||
void begin();
|
||||
void end();
|
||||
void mute();
|
||||
void tone(uint16_t frequency);
|
||||
void setVolume(uint8_t volume);
|
||||
|
||||
private:
|
||||
uint8_t _volume;
|
||||
bool _begun;
|
||||
bool speaker_on;
|
||||
};
|
||||
#endif
|
|
@ -4,8 +4,11 @@ board = m5stack-core-esp32
|
|||
upload_port = COM8
|
||||
monitor_port = COM8
|
||||
monitor_filters = esp32_exception_decoder
|
||||
src_filter =
|
||||
${esp32_base.src_filter}
|
||||
+<../variants/m5stack_core>
|
||||
build_flags =
|
||||
${esp32_base.build_flags} -D PRIVATE_HW -I variants/m5stack_core
|
||||
${esp32_base.build_flags} -I variants/m5stack_core
|
||||
-DILI9341_DRIVER
|
||||
-DM5STACK
|
||||
-DUSER_SETUP_LOADED
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
#define BUTTON_PIN 38
|
||||
|
||||
#define PIN_BUZZER 25
|
||||
#define TONE_PIN_CHANNEL 0
|
||||
|
||||
#undef RF95_SCK
|
||||
#undef RF95_MISO
|
||||
#undef RF95_MOSI
|
||||
|
@ -32,8 +35,6 @@
|
|||
#define GPS_RX_PIN 16
|
||||
#define GPS_TX_PIN 17
|
||||
|
||||
#define NO_GPS
|
||||
|
||||
// Define if screen should be mirrored left to right
|
||||
#define SCREEN_ROTATE
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue