added dfu button to debug app

This commit is contained in:
Bernd Herzog
2023-04-16 18:23:54 +02:00
parent 8382eaf45f
commit bcefa774cd
10 changed files with 27 additions and 10 deletions

View File

@@ -266,7 +266,7 @@ bool ControlsSwitchesWidget::on_key(const KeyEvent key) {
}
void ControlsSwitchesWidget::paint(Painter& painter) {
const std::array<Rect, 7> button_rects { {
const std::array<Rect, 8> button_rects { {
{ 64, 32, 16, 16 }, // Right
{ 0, 32, 16, 16 }, // Left
{ 32, 64, 16, 16 }, // Down
@@ -274,10 +274,12 @@ void ControlsSwitchesWidget::paint(Painter& painter) {
{ 32, 32, 16, 16 }, // Select
{ 16, 96, 16, 16 }, // Encoder phase 0
{ 48, 96, 16, 16 }, // Encoder phase 1
{ 64, 0, 16, 16 }, // Dfu
} };
const auto pos = screen_pos();
auto switches_raw = control::debug::switches();
auto switches_debounced = get_switches_state().to_ulong();
auto switches_raw = control::debug::switches(); // all 7 + dfu
auto switches_debounced = get_switches_state().to_ulong(); // stops at 5, 6 is dfu
switches_debounced = (switches_debounced & 0x1f) | ((switches_debounced >> 5) << 7);
auto switches_event = key_event_mask;
for(const auto r : button_rects) {

View File

@@ -42,7 +42,7 @@ using namespace hackrf::one;
static Thread* thread_controls_event = NULL;
static std::array<Debounce, 7> switch_debounce;
static std::array<Debounce, 8> switch_debounce;
static Encoder encoder;
@@ -193,11 +193,13 @@ void controls_init() {
SwitchesState get_switches_state() {
SwitchesState result;
for(size_t i=0; i<result.size(); i++) {
for(size_t i=0; i<result.size()-1; i++) {
// TODO: Ignore multiple keys at the same time?
result[i] = switch_debounce[i].state();
}
result[result.size()-1] = switch_debounce[switch_debounce.size()-1].state();
return result;
}

View File

@@ -33,9 +33,10 @@ enum class Switch {
Down = 2,
Up = 3,
Sel = 4,
Dfu = 5,
};
using SwitchesState = std::bitset<5>;
using SwitchesState = std::bitset<6>;
using EncoderPosition = uint32_t;

View File

@@ -61,7 +61,7 @@ portapack::IO io {
portapack::gpio_io_stbx,
portapack::gpio_addr,
portapack::gpio_lcd_te,
portapack::gpio_unused,
portapack::gpio_dfu,
};
portapack::BacklightCAT4004 backlight_cat4004;