Skip to content

Commit d4218db

Browse files
committed
Series-II @ HW v0.2 ready
1 parent e814146 commit d4218db

12 files changed

+277
-357
lines changed

src/drivers/ui/SaboCoverUI/sabo_cover_ui_cabo_driver_base.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void SaboCoverUICaboDriverBase::ProcessLedStates() {
105105
current_led_mask_ |= leds_.fast_blink_state ? leds_.fast_blink_mask : 0;
106106
}
107107

108-
void SaboCoverUICaboDriverBase::DebounceRawButtons(const uint16_t raw_buttons) {
108+
void SaboCoverUICaboDriverBase::DebounceRawButtons(uint16_t raw_buttons) {
109109
static uint16_t btn_last_raw_mask_ = 0xFFFF; // Last raw button state
110110
static size_t btn_debounce_counter_ = 0; // If >= DEBOUNCE_TICKS, the button state is stable/debounced
111111

@@ -119,13 +119,18 @@ void SaboCoverUICaboDriverBase::DebounceRawButtons(const uint16_t raw_buttons) {
119119
btn_last_raw_mask_ = raw_buttons;
120120
}
121121

122-
bool SaboCoverUICaboDriverBase::IsButtonPressed(const ButtonID btn) const {
122+
bool SaboCoverUICaboDriverBase::IsButtonPressed(ButtonID btn) const {
123123
if (!series_) return false;
124124
auto btn_mask = series_->MapButtonIDToMask(btn);
125125
if (btn_mask == 0) return false; // Unknown button ID = "not pressed"
126126
return (btn_stable_raw_mask_ & series_->MapButtonIDToMask(btn)) == 0; // low-active
127127
}
128128

129+
bool SaboCoverUICaboDriverBase::IsAnyButtonPressed() const {
130+
if (!series_) return false;
131+
return (btn_stable_raw_mask_ & series_->AllButtonsMask()) != series_->AllButtonsMask(); // low-active
132+
}
133+
129134
bool SaboCoverUICaboDriverBase::IsReady() const {
130135
return state_ == DriverState::READY;
131136
}

src/drivers/ui/SaboCoverUI/sabo_cover_ui_cabo_driver_base.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include "ch.h"
99
#include "hal.h"
10+
#include "sabo_cover_ui_defs.hpp"
1011
#include "sabo_cover_ui_series_interface.hpp"
11-
#include "sabo_cover_ui_types.hpp"
1212

1313
namespace xbot::driver::ui {
1414

@@ -18,23 +18,25 @@ class SaboCoverUICaboDriverBase {
1818
public:
1919
explicit SaboCoverUICaboDriverBase(CaboCfg cabo_cfg) : cabo_cfg_(cabo_cfg){};
2020

21-
// 4 * 10ms(tick) / 2(alternating button rows) = 20ms debounce time
22-
// Series-I has no alternating button rows, so it will debounce in 40ms (who cares)
23-
static constexpr uint8_t DEBOUNCE_TICKS = 4;
21+
// 6 * 10ms(tick) / 2(alternating button rows) = 30ms debounce time
22+
// Series-I has no alternating button rows, so it will debounce in 60ms (who cares)
23+
static constexpr uint8_t DEBOUNCE_TICKS = 5;
2424

2525
virtual bool Init(); // Init GPIOs, SPI and assign series_ driver
2626
virtual void LatchLoad() = 0; // Latch data (LEDs, Button-rows, signals) and load inputs (buttons, signals, ...)
2727
virtual void PowerOnAnimation(); // KIT like anim
28-
virtual bool IsButtonPressed(const ButtonID btn) const; // Check if a specific button is pressed
29-
virtual void Tick(); // Call this function every 1ms to update LEDs, read and debounce buttons, ...
28+
virtual void Tick(); // Call this function every 1ms to update LEDs, read and debounce buttons, ...
29+
30+
bool IsButtonPressed(ButtonID btn) const; // Check if a specific button is pressed
31+
bool IsAnyButtonPressed() const; // Check if any button is pressed
3032

3133
bool IsReady() const; // True if CoverUI detected, boot anim played and ready to serve requests
3234

3335
void SetLED(LEDID id, LEDMode mode); // Set state of a single LED
3436

3537
// Debounce all raw buttons at once in one quick XOR operation
3638
// This Method needs to be called by driver implementation once it read the buttons
37-
void DebounceRawButtons(const uint16_t raw_buttons);
39+
void DebounceRawButtons(uint16_t raw_buttons);
3840

3941
protected:
4042
CaboCfg cabo_cfg_;

src/drivers/ui/SaboCoverUI/sabo_cover_ui_cabo_driver_v02.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SaboCoverUICaboDriverV02 : public SaboCoverUICaboDriverBase {
3434
// Relevant input bits of 74HC165 parallel-input shift register
3535
static constexpr uint16_t INP_MASK_S1_CONNECTED_L = (1 << 2); // Series-I CoverUI /Connected
3636
static constexpr uint16_t INP_MASK_S2_CONNECTED_L = (1 << 9); // Series-II CoverUI /Connected
37-
static constexpr uint16_t INP_MASK_JP3_L = (1 << 11); // Mainboard solder jumper JP3
37+
static constexpr uint16_t INP_MASK_JP3_L = (1 << 11); // Carrierboard solder jumper JP3
3838

3939
// See also LED and Button bits in sabo_cover_ui_series1_v02.hpp
4040

@@ -70,7 +70,7 @@ class SaboCoverUICaboDriverV02 : public SaboCoverUICaboDriverBase {
7070
return true;
7171
}
7272

73-
// Latch LEDs (as well as button-row if existent) and load button columns
73+
// Latch LEDs (as well as button-row if exists) and load button columns
7474
void LatchLoad() override {
7575
if (!series_) return;
7676

src/drivers/ui/SaboCoverUI/sabo_cover_ui_controller.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,19 @@ const char* SaboCoverUIController::ButtonIDToString(const ButtonID id) {
127127

128128
void SaboCoverUIController::ThreadFunc() {
129129
if (display_) {
130-
SaboCoverUIDisplayDriverUC1698::Instance().Start();
130+
display_->Start();
131131
display_->WakeUp();
132132
}
133133

134+
ULOG_INFO("Controller-Thread: %p", chThdGetSelfX());
135+
134136
while (true) {
135137
cabo_->Tick();
136138
UpdateStates();
137-
if (display_) display_->Tick();
139+
if (display_) {
140+
display_->Tick();
141+
if (cabo_->IsAnyButtonPressed()) display_->WakeUp();
142+
}
138143

139144
// ----- Debug -----
140145
static uint32_t last_debug_time = 0;

src/drivers/ui/SaboCoverUI/sabo_cover_ui_controller.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "ch.h"
99
#include "sabo_cover_ui_cabo_driver_v01.hpp"
1010
#include "sabo_cover_ui_cabo_driver_v02.hpp"
11+
#include "sabo_cover_ui_defs.hpp"
1112
#include "sabo_cover_ui_display.hpp"
12-
#include "sabo_cover_ui_types.hpp"
1313

1414
namespace xbot::driver::ui {
1515

@@ -24,7 +24,7 @@ class SaboCoverUIController {
2424
static const char* ButtonIDToString(const ButtonID id); // Get string for ButtonID
2525

2626
private:
27-
THD_WORKING_AREA(wa_, 8192);
27+
THD_WORKING_AREA(wa_, 4096); // AH20250714 In use = 2912. Let's be save for future LVGL GUI
2828
thread_t* thread_ = nullptr;
2929

3030
bool configured_ = false;

src/drivers/ui/SaboCoverUI/sabo_cover_ui_types.hpp renamed to src/drivers/ui/SaboCoverUI/sabo_cover_ui_defs.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Created by Apehaenger on 5/31/25.
33
//
44

5-
#ifndef OPENMOWER_SABO_COVER_UI_TYPES_HPP
6-
#define OPENMOWER_SABO_COVER_UI_TYPES_HPP
5+
#ifndef OPENMOWER_SABO_COVER_UI_DEFS_HPP
6+
#define OPENMOWER_SABO_COVER_UI_DEFS_HPP
77

88
#include "ch.h"
99

@@ -68,6 +68,15 @@ enum class ButtonID {
6868

6969
enum class SeriesType { Series1, Series2 };
7070

71+
namespace display {
72+
constexpr uint16_t LCD_WIDTH = 240; // ATTENTION: LVGL I1 mode requires a multiple of 8 width
73+
constexpr uint16_t LCD_HEIGHT = 160;
74+
constexpr uint8_t BUFFER_FRACTION = 10; // 1/10 screen size for buffers
75+
76+
constexpr systime_t BACKLIGHT_TIMEOUT = TIME_S2I(120); // 2 Minutes
77+
constexpr systime_t LCD_SLEEP_TIMEOUT = TIME_S2I(300); // 5 Minutes
78+
} // namespace display
79+
7180
} // namespace xbot::driver::ui::sabo
7281

73-
#endif // OPENMOWER_SABO_COVER_UI_TYPES_HPP
82+
#endif // OPENMOWER_SABO_COVER_UI_DEFS_HPP

0 commit comments

Comments
 (0)