mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-08 14:42:33 -04:00
support for battery if any + TPMS app to ext (#2129)
* batt initial * batt widgets * settings modify * batt info screen * ability to hide icon * battView * redo tmps * hide curr + charge if no data * fix flashing
This commit is contained in:
parent
f572b00391
commit
f6a2d21624
23 changed files with 767 additions and 44 deletions
|
@ -33,6 +33,8 @@
|
|||
#include "portapack.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include "ui/ui_font_fixed_5x8.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -781,6 +783,52 @@ class TextField : public Text {
|
|||
using Text::set;
|
||||
};
|
||||
|
||||
class BatteryTextField : public Widget {
|
||||
public:
|
||||
std::function<void()> on_select{};
|
||||
|
||||
BatteryTextField(Rect parent_rect, uint8_t percent);
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
void set_battery(uint8_t percentage, bool charge);
|
||||
void set_text(std::string_view value);
|
||||
|
||||
bool on_key(KeyEvent key) override;
|
||||
bool on_touch(TouchEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
uint8_t percent_{102};
|
||||
bool charge_{false};
|
||||
|
||||
static constexpr Style style{
|
||||
.font = font::fixed_5x8,
|
||||
.background = Color::dark_grey(),
|
||||
.foreground = Color::white(),
|
||||
};
|
||||
};
|
||||
|
||||
class BatteryIcon : public Widget {
|
||||
public:
|
||||
std::function<void()> on_select{};
|
||||
|
||||
BatteryIcon(Rect parent_rect, uint8_t percent);
|
||||
void paint(Painter& painter) override;
|
||||
void set_battery(uint8_t percentage, bool charge);
|
||||
|
||||
bool on_key(KeyEvent key) override;
|
||||
bool on_touch(TouchEvent event) override;
|
||||
|
||||
void getAccessibilityText(std::string& result) override;
|
||||
void getWidgetName(std::string& result) override;
|
||||
|
||||
private:
|
||||
uint8_t percent_{102};
|
||||
bool charge_{false};
|
||||
};
|
||||
|
||||
class NumberField : public Widget {
|
||||
public:
|
||||
std::function<void(NumberField&)> on_select{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue