Merge branch 'master' into create-pull-request/patch

pull/1447/head
Thomas Göttgens 2022-05-10 10:46:36 +01:00 zatwierdzone przez GitHub
commit 54bf02352f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 94 dodań i 5 usunięć

Wyświetl plik

@ -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},

Wyświetl plik

@ -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

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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

Wyświetl plik

@ -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
@ -24,4 +27,4 @@ lib_ignore =
m5stack-core
lib_deps =
${esp32_base.lib_deps}
bodmer/TFT_eSPI@^2.4.61
bodmer/TFT_eSPI@^2.4.61

Wyświetl plik

@ -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,11 +35,9 @@
#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
// LCD screens are slow, so slowdown the wipe so it looks better
#define SCREEN_TRANSITION_MSECS 1
#define SCREEN_TRANSITION_FRAMERATE 1 // fps
#define SCREEN_TRANSITION_FRAMERATE 1 // fps