-
-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version independent external apps (standalone apps) (#2145)
This pull requests adds a new type of external app to the firmware: The standalone app. Pros: Will work after an upgrade. Size of image is only limited by shared heap size of M0 (application) (64kb total). Cons: No full access to all functions in the main firmware. One well defined (and versioned) API handles all communication. The Pacman app was converted to be the first the the new kind.
- Loading branch information
1 parent
fe71592
commit 100bea6
Showing
23 changed files
with
807 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (C) 2024 Bernd Herzog | ||
* | ||
* This file is part of PortaPack. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "ui_standalone_view.hpp" | ||
#include "irq_controls.hpp" | ||
|
||
namespace ui { | ||
|
||
void create_thread(int32_t (*fn)(void*), void* arg, size_t stack_size, int priority) { | ||
// TODO: collect memory on terminate, once this is used | ||
chThdCreateFromHeap(NULL, stack_size, priority, fn, arg); | ||
} | ||
|
||
void fill_rectangle(int x, int y, int width, int height, uint16_t color) { | ||
ui::Painter painter; | ||
painter.fill_rectangle({x, y, width, height}, ui::Color(color)); | ||
} | ||
|
||
void* alloc(size_t size) { | ||
void* p = chHeapAlloc(0x0, size); | ||
if (p == nullptr) | ||
chDbgPanic("Out of Memory"); | ||
return p; | ||
} | ||
|
||
uint64_t get_switches_state_ulong() { | ||
return get_switches_state().to_ulong(); | ||
} | ||
|
||
standalone_application_api_t api = { | ||
/* .malloc = */ &alloc, | ||
/* .calloc = */ &calloc, | ||
/* .realloc = */ &realloc, | ||
/* .free = */ &chHeapFree, | ||
/* .create_thread = */ &create_thread, | ||
/* .fill_rectangle = */ &fill_rectangle, | ||
/* .swizzled_switches = */ &swizzled_switches, | ||
/* .get_switches_state = */ &get_switches_state_ulong, | ||
}; | ||
|
||
StandaloneView::StandaloneView(NavigationView& nav, std::unique_ptr<uint8_t[]> app_image) | ||
: nav_(nav), _app_image(std::move(app_image)) { | ||
get_application_information()->initialize(api); | ||
add_children({&dummy}); | ||
} | ||
|
||
void StandaloneView::focus() { | ||
dummy.focus(); | ||
} | ||
|
||
void StandaloneView::paint(Painter& painter) { | ||
(void)painter; | ||
} | ||
|
||
void StandaloneView::frame_sync() { | ||
// skip first refresh | ||
if (!initialized) { | ||
initialized = true; | ||
} else { | ||
get_application_information()->on_event(1); | ||
} | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.