mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-11-22 13:01:00 -05:00
Standalone imp (#2791)
* Moved ui elements to common folder in standalone, and add screen parameters to the api v4 * pass it as a pointer, so if standalone app supports it can change
This commit is contained in:
parent
d80f41e9d7
commit
9afd3a9dca
45 changed files with 39 additions and 14 deletions
|
|
@ -233,6 +233,9 @@ standalone_application_api_t api = {
|
|||
.draw_pixels = &ext_draw_pixels,
|
||||
.draw_pixel = &ext_draw_pixel,
|
||||
.exit_app = &exit_app,
|
||||
// version 4
|
||||
.screen_height = &screen_height,
|
||||
.screen_width = &screen_width,
|
||||
};
|
||||
|
||||
StandaloneView::StandaloneView(NavigationView& nav, uint8_t* app_image)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include "ui.hpp"
|
||||
#include "file.hpp"
|
||||
|
||||
#define CURRENT_STANDALONE_APPLICATION_API_VERSION 3
|
||||
#define CURRENT_STANDALONE_APPLICATION_API_VERSION 4
|
||||
|
||||
struct standalone_application_api_t {
|
||||
// Version 1
|
||||
|
|
@ -105,6 +105,11 @@ struct standalone_application_api_t {
|
|||
void (*draw_pixels)(const ui::Rect r, const ui::Color* const colors, const size_t count);
|
||||
void (*draw_pixel)(const ui::Point p, const ui::Color color);
|
||||
void (*exit_app)();
|
||||
|
||||
// Version 4
|
||||
uint16_t* screen_height;
|
||||
uint16_t* screen_width;
|
||||
|
||||
// TODO: add baseband access functions
|
||||
|
||||
// HOW TO extend this interface:
|
||||
|
|
|
|||
|
|
@ -86,15 +86,17 @@ set(LDSCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/external.ld)
|
|||
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
FILE(GLOB_RECURSE Sources_C ${CMAKE_CURRENT_LIST_DIR}/*.c)
|
||||
FILE(GLOB_RECURSE Sources_C_COMMON ${CMAKE_CURRENT_LIST_DIR}/../common/*.c)
|
||||
set(CSRC
|
||||
${Sources_C}
|
||||
${Sources_C} ${Sources_C_COMMON}
|
||||
)
|
||||
|
||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
FILE(GLOB_RECURSE Sources_CPP ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
|
||||
FILE(GLOB_RECURSE Sources_CPP_COMMON ${CMAKE_CURRENT_LIST_DIR}/../common/*.cpp)
|
||||
set(CPPSRC
|
||||
${Sources_CPP}
|
||||
${Sources_CPP} ${Sources_CPP_COMMON}
|
||||
)
|
||||
|
||||
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||
|
|
@ -122,6 +124,8 @@ set(ASMSRC)
|
|||
|
||||
set(INCDIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../common/ui
|
||||
${COMMON}
|
||||
${COMMON}/../application
|
||||
${COMMON}/../application/hw
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ void initialize(const standalone_application_api_t& api) {
|
|||
_api = &api;
|
||||
|
||||
context = new ui::Context();
|
||||
standaloneViewMirror = new StandaloneViewMirror(*context, {0, 16, 240, 304});
|
||||
screen_height = *(_api->screen_height);
|
||||
screen_width = *(_api->screen_width);
|
||||
standaloneViewMirror = new StandaloneViewMirror(*context, {0, 16, screen_width, screen_height - 16});
|
||||
}
|
||||
|
||||
// event 1 == frame sync. called each 1/60th of second, so 6 = 100ms
|
||||
|
|
@ -78,7 +80,7 @@ ui::Widget* captured_widget{nullptr};
|
|||
void OnTouchEvent(int, int, uint32_t) {
|
||||
if (standaloneViewMirror) {
|
||||
_api->exit_app();
|
||||
/*
|
||||
/* //left here for example, but not used in digital rain
|
||||
ui::TouchEvent event{{x, y}, static_cast<ui::TouchEvent::Type>(type)};
|
||||
|
||||
if (event.type == ui::TouchEvent::Type::Start) {
|
||||
|
|
@ -105,7 +107,8 @@ bool OnKeyEvent(uint8_t) {
|
|||
// ui::KeyEvent key = (ui::KeyEvent)key_val;
|
||||
if (context) {
|
||||
_api->exit_app();
|
||||
/* auto focus_widget = context->focus_manager().focus_widget();
|
||||
/* left here for example, but not used in digital rain
|
||||
auto focus_widget = context->focus_manager().focus_widget();
|
||||
|
||||
if (focus_widget) {
|
||||
if (focus_widget->on_key(key))
|
||||
|
|
@ -130,6 +133,7 @@ bool OnEncoder(int32_t) {
|
|||
if (context) {
|
||||
_api->exit_app();
|
||||
/*
|
||||
left here for example, but not used in digital rain
|
||||
auto focus_widget = context->focus_manager().focus_widget();
|
||||
|
||||
if (focus_widget) return focus_widget->on_encoder((ui::EncoderEvent)delta);
|
||||
|
|
@ -143,6 +147,7 @@ bool OnKeyboad(uint8_t) {
|
|||
if (context) {
|
||||
_api->exit_app();
|
||||
/*
|
||||
left here for example, but not used in digital rain
|
||||
auto focus_widget = context->focus_manager().focus_widget();
|
||||
|
||||
if (focus_widget)
|
||||
|
|
|
|||
|
|
@ -45,17 +45,19 @@ bool OnKeyboad(uint8_t);
|
|||
void PaintViewMirror();
|
||||
|
||||
extern const standalone_application_api_t* _api;
|
||||
extern uint16_t screen_height;
|
||||
extern uint16_t screen_width;
|
||||
|
||||
class DigitalRain {
|
||||
private:
|
||||
ui::Painter painter{};
|
||||
static const int WIDTH = 240;
|
||||
static const int HEIGHT = 325;
|
||||
static const int MARGIN_TOP = 20;
|
||||
static const int CHAR_WIDTH = 5;
|
||||
static const int CHAR_HEIGHT = 8;
|
||||
static const int COLS = WIDTH / CHAR_WIDTH;
|
||||
static const int ROWS = (HEIGHT - MARGIN_TOP) / CHAR_HEIGHT;
|
||||
int WIDTH = 0; // 240;
|
||||
int HEIGHT = 0; // 325;
|
||||
int MARGIN_TOP = 20;
|
||||
int CHAR_WIDTH = 5;
|
||||
int CHAR_HEIGHT = 8;
|
||||
int COLS = 0; // WIDTH / CHAR_WIDTH;
|
||||
int ROWS = 0; //(HEIGHT - MARGIN_TOP) / CHAR_HEIGHT;
|
||||
static const int MAX_DROPS = 36;
|
||||
|
||||
const ui::Font& font = ui::font::fixed_5x8();
|
||||
|
|
@ -124,7 +126,10 @@ class DigitalRain {
|
|||
public:
|
||||
DigitalRain() {
|
||||
std::srand(0);
|
||||
|
||||
WIDTH = screen_width;
|
||||
HEIGHT = screen_height + 5;
|
||||
COLS = WIDTH / CHAR_WIDTH;
|
||||
ROWS = (HEIGHT - MARGIN_TOP) / CHAR_HEIGHT;
|
||||
for (uint8_t i = 0; i < MAX_DROPS; ++i) {
|
||||
init_drop(i, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,3 +176,6 @@ extern "C" int f_printf(FIL* fp, const TCHAR* str, ...) {
|
|||
extern "C" TCHAR* f_gets(TCHAR* buff, int len, FIL* fp) {
|
||||
return _api->f_gets(buff, len, fp);
|
||||
}
|
||||
|
||||
uint16_t screen_height = 320;
|
||||
uint16_t screen_width = 240;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue