mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 09:39:30 +00:00
add tap tempo to metronomic app (#2605)
* _ * format * fix new tree in Arch
This commit is contained in:
committed by
GitHub
parent
ecd1a217d7
commit
4bbe1175c1
@@ -27,6 +27,8 @@
|
||||
#include "audio.hpp"
|
||||
#include "ch.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
namespace ui::external_app::metronome {
|
||||
|
||||
class MetronomeView : public View {
|
||||
@@ -73,6 +75,11 @@ class MetronomeView : public View {
|
||||
1,
|
||||
' '};
|
||||
|
||||
Button button_enter_tap_tempo{
|
||||
{(sizeof("BPM:") + 6) * 8, 1 * 16, (sizeof("Tap Tempo") + 3) * 8, 16},
|
||||
"Tap Tempo",
|
||||
};
|
||||
|
||||
NumberField field_rythm_unaccent_time{// e.g. 3 in 3/4 beat
|
||||
{(sizeof("Rhythm:") + 1) * 8, 4 * 16},
|
||||
2,
|
||||
@@ -121,6 +128,45 @@ class MetronomeView : public View {
|
||||
{0 * 16, 8 * 16, screen_width, screen_height - 14 * 16}};
|
||||
};
|
||||
|
||||
class MetronomeTapTempoView : public View {
|
||||
public:
|
||||
std::function<void(uint16_t)> on_apply{};
|
||||
|
||||
MetronomeTapTempoView(NavigationView& nav, uint16_t bpm);
|
||||
|
||||
std::string title() const override { return "Tap.T"; };
|
||||
void focus() override;
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
private:
|
||||
void on_tap(Painter& painter);
|
||||
|
||||
NavigationView& nav_;
|
||||
|
||||
uint16_t bpm_{0};
|
||||
uint16_t bpm_when_entered_{0}; // this pass from MetronomeView and need to restore if user cancel
|
||||
std::deque<uint16_t> bpms_deque = {0}; // take average for recent taps to debounce
|
||||
uint32_t last_tap_time{0};
|
||||
|
||||
std::string input_buffer{""}; // needed by text_prompt
|
||||
|
||||
Button button_input{
|
||||
{0, 0, screen_width, 2 * 16},
|
||||
"Input BPM"};
|
||||
|
||||
Button button_tap{
|
||||
{0, 8 * 16, screen_width, 7 * 16},
|
||||
"Tap BPM"};
|
||||
|
||||
Button button_cancel{
|
||||
{1, 17 * 16, screen_width / 2 - 4, 2 * 16},
|
||||
"Cancel"};
|
||||
|
||||
Button button_apply{
|
||||
{1 + screen_width / 2 + 1, 17 * 16, screen_width / 2 - 4, 2 * 16},
|
||||
"Apply"};
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::metronome
|
||||
|
||||
#endif /*__UI_METRONOME_H__*/
|
||||
Reference in New Issue
Block a user