Compare commits

...

9 Commits

Author SHA1 Message Date
Bernd Herzog 4740df2e2c Usb serial shell workerthread #2 (#1738) 2024-01-07 22:25:43 +01:00
Bernd Herzog ec0f45a488 added sys locks to time critical lcd updates (#1737) 2024-01-07 19:50:26 +01:00
Totoo 9d7e06c255 Appstart and applist from serial (#1736)
* Start app, and list fixed ones.
* Add ext app support
2024-01-07 18:56:09 +01:00
sommermoregentraum 4b93e78dd9 make pacman's face (mouse) face to the dir which he hits the wall (#1735) 2024-01-07 16:55:45 +01:00
Bernd Herzog 5ced8c90d3 added radio saturation to performance counter (#1734) 2024-01-07 15:31:08 +01:00
Bernd Herzog 9d22711368 added usb event to not wait for the next frame (#1733) 2024-01-07 14:09:22 +01:00
Bernd Herzog 23e6295dd2 removed the use of the hackrf cpld eeprom (#1732)
* removed the use of the hackrf cpld eeprom

* readded comment
2024-01-07 12:29:53 +01:00
Bernd Herzog bbd75ab7ef fixed usb descriptor product string length (#1731) 2024-01-07 11:57:16 +01:00
jLynx 7508fee62c Fixed sdcard zip folder structure (#1730)
* Fixed sd card zip folder structure

* Update create_nightly_release.yml

Updated zip for work map

* Update create_stable_release.yml

Replicated on stable release
2024-01-07 19:51:27 +13:00
20 changed files with 504 additions and 63 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ jobs:
run: docker run -e VERSION_STRING=${{ steps.version_date.outputs.date }} -i -v ${{ github.workspace }}:/havoc portapack-dev
- name: Create Small SD Card ZIP - No World Map
run: |
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version_date.outputs.date }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && zip -r sdcard-no-map.zip sdcard
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version_date.outputs.date }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && cd sdcard && zip -r ../sdcard-no-map.zip . && cd ..
- name: Download world map
run: |
wget https://github.com/eried/portapack-mayhem/releases/download/world_map/world_map.zip
@@ -66,7 +66,7 @@ jobs:
zip -j firmware.zip build/firmware/portapack-h1_h2-mayhem.bin && cd flashing && zip -r ../firmware.zip *
- name: Create SD Card ZIP
run: |
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version_date.outputs.date }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && zip -r sdcard.zip sdcard
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version_date.outputs.date }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && cd sdcard && zip -r ../sdcard.zip . && cd ..
- name: Create changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+2 -2
View File
@@ -38,7 +38,7 @@ jobs:
run: docker run -e VERSION_STRING=${{ steps.version.outputs.version }} -i -v ${{ github.workspace }}:/havoc portapack-dev
- name: Create Small SD Card ZIP - No World Map
run: |
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version.outputs.version }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && zip -r sdcard-no-map.zip sdcard
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version.outputs.version }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && cd sdcard && zip -r ../sdcard-no-map.zip . && cd ..
- name: Download world map
run: |
wget https://github.com/eried/portapack-mayhem/releases/download/world_map/world_map.zip
@@ -50,7 +50,7 @@ jobs:
zip -j firmware.zip build/firmware/portapack-h1_h2-mayhem.bin && cd flashing && zip -r ../firmware.zip *
- name: Create SD Card ZIP
run: |
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version.outputs.version }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && zip -r sdcard.zip sdcard
mkdir -p sdcard/FIRMWARE && cp build/firmware/portapack-h1_h2-mayhem.bin sdcard/FIRMWARE/portapack-mayhem_${{ steps.version.outputs.version }}.bin && mkdir -p sdcard/APPS && cp build/firmware/application/*.ppma sdcard/APPS && cd sdcard && zip -r ../sdcard.zip . && cd ..
- name: Create changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+12 -10
View File
@@ -48,7 +48,7 @@ void DfuMenu::paint(Painter& painter) {
text_info_line_3.set(to_string_dec_uint(utilisation, 6));
text_info_line_4.set(to_string_dec_uint(shared_memory.m4_heap_usage, 6));
text_info_line_5.set(to_string_dec_uint(shared_memory.m4_stack_usage, 6));
text_info_line_6.set(to_string_dec_uint(shared_memory.m4_cpu_usage, 6));
text_info_line_6.set(to_string_dec_uint(shared_memory.m4_performance_counter, 6));
text_info_line_7.set(to_string_dec_uint(shared_memory.m4_buffer_missed, 6));
text_info_line_8.set(to_string_dec_uint(chTimeNow() / 1000, 6));
@@ -94,23 +94,25 @@ DfuMenu2::DfuMenu2(NavigationView& nav)
&text_info_line_7,
&text_info_line_8,
&text_info_line_9,
&text_info_line_10});
&text_info_line_10,
&text_info_line_11});
}
void DfuMenu2::paint(Painter& painter) {
text_info_line_1.set(to_string_dec_uint(portapack::receiver_model.target_frequency(), 10));
text_info_line_2.set(to_string_dec_uint(portapack::receiver_model.baseband_bandwidth(), 10));
text_info_line_3.set(to_string_dec_uint(portapack::receiver_model.sampling_rate(), 10));
text_info_line_4.set(to_string_dec_uint((uint32_t)portapack::receiver_model.modulation(), 10));
text_info_line_5.set(to_string_dec_uint(portapack::receiver_model.am_configuration(), 10));
text_info_line_6.set(to_string_dec_uint(portapack::receiver_model.nbfm_configuration(), 10));
text_info_line_7.set(to_string_dec_uint(portapack::receiver_model.wfm_configuration(), 10));
text_info_line_8.set(to_string_dec_uint(portapack::transmitter_model.target_frequency(), 10));
text_info_line_9.set(to_string_dec_uint(portapack::transmitter_model.baseband_bandwidth(), 10));
text_info_line_10.set(to_string_dec_uint(portapack::transmitter_model.sampling_rate(), 10));
text_info_line_4.set(to_string_dec_uint(((uint32_t)shared_memory.m4_performance_counter) * 100 / 127, 10));
text_info_line_5.set(to_string_dec_uint((uint32_t)portapack::receiver_model.modulation(), 10));
text_info_line_6.set(to_string_dec_uint(portapack::receiver_model.am_configuration(), 10));
text_info_line_7.set(to_string_dec_uint(portapack::receiver_model.nbfm_configuration(), 10));
text_info_line_8.set(to_string_dec_uint(portapack::receiver_model.wfm_configuration(), 10));
text_info_line_9.set(to_string_dec_uint(portapack::transmitter_model.target_frequency(), 10));
text_info_line_10.set(to_string_dec_uint(portapack::transmitter_model.baseband_bandwidth(), 10));
text_info_line_11.set(to_string_dec_uint(portapack::transmitter_model.sampling_rate(), 10));
constexpr auto margin = 5;
constexpr auto lines = 10 + 2;
constexpr auto lines = 11 + 2;
painter.fill_rectangle(
{{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
+10 -7
View File
@@ -83,13 +83,15 @@ class DfuMenu2 : public View {
{{5 * CHARACTER_WIDTH, 5 * LINE_HEIGHT}, "RX Freq:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 6 * LINE_HEIGHT}, "RX BW:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 7 * LINE_HEIGHT}, "RX SampR:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 8 * LINE_HEIGHT}, "Modulatn:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 9 * LINE_HEIGHT}, "AM cfg:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 10 * LINE_HEIGHT}, "NBFM cfg:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 11 * LINE_HEIGHT}, "WFM cfg:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 12 * LINE_HEIGHT}, "TX Freq:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 13 * LINE_HEIGHT}, "TX BW:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 14 * LINE_HEIGHT}, "TX SampR:", Color::dark_cyan()}};
{{5 * CHARACTER_WIDTH, 8 * LINE_HEIGHT}, "RX Satu%:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 9 * LINE_HEIGHT}, "Modulatn:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 10 * LINE_HEIGHT}, "AM cfg:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 11 * LINE_HEIGHT}, "NBFM cfg:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 12 * LINE_HEIGHT}, "WFM cfg:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 13 * LINE_HEIGHT}, "TX Freq:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 14 * LINE_HEIGHT}, "TX BW:", Color::dark_cyan()},
{{5 * CHARACTER_WIDTH, 15 * LINE_HEIGHT}, "TX SampR:", Color::dark_cyan()},
};
Text text_info_line_1{{14 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
Text text_info_line_2{{14 * CHARACTER_WIDTH, 6 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
@@ -101,6 +103,7 @@ class DfuMenu2 : public View {
Text text_info_line_8{{14 * CHARACTER_WIDTH, 12 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
Text text_info_line_9{{14 * CHARACTER_WIDTH, 13 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
Text text_info_line_10{{14 * CHARACTER_WIDTH, 14 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
Text text_info_line_11{{14 * CHARACTER_WIDTH, 15 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
};
} /* namespace ui */
+62 -3
View File
@@ -113,7 +113,6 @@ void EventDispatcher::run() {
while (is_running) {
const auto events = wait();
dispatch(events);
portapack::usb_serial.dispatch();
}
}
@@ -151,6 +150,8 @@ void EventDispatcher::dispatch(const eventmask_t events) {
*(uint32_t*)&shared_memory.bb_data.data[4]);
}
handle_shell();
if (events & EVT_MASK_APPLICATION) {
handle_application_queue();
}
@@ -163,6 +164,10 @@ void EventDispatcher::dispatch(const eventmask_t events) {
handle_rtc_tick();
}
if (events & EVT_MASK_USB) {
handle_usb();
}
if (events & EVT_MASK_SWITCHES) {
handle_switches();
}
@@ -216,6 +221,30 @@ void EventDispatcher::handle_rtc_tick() {
portapack::persistent_memory::cache::persist();
}
void EventDispatcher::handle_usb() {
portapack::usb_serial.dispatch();
}
void EventDispatcher::handle_shell() {
if (waiting_for_shellmode) {
waiting_for_shellmode = false;
shellmode_active = true;
while (shellmode_active) {
chThdSleepMilliseconds(5);
}
}
if (injected_touch_event != nullptr) {
on_touch_event(*injected_touch_event);
injected_touch_event = nullptr;
}
if (injected_keyboard_event != nullptr) {
on_keyboard_event(*injected_keyboard_event);
injected_keyboard_event = nullptr;
}
}
ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent event) {
if (!w->hidden()) {
// To achieve reverse depth ordering (last object drawn is
@@ -239,11 +268,17 @@ ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent ev
}
void EventDispatcher::emulateTouch(ui::TouchEvent event) {
on_touch_event(event);
injected_touch_event = &event;
while (injected_touch_event != nullptr) {
chThdSleepMilliseconds(5);
}
}
void EventDispatcher::emulateKeyboard(ui::KeyboardEvent event) {
on_keyboard_event(event);
injected_keyboard_event = &event;
while (injected_keyboard_event != nullptr) {
chThdSleepMilliseconds(5);
}
}
void EventDispatcher::on_keyboard_event(ui::KeyboardEvent event) {
@@ -283,6 +318,8 @@ ui::Widget* EventDispatcher::getFocusedWidget() {
}
void EventDispatcher::handle_lcd_frame_sync() {
bool waiting_for_frame = this->waiting_for_frame;
DisplayFrameSyncMessage message;
message_map.send(&message);
@@ -290,6 +327,28 @@ void EventDispatcher::handle_lcd_frame_sync() {
painter.paint_widget_tree(top_widget);
portapack::backlight()->on();
if (waiting_for_frame)
this->waiting_for_frame = false;
}
void EventDispatcher::wait_finish_frame() {
waiting_for_frame = true;
while (waiting_for_frame) {
chThdSleepMilliseconds(5);
}
}
void EventDispatcher::enter_shell_working_mode() {
waiting_for_shellmode = true;
while (waiting_for_shellmode) {
chThdSleepMilliseconds(5);
}
}
void EventDispatcher::exit_shell_working_mode() {
shellmode_active = false;
}
void EventDispatcher::handle_switches() {
+12
View File
@@ -45,6 +45,7 @@ constexpr auto EVT_MASK_ENCODER = EVENT_MASK(4);
constexpr auto EVT_MASK_TOUCH = EVENT_MASK(5);
constexpr auto EVT_MASK_APPLICATION = EVENT_MASK(6);
constexpr auto EVT_MASK_LOCAL = EVENT_MASK(7);
constexpr auto EVT_MASK_USB = EVENT_MASK(8);
class EventDispatcher {
public:
@@ -89,6 +90,10 @@ class EventDispatcher {
void emulateTouch(ui::TouchEvent event);
void emulateKeyboard(ui::KeyboardEvent event);
void wait_finish_frame();
void enter_shell_working_mode();
void exit_shell_working_mode();
ui::Widget* getTopWidget();
ui::Widget* getFocusedWidget();
@@ -104,6 +109,11 @@ class EventDispatcher {
bool sd_card_present = false;
static bool display_sleep;
bool in_key_event = false;
volatile bool waiting_for_frame = false;
volatile bool waiting_for_shellmode = false;
volatile bool shellmode_active = false;
ui::TouchEvent* volatile injected_touch_event = nullptr;
ui::KeyboardEvent* volatile injected_keyboard_event = nullptr;
eventmask_t wait();
void dispatch(const eventmask_t events);
@@ -111,6 +121,8 @@ class EventDispatcher {
void handle_application_queue();
void handle_local_queue();
void handle_rtc_tick();
void handle_usb();
void handle_shell();
static ui::Widget* touch_widget(ui::Widget* const w, ui::TouchEvent event);
+21 -7
View File
@@ -205,11 +205,13 @@ class Sprite {
byte who;
byte _speed;
byte dir;
byte lastDir;
byte phase;
// Sprite bits
byte palette2; // 4->16 color map index
byte bits; // index of sprite bits
signed char sy;
void Init(const byte* s) {
@@ -274,9 +276,17 @@ class Sprite {
f = pgm_read_byte(_pacLeftAnim + f);
else if (dir == MRight)
f = pgm_read_byte(_pacRightAnim + f);
else
else if (dir == MDown || dir == MUp)
f = pgm_read_byte(_pacVAnim + f);
if (dir == MUp)
else if (dir == MStopped) {
if (lastDir == MLeft)
f = pgm_read_byte(_pacLeftAnim + f);
else if (lastDir == MRight)
f = pgm_read_byte(_pacRightAnim + f);
else if (lastDir == MDown || lastDir == MUp)
f = pgm_read_byte(_pacVAnim + f);
}
if ((dir == MUp) || (dir == MStopped && lastDir == MUp))
sy = -1;
bits = f + PACMANSPRITE;
}
@@ -838,15 +848,19 @@ class Playfield {
else if (DEMO == 0 && s->who == PACMAN && choice[3] < 0x7FFF && but_RIGHT)
dir = MRight;
else if (DEMO == 0 && choice[0] < 0x7FFF && s->who == PACMAN && dir == MUp)
else if (DEMO == 0 && choice[0] < 0x7FFF && s->who == PACMAN && dir == MUp) {
dir = MUp;
else if (DEMO == 0 && choice[1] < 0x7FFF && s->who == PACMAN && dir == MLeft)
s->lastDir = MUp;
} else if (DEMO == 0 && choice[1] < 0x7FFF && s->who == PACMAN && dir == MLeft) {
dir = MLeft;
else if (DEMO == 0 && choice[2] < 0x7FFF && s->who == PACMAN && dir == MDown)
s->lastDir = MLeft;
} else if (DEMO == 0 && choice[2] < 0x7FFF && s->who == PACMAN && dir == MDown) {
dir = MDown;
else if (DEMO == 0 && choice[3] < 0x7FFF && s->who == PACMAN && dir == MRight)
s->lastDir = MDown;
} else if (DEMO == 0 && choice[3] < 0x7FFF && s->who == PACMAN && dir == MRight) {
dir = MRight;
else if ((DEMO == 0 && s->who != PACMAN) || DEMO == 1) {
s->lastDir = MRight;
} else if ((DEMO == 0 && s->who != PACMAN) || DEMO == 1) {
// Don't choose opposite of current direction?
int16_t dist = choice[4 - dir]; // favor current direction
+2 -10
View File
@@ -116,16 +116,8 @@ void set_direction(const rf::Direction new_direction) {
/* TODO: Refactor all the various "Direction" enumerations into one. */
/* TODO: Only make changes if direction changes, but beware of clock enabling. */
// Hack to fix the CPLD (clocking ?) bug: toggle CPLD SRAM overlay depending on new direction.
// Use CPLD's EEPROM config when transmitting
// Use the SRAM overlay when receiving
if (direction != new_direction) {
if (new_direction == rf::Direction::Transmit)
hackrf::cpld::init_from_eeprom();
else
// Prevents ghosting when switching back to RX from TX mode.
hackrf::cpld::load_sram_no_verify();
}
// Prevents ghosting when switching back to RX from TX mode.
hackrf::cpld::load_sram_no_verify();
direction = new_direction;
@@ -6,6 +6,44 @@ namespace ui {
/* static */ std::vector<DynamicBitmap<16, 16>> ExternalItemsMenuLoader::bitmaps;
// iterates over all ppma-s, and if it is runnable on the current system, it'll call the callback, and pass info.
/* static */ void ExternalItemsMenuLoader::load_all_external_items_callback(std::function<void(AppInfoConsole&)> callback) {
if (!callback) return;
if (sd_card::status() != sd_card::Status::Mounted)
return;
for (const auto& entry : std::filesystem::directory_iterator(u"APPS", u"*.ppma")) {
auto filePath = u"/APPS/" + entry.path();
File app;
auto openError = app.open(filePath);
if (openError)
continue;
application_information_t application_information = {};
auto readResult = app.read(&application_information, sizeof(application_information_t));
if (!readResult)
continue;
if (application_information.header_version != CURRENT_HEADER_VERSION)
continue;
bool versionMatches = VERSION_MD5 == application_information.app_version;
if (!versionMatches) continue;
// here the app is startable and good.
std::string appshortname = filePath.filename().string();
if (appshortname.size() >= 5 && appshortname.substr(appshortname.size() - 5) == ".ppma") {
// Remove the ".ppma" suffix
appshortname = appshortname.substr(0, appshortname.size() - 5);
}
AppInfoConsole info{
.appCallName = appshortname.c_str(),
.appFriendlyName = reinterpret_cast<char*>(&application_information.app_name[0]),
.appLocation = application_information.menu_location};
callback(info);
}
}
/* static */ std::vector<GridItem> ExternalItemsMenuLoader::load_external_items(app_location_t app_location, NavigationView& nav) {
bitmaps.clear();
@@ -47,7 +85,9 @@ namespace ui {
bitmaps.push_back(std::move(dyn_bmp));
gridItem.on_select = [&nav, app_location, filePath]() {
run_external_app(nav, filePath);
if (!run_external_app(nav, filePath)) {
nav.display_modal("Error", "The .ppma file in your APPS\nfolder can't be read. Please\nupdate your SD Card content.");
}
};
} else {
gridItem.color = Color::light_grey();
@@ -65,19 +105,19 @@ namespace ui {
return external_apps;
}
/* static */ void ExternalItemsMenuLoader::run_external_app(ui::NavigationView& nav, std::filesystem::path filePath) {
/* static */ bool ExternalItemsMenuLoader::run_external_app(ui::NavigationView& nav, std::filesystem::path filePath) {
File app;
auto openError = app.open(filePath);
if (openError)
chDbgPanic("file gone");
return false;
application_information_t application_information = {};
auto readResult = app.read(&application_information, sizeof(application_information_t));
if (!readResult)
chDbgPanic("no data");
return false;
app.seek(0);
@@ -93,7 +133,7 @@ namespace ui {
readResult = app.read(&application_information.memory_location[file_read_index], bytes_to_read);
if (!readResult)
chDbgPanic("read error");
return false;
if (readResult.value() < std::filesystem::max_file_block_size)
break;
@@ -114,7 +154,7 @@ namespace ui {
readResult = app.read(target_memory, bytes_to_read);
if (!readResult)
chDbgPanic("read error #2");
return false;
if (readResult.value() != bytes_to_read)
break;
@@ -126,7 +166,7 @@ namespace ui {
readResult = app.read(&application_information.memory_location[file_read_index], bytes_to_read);
if (!readResult)
chDbgPanic("read error #3");
return false;
if (readResult.value() < std::filesystem::max_file_block_size)
break;
@@ -134,6 +174,7 @@ namespace ui {
}
application_information.externalAppEntry(nav);
return true;
}
} // namespace ui
@@ -54,11 +54,11 @@ class ExternalItemsMenuLoader {
public:
static std::vector<GridItem> load_external_items(app_location_t, NavigationView&);
ExternalItemsMenuLoader() = delete;
static bool run_external_app(ui::NavigationView&, std::filesystem::path);
static void load_all_external_items_callback(std::function<void(AppInfoConsole&)> callback);
private:
static std::vector<DynamicBitmap<16, 16>> bitmaps;
static void run_external_app(ui::NavigationView&, std::filesystem::path);
};
} // namespace ui
+169 -2
View File
@@ -111,6 +111,169 @@ namespace pmem = portapack::persistent_memory;
namespace ui {
// When adding or removing apps from the Menu, please update it here:
std::vector<AppInfoConsole> NavigationView::fixedAppListFC = {
{"adsbrx", "ADS-B", RX},
{"ais", "AIS Boats", RX},
{"aprsrx", "APRS", RX},
{"audio", "Audio", RX},
{"blerx", "BLE Rx", RX},
{"ert", "ERT Meter", RX},
{"level", "Level", RX},
{"pocsagrx", "POCSAG", RX},
{"radiosnde", "Radiosnde", RX},
{"recon", "Recon", RX},
{"search", "Search", RX},
{"tpms", "TPMS Cars", RX},
{"weather", "Weather", RX},
{"subghzd", "SubGhzD", RX},
{"adsbtx", "ADS-B", TX},
{"aprstx", "APRS TX", TX},
{"bht", "BHT Xy/EP", TX},
{"bletx", "BLE Tx", TX},
{"morsetx", "Morse", TX},
{"ooktx", "OOK", TX},
{"pocsatx", "POCSAG TX", TX},
{"rdstx", "RDS TX", TX},
{"soundbrd", "Soundbrd", TX},
{"sstvtx", "SSTV", TX},
{"touchtune", "TouchTune", TX},
{"capture", "Capture", RX},
{"replay", "Replay", TX},
{"remote", "Remote", TX},
{"scanner", "Scanner", RX},
{"microphone", "Microphone", TX},
{"lookingglass", "Looking Glass", RX}};
bool NavigationView::StartAppByName(const char* name) {
pop();
if (strcmp(name, "adsbrx") == 0) {
push<ADSBRxView>();
return true;
}
if (strcmp(name, "ais") == 0) {
push<AISAppView>();
return true;
}
if (strcmp(name, "aprsrx") == 0) {
push<APRSRXView>();
return true;
}
if (strcmp(name, "audio") == 0) {
push<AnalogAudioView>();
return true;
}
if (strcmp(name, "blerx") == 0) {
push<BLERxView>();
return true;
}
if (strcmp(name, "ert") == 0) {
push<ERTAppView>();
return true;
}
if (strcmp(name, "level") == 0) {
push<LevelView>();
return true;
}
if (strcmp(name, "pocsagrx") == 0) {
push<POCSAGAppView>();
return true;
}
if (strcmp(name, "radiosnode") == 0) {
push<SondeView>();
return true;
}
if (strcmp(name, "recon") == 0) {
push<ReconView>();
return true;
}
if (strcmp(name, "search") == 0) {
push<SearchView>();
return true;
}
if (strcmp(name, "tpms") == 0) {
push<TPMSAppView>();
return true;
}
if (strcmp(name, "weather") == 0) {
push<WeatherView>();
return true;
}
if (strcmp(name, "subghzd") == 0) {
push<SubGhzDView>();
return true;
}
if (strcmp(name, "adsbtx") == 0) {
push<ADSBTxView>();
return true;
}
if (strcmp(name, "aprstx") == 0) {
push<APRSTXView>();
return true;
}
if (strcmp(name, "bht") == 0) {
push<BHTView>();
return true;
}
if (strcmp(name, "bletx") == 0) {
push<BLETxView>();
return true;
}
if (strcmp(name, "morsetx") == 0) {
push<MorseView>();
return true;
}
if (strcmp(name, "ooktx") == 0) {
push<EncodersView>();
return true;
}
if (strcmp(name, "pocsatx") == 0) {
push<POCSAGTXView>();
return true;
}
if (strcmp(name, "rdstx") == 0) {
push<RDSView>();
return true;
}
if (strcmp(name, "soundbrd") == 0) {
push<SoundBoardView>();
return true;
}
if (strcmp(name, "sstvtx") == 0) {
push<SSTVTXView>();
return true;
}
if (strcmp(name, "touchtune") == 0) {
push<TouchTunesView>();
return true;
}
if (strcmp(name, "capture") == 0) {
push<CaptureAppView>();
return true;
}
if (strcmp(name, "replay") == 0) {
push<PlaylistView>();
return true;
}
if (strcmp(name, "remote") == 0) {
push<RemoteView>();
return true;
}
if (strcmp(name, "scanner") == 0) {
push<ScannerView>();
return true;
}
if (strcmp(name, "microphone") == 0) {
push<MicTXView>();
return true;
}
if (strcmp(name, "lookingglass") == 0) {
push<GlassView>();
return true;
}
return false;
}
/* StatusTray ************************************************************/
StatusTray::StatusTray(Point pos)
@@ -751,6 +914,9 @@ SystemView::SystemView(
Context& SystemView::context() const {
return context_;
}
NavigationView* SystemView::get_navigation_view() {
return &navigation_view;
}
void SystemView::toggle_overlay() {
switch (++overlay_active) {
@@ -758,7 +924,7 @@ void SystemView::toggle_overlay() {
this->add_child(&this->overlay);
this->set_dirty();
shared_memory.request_m4_performance_counter = 1;
shared_memory.m4_cpu_usage = 0;
shared_memory.m4_performance_counter = 0;
shared_memory.m4_heap_usage = 0;
shared_memory.m4_stack_usage = 0;
break;
@@ -766,11 +932,12 @@ void SystemView::toggle_overlay() {
this->remove_child(&this->overlay);
this->add_child(&this->overlay2);
this->set_dirty();
shared_memory.request_m4_performance_counter = 0;
shared_memory.request_m4_performance_counter = 2;
break;
case 3:
this->remove_child(&this->overlay2);
this->set_dirty();
shared_memory.request_m4_performance_counter = 0;
overlay_active = 0;
break;
}
+11 -1
View File
@@ -40,7 +40,7 @@
#include "diskio.h"
#include "lfsr_random.hpp"
#include "sd_card.hpp"
#include "external_app.hpp"
#include <vector>
#include <utility>
@@ -57,6 +57,12 @@ enum modal_t {
ABORT
};
struct AppInfoConsole {
const char* appCallName;
const char* appFriendlyName;
const app_location_t appLocation;
};
class NavigationView : public View {
public:
std::function<void(const View&)> on_view_changed{};
@@ -99,6 +105,8 @@ class NavigationView : public View {
* Returns true if the handler was bound successfully. */
bool set_on_pop(std::function<void()> on_pop);
static std::vector<AppInfoConsole> fixedAppListFC; // fixed app list for console. vector, so can be incomplete and still iterateable
bool StartAppByName(const char* name); // Starts a View (app) by name stored in fixedAppListFC. This is to start apps from console
private:
struct ViewState {
std::unique_ptr<View> view;
@@ -321,6 +329,8 @@ class SystemView : public View {
void toggle_overlay();
void paint_overlay();
NavigationView* get_navigation_view();
private:
uint8_t overlay_active{0};
+11
View File
@@ -23,10 +23,20 @@
#include "usb_serial_endpoints.h"
#include "usb_serial_event.hpp"
uint32_t EVT_MASK_USB = EVENT_MASK(8);
extern void usb0_isr(void);
static Thread* thread_usb_event = NULL;
CH_IRQ_HANDLER(USB0_IRQHandler) {
CH_IRQ_PROLOGUE();
usb0_isr();
chSysLockFromIsr();
chEvtSignalI(thread_usb_event, EVT_MASK_USB);
chSysUnlockFromIsr();
CH_IRQ_EPILOGUE();
}
@@ -46,6 +56,7 @@ uint32_t __strex(uint32_t val, volatile uint32_t* addr) {
void nvic_enable_irq(uint8_t irqn) {
NVIC_ISER(irqn / 32) = (1 << (irqn % 32));
thread_usb_event = chThdSelf();
}
void usb_configuration_changed(usb_device_t* const device) {
+1 -1
View File
@@ -264,7 +264,7 @@ uint8_t usb_descriptor_string_manufacturer[] = {
};
uint8_t usb_descriptor_string_product[] = {
43, // bLength
34, // bLength
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
'P', 0x00,
'o', 0x00,
+103 -1
View File
@@ -40,9 +40,12 @@
#include "ff.h"
#include "chprintf.h"
#include "chqueues.h"
#include "ui_external_items_menu_loader.hpp"
#include "untar.hpp"
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include <string>
#include <codecvt>
#include <cstring>
@@ -245,6 +248,9 @@ static void cmd_screenframe(BaseSequentialStream* chp, int argc, char* argv[]) {
(void)argc;
(void)argv;
auto evtd = getEventDispatcherInstance();
evtd->enter_shell_working_mode();
for (int i = 0; i < ui::screen_height; i++) {
std::array<ui::ColorRGB888, ui::screen_width> row;
portapack::display.read_pixels({0, i, ui::screen_width, 1}, row);
@@ -255,6 +261,9 @@ static void cmd_screenframe(BaseSequentialStream* chp, int argc, char* argv[]) {
}
chprintf(chp, "\r\n");
}
evtd->exit_shell_working_mode();
chprintf(chp, "ok\r\n");
}
@@ -272,6 +281,9 @@ static void cmd_screenframeshort(BaseSequentialStream* chp, int argc, char* argv
(void)argc;
(void)argv;
auto evtd = getEventDispatcherInstance();
evtd->enter_shell_working_mode();
for (int y = 0; y < ui::screen_height; y++) {
std::array<ui::ColorRGB888, ui::screen_width> row;
portapack::display.read_pixels({0, y, ui::screen_width, 1}, row);
@@ -285,8 +297,10 @@ static void cmd_screenframeshort(BaseSequentialStream* chp, int argc, char* argv
chprintf(chp, "\r\n");
}
evtd->exit_shell_working_mode();
chprintf(chp, "ok\r\n");
}
static void cmd_write_memory(BaseSequentialStream* chp, int argc, char* argv[]) {
if (argc != 2) {
chprintf(chp, "usage: write_memory <address> <value (1 or 4 bytes)>\r\n");
@@ -341,6 +355,11 @@ static void cmd_button(BaseSequentialStream* chp, int argc, char* argv[]) {
control::debug::inject_switch(button);
// Wait two frame syncs to ensure action has painted
auto evtd = getEventDispatcherInstance();
evtd->wait_finish_frame();
evtd->wait_finish_frame();
chprintf(chp, "ok\r\n");
}
@@ -363,6 +382,11 @@ static void cmd_touch(BaseSequentialStream* chp, int argc, char* argv[]) {
}
evtd->emulateTouch({{x, y}, ui::TouchEvent::Type::Start});
evtd->emulateTouch({{x, y}, ui::TouchEvent::Type::End});
// Wait two frame syncs to ensure action has painted
evtd->wait_finish_frame();
evtd->wait_finish_frame();
chprintf(chp, "ok\r\n");
}
@@ -401,6 +425,10 @@ static void cmd_keyboard(BaseSequentialStream* chp, int argc, char* argv[]) {
evtd->emulateKeyboard(chr);
}
// Wait two frame syncs to ensure action has painted
evtd->wait_finish_frame();
evtd->wait_finish_frame();
chprintf(chp, "ok\r\n");
}
@@ -843,6 +871,78 @@ static void cmd_accessibility_readcurr(BaseSequentialStream* chp, int argc, char
chprintf(chp, "\r\nok\r\n");
}
static void cmd_appstart(BaseSequentialStream* chp, int argc, char* argv[]) {
(void)argc;
(void)argv;
if (argc != 1) {
chprintf(chp, "Usage: appstart APPCALLNAME");
return;
}
auto evtd = getEventDispatcherInstance();
if (!evtd) return;
auto top_widget = evtd->getTopWidget();
if (!top_widget) return;
auto nav = static_cast<ui::SystemView*>(top_widget)->get_navigation_view();
if (!nav) return;
if (nav->StartAppByName(argv[0])) {
chprintf(chp, "ok\r\n");
return;
}
// since ext app loader changed, we can just pass the string to it, and it"ll return if started or not.
std::string appwithpath = "/APPS/";
appwithpath += argv[0];
appwithpath += ".ppma";
bool ret = ui::ExternalItemsMenuLoader::run_external_app(*nav, path_from_string8((char*)appwithpath.c_str()));
if (!ret) {
chprintf(chp, "error\r\n");
return;
}
chprintf(chp, "ok\r\n");
}
static void printAppInfo(BaseSequentialStream* chp, ui::AppInfoConsole& element) {
if (strlen(element.appCallName) == 0) return;
chprintf(chp, element.appCallName);
chprintf(chp, " ");
chprintf(chp, element.appFriendlyName);
chprintf(chp, " ");
switch (element.appLocation) {
case RX:
chprintf(chp, "[RX]\r\n");
break;
case TX:
chprintf(chp, "[TX]\r\n");
break;
case UTILITIES:
chprintf(chp, "[UTIL]\r\n");
break;
case DEBUG:
chprintf(chp, "[DEBUG]\r\n");
break;
default:
break;
}
}
// returns the installed apps, those can be called by appstart APPNAME
static void cmd_applist(BaseSequentialStream* chp, int argc, char* argv[]) {
(void)argc;
(void)argv;
auto evtd = getEventDispatcherInstance();
if (!evtd) return;
auto top_widget = evtd->getTopWidget();
if (!top_widget) return;
auto nav = static_cast<ui::SystemView*>(top_widget)->get_navigation_view();
if (!nav) return;
for (auto element : ui::NavigationView::fixedAppListFC) {
printAppInfo(chp, element);
}
ui::ExternalItemsMenuLoader::load_all_external_items_callback([chp](ui::AppInfoConsole& info) {
printAppInfo(chp, info);
});
chprintf(chp, "ok\r\n");
}
static void cmd_cpld_read(BaseSequentialStream* chp, int argc, char* argv[]) {
const char* usage =
"usage: cpld_read <device> <target>\r\n"
@@ -1032,6 +1132,8 @@ static const ShellCommand commands[] = {
{"cpld_read", cmd_cpld_read},
{"accessibility_readall", cmd_accessibility_readall},
{"accessibility_readcurr", cmd_accessibility_readcurr},
{"applist", cmd_applist},
{"appstart", cmd_appstart},
{NULL, NULL}};
static const ShellConfig shell_cfg1 = {
@@ -1040,5 +1142,5 @@ static const ShellConfig shell_cfg1 = {
void create_shell(EventDispatcher* evtd) {
_eventDispatcherInstance = evtd;
shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 10);
}
+14
View File
@@ -95,6 +95,20 @@ void BasebandThread::run() {
buffer_c8_t buffer{
buffer_tmp.p, buffer_tmp.count, sampling_rate_};
if (shared_memory.request_m4_performance_counter == 0x02) {
uint8_t max = shared_memory.m4_performance_counter;
for (size_t i = 0; i < buffer_tmp.count; i++) {
int8_t a = buffer_tmp.p[i].real();
if (a < 0)
a = -a;
if (a > max)
max = a;
}
shared_memory.m4_performance_counter = max;
}
if (baseband_processor_) {
baseband_processor_->execute(buffer);
}
+10 -6
View File
@@ -135,13 +135,17 @@ void update_performance_counters() {
last_paint_state = !last_paint_state;
auto utilisation = get_cpu_utilisation_in_percent();
auto free_stack = (uint32_t)get_free_stack_space();
auto free_heap = chCoreStatus();
if (performance_counter_active == 0x01) {
auto utilisation = get_cpu_utilisation_in_percent();
auto free_stack = (uint32_t)get_free_stack_space();
auto free_heap = chCoreStatus();
shared_memory.m4_cpu_usage = utilisation;
shared_memory.m4_stack_usage = free_stack;
shared_memory.m4_heap_usage = free_heap;
shared_memory.m4_performance_counter = utilisation;
shared_memory.m4_stack_usage = free_stack;
shared_memory.m4_heap_usage = free_heap;
} else if (performance_counter_active == 0x02) {
shared_memory.m4_performance_counter = 0;
}
}
} /* extern "C" */
@@ -186,7 +186,7 @@ uint8_t usb_descriptor_string_manufacturer[] = {
uint8_t usb_descriptor_string_product[] = {
#ifdef HACKRF_ONE
43, // bLength
34, // bLength
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
'P', 0x00,
'o', 0x00,
+10
View File
@@ -191,6 +191,7 @@ class IO {
}
uint32_t io_read() {
chSysLock(); // Dont interrupt time critical tasks
io_stb_assert();
dir_read();
addr_0();
@@ -199,6 +200,7 @@ class IO {
__asm__("nop");
const auto switches_raw = data_read();
io_stb_deassert();
chSysUnlock();
return switches_raw;
}
@@ -297,6 +299,7 @@ class IO {
}
void lcd_command(const uint32_t value) {
chSysLock(); // Dont interrupt time critical tasks
data_write_high(0); /* Drive high byte (with zero -- don't care) */
dir_write(); /* Turn around data bus, MCU->CPLD */
addr(0); /* Indicate command */
@@ -312,9 +315,11 @@ class IO {
lcd_wr_deassert(); /* Complete write operation */
addr(1); /* Set up for data phase (most likely after a command) */
chSysUnlock();
}
void lcd_write_data(const uint32_t value) __attribute__((always_inline)) {
chSysLock(); // Dont interrupt time critical tasks
// NOTE: Assumes and DIR=0 and ADDR=1 from command phase.
data_write_high(value); /* Drive high byte */
__asm__("nop");
@@ -325,9 +330,11 @@ class IO {
__asm__("nop");
__asm__("nop");
lcd_wr_deassert(); /* Complete write operation */
chSysUnlock();
}
uint32_t lcd_read_data() {
chSysLock(); // Dont interrupt time critical tasks
// NOTE: Assumes ADDR=1 from command phase.
dir_read();
@@ -345,10 +352,12 @@ class IO {
halPolledDelay(18); // 90ns
const auto value_low = data_read();
chSysUnlock();
return (value_high << 8) | value_low;
}
void io_write(const bool address, const uint_fast16_t value) {
chSysLock(); // Dont interrupt time critical tasks
data_write_low(value);
dir_write();
addr(address);
@@ -360,6 +369,7 @@ class IO {
__asm__("nop");
__asm__("nop");
io_stb_deassert();
chSysUnlock();
}
/*
void lcd_data_write_command_and_data(
+1 -1
View File
@@ -71,7 +71,7 @@ struct SharedMemory {
void set_baseband_ready() { baseband_ready = true; }
uint8_t volatile request_m4_performance_counter{0};
uint8_t volatile m4_cpu_usage{0};
uint8_t volatile m4_performance_counter{0};
uint16_t volatile m4_stack_usage{0};
uint32_t volatile m4_heap_usage{0};
uint16_t volatile m4_buffer_missed{0};