Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions targets/embedded_esp32s3/main/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ constexpr uint16_t kHeight = 135;
namespace spi {
constexpr int kMosiGpio = 35;
constexpr int kSclkGpio = 36;
constexpr int kCsGpio = 37;
constexpr int kCsGpio = 7;
} // namespace spi

constexpr int kDcGpio = 38;
constexpr int kResetGpio = 39;
constexpr int kBacklightGpio = 40;
constexpr int kDcGpio = 39;
constexpr int kResetGpio = 40;
constexpr int kBacklightGpio = 38;
} // namespace tft

namespace encoder {
Expand All @@ -45,10 +45,11 @@ namespace encoder {
constexpr int kA = 14;
constexpr int kB = 15;
constexpr int kSwitch = 16;
constexpr bool kPresent = false; // Set true on board revisions with populated rotary encoder.
} // namespace encoder

namespace controls {
constexpr int kBypassButton = 5;
constexpr int kBypassButton = 9;
} // namespace controls

// Guard against accidental overlap with active audio I2S signals.
Expand Down
18 changes: 13 additions & 5 deletions targets/embedded_esp32s3/main/ui_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ class UserInterface {
bool init(uint8_t* framebuffer) {
if (!display_.init(framebuffer)) return false;

if (!encoder_.init()) return false;
enc_btn_.init();
encoder_available_ = board::encoder::kPresent;
if (encoder_available_) {
encoder_available_ = encoder_.init();
if (encoder_available_) {
enc_btn_.init();
}
}
bypass_btn_.init();

// Initialize parameters matching the requested grid layout
Expand All @@ -53,7 +58,9 @@ class UserInterface {
}

void tick(ParameterBridge& bridge) {
enc_btn_.update();
if (encoder_available_) {
enc_btn_.update();
}
bypass_btn_.update();

if (bypass_btn_.justPressed()) {
Expand All @@ -63,13 +70,13 @@ class UserInterface {
display_.update();
}

if (enc_btn_.justPressed()) {
if (encoder_available_ && enc_btn_.justPressed()) {
mode_ = (mode_ == UiMode::Scroll) ? UiMode::Edit : UiMode::Scroll;
drawUI();
display_.update();
}

int delta = encoder_.getDelta();
int delta = encoder_available_ ? encoder_.getDelta() : 0;
if (delta != 0) {
if (mode_ == UiMode::Scroll) {
selected_idx_ += delta;
Expand Down Expand Up @@ -244,6 +251,7 @@ class UserInterface {
int selected_idx_ = 0;
UiMode mode_ = UiMode::Scroll;
bool bypassed_ = false;
bool encoder_available_ = false;
};

} // namespace orbit::embedded::ui