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:
Kyle Reed
2023-07-24 09:09:22 -07:00
committed by GitHub
parent e2bca9aebb
commit 3514a9a608
11 changed files with 230 additions and 95 deletions

View File

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

View File

@@ -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__*/

View File

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