Compare commits

...

23 Commits

Author SHA1 Message Date
jLynx ed834e3553 V2.0.0 setup (#1908)
* Update past_version.txt

* Update version.txt
2024-02-16 19:14:46 +00:00
Mark Thompson ce08d93ae2 Fix Pacman pause button glitches (again) (#1906) 2024-02-16 07:50:50 +01:00
Mark Thompson 13fd1b1f3b Support for configurable Menu Color & scrolling fix (#1905)
* Support for Configurable Menu Color Scheme
* Limit min value to 8 so doesn't get reset to default
* Increased max encoder rate multiplier value to 15
* Fixed menu scrolling issue
2024-02-16 07:19:43 +01:00
Mark Thompson d04c781ada Added Reboot app to Debug menu (#1904) 2024-02-16 07:18:33 +01:00
Mark Thompson 24605777a6 Show on_encoder delta in Buttons Test app (#1903) 2024-02-15 21:33:46 +01:00
Mark Thompson b5ac792853 Add color to position info lines in Notepad (#1902) 2024-02-15 18:12:40 +01:00
Mark Thompson 44c319dcc6 Refresh status bar after Pmem Reset (#1899) 2024-02-15 15:00:25 +01:00
Mark Thompson a442971b81 Eliminate unneeded screen flashing when scrolling menu (#1900) 2024-02-15 14:59:30 +01:00
Mark Thompson 8b5adb6bc1 Treat encoder rate multiplier value of 0 in pmem the same as 1 (#1898)
* Double-check encoder rate multiplier is not 0

* Eliminated redundant check in pmem init()
2024-02-15 07:05:05 +01:00
Bernd Herzog c3add0ce84 Cpld autodetect & boot splash screen (#1888)
* added delayed error message when hackrf cpld initialization fails

* refactoring

* implemented portapack cpld autodetection

* refactoring

* fixed valid config range

* added lcd fast setup

* added boot splash screen

* added one frame delay to remove flickering

* fixed config persistence
2024-02-14 23:17:33 +01:00
Mark Thompson 8725b01995 Fixed Pacman pause button (#1894) 2024-02-14 14:43:31 -06:00
E.T 936e8279f9 Add lto flag only to "internal" source files (#1895) 2024-02-14 13:54:20 -06:00
Mark Thompson 6193023c8f Fixed Pacman global object initialization (#1891) 2024-02-14 06:02:27 +01:00
Mark Thompson 1800939833 Fixed Tetris by eliminating some classes (#1890) 2024-02-13 20:54:40 +01:00
Mark Thompson 2f48fc2ef9 Disable LTO for external apps (#1886)
* Disable lto for external apps only

* Modified "shared external code" checks
2024-02-13 10:11:54 -06:00
Bernd Herzog 918ec0574f added delayed error message when hackrf cpld initialization fails (#1887)
* added delayed error message when hackrf cpld initialization fails

* refactoring
2024-02-13 13:06:47 +01:00
Mark Thompson 1139b22141 Fix compile error (#1884) 2024-02-12 19:04:48 +01:00
Brumi-2021 7598c25fc8 Solves random USB/LSB mode in SSB Mic App (H1R1). (#1882)
* Solves random USB/LSB mode in SSB Mic App (H1R1).

* format
2024-02-11 23:16:29 +01:00
Mark Thompson 0f6a9277a8 Warning for shared external code during build (#1881) 2024-02-11 21:25:00 +01:00
Mark Thompson 6a8650d484 Update Copyright in comment blocks (#1878) 2024-02-10 16:56:50 +01:00
Mark Thompson 46d9e02684 Encoder rotation rate multiplier support (#1876) 2024-02-10 09:32:03 +01:00
Mark Thompson 367479d163 Just shift menu icons up 1 row when hit bottom (#1874) 2024-02-10 09:21:35 +01:00
Mark Thompson bbbf5a37c8 Add progress bar to Soundboard app (#1875)
* Add progress bar to Soundboard app

* Clang
2024-02-10 09:04:00 +08:00
85 changed files with 1029 additions and 368 deletions
+1 -1
View File
@@ -1 +1 @@
v1.9.0
v1.9.1
+1 -1
View File
@@ -1 +1 @@
v1.9.1
v2.0.0
+8 -6
View File
@@ -44,7 +44,7 @@ if(cpp20_supported)
else()
set(USE_CPPOPT "-std=c++17")
endif()
set(USE_CPPOPT "${USE_CPPOPT} -flto -fno-rtti -fno-exceptions -Weffc++ -Wuninitialized -Wno-volatile")
set(USE_CPPOPT "${USE_CPPOPT} -fno-rtti -fno-exceptions -Weffc++ -Wuninitialized -Wno-volatile")
# Enable this if you want the linker to remove unused code and data
set(USE_LINK_GC yes)
@@ -52,7 +52,7 @@ set(USE_LINK_GC yes)
# Linker extra options here.
set(USE_LDOPT)
# Enable this if you want link time optimizations (LTO)
# Enable this if you want link time optimizations (LTO) - this flag affects chibios only
set(USE_LTO no)
# If enabled, this option allows to compile the application in THUMB mode.
@@ -293,7 +293,7 @@ set(CPPSRC
# apps/ui_jammer.cpp
# apps/ui_keyfob.cpp
# apps/ui_lcr.cpp
apps/ui_level.cpp
apps/ui_level.cpp
apps/ui_looking_glass_app.cpp
apps/ui_mictx.cpp
apps/ui_modemsetup.cpp
@@ -304,7 +304,7 @@ set(CPPSRC
apps/ui_pocsag_tx.cpp
apps/ui_rds.cpp
apps/ui_recon_settings.cpp
apps/ui_recon.cpp
apps/ui_recon.cpp
apps/ui_remote.cpp
apps/ui_scanner.cpp
apps/ui_sd_over_usb.cpp
@@ -347,10 +347,12 @@ set(CPPSRC
${HACKRF_CPLD_DATA_CPP}
ui_external_items_menu_loader.cpp
view_factory_base.cpp
${EXTCPPSRC}
)
set_source_files_properties(${CPPSRC} PROPERTIES COMPILE_FLAGS -flto) # Add lto flag to the non-external sources only
list (APPEND CPPSRC ${EXTCPPSRC}) # Append external sources after setting lto flag to internal ones
# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+6 -6
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -51,7 +52,7 @@ void SoundBoardView::stop() {
void SoundBoardView::handle_replay_thread_done(const uint32_t return_code) {
stop();
// progressbar.set_value(0);
progressbar.set_value(0);
if (return_code == ReplayThread::END_OF_FILE) {
if (check_random.value()) {
@@ -100,7 +101,7 @@ void SoundBoardView::start_tx(const uint32_t id) {
playing_id = id;
// progressbar.set_max(reader->sample_count());
progressbar.set_max(reader->sample_count());
// button_play.set_bitmap(&bitmap_stop);
@@ -148,8 +149,7 @@ void SoundBoardView::start_tx(const uint32_t id) {
}*/
void SoundBoardView::on_tx_progress(const uint32_t progress) {
(void)progress; // avoid warning
// progressbar.set_value(progress);
progressbar.set_value(progress);
}
void SoundBoardView::on_select_entry() {
@@ -213,7 +213,7 @@ void SoundBoardView::refresh_list() {
for (size_t n = 0; n < file_list.size(); n++) {
menu_view.add_item({file_list[n].string().substr(0, 30),
ui::Color::white(),
ui::Color::dark_magenta(),
nullptr,
[this](KeyEvent) {
on_select_entry();
@@ -240,7 +240,7 @@ SoundBoardView::SoundBoardView(
&options_tone_key,
//&text_title,
//&text_duration,
//&progressbar,
&progressbar,
&field_volume,
&text_volume_disabled,
&page_info,
+4 -4
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -103,7 +104,7 @@ class SoundBoardView : public View {
"<="};
Text page_info{
{0, 30 * 8 - 4, 30 * 8, 16}};
{0, 29 * 8, 30 * 8, 16}};
MenuView menu_view{
{0, 0, 240, 175},
@@ -142,9 +143,8 @@ class SoundBoardView : public View {
6,
"Random"};
// ProgressBar progressbar {
// { 0 * 8, 30 * 8 - 4, 30 * 8, 16 }
// };
ProgressBar progressbar{
{0 * 8, 31 * 8 + 2, 30 * 8, 4}};
TransmitterView tx_view{
16 * 16,
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -2,6 +2,7 @@
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -2,6 +2,7 @@
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+20
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -322,6 +323,11 @@ bool ControlsSwitchesWidget::on_key(const KeyEvent key) {
return true;
}
bool ControlsSwitchesWidget::on_encoder(const EncoderEvent delta) {
last_delta = delta;
return true;
}
void ControlsSwitchesWidget::paint(Painter& painter) {
const auto pos = screen_pos();
@@ -404,6 +410,8 @@ void ControlsSwitchesWidget::paint(Painter& painter) {
switches_event >>= 1;
}
painter.draw_string({5 * 8, 12 * 16}, Styles::light_grey, to_string_dec_int(last_delta, 3));
}
void ControlsSwitchesWidget::on_frame_sync() {
@@ -449,6 +457,17 @@ DebugPeripheralsMenuView::DebugPeripheralsMenuView(NavigationView& nav) {
set_max_rows(2); // allow wider buttons
}
/* DebugReboot **********************************************/
DebugReboot::DebugReboot(NavigationView& nav) {
(void)nav;
LPC_RGU->RESET_CTRL[0] = (1 << 0);
while (1)
__WFE();
}
/* DebugMenuView *********************************************************/
DebugMenuView::DebugMenuView(NavigationView& nav) {
@@ -464,6 +483,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
{"Peripherals", ui::Color::dark_cyan(), &bitmap_icon_peripherals, [&nav]() { nav.push<DebugPeripheralsMenuView>(); }},
{"Pers. Memory", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { nav.push<DebugPmemView>(); }},
//{ "Radio State", ui::Color::white(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
{"Reboot", ui::Color::dark_cyan(), &bitmap_icon_setup, [&nav]() { nav.push<DebugReboot>(); }},
{"SD Card", ui::Color::dark_cyan(), &bitmap_icon_sdcard, [&nav]() { nav.push<SDCardDebugView>(); }},
{"Temperature", ui::Color::dark_cyan(), &bitmap_icon_temperature, [&nav]() { nav.push<TemperatureView>(); }},
{"Touch Test", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push<DebugScreenTest>(); }},
+11 -1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -251,18 +252,21 @@ class ControlsSwitchesWidget : public Widget {
Rect parent_rect)
: Widget{parent_rect},
key_event_mask(0),
long_press_key_event_mask{0} {
long_press_key_event_mask{0},
last_delta{0} {
set_focusable(true);
}
void on_show() override;
bool on_key(const KeyEvent key) override;
bool on_encoder(const EncoderEvent delta) override;
void paint(Painter& painter) override;
private:
uint8_t key_event_mask;
uint8_t long_press_key_event_mask;
EncoderEvent last_delta;
MessageHandlerRegistration message_handler_frame_sync{
Message::ID::DisplayFrameSync,
@@ -284,6 +288,7 @@ class DebugControlsView : public View {
private:
Labels labels{
{{8 * 8, 1 * 16}, "Controls State", Color::white()},
{{0 * 8, 11 * 16}, "Dial:", Color::grey()},
{{0 * 8, 14 * 16}, "Long-Press Mode:", Color::grey()}};
ControlsSwitchesWidget switches_widget{
@@ -419,6 +424,11 @@ class DebugPeripheralsMenuView : public BtnGridView {
std::string title() const override { return "Peripherals"; };
};
class DebugReboot : public BtnGridView {
public:
DebugReboot(NavigationView& nav);
};
class DebugMenuView : public BtnGridView {
public:
DebugMenuView(NavigationView& nav);
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Bernd Herzog
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Bernd Herzog
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -3,6 +3,7 @@
* Copyright (C) 2016 Furrtek
* Copyleft () 2022 NotPike
* Copyright (C) 2023 Kyle Reed, zxkmm
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -2,6 +2,7 @@
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2023 Kyle Reed, zxkmm
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2018 Furrtek
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2018 Furrtek
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+57 -2
View File
@@ -3,6 +3,7 @@
* Copyright (C) 2016 Furrtek
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2024 Mark Thompson
* Copyleft (ɔ) 2024 zxkmm under GPL license
*
* This file is part of PortaPack.
@@ -43,6 +44,7 @@ namespace fs = std::filesystem;
#include "string_format.hpp"
#include "ui_styles.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "cpld_update.hpp"
#include "config_mode.hpp"
@@ -611,6 +613,8 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
[this](bool choice) {
if (choice) {
pmem::cache::defaults();
// Refresh status bar
send_system_refresh();
}
});
};
@@ -680,13 +684,16 @@ void SetQRCodeView::focus() {
SetEncoderDialView::SetEncoderDialView(NavigationView& nav) {
add_children({&labels,
&field_encoder_dial_sensitivity,
&field_encoder_rate_multiplier,
&button_save,
&button_cancel});
field_encoder_dial_sensitivity.set_by_value(pmem::config_encoder_dial_sensitivity());
field_encoder_dial_sensitivity.set_by_value(pmem::encoder_dial_sensitivity());
field_encoder_rate_multiplier.set_value(pmem::encoder_rate_multiplier());
button_save.on_select = [&nav, this](Button&) {
pmem::set_encoder_dial_sensitivity(field_encoder_dial_sensitivity.selected_index_value());
pmem::set_encoder_rate_multiplier(field_encoder_rate_multiplier.value());
nav.pop();
};
@@ -751,7 +758,7 @@ void SetConfigModeView::focus() {
button_save.focus();
}
/* FakeBrightnessView ************************************/
/* SetFakeBrightnessView ************************************/
SetFakeBrightnessView::SetFakeBrightnessView(NavigationView& nav) {
add_children({&labels,
@@ -779,6 +786,53 @@ void SetFakeBrightnessView::focus() {
button_save.focus();
}
/* SetMenuColorView ************************************/
void SetMenuColorView::paint_sample() {
Color c = Color(field_red_level.value(), field_green_level.value(), field_blue_level.value());
button_sample.set_bg_color(c);
}
SetMenuColorView::SetMenuColorView(NavigationView& nav) {
add_children({&labels,
&button_sample,
&field_red_level,
&field_green_level,
&field_blue_level,
&button_save,
&button_cancel});
button_sample.set_focusable(false);
Color c = pmem::menu_color();
field_red_level.set_value(c.r());
field_green_level.set_value(c.g());
field_blue_level.set_value(c.b());
paint_sample();
const auto color_changed_fn = [this](int32_t) {
paint_sample();
};
field_red_level.on_change = color_changed_fn;
field_green_level.on_change = color_changed_fn;
field_blue_level.on_change = color_changed_fn;
button_save.on_select = [&nav, this](Button&) {
Color c = Color(field_red_level.value(), field_green_level.value(), field_blue_level.value());
pmem::set_menu_color(c);
send_system_refresh();
nav.pop();
};
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
void SetMenuColorView::focus() {
button_save.focus();
}
/* SettingsMenuView **************************************/
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
@@ -800,6 +854,7 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) {
{"User Interface", ui::Color::dark_cyan(), &bitmap_icon_options_ui, [&nav]() { nav.push<SetUIView>(); }},
{"QR Code", ui::Color::dark_cyan(), &bitmap_icon_qr_code, [&nav]() { nav.push<SetQRCodeView>(); }},
{"Brightness", ui::Color::dark_cyan(), &bitmap_icon_brightness, [&nav]() { nav.push<SetFakeBrightnessView>(); }},
{"Menu Color", ui::Color::dark_cyan(), &bitmap_icon_brightness, [&nav]() { nav.push<SetMenuColorView>(); }},
});
set_max_rows(2); // allow wider buttons
}
+76 -4
View File
@@ -3,6 +3,7 @@
* Copyright (C) 2016 Furrtek
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2024 Mark Thompson
* Copyleft (ɔ) 2024 zxkmm under GPL license
*
* This file is part of PortaPack.
@@ -555,6 +556,7 @@ class SetQRCodeView : public View {
};
using portapack::persistent_memory::encoder_dial_sensitivity;
using portapack::persistent_memory::encoder_rate_multiplier;
class SetEncoderDialView : public View {
public:
@@ -566,18 +568,30 @@ class SetEncoderDialView : public View {
private:
Labels labels{
{{1 * 8, 1 * 16}, "Adjusts how many steps to", Color::light_grey()},
{{1 * 8, 2 * 16}, "change the encoder value.", Color::light_grey()},
{{2 * 8, 4 * 16}, "Dial sensitivity:", Color::light_grey()},
{{1 * 8, 1 * 16}, "Adjusts sensitivity to dial", Color::light_grey()},
{{1 * 8, 2 * 16}, "rotation position (number of", Color::light_grey()},
{{1 * 8, 3 * 16}, "steps per full rotation):", Color::light_grey()},
{{2 * 8, 5 * 16}, "Dial sensitivity:", Color::light_grey()},
{{1 * 8, 8 * 16}, "Adjusts sensitivity to dial", Color::light_grey()},
{{1 * 8, 9 * 16}, "rotation rate (default 1", Color::light_grey()},
{{1 * 8, 10 * 16}, "means no rate dependency):", Color::light_grey()},
{{3 * 8, 12 * 16}, "Rate multiplier:", Color::light_grey()},
};
OptionsField field_encoder_dial_sensitivity{
{20 * 8, 4 * 16},
{20 * 8, 5 * 16},
6,
{{"LOW", encoder_dial_sensitivity::DIAL_SENSITIVITY_LOW},
{"NORMAL", encoder_dial_sensitivity::DIAL_SENSITIVITY_NORMAL},
{"HIGH", encoder_dial_sensitivity::DIAL_SENSITIVITY_HIGH}}};
NumberField field_encoder_rate_multiplier{
{20 * 8, 12 * 16},
2,
{1, 15},
1,
' '};
Button button_save{
{2 * 8, 16 * 16, 12 * 8, 32},
"Save"};
@@ -717,6 +731,64 @@ class SetFakeBrightnessView : public View {
};
};
class SetMenuColorView : public View {
public:
SetMenuColorView(NavigationView& nav);
void focus() override;
std::string title() const override { return "Menu Color"; };
private:
void paint_sample();
Labels labels{
{{3 * 8, 1 * 16}, "Menu Button Color Scheme", Color::light_grey()},
{{2 * 8, 8 * 16}, "Red Level:", Color::light_grey()},
{{2 * 8, 9 * 16}, "Green Level:", Color::light_grey()},
{{2 * 8, 10 * 16}, "Blue Level:", Color::light_grey()},
};
NewButton button_sample{
{8 * 8, 4 * 16, 14 * 8, 3 * 16},
"New Color",
&bitmap_icon_brightness,
};
NumberField field_red_level{
{15 * 8, 8 * 16},
3,
{8, 248},
8,
' ',
};
NumberField field_green_level{
{15 * 8, 9 * 16},
3,
{8, 248},
8,
' ',
};
NumberField field_blue_level{
{15 * 8, 10 * 16},
3,
{8, 248},
8,
' ',
};
Button button_save{
{2 * 8, 16 * 16, 12 * 8, 32},
"Save"};
Button button_cancel{
{16 * 8, 16 * 16, 12 * 8, 32},
"Cancel",
};
};
class SettingsMenuView : public BtnGridView {
public:
SettingsMenuView(NavigationView& nav);
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -426,6 +427,9 @@ TextEditorView::TextEditorView(NavigationView& nav)
&text_size,
});
text_position.set_style(&Styles::bg_dark_blue);
text_size.set_style(&Styles::bg_dark_blue);
viewer.set_font_zoom(enable_zoom);
viewer.on_select = [this]() {
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2023 Kyle Reed
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+2 -1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -126,7 +127,7 @@ class ViewWavView : public View {
Color::white()};
ProgressBar progressbar{
{0 * 8, 11 * 16, 30 * 8, 8}};
{0 * 8, 11 * 16, 30 * 8, 4}};
NumberField field_pos_seconds{
{9 * 8, 12 * 16},
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+6
View File
@@ -44,6 +44,8 @@ using namespace lpc43xx;
#include "ui_navigation.hpp"
static int delayed_error = 0;
extern "C" {
CH_IRQ_HANDLER(M4Core_IRQHandler) {
@@ -161,6 +163,10 @@ void EventDispatcher::dispatch(const eventmask_t events) {
}
if (events & EVT_MASK_RTC_TICK) {
// delay error message by 2 seconds to wait for LCD being ready
if (portapack::init_error != nullptr && ++delayed_error > 1)
draw_guru_meditation(CORTEX_M4, portapack::init_error);
handle_rtc_tick();
}
+22 -20
View File
@@ -1,5 +1,6 @@
/*
Copyright (C) 2023 Bernd Herzog
Copyright (C) 2024 Mark Thompson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,22 +17,27 @@
MEMORY
{
/* external apps: regions can't overlap so addresses are corrected after build */
ram_external_app_pacman (rwx) : org = 0xEEE90000, len = 32k
ram_external_app_afsk_rx (rwx) : org = 0xEEEA0000, len = 32k
ram_external_app_calculator (rwx) : org = 0xEEEB0000, len = 32k
ram_external_app_font_viewer(rwx) : org = 0xEEEC0000, len = 32k
ram_external_app_blespam(rwx) : org = 0xEEED0000, len = 32k
ram_external_app_analogtv(rwx) : org = 0xEEEE0000, len = 32k
ram_external_app_nrf_rx(rwx) : org = 0xEEEF0000, len = 32k
ram_external_app_coasterp(rwx) : org = 0xEEF00000, len = 32k
ram_external_app_lge(rwx) : org = 0xEEF10000, len = 32k
ram_external_app_lcr(rwx) : org = 0xEEF20000, len = 32k
ram_external_app_jammer(rwx) : org = 0xEEF30000, len = 32k
ram_external_app_gpssim(rwx) : org = 0xEEF40000, len = 32k
ram_external_app_spainter(rwx) : org = 0xEEF50000, len = 32k
ram_external_app_keyfob(rwx) : org = 0xEEF60000, len = 32k
ram_external_app_tetris(rwx) : org = 0xEEF70000, len = 32k
/*
* External apps: regions can't overlap so addresses are corrected after build.
* Picking uncommon address values for search & replace in binaries (no false positives) - 0xADB00000-0xADEF0000 seems to be good.
* Also need to consider processor memory map - reading 0xADxxxxxx generates a fault which may be better than unexpected behavior.
* External app address ranges below must match those in python file "external_app_info.py".
*/
ram_external_app_pacman (rwx) : org = 0xADB00000, len = 32k
ram_external_app_afsk_rx (rwx) : org = 0xADB10000, len = 32k
ram_external_app_calculator (rwx) : org = 0xADB20000, len = 32k
ram_external_app_font_viewer(rwx) : org = 0xADB30000, len = 32k
ram_external_app_blespam(rwx) : org = 0xADB40000, len = 32k
ram_external_app_analogtv(rwx) : org = 0xADB50000, len = 32k
ram_external_app_nrf_rx(rwx) : org = 0xADB60000, len = 32k
ram_external_app_coasterp(rwx) : org = 0xADB70000, len = 32k
ram_external_app_lge(rwx) : org = 0xADB80000, len = 32k
ram_external_app_lcr(rwx) : org = 0xADB90000, len = 32k
ram_external_app_jammer(rwx) : org = 0xADBA0000, len = 32k
ram_external_app_gpssim(rwx) : org = 0xADBB0000, len = 32k
ram_external_app_spainter(rwx) : org = 0xADBC0000, len = 32k
ram_external_app_keyfob(rwx) : org = 0xADBD0000, len = 32k
ram_external_app_tetris(rwx) : org = 0xADBE0000, len = 32k
}
SECTIONS
@@ -60,7 +66,6 @@ SECTIONS
*(*ui*external_app*font_viewer*);
} > ram_external_app_font_viewer
.external_app_blespam : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_blespam.application_information));
@@ -91,14 +96,12 @@ SECTIONS
*(*ui*external_app*lge*);
} > ram_external_app_lge
.external_app_lcr : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_lcr.application_information));
*(*ui*external_app*lcr*);
} > ram_external_app_lcr
.external_app_jammer : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_jammer.application_information));
@@ -111,7 +114,6 @@ SECTIONS
*(*ui*external_app*gpssim*);
} > ram_external_app_gpssim
.external_app_spainter : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_spainter.application_information));
+22 -7
View File
@@ -13,8 +13,6 @@ namespace ui::external_app::pacman {
#include "playfield.hpp"
#pragma GCC diagnostic pop
Playfield _game;
PacmanView::PacmanView(NavigationView& nav)
: nav_(nav) {
add_children({&dummy});
@@ -26,19 +24,36 @@ void PacmanView::focus() {
void PacmanView::paint(Painter& painter) {
(void)painter;
static Playfield _game;
static bool wait_for_button_release{false};
if (!initialized) {
initialized = true;
_game.Init();
}
auto switches_raw = swizzled_switches() & ((1 << (int)Switch::Right) | (1 << (int)Switch::Left) | (1 << (int)Switch::Down) | (1 << (int)Switch::Up) | (1 << (int)Switch::Sel) | (1 << (int)Switch::Dfu));
auto switches_debounced = get_switches_state().to_ulong();
but_RIGHT = (switches_debounced & 0x01) == 0x01;
but_LEFT = (switches_debounced & 0x02) == 0x02;
but_DOWN = (switches_debounced & 0x04) == 0x04;
but_UP = (switches_debounced & 0x08) == 0x08;
but_A = (switches_debounced & 0x10) == 0x10;
// For the Select (Start/Pause) button, wait for release to avoid repeat
uint8_t buttons_to_wait_for = (1 << (int)Switch::Sel);
if (wait_for_button_release) {
if ((switches_debounced & buttons_to_wait_for) == 0)
wait_for_button_release = false;
switches_debounced &= ~buttons_to_wait_for;
} else {
if (switches_debounced & buttons_to_wait_for)
wait_for_button_release = true;
}
// For the directional buttons, use the raw inputs for fastest response time
but_RIGHT = (switches_raw & (1 << (int)Switch::Right)) != 0;
but_LEFT = (switches_raw & (1 << (int)Switch::Left)) != 0;
but_DOWN = (switches_raw & (1 << (int)Switch::Down)) != 0;
but_UP = (switches_raw & (1 << (int)Switch::Up)) != 0;
// For the pause button, use the debounced input to avoid glitches, and OR in the value to make sure that we don't clear it before it's seen
but_A |= (switches_debounced & (1 << (int)Switch::Sel)) != 0;
_game.Step();
}
+30 -22
View File
@@ -56,35 +56,43 @@ static const Color pp_colors[] = {
Color::black(),
};
class SPI_TFT_ILI9341 {
public:
SPI_TFT_ILI9341(int, int, int, int, int, int, std::string) { (void)0; };
// NB: ELIMINATED SPI_TFT_ILI9341 DISPLAY CLASS DUE TO GLOBAL OBJECT INITIALIZATION ISSUE WITH EXTERNAL APPS
void claim(__FILE* x) { (void)x; };
static void claim(__FILE* x) {
(void)x;
};
void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
};
static void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
};
void background(int color) { bg_color = color; };
void foreground(int color) { fg_color = color; };
static void background(int color) {
bg_color = color;
};
void locate(int x, int y) {
x_pos = x;
y_pos = y;
};
void set_orientation(int x) { (void)x; };
void set_font(unsigned char* x) { (void)x; };
static void foreground(int color) {
fg_color = color;
};
void fillrect(int x1, int y1, int x2, int y2, int color) {
painter.fill_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
};
static void locate(int x, int y) {
x_pos = x;
y_pos = y;
};
void rect(int x1, int y1, int x2, int y2, int color) {
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
};
static void set_orientation(int x) {
(void)x;
};
private:
static void set_font(unsigned char* x) {
(void)x;
};
static void fillrect(int x1, int y1, int x2, int y2, int color) {
painter.fill_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
};
static void rect(int x1, int y1, int x2, int y2, int color) {
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
};
static void printf(std::string str) {
+1 -1
View File
@@ -67,7 +67,7 @@ static bool but_DOWN;
static bool but_SELECT;
//
// AnalogIn Class -- DID NOT WORK BECAUSE INITIALIZER CODE WON'T EXECUTE -- hacked original code module instead
// AnalogIn Class -- DID NOT WORK DUE TO GLOBAL OBJECT INITIALIZER ISSUE WITH EXTERNAL APPS -- hacked original code module instead
//
// dp9 = joystick rotate button --> select button
// dp10 = joystick y --> up & down buttons
+79 -109
View File
@@ -4,9 +4,15 @@
// clang-format off
//////// PORTAPACK CHANGES HIGHLIGHTED
//////// HACKED FOR PORTAPACK -- CHANGES HIGHLIGHTED
int main();
void pause_game();
void Initialize(unsigned char c);
void DeleteFigure();
void DrawFigure();
bool InCollisionDown(char delta);
bool InCollisionLeft();
bool InCollisionRight();
//////// PORTAPACK
#include "mbed.h"
@@ -15,32 +21,29 @@ void pause_game();
#define dp23 P0_0
//////// PORTAPACK - DISABLED MOST CLASSES DUE TO GLOBAL OBJECT INITIALIZER ISSUE WITH EXTERNAL APPS:
//deklaracija display-a
SPI_TFT_ILI9341 display(dp2, dp1, dp6, dp24, dp23, dp25, "TFT");
//////// PORTAPACK - DISABLED ANALOGIN CLASS DUE TO OBJECT INITIALIZER CODE NOT RUNNING:
//SPI_TFT_ILI9341 display(dp2, dp1, dp6, dp24, dp23, dp25, "TFT");
//
//analogni ulazi za joystick
// AnalogIn VRx(dp11);
// AnalogIn VRy(dp10);
//
// AnalogIn random(dp13); //analogni ulaz za generisanje random vrijednosti
//////// PORTAPACK
//taster na joysticku za rotaciju
InterruptIn taster(dp9);
//////// PORTAPACK - DISABLED ANALOGIN CLASS DUE TO OBJECT INITIALIZER CODE NOT RUNNING:
// AnalogIn random(dp13); //analogni ulaz za generisanje random vrijednosti
//////// PORTAPACK
//ticker za spustanje figure
//timer za debouncing tastera na joysticku
Ticker game, joystick;
Timer debounceTaster;
unsigned char level = 0; //mora biti tipa usigned char jer inače se može desiti da level bude manji od 0, a i da ne trošimo memoriju
const float delays[4] = {1.2, 0.7, 0.4, 0.25}; //svakih koliko se spusti jedan red, ovo provjeriti da li je presporo ili prebrzo, ovisi o levelu
//////// PORTAPACK - UNNEEDED JOYSTICK HYSTERESIS VARIABLES
//////// PORTAPACK - DELETED UNNEEDED JOYSTICK HYSTERESIS VARIABLES
//char leftBoundary = 1, rightBoundary = 5, downBoundary = 1, upBoundary = 5;// sada je ovo tipa char
//////// PORTAPACK
@@ -49,7 +52,6 @@ bool firstTime = true; //ako je prvi put, figura se crta u Tickeru
bool gameStarted = false;
unsigned char nextFigure = 1; //ovo je sad globalna varijabla, da bi mogli unaprijed generisati sljedeću figuru radi prikaza
//white - no figure
//I - BLUE
//O - YELLOW
@@ -69,81 +71,70 @@ short figuresY[7][4] = {{0,1,2,3}, {1,0,0,1}, {1,1,2,0}, {0,1,1,2}, {0,1,1,2}, {
unsigned int GenerateRandomSeed() {
//////// PORTAPACK - USE RTC FOR SEED
return LPC_RTC->CTIME0;
// unsigned int randomNumber = 0;
// for(int i = 0; i <= 32; i += 2) {
// randomNumber += ((random.read_u16() % 3) << i);
// wait_us(10);
// }
// return randomNumber;
//////// PORTAPACK
}
void Init() {
//ovo su zajedničke osobine za sve prikaze na display-u
//nikad se ne mijenjaju i pozvat ćemo je jednom prije petlje
display.claim(stdout);
display.set_orientation(2); // 2 ili 0, zavisi kako okrenemo display, provjerit ćemo na labu kako nam je najlakše povezat
display.set_font((unsigned char*) Arial12x12);
claim(stdout);
set_orientation(2); // 2 ili 0, zavisi kako okrenemo display, provjerit ćemo na labu kako nam je najlakše povezat
set_font((unsigned char*) Arial12x12);
}
void ShowScore() {
//pomocna funkcija za prikazivanje score-a
display.fillrect(165, 20, 235, 50, White); //popunimo pravugaonik da obrišemo stari score
display.locate(200, 35); //valjda je na sredini pravougaonika
fillrect(165, 20, 235, 50, White); //popunimo pravugaonik da obrišemo stari score
locate(200, 35); //valjda je na sredini pravougaonika
printf("%d", score);
}
void ShowNextFigure() {
//prikaz sljedeće figure koristeći pomoćnu varijablu nextFigure
display.fillrect(165, 70, 235, 120, White);
fillrect(165, 70, 235, 120, White);
int upperLeftX = 176, upperLeftY = 83;
for(int i = 0; i < 4; i++) {
int x = upperLeftX + DIMENSION_NEXT * figuresY[nextFigure - 1][i], y = upperLeftY + DIMENSION_NEXT * figuresX[nextFigure - 1][i];
display.fillrect(x, y, x + DIMENSION_NEXT, y + DIMENSION_NEXT, colors[nextFigure]);
display.rect(x, y, x + DIMENSION_NEXT, y + DIMENSION_NEXT, Black);
fillrect(x, y, x + DIMENSION_NEXT, y + DIMENSION_NEXT, colors[nextFigure]);
rect(x, y, x + DIMENSION_NEXT, y + DIMENSION_NEXT, Black);
}
}
//funkcija za crtanje cursora za odabir levela
void DrawCursor(int color, unsigned char lev) {
display.fillrect(60, lev * 70 + 50, 72, lev * 70 + 50 + 12, color);
fillrect(60, lev * 70 + 50, 72, lev * 70 + 50 + 12, color);
}
// PORTAPACK - ADDED EXTRA LEVEL:
void ShowLevelMenu() {
//ovdje inicijalizujemo display
display.cls(); // brišemo prethodno
display.background(Black);
display.foreground(White);
display.locate(80, 50);
cls(); // brišemo prethodno
background(Black);
foreground(White);
locate(80, 50);
printf("LEVEL 1");
display.locate(80, 120);
locate(80, 120);
printf("LEVEL 2");
display.locate(80, 190);
locate(80, 190);
printf("LEVEL 3");
display.locate(80, 260);
locate(80, 260);
printf("LEVEL 4");
DrawCursor(White, level);
}
//////// PORTAPACK
//////// PORTAPACK - KLUDGED FOR BUTTONS VS JOYSTICK:
//////// PORTAPACK - USE BUTTONS VS JOYSTICK:
void ReadJoystickForLevel(){
unsigned char old = level;
if(but_UP){
// upBoundary = 4;
(level == 0) ? level = 3 : level--;
}
else if(but_DOWN){
//ne radi ona prethodna varijanta jer % vraća i negastivni rezultat
//to što ne koristimo unsigned tip ne pomaže jer će doći do overflow-a
// downBoundary = 2;
level = (level + 1) % 4;
}
else {
// downBoundary = 1;
// upBoundary = 5;
}
DrawCursor(Black, old); //na prethodni level popunimo bojom pozadine
DrawCursor(White, level); //na novi level popunimo bijelom bojom - pozadina je crna
//koristio sam fillrect, jer njega svakako moramo koristiti, jer možda budemo morali da brišemo fillcircle iz biblioteke
@@ -169,11 +160,11 @@ main();
void StartGame()
{
display.cls(); // brišemo ShowLevelMenu
display.background(White);
display.foreground(Black);
display.fillrect(0, 0, 160, 320, White);
display.fillrect(160, 0, 240, 320, Black); //dio za prikazivanje rezultata će biti crni pravougaonik, a tabla je bijeli
cls(); // brišemo ShowLevelMenu
background(White);
foreground(Black);
fillrect(0, 0, 160, 320, White);
fillrect(160, 0, 240, 320, Black); //dio za prikazivanje rezultata će biti crni pravougaonik, a tabla je bijeli
ShowScore();
}
@@ -206,34 +197,34 @@ void PutBorders(short x, short y) {
for(int i = x - 1; i <= x + 1; i++) {
for(int j = y - 1; j <= y + 1; j++) {
if(i < 0 || i > 9 || j < 0 || j > 19 || board[j][i] == 0) continue;
display.rect(i * DIMENSION, j * DIMENSION, (i + 1) * DIMENSION, (j + 1) * DIMENSION, Black);
rect(i * DIMENSION, j * DIMENSION, (i + 1) * DIMENSION, (j + 1) * DIMENSION, Black);
}
}
}
class Tetromino{
private:
//////// PORTAPACK - ELIMINATED CLASSES DUE TO GLOBAL OBJECT INITIALIZATION ISSUE WITH EXTERNAL APPS:
//class Tetromino{
//private:
short X[4];
short Y[4];
short boardX, boardY;
unsigned char colorIndex;//dodao sam colorIndex zasad, jer nema drugog načina da popunimo matricu sa indeksima boja
//ovo je najbezbolnija varijanta što se memorije tiče
public:
Tetromino(){
//////// PORTAPACK - NOTE - DEFAULT INITIALIZER CODE DOESN'T GET EXECUTED FOR SOME REASON:
unsigned char r = rand() % 7 + 1;
Initialize(r);
//public:
// Tetromino(){
// unsigned char r = rand() % 7 + 1;
// Initialize(r);
// }
void Tetromino(unsigned char c) {
Initialize(c);
}
Tetromino(unsigned char colorIndex) {
Initialize(colorIndex);
}
void Initialize(unsigned char colorIndex) {
Tetromino::colorIndex = colorIndex;
void Initialize(unsigned char c) {
colorIndex = c;
boardX = 0;
boardY = 4; //3,4 ili 5 najbolje da vidimo kad imamo display
copyCoordinates(X, Y, colorIndex - 1);
copyCoordinates(X, Y, c - 1);
}
void Rotate(){
@@ -266,13 +257,9 @@ public:
//stavio sam 16 za početak, možemo se opet skontati na labu
//ovo pretpostavlja da nema margina, mogu se lagano dodati uz neku konstantu kao offset
int upperLeftX = (boardX + X[i]) * DIMENSION, upperLeftY = (boardY + Y[i]) * DIMENSION;
display.fillrect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, colors[colorIndex]);
fillrect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, colors[colorIndex]);
//ovo boji granice blokova u crno, možemo skloniti ako ti se ne sviđa
//////// PORTAPACK - HIDE DEFAULT WHITE BLOCK (ALTERNATE KLUDGE FOR TETRONIMO INITIALIZATION CODE NOT RUNNING AT CONSTRUCTION)
if (colorIndex != White)
//////// PORTAPACK
display.rect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, Black);
rect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, Black);
}
}
@@ -280,7 +267,7 @@ if (colorIndex != White)
for(int i = 0; i < 4; i++) {
//ista logika kao u DrawFigure, samo popunjavamo sve blokove sa bijelim pravougaonicima
short upperLeftX = (boardX + X[i]) * DIMENSION, upperLeftY = (boardY + Y[i]) * DIMENSION;
display.fillrect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, White);
fillrect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, White);
PutBorders(upperLeftY, upperLeftX);
}
}
@@ -295,9 +282,6 @@ if (colorIndex != White)
}
bool MoveDown(char delta = 1){
//////// PORTAPACK - MOVE DEFAULT WHITE BLOCK TO BOTTOM IMMEDIATELY (ALTERNATE KLUDGE FOR TETRONIMO INITIALIZATION CODE NOT RUNNING AT CONSTRUCTION)
if (colorIndex == White) delta = 19;
//////// PORTAPACK
if(!InCollisionDown(delta)){
DeleteFigure();
boardX+=delta;
@@ -384,34 +368,23 @@ if (colorIndex == White) delta = 19;
return false;
}
};
// };
// Tetromino currentTetromino;
Tetromino currentTetromino;
//////// PORTAPACK - KLUDGED FOR BUTTONS VS JOYSTICK:
//////// PORTAPACK - USE BUTTONS VS JOYSTICK, AND ADDED PAUSE FEATURE:
void ReadJoystickForFigure() {
if(but_LEFT) {
// leftBoundary = 2;
currentTetromino.MoveLeft();
MoveLeft();
}
else if(but_RIGHT) {
// rightBoundary = 4;
currentTetromino.MoveRight();
MoveRight();
}
else if(but_UP) {
// downBoundary = 2;
pause_game();
pause_game();
}
else if(but_DOWN) {
// upBoundary = 4;
currentTetromino.SoftDrop();
}
else {
// leftBoundary = 1;
// rightBoundary = 5;
// downBoundary = 1;
// upBoundary = 5;
SoftDrop();
}
}
//////// PORTAPACK
@@ -460,10 +433,10 @@ void UpdateBoard()
board[i][j] = board[i - numberOfLines][j];
board[i - numberOfLines][j] = 0;
short tmp = i - numberOfLines;
display.fillrect( j * DIMENSION,i * DIMENSION, (j + 1) * DIMENSION , (i + 1) * DIMENSION , colors[board[i][j]]); // bojimo novi blok
display.fillrect( j * DIMENSION, tmp * DIMENSION,(j + 1) * DIMENSION, (tmp + 1) * DIMENSION , White);
fillrect( j * DIMENSION,i * DIMENSION, (j + 1) * DIMENSION , (i + 1) * DIMENSION , colors[board[i][j]]); // bojimo novi blok
fillrect( j * DIMENSION, tmp * DIMENSION,(j + 1) * DIMENSION, (tmp + 1) * DIMENSION , White);
if(board[i][j] != 0)
display.rect( j * DIMENSION,i * DIMENSION, (j + 1) * DIMENSION , (i + 1) * DIMENSION , Black);
rect( j * DIMENSION,i * DIMENSION, (j + 1) * DIMENSION , (i + 1) * DIMENSION , Black);
}
}
score += UpdateScore(numberOfLines);
@@ -480,26 +453,23 @@ bool IsOver() {
void ShowGameOverScreen() {
//////// PORTAPACK - SKIP CLS
// display.cls();
// display.background(Black);
// display.foreground(White);
display.background(White);
display.foreground(Black);
// cls();
// background(Black);
// foreground(White);
background(White);
foreground(Black);
//////// PORTAPACK
display.locate(60, 120);
locate(60, 120);
printf("GAME OVER");
display.locate(40, 150);
locate(40, 150);
printf("YOUR SCORE IS %d", score);
wait(5); //ovaj prikaz traje 3s (možemo mijenjati) a nakon toga se ponovo prikazuje meni sa levelima
}
void InitGame() {
if(firstTime) {
//////// PORTAPACK - NOTE - ATTEMPTED WORKAROUND FOR SKIPPED INITIALIZER CODE - BUT ANY OF THESE CRASHES FIRMWARE AT POWER-UP EVEN IF THERE'S NO TETRIS APP INSTALLED:
// currentTetromino = Tetromino(rand() % 7 + 1); // TEST #1
// currentTetromino.Initialize(rand() % 7 + 1); // TEST #2
//////// PORTAPACK
currentTetromino.DrawFigure();
Tetromino(rand() % 7 + 1);
DrawFigure();
nextFigure = rand() % 7 + 1;
ShowNextFigure();
firstTime = false;
@@ -508,13 +478,13 @@ void InitGame() {
void PlayGame(){
InitGame();
if(!currentTetromino.MoveDown()){
currentTetromino.OnAttached();
if(!MoveDown()){
OnAttached();
UpdateBoard();
ShowScore();
currentTetromino = Tetromino(nextFigure);
currentTetromino.DrawFigure();
Tetromino(nextFigure);
DrawFigure();
nextFigure = rand() % 7 + 1;
ShowNextFigure();
if(IsOver()) {
@@ -531,7 +501,7 @@ void PlayGame(){
void OnTasterPressed(){
if(debounceTaster.read_ms() > 200) {
if(gameStarted){
currentTetromino.Rotate();
Rotate();
}
else{
joystick.detach();
@@ -568,7 +538,7 @@ return 0;
void pause_game() {
game.detach();
joystick.detach();
display.locate(180, 200);
locate(180, 200);
printf("PAUSED");
while ((get_switches_state().to_ulong() & 0x10) == 0); // wait for SELECT button to resume
printf(" ");
+21
View File
@@ -1,3 +1,24 @@
/*
* Copyright (C) 2024 Mark Thompson
*
* 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_tetris.hpp"
namespace ui::external_app::tetris {
+16 -2
View File
@@ -24,6 +24,9 @@
#include "utility.hpp"
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp"
uint8_t Debounce::state() {
uint8_t v = state_to_report_;
simulated_pulse_ = false;
@@ -154,6 +157,10 @@ uint8_t EncoderDebounce::state() {
return state_;
}
uint8_t EncoderDebounce::rotation_rate() {
return last_rotation_rate_;
}
// Returns TRUE if encoder position phase bits changed (after debouncing)
bool EncoderDebounce::feed(const uint8_t phase_bits) {
history_ = (history_ << 2) | phase_bits;
@@ -164,14 +171,21 @@ bool EncoderDebounce::feed(const uint8_t phase_bits) {
// But, checking for equal seems to cause issues with at least 1 user's encoder, so we're treating the input
// as "stable" if at least ONE input bit is consistent for 4 ticks...
uint8_t diff = (history_ ^ expected_stable_history);
if ((diff == 0) || ((diff & 0b01010101) == 0) || ((diff & 0b10101010) == 0)) {
if (((diff & 0b01010101) == 0) || ((diff & 0b10101010) == 0)) {
// Has the debounced input value changed?
if (state_ != phase_bits) {
state_ = phase_bits;
// Rate multiplier is for larger delta increments when dial is rotated rapidly.
last_rotation_rate_ = rotation_rate_downcounter_;
rotation_rate_downcounter_ = portapack::persistent_memory::encoder_rate_multiplier();
return true;
}
}
// Unstable input, or no change
// Unstable input, or no change.
// Decrement rotation rate detector once per timer tick.
if (rotation_rate_downcounter_ > 1)
rotation_rate_downcounter_--;
return false;
}
+6
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -70,10 +71,15 @@ class EncoderDebounce {
uint8_t state(); // returns debounced phase bits from encoder
uint8_t rotation_rate(); // returns last rotation rate
private:
uint8_t history_{0}; // shift register of previous reads from encoder
uint8_t state_{0}; // actual encoder output state (after debounce logic)
uint8_t last_rotation_rate_{1};
uint8_t rotation_rate_downcounter_{1}; // down-counter to estimate rotation speed
};
#endif /*__DEBOUNCE_H__*/
+2 -1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -63,7 +64,7 @@ int_fast8_t Encoder::update(const uint_fast8_t phase_bits) {
// Require 2 state changes in same direction to register movement -- for additional level of contact switch debouncing
if (direction == prev_direction) {
if ((sensitivity_map[portapack::persistent_memory::config_encoder_dial_sensitivity()] & (1 << state)) == 0)
if ((sensitivity_map[portapack::persistent_memory::encoder_dial_sensitivity()] & (1 << state)) == 0)
return 0;
return direction;
}
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+2 -1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -166,7 +167,7 @@ static bool encoder_update(const uint8_t raw) {
}
static bool encoder_read() {
auto delta = encoder.update(encoder_debounce.state());
auto delta = encoder.update(encoder_debounce.state()) * encoder_debounce.rotation_rate();
if (injected_encoder > 0) {
if (injected_encoder == 1) delta = -1;
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+21 -14
View File
@@ -162,6 +162,8 @@ static void event_loop() {
}
int main(void) {
first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */
if (config_mode_should_enter()) {
config_mode_clear();
config_mode_run();
@@ -169,25 +171,30 @@ int main(void) {
config_mode_set();
first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */
if (portapack::init()) {
portapack::display.init();
config_mode_clear();
switch (portapack::init()) {
case portapack::init_status_t::INIT_HACKRF_CPLD_FAILED:
portapack::init_error = "HACKRF CPLD FAILED";
[[fallthrough]];
// sdcStart(&SDCD1, nullptr); // Commented out as now happens in portapack.cpp
case portapack::init_status_t::INIT_SUCCESS:
// controls_init(); // Commented out as now happens in portapack.cpp
lcd_frame_sync_configure();
rtc_interrupt_enable();
config_mode_clear();
event_loop();
lcd_frame_sync_configure();
rtc_interrupt_enable();
sdcDisconnect(&SDCD1);
sdcStop(&SDCD1);
event_loop();
portapack::shutdown();
} else {
config_mode_clear();
sdcDisconnect(&SDCD1);
sdcStop(&SDCD1);
portapack::shutdown();
break;
case portapack::init_status_t::INIT_NO_PORTAPACK:
case portapack::init_status_t::INIT_PORTAPACK_CPLD_FAILED:
config_mode_clear();
break;
}
m4_init(portapack::spi_flash::image_tag_hackrf, portapack::memory::map::m4_code_hackrf, true);
+201 -131
View File
@@ -28,6 +28,7 @@
#include "hackrf_hal.hpp"
#include "hackrf_gpio.hpp"
using namespace hackrf::one;
#include "jtag_target_gpio.hpp"
#include "clock_manager.hpp"
#include "event_m0.hpp"
@@ -50,9 +51,12 @@ using asahi_kasei::ak4951::AK4951;
#include "file.hpp"
#include "sd_card.hpp"
#include "string_format.hpp"
#include "bitmap.hpp"
namespace portapack {
const char* init_error = nullptr;
portapack::IO io{
portapack::gpio_dir,
portapack::gpio_lcd_rdx,
@@ -172,50 +176,21 @@ constexpr I2CConfig i2c_config_fast_clock{
enum class PortaPackModel {
R1_20150901,
R2_20170522,
AGM,
AUTODETECT,
};
static bool save_config(int8_t value) {
persistent_memory::set_config_cpld(value);
if (sd_card::status() == sd_card::Status::Mounted) {
ensure_directory("/hardware");
File file;
auto sucess = file.create("/hardware/settings.txt");
if (!sucess.is_valid()) {
file.write_line(to_string_dec_uint(value));
}
}
portapack::persistent_memory::cache::persist();
return true;
}
int read_file(std::string name) {
std::string return_string = "";
File file;
auto success = file.open(name);
if (!success.is_valid()) {
char one_char[1];
for (size_t pointer = 0; pointer < file.size(); pointer++) {
file.seek(pointer);
file.read(one_char, 1);
return_string += one_char[0];
}
return std::stoi(return_string);
}
return -1;
}
static int load_config() {
static Optional<int> config_value;
if (!config_value.is_valid()) {
int8_t value = portapack::persistent_memory::config_cpld();
if ((value <= 0 || value >= 5) && sd_card::status() == sd_card::Status::Mounted) {
int data = read_file("/hardware/settings.txt");
if (data != -1) {
config_value = data;
}
} else {
config_value = value;
}
config_value = value;
}
return config_value.value();
}
@@ -224,39 +199,49 @@ static PortaPackModel portapack_model() {
static Optional<PortaPackModel> model;
if (!model.is_valid()) {
const auto switches_state = get_switches_state();
// Only save config if no other multi key boot action is triggered (like pmem reset)
if (switches_state.count() == 1) {
if (switches_state[(size_t)ui::KeyEvent::Up]) {
jtag::GPIOTarget target{
portapack::gpio_cpld_tck,
portapack::gpio_cpld_tms,
portapack::gpio_cpld_tdi,
portapack::gpio_cpld_tdo};
jtag::JTAG jtag{target};
portapack::cpld::CPLD cpld{jtag};
cpld.reset();
cpld.run_test_idle();
uint32_t idcode = cpld.get_idcode();
if (idcode == 0x25610) {
model = PortaPackModel::AGM;
} else {
const auto switches_state = swizzled_switches();
// chDbgPanic(to_string_hex((uint32_t)switches_state.count(), 8).c_str());
// Only save config if no other multi key boot action is triggered (like pmem reset)
if (((switches_state >> (size_t)ui::KeyEvent::Up) & 1) == 1) {
save_config(1);
// model = PortaPackModel::R2_20170522; // Commented these out as they should be set down below anyway
} else if (switches_state[(size_t)ui::KeyEvent::Down]) {
} else if (((switches_state >> (size_t)ui::KeyEvent::Down) & 1) == 1) {
save_config(2);
// model = PortaPackModel::R1_20150901;
} else if (switches_state[(size_t)ui::KeyEvent::Left]) {
} else if (((switches_state >> (size_t)ui::KeyEvent::Left) & 1) == 1) {
save_config(3);
// model = PortaPackModel::R1_20150901;
} else if (switches_state[(size_t)ui::KeyEvent::Right]) {
} else if (((switches_state >> (size_t)ui::KeyEvent::Right) & 1) == 1) {
save_config(4);
// model = PortaPackModel::R2_20170522;
} else if (switches_state[(size_t)ui::KeyEvent::Select]) {
} else if (((switches_state >> (size_t)ui::KeyEvent::Select) & 1) == 1) {
save_config(0);
}
}
if (load_config() == 1) {
model = PortaPackModel::R2_20170522;
} else if (load_config() == 2) {
model = PortaPackModel::R1_20150901;
} else if (load_config() == 3) {
model = PortaPackModel::R1_20150901;
} else if (load_config() == 4) {
model = PortaPackModel::R2_20170522;
} else {
if (audio_codec_wm8731.detected()) {
model = PortaPackModel::R1_20150901; // H1R1
if (load_config() == 1) {
model = PortaPackModel::R2_20170522;
} else if (load_config() == 2) {
model = PortaPackModel::R1_20150901;
} else if (load_config() == 3) {
model = PortaPackModel::R1_20150901;
} else if (load_config() == 4) {
model = PortaPackModel::R2_20170522;
} else {
model = PortaPackModel::R2_20170522; // H1R2, H2, H2+
model = PortaPackModel::AUTODETECT;
}
}
}
@@ -343,6 +328,129 @@ static void shutdown_base() {
clock_manager.shutdown();
}
static void set_cpu_clock_speed() {
/* Incantation from LPC43xx UM10503 section 12.2.1.1, to bring the M4
* core clock speed to the 110 - 204MHz range.
*/
/* Step into the 90-110MHz M4 clock range */
/* OG:
* Fclkin = 40M
* /N=2 = 20M = PFDin
* Fcco = PFDin * (M=10) = 200M
* r9:
* Fclkin = 10M
* /N=1 = 10M = PFDin
* Fcco = PFDin * (M=20) = 200M
* Fclk = Fcco / (2*(P=1)) = 100M
*/
cgu::pll1::ctrl({
.pd = 1,
.bypass = 0,
.fbsel = 0,
.direct = 0,
.psel = 0,
.autoblock = 1,
.nsel = hackrf_r9 ? 0UL : 1UL,
.msel = hackrf_r9 ? 19UL : 9UL,
.clk_sel = cgu::CLK_SEL::GP_CLKIN,
});
cgu::pll1::enable();
while (!cgu::pll1::is_locked())
;
set_clock_config(clock_config_pll1_step);
/* Delay >50us at 90-110MHz clock speed */
volatile uint32_t delay = 1400;
while (delay--)
;
set_clock_config(clock_config_pll1);
/* Remove /2P divider from PLL1 output to achieve full speed */
cgu::pll1::direct();
}
static void draw_splash_screen_icon(int16_t n, const ui::Bitmap& bitmap) {
ui::Painter painter;
painter.draw_bitmap(
{portapack::display.width() / 2 - 8 - 40 + (n * 20), portapack::display.height() / 2 - 8 + 40},
bitmap,
ui::Color::white(),
ui::Color::black());
}
static bool is_portapack_present() {
systime_t timeout = 50;
uint8_t wm8731_reset_command[] = {0x0f, 0x00};
if (i2c0.transmit(0x1a /* wm8731 */, wm8731_reset_command, 2, timeout) == false) {
audio_codec_ak4951.reset();
uint8_t ak4951_init_command[] = {0x00, 0x00};
i2c0.transmit(0x12 /* ak4951 */, ak4951_init_command, 2, timeout);
chThdSleepMilliseconds(10);
if (i2c0.transmit(0x12 /* ak4951 */, ak4951_init_command, 2, timeout) == false) {
shutdown_base();
return false;
}
}
return true;
}
static bool check_portapack_cpld() {
switch (portapack_model()) {
case PortaPackModel::AUTODETECT: {
portapack::cpld::CpldUpdateStatus result = portapack::cpld::update_autodetect(
portapack::cpld::rev_20150901::config, portapack::cpld::rev_20170522::config);
if (result != portapack::cpld::CpldUpdateStatus::Success) {
shutdown_base();
return false;
}
} break;
case PortaPackModel::R1_20150901:
case PortaPackModel::R2_20170522: {
portapack::cpld::CpldUpdateStatus result = portapack::cpld::update_if_necessary(portapack_cpld_config());
if (result == portapack::cpld::CpldUpdateStatus::Program_failed) {
chThdSleepMilliseconds(10);
// Mode left (R1) and right (R2,H2,H2+) bypass going into hackrf mode after failing CPLD update
// Mode center (autodetect), up (R1) and down (R2,H2,H2+) will go into hackrf mode after failing CPLD update
if (load_config() != 3 /* left */ && load_config() != 4 /* right */) {
shutdown_base();
return false;
}
}
} break;
case PortaPackModel::AGM:
// the AGM devices are always factory flashed. so do nothing
break;
}
return true;
}
static void initialize_boot_splash_screen() {
ui::Painter painter;
portapack::display.init();
painter.fill_rectangle(
{0, 0, portapack::display.width(), portapack::display.height()},
ui::Color::black());
chThdSleepMilliseconds(17);
portapack::backlight()->on();
painter.draw_bitmap(
{portapack::display.width() / 2 - 40, portapack::display.height() / 2 - 8},
ui::bitmap_titlebar_image,
ui::Color::white(),
ui::Color::black());
}
/* Clock scheme after exiting bootloader in SPIFI mode:
*
* XTAL_OSC = powered down
@@ -389,28 +497,29 @@ static void shutdown_base() {
* everything else = IRC
*/
bool init() {
init_status_t init() {
set_idivc_base_clocks(cgu::CLK_SEL::IDIVC);
i2c0.start(i2c_config_boot_clock);
// Keeping this here for now incase we need to revert
// if( !portapack::cpld::update_if_necessary(portapack_cpld_config()) ) {
// shutdown_base();
// return false;
// }
// if( !hackrf::cpld::load_sram() ) {
// chSysHalt();
// }
chThdSleepMilliseconds(100);
configure_pins_portapack();
portapack::io.init();
persistent_memory::cache::init();
const auto switches_state = swizzled_switches() & (~(0xC0 | 0x80));
bool lcd_fast_setup = switches_state == 0 && portapack::display.read_display_status();
if (lcd_fast_setup) {
initialize_boot_splash_screen();
} else {
if (check_portapack_cpld() == false)
return init_status_t::INIT_PORTAPACK_CPLD_FAILED;
}
/* Cache some configuration data from persistent memory. */
persistent_memory::cache::init();
rtc_time::dst_init();
chThdSleepMilliseconds(10);
@@ -423,48 +532,10 @@ bool init() {
set_clock_config(clock_config_irc);
cgu::pll1::disable();
/* Incantation from LPC43xx UM10503 section 12.2.1.1, to bring the M4
* core clock speed to the 110 - 204MHz range.
*/
set_cpu_clock_speed();
/* Step into the 90-110MHz M4 clock range */
/* OG:
* Fclkin = 40M
* /N=2 = 20M = PFDin
* Fcco = PFDin * (M=10) = 200M
* r9:
* Fclkin = 10M
* /N=1 = 10M = PFDin
* Fcco = PFDin * (M=20) = 200M
* Fclk = Fcco / (2*(P=1)) = 100M
*/
cgu::pll1::ctrl({
.pd = 1,
.bypass = 0,
.fbsel = 0,
.direct = 0,
.psel = 0,
.autoblock = 1,
.nsel = hackrf_r9 ? 0UL : 1UL,
.msel = hackrf_r9 ? 19UL : 9UL,
.clk_sel = cgu::CLK_SEL::GP_CLKIN,
});
cgu::pll1::enable();
while (!cgu::pll1::is_locked())
;
set_clock_config(clock_config_pll1_step);
/* Delay >50us at 90-110MHz clock speed */
volatile uint32_t delay = 1400;
while (delay--)
;
set_clock_config(clock_config_pll1);
/* Remove /2P divider from PLL1 output to achieve full speed */
cgu::pll1::direct();
if (lcd_fast_setup)
draw_splash_screen_icon(0, ui::bitmap_icon_memory);
usb_serial.initialize();
@@ -472,18 +543,11 @@ bool init() {
chThdSleepMilliseconds(10);
/* Check if portapack is attached by checking if any of the two audio chips is present. */
systime_t timeout = 50;
uint8_t wm8731_reset_command[] = {0x0f, 0x00};
if (i2c0.transmit(0x1a /* wm8731 */, wm8731_reset_command, 2, timeout) == false) {
audio_codec_ak4951.reset();
uint8_t ak4951_init_command[] = {0x00, 0x00};
i2c0.transmit(0x12 /* ak4951 */, ak4951_init_command, 2, timeout);
chThdSleepMilliseconds(10);
if (i2c0.transmit(0x12 /* ak4951 */, ak4951_init_command, 2, timeout) == false) {
shutdown_base();
return false;
}
}
if (lcd_fast_setup == false && is_portapack_present() == false)
return init_status_t::INIT_NO_PORTAPACK;
if (lcd_fast_setup)
draw_splash_screen_icon(1, ui::bitmap_icon_remote);
touch::adc::init();
controls_init();
@@ -499,20 +563,19 @@ bool init() {
chThdSleepMilliseconds(10);
portapack::cpld::CpldUpdateStatus result = portapack::cpld::update_if_necessary(portapack_cpld_config());
if (result == portapack::cpld::CpldUpdateStatus::Program_failed) {
chThdSleepMilliseconds(10);
// Mode left (R1) and right (R2,H2,H2+) bypass going into hackrf mode after failing CPLD update
// Mode center (autodetect), up (R1) and down (R2,H2,H2+) will go into hackrf mode after failing CPLD update
if (load_config() != 3 /* left */ && load_config() != 4 /* right */) {
shutdown_base();
return false;
}
if (lcd_fast_setup)
draw_splash_screen_icon(2, ui::bitmap_icon_sd);
init_status_t return_code = init_status_t::INIT_SUCCESS;
if (!hackrf::cpld::load_sram()) {
if (lcd_fast_setup)
chDbgPanic("HACKRF CPLD FAILED");
return_code = init_status_t::INIT_HACKRF_CPLD_FAILED;
}
if (!hackrf::cpld::load_sram()) {
chSysHalt();
}
if (lcd_fast_setup)
draw_splash_screen_icon(3, ui::bitmap_icon_hackrf);
chThdSleepMilliseconds(10); // This delay seems to solve white noise audio issues
@@ -523,7 +586,14 @@ bool init() {
audio::init(portapack_audio_codec());
return true;
if (lcd_fast_setup)
draw_splash_screen_icon(4, ui::bitmap_icon_speaker);
else {
portapack::display.init();
portapack::backlight()->on();
}
return return_code;
}
void shutdown(const bool leave_screen_on) {
+10 -1
View File
@@ -41,6 +41,15 @@
* guardrails on setting properties. */
namespace portapack {
enum class init_status_t {
INIT_SUCCESS,
INIT_NO_PORTAPACK,
INIT_PORTAPACK_CPLD_FAILED,
INIT_HACKRF_CPLD_FAILED,
};
extern const char* init_error;
extern portapack::IO io;
extern lcd::ILI9341 display;
@@ -65,7 +74,7 @@ extern TemperatureLogger temperature_logger;
void set_antenna_bias(const bool v);
bool get_antenna_bias();
bool init();
init_status_t init();
void shutdown(const bool leave_screen_on = false);
void setEventDispatcherToUSBSerial(EventDispatcher* evt);
+3 -2
View File
@@ -116,8 +116,9 @@ 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. */
// Prevents ghosting when switching back to RX from TX mode.
hackrf::cpld::load_sram_no_verify();
// That below code line , was used to prevent RX interf ghosting when switching back to RX from any TX mode, but in recent code. it seems not necessary.
// Deleting that load_sram_no_verify() (or the original , load_sram() ), solves random TX swap I/Q problem in H1R1 , others OK- (and no side effects to all).
// hackrf::cpld::load_sram_no_verify(); // After commit "removed the use of the hackrf cpld eeprom #1732", in a H1R1, Mic App wrong SSB TX with random USB/LSB change.
direction = new_direction;
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+9 -2
View File
@@ -2,6 +2,7 @@
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2019 Elia Yehuda (z4ziggy)
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -126,6 +127,7 @@ void BtnGridView::add_item(GridItem new_item) {
void BtnGridView::update_items() {
size_t i = 0;
Color bg_color = portapack::persistent_memory::menu_color();
if ((menu_items.size()) > (displayed_max + offset)) {
more = true;
@@ -146,6 +148,7 @@ void BtnGridView::update_items() {
item->set_text(menu_items[i + offset].text);
item->set_bitmap(menu_items[i + offset].bitmap);
item->set_color(menu_items[i + offset].color);
item->set_bg_color(bg_color);
item->on_select = menu_items[i + offset].on_select;
item->set_dirty();
}
@@ -170,15 +173,19 @@ bool BtnGridView::set_highlighted(int32_t new_value) {
if (((uint32_t)new_value > offset) && ((new_value - offset) >= displayed_max)) {
// Shift BtnGridView up
highlighted_item = new_value;
// rounding up new offset to next multiple of rows
offset = new_value - displayed_max + rows_;
offset -= (offset % rows_);
update_items();
set_dirty();
// refresh whole screen (display flickers) only if scrolling last row up and a blank button is needed at the bottom
if ((new_value + rows_ >= item_count) && (item_count % rows_) != 0)
set_dirty();
} else if ((uint32_t)new_value < offset) {
// Shift BtnGridView down
highlighted_item = new_value;
offset = (new_value / rows_) * rows_;
update_items();
set_dirty();
// no need to set_dirty() here since all buttons have been repainted
} else {
// Just update highlight
highlighted_item = new_value;
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+6
View File
@@ -86,6 +86,12 @@ const Style Styles::bg_blue{
.foreground = Color::white(),
};
const Style Styles::bg_dark_blue{
.font = font::fixed_8x16,
.background = Color::dark_blue(),
.foreground = Color::white(),
};
const Style Styles::light_grey{
.font = font::fixed_8x16,
.background = Color::black(),
+3
View File
@@ -58,6 +58,9 @@ class Styles {
/* Blue background. */
static const Style bg_blue;
/* Dark blue background. */
static const Style bg_dark_blue;
/* Light grey foreground. */
static const Style light_grey;
+1 -1
View File
@@ -199,7 +199,7 @@ static void cmd_screenframe(BaseSequentialStream* chp, int argc, char* argv[]) {
std::array<ui::ColorRGB888, ui::screen_width> row;
portapack::display.read_pixels({0, i, ui::screen_width, 1}, row);
for (int px = 0; px < ui::screen_width; px += 5) {
char buffer[5 * 3 * 2];
char buffer[5 * 3 * 2 + 1];
sprintf(buffer, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", row[px].r, row[px].g, row[px].b, row[px + 1].r, row[px + 1].g, row[px + 1].b, row[px + 2].r, row[px + 2].g, row[px + 2].b, row[px + 3].r, row[px + 3].g, row[px + 3].b, row[px + 4].r, row[px + 4].g, row[px + 4].b);
fillOBuffer(&((SerialUSBDriver*)chp)->oqueue, (const uint8_t*)buffer, 5 * 3 * 2);
}
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+122 -2
View File
@@ -23,6 +23,7 @@
#include "hackrf_gpio.hpp"
#include "portapack_hal.hpp"
#include "portapack.hpp"
#include "jtag_target_gpio.hpp"
#include "cpld_max5.hpp"
@@ -30,11 +31,15 @@
#include "portapack_cpld_data.hpp"
#include "hackrf_cpld_data.hpp"
#include "crc.hpp"
#define REV_20150901_CHECKSUM 0xE0EF80FB
#define REV_20170522_CHECKSUM 0xD1BEB722
namespace portapack {
namespace cpld {
CpldUpdateStatus update_if_necessary(
const Config config) {
CpldUpdateStatus update_if_necessary(const Config config) {
jtag::GPIOTarget target{
portapack::gpio_cpld_tck,
portapack::gpio_cpld_tms,
@@ -87,6 +92,121 @@ CpldUpdateStatus update_if_necessary(
return ok ? CpldUpdateStatus::Success : CpldUpdateStatus::Program_failed;
}
static CpldUpdateStatus enter_maintenance_mode(CPLD& cpld) {
/* Unknown state */
cpld.reset();
cpld.run_test_idle();
/* Run-Test/Idle */
if (!cpld.idcode_ok()) {
return CpldUpdateStatus::Idcode_check_failed;
}
cpld.sample();
cpld.bypass();
cpld.enable();
/* If silicon ID doesn't match, there's a serious problem. Leave CPLD
* in passive state.
*/
if (!cpld.silicon_id_ok()) {
return CpldUpdateStatus::Silicon_id_check_failed;
}
return CpldUpdateStatus::Success;
}
static void exit_maintenance_mode(CPLD& cpld) {
cpld.disable();
cpld.bypass();
/* Initiate SRAM reload from flash we just programmed. */
cpld.sample();
cpld.clamp();
cpld.disable();
}
static uint32_t get_firmware_crc(CPLD& cpld) {
CRC<32> crc{0x04c11db7, 0xffffffff, 0xffffffff};
cpld.prepare_read(0x0000);
for (size_t i = 0; i < 3328; i++) {
uint16_t data = cpld.read();
crc.process_byte((data >> 0) & 0xff);
crc.process_byte((data >> 8) & 0xff);
crc.process_byte((data >> 16) & 0xff);
crc.process_byte((data >> 24) & 0xff);
}
cpld.prepare_read(0x0001);
for (size_t i = 0; i < 512; i++) {
uint16_t data = cpld.read();
crc.process_byte((data >> 0) & 0xff);
crc.process_byte((data >> 8) & 0xff);
crc.process_byte((data >> 16) & 0xff);
crc.process_byte((data >> 24) & 0xff);
}
return crc.checksum();
}
CpldUpdateStatus update_autodetect(const Config config_rev_20150901, const Config config_rev_20170522) {
jtag::GPIOTarget target{
portapack::gpio_cpld_tck,
portapack::gpio_cpld_tms,
portapack::gpio_cpld_tdi,
portapack::gpio_cpld_tdo};
jtag::JTAG jtag{target};
CPLD cpld{jtag};
if (portapack::display.read_display_status())
return CpldUpdateStatus::Success; // LCD is ready
CpldUpdateStatus result = enter_maintenance_mode(cpld);
if (result != CpldUpdateStatus::Success)
return result;
uint32_t checksum = get_firmware_crc(cpld);
if (checksum == REV_20170522_CHECKSUM) {
// H2 firmware present
if (!cpld.program(config_rev_20150901.block_0, config_rev_20150901.block_1))
return CpldUpdateStatus::Program_failed;
} else if (checksum == REV_20150901_CHECKSUM) {
// H1 firmware present
if (!cpld.program(config_rev_20170522.block_0, config_rev_20170522.block_1))
return CpldUpdateStatus::Program_failed;
} else {
// no firmware present
if (!cpld.program(config_rev_20150901.block_0, config_rev_20150901.block_1))
return CpldUpdateStatus::Program_failed;
}
exit_maintenance_mode(cpld);
if (portapack::display.read_display_status())
return CpldUpdateStatus::Success; // LCD is ready
if (checksum != REV_20150901_CHECKSUM && checksum != REV_20170522_CHECKSUM) {
// try the other one
CpldUpdateStatus result = enter_maintenance_mode(cpld);
if (result != CpldUpdateStatus::Success)
return result;
if (!cpld.program(config_rev_20170522.block_0, config_rev_20170522.block_1))
return CpldUpdateStatus::Program_failed;
exit_maintenance_mode(cpld);
if (portapack::display.read_display_status())
return CpldUpdateStatus::Success; // LCD is ready
}
return CpldUpdateStatus::Program_failed;
}
} /* namespace cpld */
} /* namespace portapack */
+2 -2
View File
@@ -34,8 +34,8 @@ enum class CpldUpdateStatus {
Program_failed = 3
};
CpldUpdateStatus update_if_necessary(
const Config config);
CpldUpdateStatus update_if_necessary(const Config config);
CpldUpdateStatus update_autodetect(const Config config_rev_20150901, const Config config_rev_20170522);
} /* namespace cpld */
} /* namespace portapack */
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+30
View File
@@ -84,6 +84,17 @@ void lcd_wake() {
lcd_display_on();
}
uint32_t lcd_read_display_status() {
io.lcd_data_write_command_and_data(0x09, {});
io.lcd_read_word();
uint32_t value2 = io.lcd_read_word();
uint32_t value3 = io.lcd_read_word();
uint32_t value4 = io.lcd_read_word();
uint32_t value5 = io.lcd_read_word();
return value5 + (value4 << 8) + (value3 << 16) + (value2 << 24);
}
void lcd_init() {
// LCDs are configured for IM[2:0] = 001
// 8080-I system, 16-bit parallel bus
@@ -260,6 +271,25 @@ void lcd_vertical_scrolling_start_address(
} // namespace
bool ILI9341::read_display_status() {
lcd_reset();
uint32_t display_status = lcd_read_display_status();
/* This tries to validate the display_status.
* The value could vary from device to device, so we are less specific here.
* 0xFFFFFEFF was seen when the display was not reachable
* 0x00610000 was seen when the display was reachable
*/
if (display_status > 0x0E000000ULL)
return false;
if (display_status < 0x00000100ULL)
return false;
return true;
}
void ILI9341::init() {
lcd_reset();
lcd_init();
+2
View File
@@ -42,6 +42,8 @@ class ILI9341 {
ILI9341(ILI9341&&) = delete;
void operator=(const ILI9341&) = delete;
bool read_display_status();
void init();
void shutdown();
+47 -11
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -30,6 +31,7 @@
#include "memory_map.hpp"
#include "portapack.hpp"
#include "string_format.hpp"
#include "ui.hpp"
#include "ui_styles.hpp"
#include "ui_painter.hpp"
#include "ui_flash_utility.hpp"
@@ -45,6 +47,7 @@
#include <hal.h>
using namespace std;
using namespace ui;
namespace portapack {
namespace persistent_memory {
@@ -226,7 +229,11 @@ struct data_t {
// fake brightness level (not switch, switch is in another place)
uint16_t fake_brightness_level : 4;
uint16_t UNUSED_8 : 8;
// Encoder rotation rate multiplier for larger increments when rotated rapidly
uint16_t encoder_rate_multiplier : 4;
uint16_t UNUSED : 4;
// Headphone volume in centibels.
int16_t headphone_volume_cb;
@@ -243,6 +250,11 @@ struct data_t {
// Daylight savings time
dst_config_t dst_config;
// Menu Color Scheme
Color menu_color;
uint16_t UNUSED_16;
constexpr data_t()
: structure_version(data_structure_version_enum::VERSION_CURRENT),
target_frequency(target_frequency_reset_value),
@@ -292,12 +304,16 @@ struct data_t {
encoder_dial_sensitivity(DIAL_SENSITIVITY_NORMAL),
fake_brightness_level(BRIGHTNESS_50),
UNUSED_8(0),
encoder_rate_multiplier(1),
UNUSED(0),
headphone_volume_cb(-600),
misc_config(),
ui_config2(),
config_mode_storage(CONFIG_MODE_NORMAL_VALUE),
dst_config() {
dst_config(),
menu_color(Color::grey()),
UNUSED_16() {
}
};
@@ -399,11 +415,13 @@ void defaults() {
cached_backup_ram = backup_ram_t();
// If the desired default is 0/false, then no need to set it here (buffer is initialized to 0)
// NB: This function is only called when pmem is reset; also see firmware upgrade handling below.
set_config_backlight_timer(backlight_config_t{});
set_config_splash(true);
set_config_disable_external_tcxo(false);
set_encoder_dial_sensitivity(DIAL_SENSITIVITY_NORMAL);
set_config_speaker_disable(true); // Disable AK4951 speaker by default (in case of OpenSourceSDRLab H2)
set_menu_color(Color::grey());
// Default values for recon app.
set_recon_autosave_freqs(false);
@@ -426,13 +444,15 @@ void defaults() {
}
void init() {
const auto switches_state = get_switches_state();
const auto switches_state = swizzled_switches();
// ignore for valid check
auto config_mode_backup = config_mode_storage_direct();
set_config_mode_storage_direct(CONFIG_MODE_NORMAL_VALUE);
if (!(switches_state[(size_t)ui::KeyEvent::Left] && switches_state[(size_t)ui::KeyEvent::Right]) && backup_ram->is_valid()) {
if (!(((switches_state >> (size_t)ui::KeyEvent::Left & 1) == 1) &&
((switches_state >> (size_t)ui::KeyEvent::Right & 1) == 1)) &&
backup_ram->is_valid()) {
// Copy valid persistent data into cache.
cached_backup_ram = *backup_ram;
@@ -449,9 +469,9 @@ void init() {
}
set_config_mode_storage_direct(config_mode_backup);
// Firmware upgrade handling - adjust newly defined fields where 0 is an unwanted default
if (fake_brightness_level() == 0)
set_fake_brightness_level(BRIGHTNESS_50);
// Firmware upgrade handling - adjust newly defined fields where 0 is an invalid default
if (fake_brightness_level() == 0) set_fake_brightness_level(BRIGHTNESS_50);
if (menu_color().v == 0) set_menu_color(Color::grey());
}
void persist() {
@@ -976,13 +996,20 @@ void set_config_freq_rx_correction(uint32_t v) {
}
// Rotary encoder dial settings
uint8_t config_encoder_dial_sensitivity() {
uint8_t encoder_dial_sensitivity() {
return data->encoder_dial_sensitivity;
}
void set_encoder_dial_sensitivity(uint8_t v) {
data->encoder_dial_sensitivity = v;
}
uint8_t encoder_rate_multiplier() {
uint8_t v = data->encoder_rate_multiplier;
if (v == 0) v = 1; // minimum value is 1; treat 0 the same as 1
return v;
}
void set_encoder_rate_multiplier(uint8_t v) {
data->encoder_rate_multiplier = v;
}
// Recovery mode magic value storage
static data_t* data_direct_access = reinterpret_cast<data_t*>(memory::map::backup_ram.base());
@@ -1036,6 +1063,14 @@ void toggle_fake_brightness_level() {
}
}
// Menu Color Scheme
Color menu_color() {
return data->menu_color;
}
void set_menu_color(Color v) {
data->menu_color = v;
}
// PMem to sdcard settings
bool should_use_sdcard_for_pmem() {
@@ -1137,11 +1172,12 @@ bool debug_dump() {
pmem_dump_file.write_line("frequency_rx_correction: " + to_string_dec_uint(data->frequency_rx_correction));
pmem_dump_file.write_line("frequency_tx_correction: " + to_string_dec_uint(data->frequency_tx_correction));
pmem_dump_file.write_line("encoder_dial_sensitivity: " + to_string_dec_uint(data->encoder_dial_sensitivity));
// pmem_dump_file.write_line("UNUSED_8: " + to_string_dec_uint(data->UNUSED_8));
pmem_dump_file.write_line("encoder_rate_multiplier: " + to_string_dec_uint(data->encoder_rate_multiplier));
pmem_dump_file.write_line("headphone_volume_cb: " + to_string_dec_int(data->headphone_volume_cb));
pmem_dump_file.write_line("config_mode_storage: 0x" + to_string_hex(data->config_mode_storage, 8));
pmem_dump_file.write_line("dst_config: 0x" + to_string_hex((uint32_t)data->dst_config.v, 8));
pmem_dump_file.write_line("fake_brightness_level: " + to_string_dec_uint(data->fake_brightness_level));
pmem_dump_file.write_line("menu_color: 0x" + to_string_hex(data->menu_color.v, 4));
// ui_config bits
const auto backlight_timer = portapack::persistent_memory::config_backlight_timer();
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
@@ -33,6 +34,7 @@
#include "serializer.hpp"
#include "volume.hpp"
#include "config_mode.hpp"
#include "ui.hpp"
// persistent memory from/to sdcard flag file
#define PMEM_FILEFLAG u"/SETTINGS/PMEM_FILEFLAG"
@@ -45,6 +47,7 @@
using namespace modems;
using namespace serializer;
using namespace ui;
namespace portapack {
@@ -246,8 +249,11 @@ void set_config_audio_mute(bool v);
void set_config_speaker_disable(bool v);
void set_config_backlight_timer(const backlight_config_t& new_value);
void set_disable_touchscreen(bool v);
uint8_t config_encoder_dial_sensitivity();
uint8_t encoder_dial_sensitivity();
void set_encoder_dial_sensitivity(uint8_t v);
uint8_t encoder_rate_multiplier();
void set_encoder_rate_multiplier(uint8_t v);
uint32_t config_mode_storage_direct();
void set_config_mode_storage_direct(uint32_t v);
@@ -278,6 +284,9 @@ uint8_t fake_brightness_level();
void set_fake_brightness_level(uint8_t v);
void toggle_fake_brightness_level();
Color menu_color();
void set_menu_color(Color v);
/* Recon app */
bool recon_autosave_freqs();
bool recon_autostart_recon();
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Mark Thompson
*
* This file is part of PortaPack.
*
+12
View File
@@ -78,6 +78,18 @@ struct Color {
((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3))} {
}
uint8_t r() {
return (uint8_t)((v >> 8) & 0xf8);
}
uint8_t g() {
return (uint8_t)((v >> 3) & 0xfc);
}
uint8_t b() {
return (uint8_t)((v << 3) & 0xf8);
}
uint8_t to_greyscale() {
uint32_t r = (v >> 8) & 0xf8;
uint32_t g = (v >> 3) & 0xfc;
+6 -1
View File
@@ -1290,6 +1290,11 @@ void NewButton::set_color(Color color) {
set_dirty();
}
void NewButton::set_bg_color(Color color) {
bg_color_ = color;
set_dirty();
}
void NewButton::set_vertical_center(bool value) {
vertical_center_ = value;
set_dirty();
@@ -1343,7 +1348,7 @@ Style NewButton::paint_style() {
s.background = style().foreground;
s.foreground = Color::black();
} else {
s.background = Color::grey();
s.background = bg_color_;
s.foreground = style().foreground;
}
+2
View File
@@ -504,6 +504,7 @@ class NewButton : public Widget {
void set_bitmap(const Bitmap* bitmap);
void set_text(const std::string value);
void set_color(Color value);
void set_bg_color(Color value);
void set_vertical_center(bool value);
std::string text() const;
const Bitmap* bitmap();
@@ -522,6 +523,7 @@ class NewButton : public Widget {
protected:
virtual Style paint_style();
Color color_;
Color bg_color_{Color::light_grey()};
private:
std::string text_;
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
#
# Copyright (C) 2024 Mark Thompson
#
# 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.
#
import sys
from external_app_info import maximum_application_size
from external_app_info import external_apps_address_start
from external_app_info import external_apps_address_end
usage_message = """
PortaPack ROM image checker for possible shared external code addresses
Usage: <command> <input-file>
"""
def read_image(path):
f = open(path, 'rb')
data = f.read()
f.close()
return data
if len(sys.argv) != 2:
print(usage_message)
sys.exit(-1)
image = read_image(sys.argv[1])
image = bytearray(image)
for i in range(0, len(image), 4):
snippet = image[i:i+4]
val = int.from_bytes(snippet, byteorder='little')
offset = val & 0xFFFF
if (val >= external_apps_address_start) and (val < external_apps_address_end) and ((val & 0xFFFF) < maximum_application_size):
print ("External code address", hex(val),"at offset", hex(i),"in", sys.argv[1])
+13 -9
View File
@@ -2,6 +2,7 @@
#
# Copyright (C) 2023 Bernd Herzog
# Copyright (C) 2024 Mark Thompson
#
# This file is part of PortaPack.
#
@@ -25,6 +26,9 @@ import os
import sys
import struct
import subprocess
from external_app_info import maximum_application_size
from external_app_info import external_apps_address_start
from external_app_info import external_apps_address_end
usage_message = """
PortaPack external app image creator
@@ -34,8 +38,6 @@ See firmware/application/CMakeLists.txt > COMMAND ${EXPORT_EXTERNAL_APP_IMAGES}
Usage: <command> <project source dir> <binary dir> <cmake objcopy path> <list of external image prefixes>
"""
maximum_application_size = 32*1024
if len(sys.argv) < 4:
print(usage_message)
sys.exit(-1)
@@ -51,7 +53,7 @@ def write_image(data, path):
f.write(data)
f.close()
def patch_image(image_data, search_address, replace_address):
def patch_image(path, image_data, search_address, replace_address):
if (len(image_data) % 4) != 0:
print("file size not divideable by 4")
sys.exit(-1)
@@ -62,8 +64,8 @@ def patch_image(image_data, search_address, replace_address):
snippet = image_data[x*4:4*(x+1)]
val = int.from_bytes(snippet, byteorder='little')
# in firmware/application/external/external.ld the origin is set to something like search_address=0xEEE90000
# if the value is above the search_address and inside a 40kb window (maximum size of an app) we replace it
# in firmware/application/external/external.ld the origin is set to something like search_address=0xADB00000
# if the value is above the search_address and inside a 32kb window (maximum size of an app) we replace it
# with replace_address=(0x1008000 + m4 size) where the app will actually be located. The reason we do this instead just
# using the right address in external.ld is gcc does not permit to use the same memory range multiple times.
if val > search_address and (val - search_address) < maximum_application_size:
@@ -74,7 +76,9 @@ def patch_image(image_data, search_address, replace_address):
external_application_image += new_snippet
else:
external_application_image += snippet
if (val >= external_apps_address_start) and (val < external_apps_address_end) and ((val & 0xFFFF) < maximum_application_size):
print ("WARNING: External code address", hex(val), "at offset", hex(x*4), "in", path)
return external_application_image
project_source_dir = sys.argv[1] #/portapack-mayhem/firmware/application
@@ -90,7 +94,7 @@ for external_image_prefix in sys.argv[4:]:
# COMMAND ${CMAKE_OBJCOPY} -v -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}_ext_pacman.bin --only-section=.external_app_pacman
himg = "{}/external_app_{}.himg".format(binary_dir, external_image_prefix)
subprocess.run([cmake_objcopy, "-v", "-O", "binary", "{}/application.elf".format(binary_dir), himg, "--only-section=.external_app_{}".format(external_image_prefix)])
subprocess.run([cmake_objcopy, "-v", "-O", "binary", "{}/application.elf".format(binary_dir), himg, "--only-section=.external_app_{}".format(external_image_prefix)])
external_application_image = read_image(himg)
@@ -101,7 +105,7 @@ for external_image_prefix in sys.argv[4:]:
if (chunk_data[0] == 0 and chunk_data[1] == 0 and chunk_data[2] == 0 and chunk_data[3] == 0):
replace_address = 0x10080000
search_address = int.from_bytes(external_application_image[externalAppEntry_header_position:externalAppEntry_header_position+4], byteorder='little') & 0xFFFF0000
external_application_image = patch_image(external_application_image, search_address, replace_address)
external_application_image = patch_image(himg, external_application_image, search_address, replace_address)
external_application_image[memory_location_header_position:memory_location_header_position+4] = replace_address.to_bytes(4, byteorder='little')
checksum = 0
@@ -126,7 +130,7 @@ for external_image_prefix in sys.argv[4:]:
replace_address = 0x10080000 + len(m4_image)
search_address = int.from_bytes(external_application_image[externalAppEntry_header_position:externalAppEntry_header_position+4], byteorder='little') & 0xFFFF0000
external_application_image = patch_image(external_application_image, search_address, replace_address)
external_application_image = patch_image(himg, external_application_image, search_address, replace_address)
external_application_image[memory_location_header_position:memory_location_header_position+4] = replace_address.to_bytes(4, byteorder='little')
external_application_image[m4_app_offset_header_position:m4_app_offset_header_position+4] = app_image_len.to_bytes(4, byteorder='little')
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
#
# Copyright (C) 2024 Mark Thompson
#
# 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.
#
# external app address ranges below must match those in linker file "external.ld"
maximum_application_size = 32*1024
external_apps_address_start = 0xADB00000
external_apps_address_end = 0xADF00000
+10 -2
View File
@@ -2,6 +2,7 @@
#
# Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
# Copyright (C) 2024 Mark Thompson
#
# This file is part of PortaPack.
#
@@ -22,6 +23,9 @@
#
import sys
from external_app_info import maximum_application_size
from external_app_info import external_apps_address_start
from external_app_info import external_apps_address_end
usage_message = """
PortaPack SPI flash image generator
@@ -81,10 +85,14 @@ pad_size = spi_size - 4 - len(spi_image)
for i in range(pad_size):
spi_image += spi_image_default_byte
# quick "add up the words" checksum:
# quick "add up the words" checksum, and check for possible references to code in external apps
checksum = 0
for i in range(0, len(spi_image), 4):
checksum += (spi_image[i] + (spi_image[i + 1] << 8) + (spi_image[i + 2] << 16) + (spi_image[i + 3] << 24))
snippet = spi_image[i:i+4]
val = int.from_bytes(snippet, byteorder='little')
checksum += val
if (val >= external_apps_address_start) and (val < external_apps_address_end) and ((val & 0xFFFF) < maximum_application_size):
print ("WARNING: External code address", hex(val), "at offset", hex(i), "in", sys.argv[3])
final_checksum = 0
checksum = (final_checksum - checksum) & 0xFFFFFFFF