mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 06:17:42 +00:00
Digit Mode for frequency field (#1298)
* Remove 'auto' step mode * Support per-digit edits on the freq field. * Swizzle instead of raw accessor * Fix debug ui after swizzle
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "irq_controls.hpp"
|
||||
#include "sine_table.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
@@ -102,4 +103,14 @@ Point fast_polar_to_point(int32_t angle, uint32_t distance) {
|
||||
(int16_sin_s4(((1 << 16) * (-angle - 90)) / 360) * distance) / (1 << 16));
|
||||
}
|
||||
|
||||
bool key_is_long_pressed(KeyEvent key) {
|
||||
if (key < KeyEvent::Back) {
|
||||
// TODO: this would make more sense as a flag on KeyEvent
|
||||
// passed up to the UI via event dispatch.
|
||||
return switch_is_long_pressed(static_cast<Switch>(key));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
@@ -34,6 +34,10 @@ using Dim = int16_t;
|
||||
constexpr uint16_t screen_width = 240;
|
||||
constexpr uint16_t screen_height = 320;
|
||||
|
||||
/* Dimensions for the default font character. */
|
||||
constexpr uint16_t char_width = 8;
|
||||
constexpr uint16_t char_height = 16;
|
||||
|
||||
struct Color {
|
||||
uint16_t v; // rrrrrGGGGGGbbbbb
|
||||
|
||||
@@ -328,7 +332,7 @@ struct Bitmap {
|
||||
const uint8_t* const data;
|
||||
};
|
||||
|
||||
enum class KeyEvent {
|
||||
enum class KeyEvent : uint8_t {
|
||||
/* Ordinals map to bit positions reported by CPLD */
|
||||
Right = 0,
|
||||
Left = 1,
|
||||
@@ -356,6 +360,11 @@ Point polar_to_point(float angle, uint32_t distance);
|
||||
|
||||
Point fast_polar_to_point(int32_t angle, uint32_t distance);
|
||||
|
||||
/* Default font glyph size. */
|
||||
constexpr Size char_size{char_width, char_height};
|
||||
|
||||
bool key_is_long_pressed(KeyEvent key);
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif /*__UI_H__*/
|
||||
|
@@ -53,6 +53,12 @@ constexpr typename std::underlying_type<E>::type toUType(E enumerator) noexcept
|
||||
return static_cast<typename std::underlying_type<E>::type>(enumerator);
|
||||
}
|
||||
|
||||
/* Increments an enum value. Enumerator values are assumed to be serial. */
|
||||
template <typename E>
|
||||
void incr(E& e) {
|
||||
e = static_cast<E>(toUType(e) + 1);
|
||||
}
|
||||
|
||||
inline uint32_t flp2(uint32_t v) {
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
|
Reference in New Issue
Block a user