Compare commits

...

41 Commits

Author SHA1 Message Date
sommermorgentraum 4bbe1175c1 add tap tempo to metronomic app (#2605)
* _

* format

* fix new tree in Arch
2025-04-02 22:15:12 +02:00
sommermorgentraum ecd1a217d7 Issue template again (#2602)
* test1

* test2
2025-03-27 10:12:43 +01:00
RocketGod 335cace137 Remove RF TX and use PATX baseband for audio --> speaker out only (#2601)
* Force 433.92 and remove metadata check

We already know the frequency for all files so don't need a million metadata files to match.

* Remove RF TX. Improve PATX baseband.

* code formatting of course
2025-03-27 12:33:24 +08:00
Mark Thompson dbd708a1c7 Added more Wefax stations (#2600)
* Delete sdcard/FREQMAN/WEFAX.TXT

Replace with 2 files

* Add more WeFax frequencies

* Update comments

* Oops wrong folder

* Oops wrong folder

* Change comments
2025-03-26 11:43:17 -05:00
RocketGod 4d842b5fae Force 433.92 and remove metadata check (#2599)
* Force 433.92 and remove metadata check: we already know the frequency for all files so don't need a million metadata files to match.
* Variable fixes and move to header
2025-03-26 15:56:27 +01:00
Erwin Ried e24f1b131d Create CONTRIBUTING.md (#2598) 2025-03-26 19:53:41 +08:00
Erwin Ried 3f2c7351f1 Create SECURITY.md 2025-03-26 12:22:18 +01:00
Erwin Ried afc75f6cda Create pull_request_template.md 2025-03-26 12:20:54 +01:00
Erwin Ried 69b17faddf Create CODE_OF_CONDUCT.md 2025-03-26 12:09:51 +01:00
gullradriel 2c118ae584 Remove unneeded AMFM support in those apps (#2597) 2025-03-26 11:58:11 +01:00
gullradriel 75c34747cb Externalize level (#2596)
* removing ability to focus on RSSI bars and to launch level app, until a solution to launch external apps from internal ones is given
* externalize Level app
2025-03-26 18:20:01 +08:00
gullradriel 7754c0f37f Externalize scanner (#2589)
* externalize scanner
* NFM as main baseband as it's the biggest used one
* fix modulation bug introduced with AMFM
2025-03-26 10:42:24 +01:00
sommermorgentraum 37cc35d3c6 move default splash into sdcard (#2595)
* move bmps to sdcard
* remove unrelated files
* gitignore
* credit
* format
2025-03-26 10:34:00 +01:00
gullradriel 8a7aa9c0f8 remove not yet enabled screening app (#2594) 2025-03-25 20:20:52 +08:00
Totoo 22d6e34cd6 remove dead code (#2593) 2025-03-25 12:33:28 +01:00
gullradriel 2229381ce3 Externalize dump pmem (#2590)
* initial commit

* clang

* memory icon

* text output and exit button, FOCUS OVERRIDE TO AVOID COMPILATION ERROR

* modem and data_structure_version accessor

---------

Co-authored-by: gullradriel <gullradriel@no-mail.com>
2025-03-24 18:14:08 -05:00
RocketGod 4a63bdd7a0 Fixed the I Tetromino rotation using SRS (Super Rotation System) (#2588) 2025-03-24 14:43:12 +01:00
Brumi-2021 21773cc3c3 Adding_Waterfall_ZOOM_x2_in_AM_modes_Audio_App (#2586)
* adding zoom_factor to app settings
* separated zoom_factor settings for AM and AMFM
* fix order so zoom factor is also applied correctly on modulation change
* fix zoom not applied when changing bandwidth
* temporary disable the Scanner so we are not breaking the nightly. Until we are choosing to finally remove it or find a better solution

---------

Co-authored-by: gullradriel <3157857+gullradriel@users.noreply.github.com>
Co-authored-by: gullradriel <gullradriel@no-mail.com>
2025-03-23 22:08:12 +00:00
RocketGod 4b000c8da6 Tetris: Combined cpp files. Helper files into hpp. Dark mode. Encoder on. (#2587) 2025-03-23 21:43:30 +01:00
sommermorgentraum 20c64c98bd naming space (#2585) 2025-03-23 10:44:45 +01:00
RocketGod 139ade0670 Combine cpp, move helpers to hpp (#2584) 2025-03-23 14:04:01 +08:00
RocketGod c5b7326d4b Combined cpp files, stuffed helper files in hpp, updates start and game over screens (#2583) 2025-03-23 13:29:05 +08:00
sommermorgentraum a60169c7f1 issue template fine tune (#2579) 2025-03-21 17:43:43 +01:00
sommermorgentraum 0ce6ea8318 stopwatch opt (#2578)
* stopwatch opt

* comments

* format

* fxi ms display when user tune display level
2025-03-21 10:34:10 +08:00
RocketGod 4ecc9d04fe Put ticker class and pp_colors in hpp file in namespace and remove helper files (#2577) 2025-03-20 08:08:21 +01:00
Totoo d73db884f0 Added wefax offset to audio app too. (#2572)
* added wefax offset to audio app too.

* moved from head to cpp
2025-03-19 23:03:04 +01:00
Benjamin Møller ff2f27e297 Add icon for the doom game (#2574)
* Add icon for the doom game
* Add b/w .png to convert as doom icon
2025-03-19 17:58:34 +00:00
gullradriel 443ffd8ad3 Add WEFAX freqman file (#2567)
* Add WEFAX freqman file
* fix bad escaped spaces and unicode characters
2025-03-19 18:45:35 +01:00
sommermorgentraum 403c362702 fix external app address list (#2573) 2025-03-19 18:45:11 +01:00
RocketGod 6aa29e265b Update Doom main.cpp for better icon (#2575) 2025-03-19 18:30:11 +01:00
RocketGod 40cf2b3f8c Doom - Mayhem Edition (#2570)
* Doom - Mini Mayhem version

* Update ui_doom.cpp

* Update ui_doom.cpp

* Update ui_doom.cpp

* Update ui_doom.cpp

* Update ui_doom.cpp

* Update ui_doom.cpp

* Update ui_doom.cpp

* Update ui_doom.cpp

* Doom - Mayhem Edition

Made the Doom - Mayhem Edition game. Some little bugs but good enough for nightly.

* Code formatting. Forgot like always.

* give more initial ammo until i put ammo around the maze to collect
2025-03-19 14:16:12 +08:00
Totoo 4aa5fc1fbe WeFax rx ext app (#2566)
* wf3

* Ookbrute (#2354)

* Revert "Ookbrute (#2354)"

This reverts commit abb8143eec.

* fix

* test edition

* re enable ble

* re enable ert

* steal amfm stuff

* something happens

* save bmp on start btn

* kinda works

* exit crash fixed

* redline, remove some hardcoded

* removed cpu killer red line, and some fixes

* simplify #1

* seems ok. time to improve

* added hidden freq offset to receiver model, so wefax can be set to the "correct" freq without users needs to substract 300 hz

* badly implemented sync detection, and disabled it.

* fix for fix

* fixes

* fix offset to real life off

* no line on freq enter

* fixes
2025-03-18 18:31:40 -05:00
Erwin Ried 717d615f4f Update README.md
Other link broken
2025-03-18 10:46:19 +01:00
Erwin Ried dce4e91e41 Update README.md
Fixing opesourcesdrlab link
2025-03-18 10:36:34 +01:00
Brumi-2021 dc2f3260f3 zooming_spectrum_AMFM_mode (#2565) 2025-03-16 18:35:03 +01:00
sommermorgentraum 2d85e73f0d OokBrute app opt (#2561) 2025-03-11 21:17:47 +01:00
Mark Thompson 6ee7270db7 Setting for faster Button Repeat delays (#2559)
* Setting for faster Button Repeat delays

* Tweak fast delay times

* Tweak delay times

* Added description line and tweaked delay again
2025-03-11 09:13:41 -05:00
Mark Thompson b4112f0c04 Remove deprecated QR Code code (#2558) 2025-03-10 19:13:57 +00:00
Mark Thompson e920932886 Snake icon change (#2557) 2025-03-10 12:37:30 -05:00
Mark Thompson 081b11ad41 Breakout icon change (#2556)
- Changed Breakout icon
- Changed Tetris icon color to green
2025-03-10 17:25:49 +01:00
gullradriel adc23315a2 updated bitmaps for speaker icon (#2555)
* updated bitmaps for speaker icon
* removed opera cake icon that was added by mistake
* adding missing Game menu source png
* cyan for Game menu
* regenerated icons
2025-03-10 12:33:33 +01:00
106 changed files with 11244 additions and 8292 deletions
+6
View File
@@ -8,6 +8,12 @@ body:
value: |
Thank you for taking the time to fill out an issue, this template is meant for any issues related to the Mayhem firmware.
Please try the latest nightly release before submitting this. You can find the latest nightly version here: https://github.com/portapack-mayhem/mayhem-firmware/releases
> [!NOTE]
For hardware related issue, please open as a hardware issue instead.
For feature requests, please open as a feature request instead.
If you have questions, please join our Discord server to ask.
For your information, they are options you can choose when you open an issue.
Unrelated issues will be closed without notice.
- type: textarea
id: description
attributes:
@@ -0,0 +1,38 @@
name: Hardware / QC / QA / selling
description: Issues that related with hardware, quality control, quality assurance, selling, etc.
labels:
- question
- hardware problem
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to fill out an issue.
We would like to inform you that we can't provide much help regarding hardware/QC/QA/selling issues because we are not controlling various vendors/manufacturers, and also we are not profiting from you buying your device.
You are still welcome to ask, but please be aware that for this kind of issue, ask the seller would be the best option.
- type: textarea
id: description
attributes:
label: Describe the problem
description: "A clear and concise description of what the problem is."
validations:
required: true
- type: textarea
id: hardware-info
attributes:
label: Hardware information
description: "Please provide the hardware information here."
placeholder: |
1. HackrfRF revision
2. Portapack revision
3. (if it's audio/mic/display/touchscreen/buttons related) audio chip/ CPLD/ screen info...
4. (if hardware is visually damaged) please provide a photo
validations:
required: true
- type: textarea
id: anything-else
attributes:
label: Anything else?
description: Let us know if you have anything else to share.
@@ -0,0 +1,20 @@
name: Hardware Issue Warning
on:
issues:
types: [labeled]
jobs:
add-comment:
if: github.event.label.name == 'hardware problem'
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add warning comment
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body: |
> [!IMPORTANT]
If you are a seller/vendor and your customer has directed you to this page as a reference/evidence of a "broken device" or similar issue, please be aware that we are not providing any "official guarantee of a faulty device." We are only offering suggestions based on what the submitter has stated. We do not guarantee that the device is broken or anything else.
+128
View File
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
https://github.com/portapack-mayhem/mayhem-firmware/issues/new/.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
+1
View File
@@ -0,0 +1 @@
Please see [How-to-collaborate](https://github.com/portapack-mayhem/mayhem-firmware/wiki/How-to-collaborate)
+5 -3
View File
@@ -9,7 +9,9 @@
This is a fork of the [Havoc](https://github.com/furrtek/portapack-havoc/) firmware, which itself was a fork of the [PortaPack](https://github.com/sharebrained/portapack-hackrf) firmware, an add-on for the [HackRF](http://greatscottgadgets.com/hackrf/). A fork is a derivate, in this case one that has extra features and fixes when compared to the older versions.
[<img src="https://github.com/user-attachments/assets/dea337ab-fb64-4a2a-b419-69afd272e815" height="400">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#new-h4m-mayhem-edition) [<img src="https://camo.githubusercontent.com/5c1f1da0688240ac7b2ccca0c8dbfd1d73f2540741ad8b1828ba4d5ea68af248/68747470733a2f2f6769746875622d70726f64756374696f6e2d757365722d61737365742d3632313064662e73332e616d617a6f6e6177732e636f6d2f343339333937392f3239353533323731382d38653562363631632d663934362d346365652d386232642d3061363135663737313566342e706e67" height="400">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h2m-mayhem-edition)
[<img src="https://github.com/user-attachments/assets/dea337ab-fb64-4a2a-b419-69afd272e815" height="310">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#new-h4m-mayhem-edition)
[<img src="https://camo.githubusercontent.com/5c1f1da0688240ac7b2ccca0c8dbfd1d73f2540741ad8b1828ba4d5ea68af248/68747470733a2f2f6769746875622d70726f64756374696f6e2d757365722d61737365742d3632313064662e73332e616d617a6f6e6177732e636f6d2f343339333937392f3239353533323731382d38653562363631632d663934362d346365652d386232642d3061363135663737313566342e706e67" height="310">](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h2m-mayhem-edition)
[<img src="https://camo.githubusercontent.com/c1f7dd1e7672324f60a513f0de23de76da6a669e63896a9de535d8c8093fc3c7/68747470733a2f2f7261772e6769746875622e636f6d2f7368617265627261696e65642f706f7274617061636b2d6861636b72662f6d61737465722f646f632f696d616765732f68617264776172652f706f7274617061636b5f68315f6f7065726174696e672e6a7067" height="310">]([https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h2m-mayhem-edition](https://github.com/portapack-mayhem/mayhem-firmware/wiki/PortaPack-Versions#h1r1r2))
# What is this?
@@ -26,11 +28,11 @@ This repository expands upon the previous work by many people and aims to consta
## What to buy?
<!---not direct to h4m but to opensourcesdrlab https://share.hackrf.app/TUOLYI--->
:heavy_check_mark: ![Static Badge](https://img.shields.io/badge/NEW-yellow) The fabulous H4M [complete](https://share.hackrf.app/HR60Q4) or [upgrade](https://share.hackrf.app/FPLM1H), featuring numerous improvements and accessories. Sold by our friends at [OpenSourceSDRLab](https://share.hackrf.app/99SAMT). Join their giveaways on discord (check the badge on top). _EU customers_ can purchase via [Lab401](https://share.hackrf.app/0CI2CR).
:heavy_check_mark: ![Static Badge](https://img.shields.io/badge/NEW-yellow) The fabulous H4M [complete](https://share.hackrf.app/ABDO6H) or [upgrade](https://share.hackrf.app/FPLM1H), featuring numerous improvements and accessories. Sold by our friends at [OpenSourceSDRLab](https://share.hackrf.app/99SAMT). Join their giveaways on discord (check the badge on top). _EU customers_ can purchase via [Lab401](https://share.hackrf.app/0CI2CR).
:heavy_check_mark: A recommended one is this [PortaPack H2](https://www.ebay.com/itm/116382397447), that includes everything you need with the plastic case "inspired" on [this](https://github.com/portapack-mayhem/mayhem-firmware/wiki/3d-printed-enclosure).
:heavy_check_mark: Some individuals lean towards the [H2 with a metal enclosure](https://share.hackrf.app/9FJFJE), but its advantages remain debated. Share your insights on our [wiki](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Hardware-overview).
:heavy_check_mark: Some individuals lean towards the [H2 with a metal enclosure](https://share.hackrf.app/24T3TO), but its advantages remain debated. Share your insights on our [wiki](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Hardware-overview).
:warning: Be cautious , *ask* the seller about compatibility with the latest releases. Look out for the description of the item, if they provide the firmware files for an older version or they have custom setup instructions, this means it might be **NOT compatible**, for example:
+1
View File
@@ -0,0 +1 @@
Please check [Intended-Use-and-Legality](https://github.com/portapack-mayhem/mayhem-firmware/wiki/)
-3
View File
@@ -191,7 +191,6 @@ set(CPPSRC
clock_manager.cpp
core_control.cpp
database.cpp
de_bruijn.cpp
rfm69.cpp
event_m0.cpp
file_reader.cpp
@@ -294,7 +293,6 @@ set(CPPSRC
apps/ui_flash_utility.cpp
apps/ui_freqman.cpp
apps/ui_iq_trim.cpp
apps/ui_level.cpp
apps/ui_looking_glass_app.cpp
apps/ui_mictx.cpp
apps/ui_modemsetup.cpp
@@ -303,7 +301,6 @@ set(CPPSRC
apps/ui_rds.cpp
apps/ui_recon_settings.cpp
apps/ui_recon.cpp
apps/ui_scanner.cpp
apps/ui_sd_over_usb.cpp
apps/ui_search.cpp
apps/ui_settings.cpp
+45 -5
View File
@@ -40,6 +40,7 @@ namespace ui {
/* AMOptionsView *********************************************************/
AMOptionsView::AMOptionsView(
AnalogAudioView* view,
Rect parent_rect,
const Style* style)
: View{parent_rect} {
@@ -48,12 +49,23 @@ AMOptionsView::AMOptionsView(
add_children({
&label_config,
&options_config,
&zoom_config,
});
zoom_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_am_configuration(previous_filter_array_index + n);
view->set_zoom_factor(AM_MODULATION, n);
};
// restore zoom selection
zoom_config.set_by_value(view->get_zoom_factor(AM_MODULATION));
freqman_set_bandwidth_option(AM_MODULATION, options_config); // adding the common message from freqman.cpp to the options_config
options_config.set_by_value(receiver_model.am_configuration());
options_config.on_change = [this](size_t, OptionsField::value_t n) {
options_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_am_configuration(n);
previous_filter_array_index = n;
zoom_config.set_by_value(view->get_zoom_factor(AM_MODULATION));
};
}
@@ -105,6 +117,7 @@ WFMOptionsView::WFMOptionsView(
/* AMFMAptOptionsView *********************************************************/
AMFMAptOptionsView::AMFMAptOptionsView(
AnalogAudioView* view,
Rect parent_rect,
const Style* style)
: View{parent_rect} {
@@ -113,11 +126,20 @@ AMFMAptOptionsView::AMFMAptOptionsView(
add_children({
&label_config,
&options_config,
&zoom_config,
});
freqman_set_bandwidth_option(AMFM_MODULATION, options_config); // adding the common message from freqman.cpp to the options_config
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
options_config.set_by_value(receiver_model.amfm_configuration());
zoom_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_amfm_configuration(5 + n);
view->set_zoom_factor(AMFM_MODULATION, n);
};
// restore zoom selection
zoom_config.set_by_value(view->get_zoom_factor(AMFM_MODULATION));
}
/* SPECOptionsView *******************************************************/
@@ -245,11 +267,26 @@ void AnalogAudioView::set_spec_bw(size_t index, uint32_t bw) {
receiver_model.set_baseband_bandwidth(bw / 2);
}
uint8_t AnalogAudioView::get_spec_iq_phase_calibration_value() { // define accessor functions inside AnalogAudioView to read & write real iq_phase_calibration_value
uint8_t AnalogAudioView::get_zoom_factor(uint8_t mode) { // define accessor functions inside AnalogAudioView to read zoom value
if (mode == AM_MODULATION)
return zoom_factor_am;
else if (mode == AMFM_MODULATION)
return zoom_factor_amfm;
return 0; // default if unsupported mode
}
void AnalogAudioView::set_zoom_factor(uint8_t mode, uint8_t zoom) { // define accessor functions inside AnalogAudioView to write zoom value
if (mode == AM_MODULATION)
zoom_factor_am = zoom;
else if (mode == AMFM_MODULATION)
zoom_factor_amfm = zoom;
}
uint8_t AnalogAudioView::get_spec_iq_phase_calibration_value() { // define accessor functions inside AnalogAudioView to read iq_phase_calibration_value
return iq_phase_calibration_value;
}
void AnalogAudioView::set_spec_iq_phase_calibration_value(uint8_t cal_value) { // define accessor functions
void AnalogAudioView::set_spec_iq_phase_calibration_value(uint8_t cal_value) { // define accessor functions inside AnalogAudioView to write iq_phase_calibration_value
iq_phase_calibration_value = cal_value;
radio::set_rx_max283x_iq_phase_calibration(iq_phase_calibration_value);
}
@@ -265,6 +302,7 @@ void AnalogAudioView::set_spec_trigger(uint16_t trigger) {
}
AnalogAudioView::~AnalogAudioView() {
receiver_model.set_hidden_offset(0);
audio::output::stop();
receiver_model.disable();
baseband::shutdown();
@@ -344,7 +382,7 @@ void AnalogAudioView::on_show_options_modulation() {
const auto modulation = receiver_model.modulation();
switch (modulation) {
case ReceiverModel::Mode::AMAudio:
widget = std::make_unique<AMOptionsView>(options_view_rect, Theme::getInstance()->option_active);
widget = std::make_unique<AMOptionsView>(this, options_view_rect, Theme::getInstance()->option_active);
waterfall.show_audio_spectrum_view(false);
text_ctcss.hidden(true);
break;
@@ -362,7 +400,7 @@ void AnalogAudioView::on_show_options_modulation() {
break;
case ReceiverModel::Mode::AMAudioFMApt:
widget = std::make_unique<AMFMAptOptionsView>(options_view_rect, Theme::getInstance()->option_active);
widget = std::make_unique<AMFMAptOptionsView>(this, options_view_rect, Theme::getInstance()->option_active);
waterfall.show_audio_spectrum_view(false);
text_ctcss.hidden(true);
break;
@@ -431,6 +469,8 @@ void AnalogAudioView::update_modulation(ReceiverModel::Mode modulation) {
receiver_model.set_sampling_rate(is_wideband_spectrum_mode ? spec_bw : 3072000);
receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? spec_bw / 2 : 1750000);
receiver_model.set_hidden_offset(modulation == ReceiverModel::Mode::AMAudioFMApt ? -2200 : 0); // wefax needs to be shifted, see wefax rx app.
receiver_model.enable();
// TODO: This doesn't belong here! There's a better way.
+27 -5
View File
@@ -35,9 +35,12 @@
namespace ui {
class AnalogAudioView;
class AMOptionsView : public View {
public:
AMOptionsView(Rect parent_rect, const Style* style);
AMOptionsView(AnalogAudioView* view, Rect parent_rect, const Style* style);
int16_t previous_filter_array_index = 0;
private:
Text label_config{
@@ -51,11 +54,18 @@ class AMOptionsView : public View {
{
// Using common messages from freqman_ui.cpp
}};
OptionsField zoom_config{
{23 * 8, 0 * 16},
7,
{{"ZOOM x1", 0},
{"ZOOM x2", 6}} // offset index array filters.
};
};
class AMFMAptOptionsView : public View {
public:
AMFMAptOptionsView(Rect parent_rect, const Style* style);
AMFMAptOptionsView(AnalogAudioView* view, Rect parent_rect, const Style* style);
private:
Text label_config{
@@ -65,10 +75,17 @@ class AMFMAptOptionsView : public View {
OptionsField options_config{
{3 * 8, 0 * 16},
6, // Max option length
6, // Max option length chars
{
// Using common messages from freqman_ui.cpp In HF USB , Here we only need USB Audio demod, + post-FM demod fsubcarrier FM tone to get APT signal.
}};
OptionsField zoom_config{
{23 * 8, 0 * 16},
7,
{{"ZOOM x1", 0},
{"ZOOM x2", 6}} // offset index array filters.
};
};
class NBFMOptionsView : public View {
@@ -116,8 +133,6 @@ class WFMOptionsView : public View {
}};
};
class AnalogAudioView;
class SPECOptionsView : public View {
public:
SPECOptionsView(AnalogAudioView* view, Rect parent_rect, const Style* style);
@@ -182,17 +197,24 @@ class AnalogAudioView : public View {
uint8_t get_spec_iq_phase_calibration_value();
void set_spec_iq_phase_calibration_value(uint8_t cal_value);
uint8_t get_zoom_factor(uint8_t mode);
void set_zoom_factor(uint8_t mode, uint8_t zoom);
private:
static constexpr ui::Dim header_height = 3 * 16;
NavigationView& nav_;
RxRadioState radio_state_{};
uint8_t iq_phase_calibration_value{15}; // initial default RX IQ phase calibration value , used for both max2837 & max2839
uint8_t zoom_factor_am{0}; // initial zoom factor in AM mode
uint8_t zoom_factor_amfm{0}; // initial zoom factor in AMFM mode
app_settings::SettingsManager settings_{
"rx_audio",
app_settings::Mode::RX,
{
{"iq_phase_calibration"sv, &iq_phase_calibration_value}, // we are saving and restoring that CAL from Settings.
{"zoom_factor_am"sv, &zoom_factor_am}, // we are saving and restoring AM ZOOM factor from Settings.
{"zoom_factor_amfm"sv, &zoom_factor_amfm}, // we are saving and restoring AMFM ZOOM factor from Settings.
}};
const Rect options_view_rect{0 * 8, 1 * 16, 30 * 8, 1 * 16};
-1
View File
@@ -419,7 +419,6 @@ void DebugMenuView::on_populate() {
}
add_items({
{"Buttons Test", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_controls, [this]() { nav_.push<DebugControlsView>(); }},
{"Debug Dump", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_memory, [this]() { portapack::persistent_memory::debug_dump(); }},
{"M0 Stack Dump", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_memory, [this]() { stack_dump(); }},
{"Memory Dump", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_memory, [this]() { nav_.push<DebugMemoryDumpView>(); }},
{"Peripherals", ui::Theme::getInstance()->fg_darkcyan->foreground, &bitmap_icon_peripherals, [this]() { nav_.push<DebugPeripheralsMenuView>(); }},
@@ -25,7 +25,6 @@
#include "ui_transmitter.hpp"
#include "transmitter_model.hpp"
#include "encoders.hpp"
#include "de_bruijn.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
+10 -16
View File
@@ -517,11 +517,7 @@ ReconView::ReconView(NavigationView& nav)
};
set_loop_config(continuous);
rssi.set_focusable(true);
rssi.set_peak(true, 500);
rssi.on_select = [this](RSSI&) {
nav_.replace<LevelView>();
};
// TODO: *BUG* Both transmitter_model and receiver_model share the same pmem setting for target_frequency.
button_mic_app.on_select = [this](Button&) {
@@ -1227,16 +1223,6 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
text_ctcss.set(" ");
recording_sampling_rate = 48000;
break;
case AMFM_MODULATION:
freqman_set_bandwidth_option(new_mod, field_bw);
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
receiver_model.set_modulation(ReceiverModel::Mode::AMAudioFMApt);
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
field_bw.on_change = [this](size_t, OptionsField::value_t n) { (void)n; };
field_bw.set_by_value(0);
text_ctcss.set(" ");
recording_sampling_rate = 12000;
break;
case SPEC_MODULATION:
freqman_set_bandwidth_option(new_mod, field_bw);
baseband::run_image(portapack::spi_flash::image_tag_capture);
@@ -1267,9 +1253,17 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
field_mode.set_selected_index(new_mod);
field_mode.on_change = [this](size_t, OptionsField::value_t v) {
if (v != -1) {
change_mode(v);
// initialize to a value under SPEC
static freqman_index_t last_mode = WFM_MODULATION;
if (v > SPEC_MODULATION) {
if (last_mode == SPEC_MODULATION)
v = AM_MODULATION;
else
v = SPEC_MODULATION;
field_mode.set_selected_index(v);
}
last_mode = v;
change_mode(v);
};
// for some motive, audio output gets stopped.
if (!recon && field_mode.selected_index_value() != SPEC_MODULATION)
-1
View File
@@ -31,7 +31,6 @@
#include "analog_audio_app.hpp"
#include "audio.hpp"
#include "ui_mictx.hpp"
#include "ui_level.hpp"
#include "ui_looking_glass_app.hpp"
#include "portapack_persistent_memory.hpp"
#include "baseband_api.hpp"
+31 -27
View File
@@ -674,32 +674,6 @@ void SetAudioView::focus() {
button_save.focus();
}
/* SetQRCodeView *****************************************/
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
add_children({
&labels,
&checkbox_bigger_qr,
&button_save,
&button_cancel,
});
checkbox_bigger_qr.set_value(pmem::show_bigger_qr_code());
button_save.on_select = [&nav, this](Button&) {
pmem::set_show_bigger_qr_code(checkbox_bigger_qr.value());
nav.pop();
};
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
void SetQRCodeView::focus() {
button_save.focus();
}
/* SetEncoderDialView ************************************/
SetEncoderDialView::SetEncoderDialView(NavigationView& nav) {
@@ -747,6 +721,36 @@ void SetEncoderDialView::focus() {
button_save.focus();
}
/* SetButtonsView ************************************/
SetButtonsView::SetButtonsView(NavigationView& nav) {
add_children({&labels,
&button_save,
&button_cancel,
&field_repeat_delay,
&field_repeat_speed,
&field_long_press_delay});
field_repeat_delay.set_by_value(pmem::ui_button_repeat_delay());
field_repeat_speed.set_by_value(pmem::ui_button_repeat_speed());
field_long_press_delay.set_by_value(pmem::ui_button_long_press_delay());
button_save.on_select = [&nav, this](Button&) {
pmem::set_ui_button_repeat_delay(field_repeat_delay.selected_index_value());
pmem::set_ui_button_repeat_speed(field_repeat_speed.selected_index_value());
pmem::set_ui_button_long_press_delay(field_long_press_delay.selected_index_value());
nav.pop();
};
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
void SetButtonsView::focus() {
button_save.focus();
}
/* AppSettingsView ************************************/
AppSettingsView::AppSettingsView(
@@ -1093,12 +1097,12 @@ void SettingsMenuView::on_populate() {
{"Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [this]() { nav_.push<SetConverterSettingsView>(); }},
{"Date/Time", ui::Color::dark_cyan(), &bitmap_icon_options_datetime, [this]() { nav_.push<SetDateTimeView>(); }},
{"Encoder Dial", ui::Color::dark_cyan(), &bitmap_icon_setup, [this]() { nav_.push<SetEncoderDialView>(); }},
{"Button Speed", ui::Color::dark_cyan(), &bitmap_icon_controls, [this]() { nav_.push<SetButtonsView>(); }},
{"Freq. Correct", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [this]() { nav_.push<SetFrequencyCorrectionView>(); }},
{"P.Memory Mgmt", ui::Color::dark_cyan(), &bitmap_icon_memory, [this]() { nav_.push<SetPersistentMemoryView>(); }},
{"Radio", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [this]() { nav_.push<SetRadioView>(); }},
{"SD Card", ui::Color::dark_cyan(), &bitmap_icon_sdcard, [this]() { nav_.push<SetSDCardView>(); }},
{"User Interface", ui::Color::dark_cyan(), &bitmap_icon_options_ui, [this]() { nav_.push<SetUIView>(); }},
//{"QR Code", ui::Color::dark_cyan(), &bitmap_icon_qr_code, [this]() { nav_.push<SetQRCodeView>(); }},
{"Display", ui::Color::dark_cyan(), &bitmap_icon_brightness, [this]() { nav_.push<SetDisplayView>(); }},
{"Menu Color", ui::Color::dark_cyan(), &bitmap_icon_brightness, [this]() { nav_.push<SetMenuColorView>(); }},
{"Theme", ui::Color::dark_cyan(), &bitmap_icon_setup, [this]() { nav_.push<SetThemeView>(); }},
+43 -29
View File
@@ -545,35 +545,6 @@ class SetAudioView : public View {
};
};
class SetQRCodeView : public View {
public:
SetQRCodeView(NavigationView& nav);
void focus() override;
std::string title() const override { return "QR Code"; };
private:
Labels labels{
{{1 * 8, 1 * 16}, "Change the size of the QR", Theme::getInstance()->fg_light->foreground},
{{1 * 8, 2 * 16}, "code shown in Radiosonde.", Theme::getInstance()->fg_light->foreground},
};
Checkbox checkbox_bigger_qr{
{3 * 8, 4 * 16},
20,
"Show large QR code"};
Button button_save{
{2 * 8, 16 * 16, 12 * 8, 32},
"Save"};
Button button_cancel{
{16 * 8, 16 * 16, 12 * 8, 32},
"Cancel",
};
};
using portapack::persistent_memory::encoder_dial_direction;
using portapack::persistent_memory::encoder_dial_sensitivity;
using portapack::persistent_memory::encoder_rate_multiplier;
@@ -644,6 +615,49 @@ class SetEncoderDialView : public View {
};
};
class SetButtonsView : public View {
public:
SetButtonsView(NavigationView& nav);
void focus() override;
std::string title() const override { return "Button Speed"; };
private:
Labels labels{
{{1 * 8, 1 * 16}, "Adjusts response time when a", Theme::getInstance()->fg_light->foreground},
{{1 * 8, 2 * 16}, "button is held down.", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 5 * 16}, "Repeat delay:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 7 * 16}, "Repeat speed:", Theme::getInstance()->fg_light->foreground},
{{2 * 8, 9 * 16}, "Long press delay:", Theme::getInstance()->fg_light->foreground},
};
OptionsField field_repeat_delay{
{20 * 8, 5 * 16},
6,
{{"NORMAL", false},
{"FAST", true}}};
OptionsField field_repeat_speed{
{20 * 8, 7 * 16},
6,
{{"NORMAL", false},
{"FAST", true}}};
OptionsField field_long_press_delay{
{20 * 8, 9 * 16},
6,
{{"NORMAL", false},
{"FAST", true}}};
Button button_save{
{2 * 8, 16 * 16, 12 * 8, 32},
"Save"};
Button button_cancel{
{16 * 8, 16 * 16, 12 * 8, 32},
"Cancel",
};
};
class SetPersistentMemoryView : public View {
public:
SetPersistentMemoryView(NavigationView& nav);
+12 -6
View File
@@ -66,12 +66,13 @@ static void send_message(const Message* const message) {
void AMConfig::apply() const {
const AMConfigureMessage message{
taps_6k0_decim_0, // common FIR filter taps pre-decim_0 to all 6 x AM mod types.(AM-9K, AM-6K, USB, LSB, CW, AMFM-WFAX)
taps_6k0_decim_1, // common FIR filter taps pre-decim_1 to all 6 x AM mod. types. (")
decim_2, // var decim_2 FIR taps filter , variable values, depending selected AM mod(AM 9k / 6k and all rest AM modes)
channel, // var channel FIR taps filter , variable values, depending selected AM mode, each one different (DSB-9K, DSB-6K, USB-3K, LSB-3K,CW,AMFM-WFAX)
modulation, // var parameter . enum class Modulation : int32_t {DSB = 0, SSB = 1, SSB_FM = 2}
audio_12k_iir_filter_config}; // var parameter , 300 Hz hpf all except Wefax (1.500Hz lpf)
taps_6k0_decim_0, // common FIR filter taps pre-decim_0 to all 6 x AM mod types.(AM-9K, AM-6K, USB, LSB, CW, AMFM-WFAX)
decim_1, // var decim_1 FIR taps filter , variable values , to handle two spectrum decim factor 1 and 2 (zoom) and more APT LPF filtered .
decim_2, // var decim_2 FIR taps filter , variable values, depending selected AM mod(AM 9k / 6k and all rest AM modes)
channel, // var channel FIR taps filter , variable values, depending selected AM mode, each one different (DSB-9K, DSB-6K, USB-3K, LSB-3K,CW,AMFM-WFAX)
modulation, // var parameter . enum class Modulation : int32_t {DSB = 0, SSB = 1, SSB_FM = 2}
audio_12k_iir_filter_config, // var parameter , 300 Hz hpf all except Wefax (1.500Hz lpf)
spectrum_decimation_factor}; // var parameter , waterfall no zoom : 1 ,for zoom x 2 : 2
send_message(&message);
audio::set_rate(audio::Rate::Hz_12000);
}
@@ -304,6 +305,11 @@ void set_spectrum(const size_t sampling_rate, const size_t trigger) {
send_message(&message);
}
void set_wefax_config(uint8_t lpm = 120, uint8_t ioc = 0) {
const WeFaxRxConfigureMessage message{lpm, ioc};
send_message(&message);
}
void set_siggen_tone(const uint32_t tone) {
const SigGenToneMessage message{
TONES_F2D(tone, TONES_SAMPLERATE)};
+3
View File
@@ -36,10 +36,12 @@
namespace baseband {
struct AMConfig {
const fir_taps_real<32> decim_1; // added to handle two var LPF in AMFM to avoid aliasing when spectrum zoom factor 2.
const fir_taps_real<32> decim_2; // added to handle two var types decim_2 9k, 6k
const fir_taps_complex<64> channel;
const AMConfigureMessage::Modulation modulation;
const iir_biquad_config_t audio_12k_iir_filter_config; // added to handle two var IIR filter types : 300 hpf(as before) , 1500Hz lpf for Wefax.
const size_t spectrum_decimation_factor; // used to handle LCD AM waterfall zoom x1 / zoom x2.
void apply() const;
};
@@ -90,6 +92,7 @@ void set_siggen_tone(const uint32_t tone);
void set_siggen_config(const uint32_t bw, const uint32_t shape, const uint32_t duration);
void set_spectrum_painter_config(const uint16_t width, const uint16_t height, bool update, int32_t bw);
void set_subghzd_config(uint8_t modulation, uint32_t sampling_rate);
void set_wefax_config(uint8_t lpm, uint8_t ioc);
void request_roger_beep();
void request_rssi_beep();
File diff suppressed because it is too large Load Diff
@@ -1,72 +0,0 @@
unsigned char modal_warning_bmp[] = {
0x42, 0x4d, 0xfa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x00,
0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa8, 0x02,
0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xff, 0x00, 0x00, 0x5a,
0xff, 0x00, 0x78, 0x78, 0x78, 0x00, 0x00, 0x7c, 0xff, 0x00, 0x00, 0xa9,
0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x02, 0x03, 0x24, 0x66, 0x02, 0x30,
0x00, 0x00, 0x02, 0x36, 0x24, 0x66, 0x02, 0x63, 0x00, 0x00, 0x02, 0x66,
0x02, 0x63, 0x20, 0x00, 0x02, 0x36, 0x02, 0x66, 0x00, 0x00, 0x02, 0x36,
0x02, 0x60, 0x20, 0x00, 0x02, 0x06, 0x02, 0x63, 0x00, 0x00, 0x02, 0x06,
0x02, 0x60, 0x0c, 0x00, 0x00, 0x08, 0x03, 0x66, 0x66, 0x30, 0x0c, 0x00,
0x02, 0x06, 0x02, 0x60, 0x00, 0x00, 0x02, 0x03, 0x02, 0x66, 0x0c, 0x00,
0x00, 0x08, 0x06, 0x11, 0x11, 0x60, 0x0c, 0x00, 0x02, 0x66, 0x02, 0x30,
0x00, 0x00, 0x02, 0x00, 0x02, 0x66, 0x0c, 0x00, 0x00, 0x08, 0x06, 0x21,
0x21, 0x60, 0x0c, 0x00, 0x02, 0x66, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x36, 0x60, 0x00, 0x0a, 0x00, 0x00, 0x08, 0x06, 0x42, 0x42, 0x60,
0x0a, 0x00, 0x00, 0x06, 0x06, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x06, 0x60, 0x00, 0x0a, 0x00, 0x00, 0x08, 0x06, 0x54, 0x45, 0x60,
0x0a, 0x00, 0x00, 0x06, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x03, 0x66, 0x00, 0x0a, 0x00, 0x00, 0x08, 0x03, 0x66, 0x66, 0x30,
0x0a, 0x00, 0x00, 0x06, 0x66, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x00, 0x66, 0x00, 0x1c, 0x00, 0x00, 0x06, 0x66, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x36, 0x60, 0x18, 0x00, 0x00, 0x08,
0x06, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x06, 0x60,
0x0a, 0x00, 0x02, 0x36, 0x02, 0x63, 0x0a, 0x00, 0x00, 0x08, 0x06, 0x60,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x66, 0x08, 0x00,
0x00, 0x08, 0x03, 0x61, 0x16, 0x30, 0x08, 0x00, 0x00, 0x08, 0x66, 0x30,
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x66, 0x08, 0x00, 0x00, 0x08,
0x06, 0x11, 0x11, 0x60, 0x08, 0x00, 0x02, 0x66, 0x06, 0x00, 0x00, 0x00,
0x06, 0x00, 0x02, 0x36, 0x02, 0x60, 0x06, 0x00, 0x00, 0x08, 0x06, 0x11,
0x11, 0x60, 0x06, 0x00, 0x02, 0x06, 0x02, 0x63, 0x06, 0x00, 0x00, 0x00,
0x06, 0x00, 0x02, 0x06, 0x02, 0x60, 0x06, 0x00, 0x00, 0x08, 0x06, 0x11,
0x11, 0x60, 0x06, 0x00, 0x02, 0x06, 0x02, 0x60, 0x06, 0x00, 0x00, 0x00,
0x06, 0x00, 0x02, 0x03, 0x02, 0x66, 0x06, 0x00, 0x00, 0x08, 0x06, 0x11,
0x11, 0x60, 0x06, 0x00, 0x02, 0x66, 0x02, 0x30, 0x06, 0x00, 0x00, 0x00,
0x08, 0x00, 0x02, 0x66, 0x06, 0x00, 0x00, 0x08, 0x06, 0x11, 0x11, 0x60,
0x06, 0x00, 0x02, 0x66, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18,
0x36, 0x60, 0x00, 0x00, 0x06, 0x11, 0x11, 0x60, 0x00, 0x00, 0x06, 0x63,
0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x06, 0x60, 0x00, 0x00,
0x06, 0x21, 0x21, 0x60, 0x00, 0x00, 0x06, 0x60, 0x08, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x18, 0x03, 0x66, 0x00, 0x00, 0x06, 0x12, 0x12, 0x60,
0x00, 0x00, 0x66, 0x30, 0x08, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x14,
0x66, 0x00, 0x00, 0x06, 0x21, 0x21, 0x60, 0x00, 0x00, 0x66, 0x0a, 0x00,
0x00, 0x00, 0x0a, 0x00, 0x00, 0x14, 0x36, 0x60, 0x00, 0x06, 0x22, 0x22,
0x60, 0x00, 0x06, 0x63, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x14,
0x06, 0x60, 0x00, 0x06, 0x24, 0x24, 0x60, 0x00, 0x06, 0x60, 0x0a, 0x00,
0x00, 0x00, 0x0a, 0x00, 0x00, 0x14, 0x03, 0x66, 0x00, 0x06, 0x42, 0x42,
0x60, 0x00, 0x66, 0x30, 0x0a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10,
0x66, 0x00, 0x06, 0x54, 0x45, 0x60, 0x00, 0x66, 0x0c, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x10, 0x36, 0x60, 0x03, 0x66, 0x66, 0x30, 0x06, 0x63,
0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x02, 0x06, 0x02, 0x60, 0x08, 0x00,
0x02, 0x06, 0x02, 0x60, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x02, 0x03,
0x02, 0x66, 0x08, 0x00, 0x02, 0x66, 0x02, 0x30, 0x0c, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x02, 0x66, 0x08, 0x00, 0x02, 0x66, 0x0e, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x0c, 0x36, 0x60, 0x00, 0x00, 0x06, 0x63, 0x0e, 0x00,
0x00, 0x00, 0x0e, 0x00, 0x00, 0x0c, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60,
0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0c, 0x03, 0x66, 0x00, 0x00,
0x66, 0x30, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x66, 0x00,
0x00, 0x66, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x36, 0x60,
0x06, 0x63, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x06, 0x60,
0x06, 0x60, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x03, 0x66,
0x66, 0x30, 0x10, 0x00, 0x00, 0x00, 0x12, 0x00, 0x02, 0x66, 0x02, 0x66,
0x12, 0x00, 0x00, 0x00, 0x12, 0x00, 0x02, 0x36, 0x02, 0x63, 0x12, 0x00,
0x00, 0x01};
unsigned int modal_warning_bmp_len = 830;
-327
View File
@@ -1,327 +0,0 @@
// converted by bmp_to_hex_cpp_arr.py at the firmware/tools dir
// fake transparent px should be the exact color rgb dec(41,24,22), then use true for the last arg when drawing bmp with the draw func
const unsigned char splash_bmp[] = {
0x42, 0x4d, 0x0e, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x00,
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00, 0x32, 0x00,
0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x9c, 0x0e,
0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x0f, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x19, 0xf6, 0x00, 0x00, 0x14,
0xc9, 0x00, 0x00, 0x0c, 0x78, 0x00, 0x16, 0x18, 0x29, 0x00, 0xfd, 0xfd,
0xfd, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xe7, 0xe7, 0xe7, 0x00, 0xda, 0xda,
0xda, 0x00, 0xcd, 0xcd, 0xcd, 0x00, 0xc7, 0xc7, 0xc7, 0x00, 0xba, 0xba,
0xba, 0x00, 0xad, 0xad, 0xad, 0x00, 0x96, 0x96, 0x96, 0x00, 0x5c, 0x5c,
0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33,
0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0x00, 0x08,
0x33, 0x44, 0x44, 0x47, 0x0a, 0x33, 0x00, 0x06, 0xd5, 0x44, 0x7d, 0x00,
0x0a, 0x33, 0x00, 0x0a, 0x44, 0x44, 0x48, 0x33, 0x3a, 0x00, 0x06, 0x44,
0x02, 0xd3, 0x12, 0x33, 0x00, 0x08, 0xa4, 0x44, 0x45, 0x9d, 0x08, 0x33,
0x00, 0x08, 0xc4, 0x44, 0x45, 0xc3, 0x10, 0x33, 0x00, 0x08, 0x34, 0x44,
0x44, 0x6d, 0x16, 0x33, 0x00, 0x08, 0x34, 0x44, 0x44, 0x6d, 0x08, 0x33,
0x02, 0xd5, 0x1a, 0x44, 0x00, 0x0c, 0x45, 0xc3, 0x33, 0x44, 0x44, 0x47,
0x0a, 0x33, 0x00, 0x06, 0xd5, 0x44, 0x7d, 0x00, 0x0a, 0x33, 0x00, 0x08,
0x44, 0x44, 0x48, 0x33, 0x00, 0x00, 0x00, 0x0a, 0x33, 0x49, 0x99, 0x95,
0xd3, 0x00, 0x06, 0x33, 0x00, 0x0a, 0xd4, 0x46, 0x89, 0x98, 0xb3, 0x00,
0x08, 0x33, 0x00, 0x12, 0x49, 0x99, 0x94, 0x33, 0x3d, 0x79, 0x99, 0x99,
0x73, 0x00, 0x10, 0x33, 0x00, 0x0a, 0x3d, 0x47, 0x99, 0x95, 0xa3, 0x00,
0x08, 0x33, 0x00, 0x08, 0xc7, 0x99, 0x97, 0xa3, 0x10, 0x33, 0x00, 0x08,
0x34, 0x99, 0x99, 0x7c, 0x16, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x7c,
0x06, 0x33, 0x00, 0x06, 0xb4, 0x56, 0x89, 0x00, 0x18, 0x99, 0x00, 0x0e,
0x97, 0xa3, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x00, 0x06, 0x33, 0x00, 0x0a,
0xd4, 0x46, 0x89, 0x98, 0xb3, 0x00, 0x08, 0x33, 0x00, 0x08, 0x49, 0x99,
0x94, 0x33, 0x00, 0x00, 0x00, 0x0a, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x00,
0x06, 0x33, 0x02, 0x55, 0x06, 0x99, 0x02, 0x9b, 0x08, 0x33, 0x00, 0x12,
0x49, 0x99, 0x94, 0x33, 0x33, 0xb9, 0x99, 0x99, 0x8d, 0x00, 0x10, 0x33,
0x00, 0x0a, 0x37, 0x69, 0x99, 0x74, 0xd3, 0x00, 0x08, 0x33, 0x00, 0x08,
0xc7, 0x99, 0x97, 0xa3, 0x10, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x7c,
0x16, 0x33, 0x00, 0x10, 0x34, 0x99, 0x99, 0x7c, 0x33, 0x33, 0x3a, 0x47,
0x1c, 0x99, 0x00, 0x0e, 0x97, 0xa3, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x00,
0x06, 0x33, 0x02, 0x55, 0x06, 0x99, 0x02, 0x9b, 0x08, 0x33, 0x00, 0x08,
0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x12, 0x33, 0x49, 0x99, 0x95,
0xd3, 0x33, 0x33, 0x3a, 0x48, 0x00, 0x06, 0x99, 0x02, 0x98, 0x02, 0xd3,
0x06, 0x33, 0x00, 0x12, 0x49, 0x99, 0x94, 0x33, 0x33, 0xd7, 0x99, 0x99,
0x98, 0x00, 0x10, 0x33, 0x00, 0x08, 0xd4, 0x89, 0x99, 0x5a, 0x0a, 0x33,
0x00, 0x08, 0xc7, 0x99, 0x97, 0xa3, 0x10, 0x33, 0x00, 0x08, 0x34, 0x99,
0x99, 0x7c, 0x16, 0x33, 0x00, 0x10, 0x34, 0x99, 0x99, 0x7c, 0x33, 0x33,
0xb4, 0x79, 0x1c, 0x99, 0x00, 0x16, 0x97, 0xa3, 0x33, 0x49, 0x99, 0x95,
0xd3, 0x33, 0x33, 0x3a, 0x48, 0x00, 0x06, 0x99, 0x02, 0x98, 0x02, 0xd3,
0x06, 0x33, 0x00, 0x08, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x12,
0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x33, 0xd4, 0x79, 0x00, 0x08, 0x99,
0x02, 0x73, 0x06, 0x33, 0x00, 0x0c, 0x49, 0x99, 0x94, 0x33, 0x33, 0x3b,
0x06, 0x99, 0x02, 0xc3, 0x0e, 0x33, 0x00, 0x08, 0x56, 0x99, 0x97, 0x4d,
0x0a, 0x33, 0x00, 0x08, 0xc7, 0x99, 0x97, 0xa3, 0x10, 0x33, 0x00, 0x08,
0x34, 0x99, 0x99, 0x7c, 0x16, 0x33, 0x00, 0x0e, 0x34, 0x99, 0x99, 0x7c,
0x33, 0x3d, 0x47, 0x00, 0x1e, 0x99, 0x00, 0x16, 0x97, 0xa3, 0x33, 0x49,
0x99, 0x95, 0xd3, 0x33, 0x33, 0xd4, 0x79, 0x00, 0x08, 0x99, 0x02, 0x73,
0x06, 0x33, 0x00, 0x08, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x10,
0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x33, 0xa5, 0x0a, 0x99, 0x02, 0x8d,
0x06, 0x33, 0x00, 0x14, 0x49, 0x99, 0x94, 0x33, 0x33, 0x3d, 0x79, 0x99,
0x99, 0x73, 0x0c, 0x33, 0x00, 0x0a, 0x3c, 0x48, 0x99, 0x95, 0xa3, 0x00,
0x0a, 0x33, 0x00, 0x08, 0xc7, 0x99, 0x97, 0xa3, 0x10, 0x33, 0x00, 0x08,
0x34, 0x99, 0x99, 0x7c, 0x16, 0x33, 0x00, 0x0e, 0x34, 0x99, 0x99, 0x7c,
0x33, 0x37, 0x69, 0x00, 0x1e, 0x99, 0x00, 0x14, 0x97, 0xa3, 0x33, 0x49,
0x99, 0x95, 0xd3, 0x33, 0x33, 0xa5, 0x0a, 0x99, 0x02, 0x8d, 0x06, 0x33,
0x00, 0x08, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x1c, 0x33, 0x49,
0x99, 0x95, 0xd3, 0x33, 0x3d, 0x47, 0x99, 0x97, 0x89, 0x99, 0x99, 0x97,
0x06, 0x33, 0x00, 0x06, 0x49, 0x99, 0x94, 0x00, 0x06, 0x33, 0x00, 0x08,
0xb9, 0x99, 0x99, 0x9d, 0x0c, 0x33, 0x00, 0x0a, 0x34, 0x69, 0x99, 0x74,
0xd3, 0x00, 0x0a, 0x33, 0x00, 0x08, 0xc7, 0x99, 0x98, 0xa3, 0x10, 0x33,
0x00, 0x08, 0x34, 0x99, 0x99, 0x7c, 0x16, 0x33, 0x00, 0x12, 0x34, 0x99,
0x99, 0x7c, 0x33, 0x34, 0x89, 0x99, 0x64, 0x00, 0x1c, 0x44, 0x00, 0x1e,
0xa3, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x3d, 0x47, 0x99, 0x97, 0x89,
0x99, 0x99, 0x97, 0x00, 0x06, 0x33, 0x00, 0x08, 0x49, 0x99, 0x94, 0x33,
0x00, 0x00, 0x00, 0x28, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x3c, 0x59,
0x99, 0x95, 0xbc, 0x99, 0x99, 0x98, 0xd3, 0x33, 0x33, 0x49, 0x99, 0x94,
0x06, 0x33, 0x02, 0xd7, 0x06, 0x99, 0x02, 0x74, 0x0c, 0x44, 0x00, 0x06,
0x99, 0x99, 0x4b, 0x00, 0x0c, 0x33, 0x00, 0x08, 0xb7, 0x99, 0x99, 0xa3,
0x10, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x7c, 0x16, 0x33, 0x00, 0x12,
0x34, 0x99, 0x99, 0x7c, 0x33, 0xd5, 0x99, 0x99, 0x6d, 0x00, 0x20, 0x33,
0x00, 0x28, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x3c, 0x59, 0x99, 0x95, 0xbc,
0x99, 0x99, 0x98, 0xd3, 0x33, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00,
0x00, 0x28, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x34, 0x79, 0x99, 0x84,
0xdd, 0x89, 0x99, 0x99, 0x83, 0x33, 0x33, 0x49, 0x99, 0x94, 0x06, 0x33,
0x02, 0x3b, 0x16, 0x99, 0x02, 0x97, 0x02, 0x43, 0x0a, 0x33, 0x00, 0x0a,
0x3d, 0x47, 0x99, 0x99, 0x9d, 0x00, 0x10, 0x33, 0x00, 0x08, 0x34, 0x99,
0x99, 0x9d, 0x16, 0x33, 0x00, 0x12, 0x34, 0x99, 0x99, 0x7c, 0x33, 0xd6,
0x99, 0x99, 0x6d, 0x00, 0x20, 0x33, 0x00, 0x28, 0x49, 0x99, 0x95, 0xd3,
0x33, 0x34, 0x79, 0x99, 0x84, 0xdd, 0x89, 0x99, 0x99, 0x83, 0x33, 0x33,
0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x28, 0x33, 0x49, 0x99, 0x95,
0xd3, 0x33, 0xc4, 0x99, 0x99, 0x67, 0x33, 0x79, 0x99, 0x99, 0x8d, 0x33,
0x33, 0x49, 0x99, 0x94, 0x06, 0x33, 0x02, 0x3d, 0x02, 0x79, 0x14, 0x99,
0x02, 0x94, 0x02, 0xc3, 0x0a, 0x33, 0x00, 0x0a, 0x35, 0x59, 0x99, 0x99,
0x98, 0x00, 0x10, 0x33, 0x02, 0x34, 0x06, 0x99, 0x02, 0x74, 0x16, 0x44,
0x00, 0x10, 0x99, 0x99, 0x7c, 0x33, 0xd6, 0x99, 0x99, 0x9d, 0x20, 0x33,
0x00, 0x28, 0x49, 0x99, 0x95, 0xd3, 0x33, 0xc4, 0x99, 0x99, 0x67, 0x33,
0x79, 0x99, 0x99, 0x8d, 0x33, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00,
0x00, 0x28, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x57, 0x99, 0x99, 0x4d,
0x33, 0xd8, 0x99, 0x99, 0x98, 0x33, 0x33, 0x49, 0x99, 0x94, 0x08, 0x33,
0x02, 0xc9, 0x14, 0x99, 0x02, 0x74, 0x0c, 0x33, 0x02, 0x84, 0x02, 0x89,
0x06, 0x99, 0x02, 0xa3, 0x0e, 0x33, 0x02, 0x34, 0x22, 0x99, 0x00, 0x06,
0x7c, 0x33, 0xd6, 0x00, 0x06, 0x99, 0x02, 0x64, 0x18, 0x44, 0x00, 0x2e,
0x45, 0xc3, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x33, 0x57, 0x99, 0x99, 0x4d,
0x33, 0xd8, 0x99, 0x99, 0x98, 0x33, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00,
0x00, 0x00, 0x00, 0x28, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x3d, 0x48, 0x99,
0x97, 0x43, 0x33, 0x37, 0x99, 0x99, 0x97, 0xd3, 0x33, 0x49, 0x99, 0x94,
0x08, 0x33, 0x02, 0x37, 0x14, 0x99, 0x02, 0x4c, 0x0a, 0x33, 0x02, 0x3b,
0x02, 0x48, 0x08, 0x99, 0x02, 0x9b, 0x0e, 0x33, 0x02, 0x34, 0x22, 0x99,
0x00, 0x06, 0x7c, 0x33, 0xd6, 0x00, 0x20, 0x99, 0x00, 0x2e, 0x97, 0xa3,
0x33, 0x49, 0x99, 0x95, 0xd3, 0x3d, 0x48, 0x99, 0x97, 0x43, 0x33, 0x37,
0x99, 0x99, 0x97, 0xd3, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00,
0x00, 0x28, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x35, 0x69, 0x99, 0x95, 0xc3,
0x33, 0x3c, 0x89, 0x99, 0x99, 0xb3, 0x33, 0x49, 0x99, 0x94, 0x08, 0x33,
0x02, 0x3c, 0x12, 0x99, 0x02, 0x97, 0x02, 0x43, 0x0a, 0x33, 0x02, 0xd4,
0x02, 0x79, 0x0a, 0x99, 0x02, 0xd3, 0x0c, 0x33, 0x02, 0x34, 0x22, 0x99,
0x00, 0x06, 0x7c, 0x33, 0xd6, 0x00, 0x20, 0x99, 0x00, 0x2e, 0x97, 0xa3,
0x33, 0x49, 0x99, 0x95, 0xd3, 0x35, 0x69, 0x99, 0x95, 0xc3, 0x33, 0x3c,
0x89, 0x99, 0x99, 0xb3, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00,
0x00, 0x12, 0x33, 0x49, 0x99, 0x95, 0xd3, 0xd4, 0x89, 0x99, 0x74, 0x00,
0x06, 0x33, 0x00, 0x10, 0x79, 0x99, 0x99, 0x7d, 0x33, 0x49, 0x99, 0x94,
0x0a, 0x33, 0x00, 0x16, 0x79, 0x99, 0x99, 0x64, 0x44, 0x44, 0x89, 0x99,
0x99, 0x94, 0xc3, 0x00, 0x08, 0x33, 0x00, 0x0a, 0x3d, 0x46, 0x99, 0x98,
0x59, 0x00, 0x06, 0x99, 0x02, 0x8d, 0x0c, 0x33, 0x02, 0x34, 0x22, 0x99,
0x00, 0x06, 0x7c, 0x33, 0xd6, 0x00, 0x20, 0x99, 0x00, 0x16, 0x97, 0xa3,
0x33, 0x49, 0x99, 0x95, 0xd3, 0xd4, 0x89, 0x99, 0x74, 0x00, 0x06, 0x33,
0x00, 0x12, 0x79, 0x99, 0x99, 0x7d, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00,
0x00, 0x00, 0x00, 0x12, 0x33, 0x49, 0x99, 0x95, 0xd3, 0x76, 0x99, 0x99,
0x6a, 0x00, 0x06, 0x33, 0x00, 0x10, 0xa9, 0x99, 0x99, 0x9b, 0x33, 0x49,
0x99, 0x94, 0x0a, 0x33, 0x00, 0x14, 0xc9, 0x99, 0x99, 0x9c, 0x33, 0x33,
0x3b, 0x99, 0x99, 0x74, 0x0a, 0x33, 0x00, 0x0a, 0x35, 0x59, 0x99, 0x95,
0x7d, 0x00, 0x06, 0x99, 0x02, 0x9a, 0x0c, 0x33, 0x02, 0x34, 0x22, 0x99,
0x00, 0x06, 0x7c, 0x33, 0xd6, 0x00, 0x20, 0x99, 0x00, 0x16, 0x97, 0xa3,
0x33, 0x49, 0x99, 0x95, 0xd3, 0x76, 0x99, 0x99, 0x6a, 0x00, 0x06, 0x33,
0x00, 0x12, 0xa9, 0x99, 0x99, 0x9b, 0x33, 0x49, 0x99, 0x94, 0x33, 0x00,
0x00, 0x00, 0x00, 0x12, 0x33, 0x49, 0x99, 0x95, 0x3d, 0x48, 0x99, 0x98,
0x4d, 0x00, 0x06, 0x33, 0x00, 0x10, 0xd7, 0x99, 0x99, 0x97, 0xd3, 0x49,
0x99, 0x94, 0x0a, 0x33, 0x00, 0x14, 0x37, 0x99, 0x99, 0x97, 0x33, 0x33,
0xc4, 0x89, 0x99, 0x4c, 0x0a, 0x33, 0x00, 0x0c, 0x84, 0x89, 0x99, 0x64,
0x33, 0xd9, 0x06, 0x99, 0x02, 0xa3, 0x0a, 0x33, 0x00, 0x08, 0x34, 0x99,
0x99, 0x64, 0x16, 0x44, 0x06, 0x99, 0x00, 0x06, 0x7c, 0x33, 0xd6, 0x00,
0x20, 0x99, 0x00, 0x16, 0x97, 0xa3, 0x33, 0x49, 0x99, 0x95, 0x3d, 0x48,
0x99, 0x98, 0x4d, 0x00, 0x06, 0x33, 0x00, 0x12, 0xd7, 0x99, 0x99, 0x97,
0xd3, 0x49, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x00, 0x12, 0x33, 0x49,
0x99, 0x96, 0x3b, 0x69, 0x99, 0x96, 0x53, 0x00, 0x06, 0x33, 0x02, 0x38,
0x06, 0x99, 0x00, 0x08, 0xc3, 0x49, 0x99, 0x94, 0x0a, 0x33, 0x02, 0x3c,
0x06, 0x99, 0x00, 0x0c, 0xb3, 0x33, 0x46, 0x99, 0x96, 0x43, 0x08, 0x33,
0x00, 0x0e, 0x3b, 0x48, 0x99, 0x97, 0x4d, 0x33, 0x3d, 0x00, 0x06, 0x99,
0x02, 0x9c, 0x0a, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x6d, 0x16, 0x33,
0x00, 0x12, 0x39, 0x99, 0x99, 0x7c, 0x33, 0xd6, 0x99, 0x99, 0x54, 0x00,
0x1c, 0x44, 0x00, 0x14, 0xa3, 0x33, 0x49, 0x99, 0x96, 0x3b, 0x69, 0x99,
0x96, 0x53, 0x06, 0x33, 0x02, 0x38, 0x06, 0x99, 0x00, 0x0a, 0xc3, 0x49,
0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x00, 0x12, 0x33, 0x49, 0x99, 0x98,
0xd5, 0x79, 0x99, 0x94, 0xd3, 0x00, 0x06, 0x33, 0x00, 0x10, 0x3d, 0x89,
0x99, 0x99, 0x73, 0x49, 0x99, 0x94, 0x0c, 0x33, 0x00, 0x12, 0x79, 0x99,
0x99, 0x8d, 0x3a, 0x59, 0x99, 0x84, 0xd3, 0x00, 0x08, 0x33, 0x00, 0x10,
0xd4, 0x79, 0x99, 0x84, 0xb3, 0x33, 0x33, 0xb9, 0x06, 0x99, 0x02, 0xd3,
0x08, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x6d, 0x16, 0x33, 0x00, 0x12,
0x34, 0x99, 0x99, 0x7c, 0x33, 0xd6, 0x99, 0x99, 0x5d, 0x00, 0x20, 0x33,
0x00, 0x10, 0x49, 0x99, 0x98, 0xd5, 0x79, 0x99, 0x94, 0xd3, 0x06, 0x33,
0x00, 0x12, 0x3d, 0x89, 0x99, 0x99, 0x73, 0x49, 0x99, 0x94, 0x33, 0x00,
0x00, 0x00, 0x00, 0x10, 0x33, 0x49, 0x99, 0x99, 0xa6, 0x99, 0x99, 0x74,
0x0a, 0x33, 0x00, 0x0e, 0x79, 0x99, 0x99, 0x9c, 0x59, 0x99, 0x94, 0x00,
0x0c, 0x33, 0x00, 0x10, 0xc9, 0x99, 0x99, 0x9a, 0xd4, 0x79, 0x99, 0x65,
0x08, 0x33, 0x00, 0x0a, 0x3d, 0x46, 0x99, 0x98, 0x48, 0x00, 0x06, 0x33,
0x02, 0x3a, 0x06, 0x99, 0x02, 0x83, 0x08, 0x33, 0x00, 0x08, 0x34, 0x99,
0x99, 0x6d, 0x16, 0x33, 0x00, 0x12, 0x34, 0x99, 0x99, 0x7c, 0x33, 0xd6,
0x99, 0x99, 0x93, 0x00, 0x20, 0x33, 0x00, 0x0e, 0x49, 0x99, 0x99, 0xa6,
0x99, 0x99, 0x74, 0x00, 0x0a, 0x33, 0x00, 0x10, 0x79, 0x99, 0x99, 0x9c,
0x59, 0x99, 0x94, 0x33, 0x00, 0x00, 0x00, 0x10, 0x33, 0x49, 0x99, 0x99,
0x98, 0x99, 0x99, 0x5c, 0x0a, 0x33, 0x02, 0xd8, 0x06, 0x99, 0x00, 0x06,
0x79, 0x99, 0x84, 0x00, 0x0c, 0x33, 0x02, 0x37, 0x06, 0x99, 0x00, 0x08,
0x86, 0x99, 0x98, 0x4d, 0x08, 0x33, 0x00, 0x0a, 0x35, 0x59, 0x99, 0x95,
0x53, 0x00, 0x08, 0x33, 0x00, 0x08, 0x89, 0x99, 0x99, 0x9a, 0x08, 0x33,
0x00, 0x08, 0x34, 0x99, 0x99, 0x6d, 0x16, 0x33, 0x00, 0x0c, 0x34, 0x99,
0x99, 0x7c, 0x33, 0x36, 0x06, 0x99, 0x02, 0x54, 0x18, 0x44, 0x00, 0x14,
0x45, 0xc3, 0x33, 0x49, 0x99, 0x99, 0x98, 0x99, 0x99, 0x5c, 0x0a, 0x33,
0x02, 0xd8, 0x06, 0x99, 0x00, 0x08, 0x79, 0x99, 0x84, 0x33, 0x00, 0x00,
0x02, 0x33, 0x02, 0x59, 0x08, 0x99, 0x02, 0x97, 0x02, 0x4d, 0x0a, 0x33,
0x02, 0x36, 0x0a, 0x99, 0x02, 0x75, 0x0c, 0x33, 0x02, 0x3c, 0x0a, 0x99,
0x02, 0x96, 0x02, 0x53, 0x08, 0x33, 0x00, 0x0a, 0x84, 0x89, 0x99, 0x64,
0xd3, 0x00, 0x08, 0x33, 0x02, 0xd9, 0x06, 0x99, 0x02, 0xb3, 0x06, 0x33,
0x00, 0x08, 0x34, 0x99, 0x99, 0x6d, 0x16, 0x33, 0x00, 0x0c, 0x34, 0x99,
0x99, 0x7c, 0x33, 0x36, 0x20, 0x99, 0x00, 0x08, 0x97, 0xa3, 0x33, 0x59,
0x08, 0x99, 0x02, 0x97, 0x02, 0x4d, 0x0a, 0x33, 0x02, 0x36, 0x0a, 0x99,
0x02, 0x75, 0x02, 0x33, 0x00, 0x00, 0x02, 0x33, 0x02, 0xa8, 0x08, 0x99,
0x02, 0x95, 0x02, 0xa3, 0x0a, 0x33, 0x02, 0x3c, 0x0a, 0x99, 0x02, 0x5b,
0x0e, 0x33, 0x02, 0x89, 0x08, 0x99, 0x02, 0x84, 0x02, 0xd3, 0x06, 0x33,
0x00, 0x0a, 0x3b, 0x48, 0x99, 0x97, 0x4c, 0x00, 0x0a, 0x33, 0x02, 0x3d,
0x06, 0x99, 0x02, 0x9d, 0x06, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x6d,
0x16, 0x33, 0x00, 0x0e, 0x34, 0x99, 0x99, 0x7c, 0x33, 0x3d, 0x89, 0x00,
0x1e, 0x99, 0x00, 0x08, 0x97, 0xa3, 0x33, 0xa8, 0x08, 0x99, 0x02, 0x95,
0x02, 0xa3, 0x0a, 0x33, 0x02, 0x3c, 0x0a, 0x99, 0x02, 0x5b, 0x02, 0x33,
0x00, 0x00, 0x02, 0x33, 0x02, 0xd7, 0x08, 0x99, 0x02, 0x64, 0x0e, 0x33,
0x02, 0x79, 0x06, 0x99, 0x02, 0x96, 0x02, 0x4d, 0x0e, 0x33, 0x02, 0xd8,
0x06, 0x99, 0x02, 0x98, 0x02, 0x48, 0x08, 0x33, 0x00, 0x0a, 0xd4, 0x79,
0x99, 0x84, 0xb3, 0x00, 0x0c, 0x33, 0x00, 0x16, 0xb9, 0x99, 0x99, 0x98,
0xd3, 0x33, 0x33, 0x34, 0x99, 0x99, 0x6d, 0x00, 0x16, 0x33, 0x00, 0x0c,
0x34, 0x99, 0x99, 0x7c, 0x33, 0x33, 0x20, 0x99, 0x00, 0x08, 0x97, 0xa3,
0x33, 0xd7, 0x08, 0x99, 0x02, 0x64, 0x0e, 0x33, 0x02, 0x79, 0x06, 0x99,
0x00, 0x06, 0x96, 0x4d, 0x33, 0x00, 0x00, 0x00, 0x02, 0x33, 0x02, 0x3c,
0x06, 0x99, 0x02, 0x96, 0x02, 0x4d, 0x0e, 0x33, 0x02, 0xd9, 0x06, 0x99,
0x02, 0x74, 0x02, 0xc3, 0x0e, 0x33, 0x02, 0x3d, 0x06, 0x99, 0x02, 0x85,
0x02, 0x53, 0x06, 0x33, 0x00, 0x0a, 0x3d, 0x46, 0x99, 0x99, 0x57, 0x00,
0x0e, 0x33, 0x02, 0x39, 0x06, 0x99, 0x00, 0x0e, 0xa3, 0x33, 0x33, 0x34,
0x99, 0x99, 0x6d, 0x00, 0x16, 0x33, 0x00, 0x0e, 0x34, 0x99, 0x99, 0x7c,
0x33, 0x33, 0x3a, 0x00, 0x1e, 0x99, 0x00, 0x08, 0x97, 0xa3, 0x33, 0x3c,
0x06, 0x99, 0x02, 0x96, 0x02, 0x4d, 0x0e, 0x33, 0x02, 0xd9, 0x06, 0x99,
0x00, 0x06, 0x74, 0xc3, 0x33, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x33, 0x33,
0xc8, 0x99, 0x96, 0x44, 0xd3, 0x00, 0x0e, 0x33, 0x00, 0x0a, 0x3d, 0x79,
0x99, 0x76, 0x4b, 0x00, 0x12, 0x33, 0x00, 0x0a, 0xc7, 0x99, 0x96, 0x45,
0xd3, 0x00, 0x06, 0x33, 0x00, 0x0a, 0x35, 0x59, 0x99, 0x96, 0x43, 0x00,
0x10, 0x33, 0x00, 0x14, 0x89, 0x99, 0x99, 0x9a, 0x33, 0x33, 0x34, 0x99,
0x99, 0x6d, 0x16, 0x33, 0x00, 0x08, 0x34, 0x99, 0x99, 0x7c, 0x06, 0x33,
0x02, 0xa6, 0x1c, 0x99, 0x00, 0x12, 0x97, 0xa3, 0x33, 0x33, 0xc8, 0x99,
0x96, 0x44, 0xd3, 0x00, 0x0e, 0x33, 0x00, 0x0e, 0x3d, 0x79, 0x99, 0x76,
0x4b, 0x33, 0x33, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x33, 0x33, 0x3d, 0x84,
0x44, 0xc3, 0x12, 0x33, 0x00, 0x08, 0xdc, 0x44, 0x4a, 0xd3, 0x12, 0x33,
0x00, 0x08, 0x3d, 0xa4, 0x44, 0xd3, 0x08, 0x33, 0x02, 0xc8, 0x06, 0x44,
0x02, 0xd3, 0x10, 0x33, 0x02, 0xd4, 0x06, 0x44, 0x00, 0x0c, 0xa3, 0x33,
0x38, 0x44, 0x44, 0x4d, 0x16, 0x33, 0x00, 0x08, 0x38, 0x44, 0x44, 0x4c,
0x06, 0x33, 0x02, 0x3d, 0x02, 0xc4, 0x1c, 0x44, 0x00, 0x0e, 0xa3, 0x33,
0x33, 0x3d, 0x84, 0x44, 0xc3, 0x00, 0x12, 0x33, 0x00, 0x0c, 0xdc, 0x44,
0x4a, 0xd3, 0x33, 0x33, 0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33,
0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33,
0x00, 0x00, 0x00, 0x1e, 0x33, 0x20, 0x00, 0x23, 0x30, 0x00, 0x13, 0x31,
0x00, 0x02, 0x33, 0x00, 0x01, 0x33, 0x32, 0x00, 0x08, 0x00, 0x00, 0x26,
0x13, 0x31, 0x00, 0x02, 0x33, 0x00, 0x01, 0x33, 0x00, 0x00, 0x13, 0x33,
0x00, 0x00, 0x13, 0x32, 0x00, 0x00, 0x23, 0x00, 0x24, 0x33, 0x00, 0x06,
0x32, 0x00, 0x02, 0x00, 0x08, 0x33, 0x02, 0x32, 0x06, 0x00, 0x00, 0x30,
0x01, 0x33, 0x31, 0x00, 0x02, 0x33, 0x00, 0x01, 0x33, 0x33, 0x32, 0x00,
0x02, 0x33, 0x33, 0x30, 0x00, 0x13, 0x32, 0x00, 0x02, 0x33, 0x00, 0x01,
0x08, 0x33, 0x00, 0x10, 0x30, 0x00, 0x13, 0x31, 0x00, 0x02, 0x33, 0x30,
0x08, 0x00, 0x00, 0x10, 0x23, 0x30, 0x00, 0x13, 0x31, 0x00, 0x02, 0x33,
0x00, 0x00, 0x00, 0x20, 0x33, 0x20, 0x11, 0x13, 0x30, 0x11, 0x03, 0x31,
0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x10, 0x10, 0x06, 0x00, 0x00, 0x26,
0x03, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x01, 0x11, 0x03, 0x33,
0x01, 0x11, 0x13, 0x32, 0x01, 0x11, 0x23, 0x00, 0x24, 0x33, 0x00, 0x06,
0x32, 0x01, 0x11, 0x00, 0x08, 0x33, 0x00, 0x38, 0x10, 0x10, 0x00, 0x11,
0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x33, 0x32, 0x01,
0x11, 0x33, 0x33, 0x30, 0x11, 0x03, 0x32, 0x01, 0x11, 0x33, 0x01, 0x10,
0x08, 0x33, 0x00, 0x12, 0x30, 0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x00,
0x10, 0x00, 0x06, 0x00, 0x00, 0x10, 0x23, 0x30, 0x11, 0x03, 0x31, 0x11,
0x02, 0x33, 0x00, 0x00, 0x00, 0x22, 0x33, 0x20, 0x11, 0x13, 0x30, 0x11,
0x03, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x11, 0x10, 0x23, 0x00,
0x06, 0x33, 0x00, 0x24, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x01,
0x11, 0x13, 0x33, 0x01, 0x10, 0x13, 0x32, 0x01, 0x11, 0x23, 0x24, 0x33,
0x00, 0x06, 0x32, 0x01, 0x11, 0x00, 0x08, 0x33, 0x00, 0x38, 0x11, 0x10,
0x23, 0x31, 0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x33,
0x32, 0x01, 0x11, 0x33, 0x33, 0x30, 0x11, 0x03, 0x32, 0x01, 0x11, 0x33,
0x01, 0x10, 0x08, 0x33, 0x00, 0x12, 0x30, 0x11, 0x03, 0x31, 0x11, 0x02,
0x33, 0x01, 0x10, 0x00, 0x08, 0x33, 0x00, 0x0e, 0x30, 0x11, 0x03, 0x31,
0x11, 0x02, 0x33, 0x00, 0x00, 0x00, 0x00, 0x22, 0x33, 0x20, 0x11, 0x23,
0x30, 0x11, 0x03, 0x31, 0x11, 0x12, 0x33, 0x01, 0x10, 0x33, 0x11, 0x10,
0x23, 0x00, 0x06, 0x33, 0x00, 0x28, 0x31, 0x11, 0x12, 0x33, 0x01, 0x00,
0x33, 0x01, 0x11, 0x11, 0x00, 0x01, 0x12, 0x33, 0x32, 0x01, 0x11, 0x11,
0x00, 0x23, 0x20, 0x33, 0x00, 0x06, 0x32, 0x01, 0x12, 0x00, 0x08, 0x33,
0x00, 0x38, 0x11, 0x10, 0x23, 0x30, 0x11, 0x03, 0x31, 0x11, 0x12, 0x33,
0x01, 0x00, 0x33, 0x33, 0x32, 0x01, 0x11, 0x33, 0x33, 0x30, 0x11, 0x13,
0x32, 0x01, 0x11, 0x33, 0x01, 0x11, 0x08, 0x33, 0x00, 0x12, 0x30, 0x11,
0x03, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x00, 0x08, 0x33, 0x00, 0x0e,
0x30, 0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x00, 0x00, 0x00, 0x00, 0x22,
0x33, 0x20, 0x11, 0x11, 0x00, 0x11, 0x03, 0x31, 0x11, 0x11, 0x00, 0x01,
0x10, 0x33, 0x11, 0x10, 0x23, 0x00, 0x06, 0x33, 0x00, 0x10, 0x31, 0x11,
0x11, 0x00, 0x01, 0x13, 0x33, 0x01, 0x08, 0x11, 0x00, 0x10, 0x12, 0x33,
0x32, 0x01, 0x11, 0x11, 0x10, 0x23, 0x20, 0x33, 0x00, 0x60, 0x32, 0x01,
0x11, 0x10, 0x00, 0x03, 0x33, 0x11, 0x10, 0x23, 0x30, 0x11, 0x03, 0x31,
0x11, 0x12, 0x22, 0x01, 0x02, 0x33, 0x33, 0x32, 0x01, 0x11, 0x33, 0x33,
0x30, 0x11, 0x12, 0x21, 0x01, 0x11, 0x33, 0x01, 0x11, 0x22, 0x22, 0x23,
0x33, 0x30, 0x11, 0x12, 0x21, 0x11, 0x02, 0x33, 0x01, 0x10, 0x08, 0x33,
0x00, 0x0e, 0x30, 0x11, 0x12, 0x21, 0x10, 0x13, 0x33, 0x00, 0x00, 0x00,
0x00, 0x22, 0x33, 0x20, 0x11, 0x00, 0x11, 0x11, 0x03, 0x31, 0x11, 0x00,
0x01, 0x11, 0x10, 0x33, 0x11, 0x10, 0x23, 0x00, 0x06, 0x33, 0x00, 0x28,
0x31, 0x11, 0x00, 0x01, 0x11, 0x13, 0x33, 0x01, 0x11, 0x00, 0x01, 0x11,
0x12, 0x33, 0x32, 0x01, 0x11, 0x00, 0x00, 0x23, 0x20, 0x33, 0x00, 0x60,
0x32, 0x01, 0x10, 0x01, 0x11, 0x12, 0x33, 0x11, 0x10, 0x23, 0x30, 0x11,
0x03, 0x31, 0x11, 0x10, 0x10, 0x11, 0x13, 0x33, 0x33, 0x32, 0x01, 0x11,
0x33, 0x33, 0x30, 0x11, 0x10, 0x10, 0x11, 0x11, 0x33, 0x01, 0x11, 0x01,
0x00, 0x01, 0x23, 0x30, 0x11, 0x00, 0x10, 0x11, 0x02, 0x33, 0x01, 0x10,
0x08, 0x33, 0x00, 0x0e, 0x30, 0x11, 0x00, 0x10, 0x11, 0x23, 0x33, 0x00,
0x00, 0x00, 0x00, 0x22, 0x33, 0x20, 0x11, 0x13, 0x31, 0x11, 0x03, 0x31,
0x11, 0x02, 0x33, 0x11, 0x10, 0x33, 0x11, 0x10, 0x23, 0x00, 0x06, 0x33,
0x00, 0x24, 0x31, 0x11, 0x02, 0x33, 0x11, 0x10, 0x33, 0x01, 0x11, 0x03,
0x33, 0x11, 0x11, 0x13, 0x32, 0x01, 0x11, 0x23, 0x24, 0x33, 0x00, 0x60,
0x32, 0x01, 0x11, 0x33, 0x11, 0x10, 0x33, 0x11, 0x10, 0x23, 0x30, 0x11,
0x03, 0x31, 0x11, 0x01, 0x22, 0x11, 0x12, 0x33, 0x33, 0x32, 0x01, 0x11,
0x33, 0x33, 0x30, 0x11, 0x02, 0x22, 0x11, 0x11, 0x33, 0x01, 0x10, 0x22,
0x21, 0x11, 0x13, 0x30, 0x11, 0x02, 0x21, 0x11, 0x02, 0x33, 0x01, 0x10,
0x08, 0x33, 0x00, 0x0e, 0x30, 0x11, 0x02, 0x21, 0x11, 0x23, 0x33, 0x00,
0x00, 0x00, 0x00, 0x22, 0x33, 0x20, 0x11, 0x13, 0x30, 0x11, 0x03, 0x31,
0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x11, 0x10, 0x23, 0x00, 0x06, 0x33,
0x00, 0x24, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x01, 0x11, 0x13,
0x33, 0x01, 0x11, 0x13, 0x32, 0x01, 0x11, 0x23, 0x24, 0x33, 0x00, 0x60,
0x32, 0x01, 0x11, 0x33, 0x01, 0x10, 0x33, 0x11, 0x11, 0x23, 0x30, 0x11,
0x03, 0x31, 0x11, 0x12, 0x33, 0x11, 0x10, 0x33, 0x33, 0x32, 0x01, 0x11,
0x33, 0x33, 0x30, 0x11, 0x13, 0x32, 0x11, 0x11, 0x33, 0x01, 0x11, 0x33,
0x21, 0x11, 0x13, 0x30, 0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10,
0x08, 0x33, 0x00, 0x0e, 0x30, 0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x00,
0x00, 0x00, 0x00, 0x22, 0x33, 0x20, 0x11, 0x13, 0x30, 0x11, 0x03, 0x31,
0x11, 0x12, 0x33, 0x01, 0x00, 0x33, 0x11, 0x11, 0x23, 0x00, 0x06, 0x33,
0x00, 0x2c, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x01, 0x11, 0x11,
0x00, 0x01, 0x10, 0x13, 0x32, 0x01, 0x11, 0x11, 0x00, 0x00, 0x01, 0x23,
0x1c, 0x33, 0x00, 0x60, 0x32, 0x01, 0x12, 0x33, 0x01, 0x00, 0x33, 0x11,
0x11, 0x22, 0x20, 0x11, 0x03, 0x31, 0x11, 0x12, 0x22, 0x01, 0x10, 0x33,
0x33, 0x32, 0x01, 0x12, 0x33, 0x33, 0x30, 0x11, 0x12, 0x21, 0x01, 0x11,
0x33, 0x01, 0x11, 0x22, 0x10, 0x11, 0x13, 0x30, 0x11, 0x12, 0x21, 0x11,
0x02, 0x33, 0x01, 0x11, 0x08, 0x33, 0x00, 0x0e, 0x30, 0x11, 0x03, 0x31,
0x11, 0x02, 0x33, 0x00, 0x00, 0x00, 0x00, 0x38, 0x33, 0x20, 0x11, 0x13,
0x30, 0x11, 0x03, 0x32, 0x11, 0x11, 0x00, 0x01, 0x02, 0x33, 0x21, 0x11,
0x10, 0x00, 0x00, 0x13, 0x31, 0x11, 0x02, 0x33, 0x01, 0x10, 0x33, 0x01,
0x08, 0x11, 0x00, 0x08, 0x12, 0x33, 0x33, 0x21, 0x08, 0x11, 0x02, 0x10,
0x02, 0x23, 0x1c, 0x33, 0x00, 0x0e, 0x32, 0x01, 0x11, 0x10, 0x01, 0x02,
0x33, 0x00, 0x06, 0x11, 0x00, 0x62, 0x01, 0x10, 0x03, 0x31, 0x11, 0x11,
0x10, 0x11, 0x00, 0x33, 0x10, 0x00, 0x01, 0x11, 0x10, 0x13, 0x30, 0x11,
0x11, 0x10, 0x11, 0x01, 0x33, 0x01, 0x11, 0x11, 0x01, 0x10, 0x13, 0x30,
0x11, 0x11, 0x00, 0x10, 0x02, 0x33, 0x01, 0x11, 0x10, 0x00, 0x00, 0x23,
0x30, 0x11, 0x03, 0x31, 0x11, 0x02, 0x33, 0x00, 0x00, 0x00, 0x00, 0x12,
0x33, 0x20, 0x00, 0x13, 0x31, 0x00, 0x03, 0x33, 0x20, 0x00, 0x06, 0x00,
0x00, 0x06, 0x13, 0x33, 0x32, 0x00, 0x08, 0x00, 0x00, 0x12, 0x03, 0x32,
0x00, 0x02, 0x33, 0x10, 0x00, 0x33, 0x10, 0x00, 0x08, 0x00, 0x00, 0x08,
0x02, 0x33, 0x33, 0x30, 0x0a, 0x00, 0x02, 0x23, 0x1c, 0x33, 0x02, 0x32,
0x08, 0x00, 0x00, 0x06, 0x03, 0x33, 0x32, 0x00, 0x06, 0x00, 0x00, 0x06,
0x01, 0x33, 0x32, 0x00, 0x08, 0x00, 0x00, 0x06, 0x13, 0x33, 0x20, 0x00,
0x08, 0x00, 0x00, 0x06, 0x03, 0x33, 0x10, 0x00, 0x06, 0x00, 0x00, 0x06,
0x23, 0x33, 0x10, 0x00, 0x06, 0x00, 0x00, 0x06, 0x02, 0x33, 0x33, 0x00,
0x08, 0x00, 0x00, 0x06, 0x23, 0x33, 0x30, 0x00, 0x08, 0x00, 0x00, 0x10,
0x23, 0x31, 0x00, 0x03, 0x32, 0x00, 0x02, 0x33, 0x00, 0x00, 0xe6, 0x33,
0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33, 0x00, 0x00, 0xe6, 0x33,
0x00, 0x01};
unsigned int splash_new__new_t_len = 3854;
-104
View File
@@ -1,104 +0,0 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
*
* 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 "de_bruijn.hpp"
/* How this works:
* B(2,4) means:
* Alphabet size = 2 (binary)
* Code length = 4
* The length of the bitstream is (2 ^ 4) + (4 - 1) = 19 bits
* The primitive polynomials come from the de_bruijn_polys[] array (one for each code length)
* The shift register is init with 1 and shifted left each step
* The polynomial is kept on the right, and used as a AND mask applied on the corresponding shift register bits
* The resulting bits are XORed together to produce the new bit pushed in the shift register
*
* 0001 (init)
* AND 1001 (polynomial)
* 0001 XOR'd -> 1
*
* 00011 (shift left)
* AND 1001
* 0001 XOR'd -> 1
*
* 000111 (shift left)
* AND 1001
* 0001 XOR'd -> 1
*
* 0001111 (shift left)
* AND 1001
* 1001 XOR'd -> 0
*
* 00011110 (shift left)
* AND 1001
* 1000 XOR'd -> 1
* ...
* After 16 steps: (0+) 000111101011001000
* Each of the 16 possible values appears in the sequence:
* -0000-111101011001000 0
* 0-0001-11101011001000 1
* 0000111101011-0010-00 2
* 00-0011-1101011001000 3
* 00001111010110-0100-0 4
* 00001111-0101-1001000 5
* 0000111101-0110-01000 6
* 000-0111-101011001000 7
* 000011110101100-1000- 8
* 000011110101-1001-000 9
* 0000111-1010-11001000 10
* 000011110-1011-001000 11
* 00001111010-1100-1000 12
* 000011-1101-011001000 13
* 00001-1110-1011001000 14
* 0000-1111-01011001000 15
*/
size_t de_bruijn::init(const uint32_t n) {
// Cap
if ((n < 3) || (n > 16))
length = 3;
else
length = n;
poly = de_bruijn_polys[length - 3];
shift_register = 1;
return (1U << length) + (length - 1);
}
uint32_t de_bruijn::compute(const uint32_t steps) {
uint32_t step, bits, masked;
uint8_t new_bit;
for (step = 0; step < steps; step++) {
masked = shift_register & poly;
new_bit = 0;
for (bits = 0; bits < length; bits++) {
new_bit ^= (masked & 1);
masked >>= 1;
}
shift_register <<= 1;
shift_register |= new_bit;
}
return shift_register;
}
-57
View File
@@ -1,57 +0,0 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 Furrtek
*
* 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 <string>
#include <cstdint>
#ifndef __DE_BRUIJN_H__
#define __DE_BRUIJN_H__
// n from 3 to 16
const uint32_t de_bruijn_polys[14]{
0b0000000000000101,
0b0000000000001001,
0b0000000000011011,
0b0000000000110011,
0b0000000001010011,
0b0000000010001101,
0b0000000100100001,
0b0000001000100001,
0b0000010001100001,
0b0000110101000011,
0b0001001001100101,
0b0010101100000011,
0b0101000000001001,
0b1010000101000101};
struct de_bruijn {
public:
size_t init(const uint32_t n);
uint32_t compute(const uint32_t steps);
private:
uint32_t length{};
uint32_t poly{};
uint32_t shift_register{};
};
#endif /*__DE_BRUIJN_H__*/
-29
View File
@@ -1,29 +0,0 @@
/*
* 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.
*/
// dummy include file to avoid changing original source
#ifndef __UI_Arial12x12_H__
#define __UI_Arial12x12_H__
#define Arial12x12 (0)
#endif /*__UI_Arial12x12_H__*/
@@ -1,68 +0,0 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#ifndef __UI_SPI_TFT_ILI9341_H__
#define __UI_SPI_TFT_ILI9341_H__
ui::Painter painter;
static int bg_color;
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
static const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
static void claim(__FILE* x) {
(void)x;
};
static void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
};
static void background(int color) {
bg_color = color;
};
static void set_orientation(int x) {
(void)x;
};
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]);
};
#endif /*__UI_SPI_TFT_ILI9341_H__*/
-429
View File
@@ -1,429 +0,0 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#include "mbed.h"
#include "SPI_TFT_ILI9341.h"
#include "Arial12x12.h"
#include "ui.hpp"
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define PADDLE_WIDTH 40
#define PADDLE_HEIGHT 10
#define BALL_SIZE 8
#define BRICK_WIDTH 20
#define BRICK_HEIGHT 10
#define BRICK_ROWS 5
#define BRICK_COLS 10
#define BRICK_GAP 2
#define GAME_AREA_TOP 50
#define GAME_AREA_BOTTOM 310
#define PADDLE_Y (GAME_AREA_BOTTOM - PADDLE_HEIGHT)
#define BALL_SPEED_INCREASE 0.1f
#define STATE_MENU 0
#define STATE_PLAYING 1
#define STATE_GAME_OVER 3
#define COLOR_BACKGROUND Black
#define COLOR_PADDLE Blue
#define COLOR_BALL White
#define COLOR_BORDER White
#define COLOR_BRICK_COLORS \
{ Red, Orange, Yellow, Green, Purple }
Ticker game_timer;
int paddle_x = (SCREEN_WIDTH - PADDLE_WIDTH) / 2;
float ball_x = SCREEN_WIDTH / 2;
float ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
float ball_dx = 1.5f;
float ball_dy = -2.0f;
int score = 0;
int lives = 3;
int level = 1;
int game_state = STATE_MENU;
bool initialized = false;
bool ball_attached = true;
unsigned int brick_count = 0;
bool bricks[BRICK_ROWS][BRICK_COLS];
int brick_colors[BRICK_ROWS];
extern ui::Painter painter;
void init_game();
void init_level();
void draw_screen();
void draw_bricks();
void draw_paddle();
void draw_ball();
void draw_score();
void draw_lives();
void draw_level();
void draw_borders();
void move_paddle_left();
void move_paddle_right();
void launch_ball();
void update_game();
void check_collisions();
bool check_brick_collision(int row, int col);
void handle_game_over();
void show_menu();
void show_game_over();
bool check_level_complete();
void next_level();
void reset_game();
void game_timer_check() {
if (game_state == STATE_PLAYING) {
update_game();
}
}
void init_game() {
claim(stdout);
set_orientation(2);
set_font((unsigned char*)Arial12x12);
paddle_x = (SCREEN_WIDTH - PADDLE_WIDTH) / 2;
score = 0;
lives = 3;
level = 1;
brick_colors[0] = Red;
brick_colors[1] = Orange;
brick_colors[2] = Yellow;
brick_colors[3] = Green;
brick_colors[4] = Purple;
init_level();
game_state = STATE_MENU;
show_menu();
}
void init_level() {
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
float speed_multiplier = (level == 1) ? 1.0f : 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
ball_dx = (ball_dx > 0 ? 1.5f : -1.5f) * speed_multiplier;
ball_dy = -2.0f * speed_multiplier;
ball_attached = true;
brick_count = 0;
for (int row = 0; row < BRICK_ROWS; row++) {
for (int col = 0; col < BRICK_COLS; col++) {
bricks[row][col] = true;
brick_count++;
}
}
}
void draw_screen() {
cls();
background(COLOR_BACKGROUND);
draw_borders();
draw_bricks();
draw_paddle();
draw_ball();
draw_score();
draw_lives();
draw_level();
}
void draw_borders() {
rect(0, GAME_AREA_TOP - 1, SCREEN_WIDTH, GAME_AREA_TOP, COLOR_BORDER);
}
void draw_bricks() {
for (int row = 0; row < BRICK_ROWS; row++) {
for (int col = 0; col < BRICK_COLS; col++) {
if (bricks[row][col]) {
int x = col * (BRICK_WIDTH + BRICK_GAP);
int y = GAME_AREA_TOP + row * (BRICK_HEIGHT + BRICK_GAP) + 5;
fillrect(x, y, x + BRICK_WIDTH, y + BRICK_HEIGHT, brick_colors[row]);
rect(x, y, x + BRICK_WIDTH, y + BRICK_HEIGHT, Black);
}
}
}
}
void draw_paddle() {
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_PADDLE);
}
void draw_ball() {
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BALL);
}
void draw_score() {
auto style = *ui::Theme::getInstance()->fg_green;
painter.draw_string({5, 10}, style, "Score: " + std::to_string(score));
}
void draw_lives() {
auto style = *ui::Theme::getInstance()->fg_red;
painter.draw_string({5, 30}, style, "Lives: " + std::to_string(lives));
}
void draw_level() {
auto style = *ui::Theme::getInstance()->fg_yellow;
painter.draw_string({80, 30}, style, "Level: " + std::to_string(level));
}
void move_paddle_left() {
if (paddle_x > 0) {
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
if (ball_attached) {
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
}
paddle_x -= 10;
if (paddle_x < 0) paddle_x = 0;
if (ball_attached) {
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
}
draw_paddle();
if (ball_attached) {
draw_ball();
}
}
}
void move_paddle_right() {
if (paddle_x < SCREEN_WIDTH - PADDLE_WIDTH) {
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
if (ball_attached) {
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
}
paddle_x += 10;
if (paddle_x > SCREEN_WIDTH - PADDLE_WIDTH) paddle_x = SCREEN_WIDTH - PADDLE_WIDTH;
if (ball_attached) {
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
}
draw_paddle();
if (ball_attached) {
draw_ball();
}
}
}
void launch_ball() {
if (ball_attached) {
ball_attached = false;
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
float speed_multiplier = (level == 1) ? 1.0f : 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
ball_dx = 1.5f * speed_multiplier;
ball_dy = -2.0f * speed_multiplier;
}
}
void update_game() {
if (ball_attached) {
return;
}
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
float next_ball_y = ball_y + ball_dy;
if (next_ball_y > GAME_AREA_BOTTOM) {
lives--;
draw_lives();
if (lives <= 0) {
handle_game_over();
} else {
ball_attached = true;
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
draw_ball();
}
return;
}
ball_x += ball_dx;
ball_y = next_ball_y;
if (ball_x < 0) {
ball_x = 0;
ball_dx = -ball_dx;
} else if (ball_x > SCREEN_WIDTH - BALL_SIZE) {
ball_x = SCREEN_WIDTH - BALL_SIZE;
ball_dx = -ball_dx;
}
if (ball_y < GAME_AREA_TOP) {
ball_y = GAME_AREA_TOP;
ball_dy = -ball_dy;
}
if (ball_y + BALL_SIZE >= PADDLE_Y && ball_y <= PADDLE_Y + PADDLE_HEIGHT) {
if (ball_x + BALL_SIZE >= paddle_x && ball_x <= paddle_x + PADDLE_WIDTH) {
ball_y = PADDLE_Y - BALL_SIZE;
float hit_position = (ball_x + (BALL_SIZE / 2)) - paddle_x;
float angle = (hit_position / PADDLE_WIDTH) - 0.5f;
ball_dx = angle * 4.0f;
if (ball_dx > -0.5f && ball_dx < 0.5f) {
ball_dx = (ball_dx > 0) ? 0.5f : -0.5f;
}
ball_dy = -ball_dy;
}
}
check_collisions();
draw_ball();
if (check_level_complete()) {
next_level();
}
}
void check_collisions() {
int grid_x = ball_x / (BRICK_WIDTH + BRICK_GAP);
int grid_y = (ball_y - GAME_AREA_TOP - 5) / (BRICK_HEIGHT + BRICK_GAP);
for (int row = grid_y - 1; row <= grid_y + 1; row++) {
for (int col = grid_x - 1; col <= grid_x + 1; col++) {
if (row >= 0 && row < BRICK_ROWS && col >= 0 && col < BRICK_COLS) {
if (bricks[row][col] && check_brick_collision(row, col)) {
return;
}
}
}
}
}
bool check_brick_collision(int row, int col) {
int brick_x = col * (BRICK_WIDTH + BRICK_GAP);
int brick_y = GAME_AREA_TOP + row * (BRICK_HEIGHT + BRICK_GAP) + 5;
if (ball_x + BALL_SIZE >= brick_x && ball_x <= brick_x + BRICK_WIDTH &&
ball_y + BALL_SIZE >= brick_y && ball_y <= brick_y + BRICK_HEIGHT) {
fillrect(brick_x, brick_y, brick_x + BRICK_WIDTH, brick_y + BRICK_HEIGHT, COLOR_BACKGROUND);
bricks[row][col] = false;
brick_count--;
score += (5 - row) * 10;
draw_score();
float center_x = brick_x + BRICK_WIDTH / 2;
float center_y = brick_y + BRICK_HEIGHT / 2;
float ball_center_x = ball_x + BALL_SIZE / 2;
float ball_center_y = ball_y + BALL_SIZE / 2;
float dx = std::abs(ball_center_x - center_x);
float dy = std::abs(ball_center_y - center_y);
if (dx * BRICK_HEIGHT > dy * BRICK_WIDTH) {
ball_dx = -ball_dx;
} else {
ball_dy = -ball_dy;
}
return true;
}
return false;
}
bool check_level_complete() {
return brick_count == 0;
}
void next_level() {
level++;
init_level();
draw_screen();
}
void handle_game_over() {
game_state = STATE_GAME_OVER;
show_game_over();
}
void show_menu() {
cls();
background(COLOR_BACKGROUND);
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_white = *ui::Theme::getInstance()->fg_light;
auto style_green = *ui::Theme::getInstance()->fg_green;
auto style_red = *ui::Theme::getInstance()->fg_red;
painter.draw_string({0, 40}, style_yellow, "* * * BREAKOUT * * *");
painter.draw_string({0, 70}, style_white, "========================");
painter.draw_string({0, 120}, style_green, "| ROTARY: MOVE PADDLE |");
painter.draw_string({0, 150}, style_green, "| SELECT: START/LAUNCH |");
painter.draw_string({0, 190}, style_white, "========================");
painter.draw_string({24, 230}, style_red, "* PRESS SELECT *");
}
void show_game_over() {
cls();
background(COLOR_BACKGROUND);
auto style_red = *ui::Theme::getInstance()->fg_red;
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_green = *ui::Theme::getInstance()->fg_green;
painter.draw_string({72, 120}, style_red, "GAME OVER");
painter.draw_string({12, 160}, style_yellow, "FINAL SCORE: " + std::to_string(score));
painter.draw_string({0, 200}, style_green, "PRESS SELECT TO RESTART");
wait(1);
}
void reset_game() {
level = 1;
score = 0;
lives = 3;
game_state = STATE_PLAYING;
init_level();
draw_screen();
}
int main() {
if (!initialized) {
initialized = true;
game_timer.attach(&game_timer_check, 1.0 / 60.0);
init_game();
}
while (1) {
if (but_SELECT && game_state == STATE_MENU) {
game_state = STATE_PLAYING;
reset_game();
}
if (but_SELECT && game_state == STATE_GAME_OVER) {
reset_game();
}
if (but_SELECT && game_state == STATE_PLAYING && ball_attached) {
launch_ball();
}
if (but_LEFT && game_state == STATE_PLAYING) {
move_paddle_left();
}
if (but_RIGHT && game_state == STATE_PLAYING) {
move_paddle_right();
}
}
}
+44 -44
View File
@@ -20,51 +20,51 @@ void initialize_app(ui::NavigationView& nav) {
extern "C" {
__attribute__((section(".external_app.app_breakout.application_information"), used)) application_information_t _application_information_breakout = {
/*.memory_location = */ (uint8_t*)0x00000000, // will be filled at compile time
/*.externalAppEntry = */ ui::external_app::breakout::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
(uint8_t*)0x00000000,
ui::external_app::breakout::initialize_app,
CURRENT_HEADER_VERSION,
VERSION_MD5,
/*.app_name = */ "Breakout",
/*.bitmap_data = */ {
0xFF,
0xFF,
0x01,
0x01,
0x01,
0x01,
0x01,
0x01,
0xFF,
0xFF,
0x80,
0x80,
0x80,
0x80,
0x80,
0x80,
0xFF,
0xFF,
0x01,
0x01,
0x01,
0x01,
0x01,
0x01,
0xFF,
0xFF,
0x80,
0x80,
0x80,
0x80,
0x80,
0x80,
"Breakout",
{
0x00,
0x00,
0x7F,
0x7F,
0x7F,
0x7F,
0x7F,
0x7F,
0x00,
0x00,
0xF7,
0xF7,
0xF7,
0xF7,
0xF7,
0xF7,
0x00,
0x00,
0x7F,
0x7F,
0x7F,
0x7F,
0x7F,
0x7F,
0x00,
0x00,
0xF7,
0xF7,
0xF7,
0xF7,
0xF7,
0xF7,
},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::GAMES,
/*.desired_menu_position = */ -1,
ui::Color::green().v,
app_location_t::GAMES,
-1,
/*.m4_app_tag = portapack::spi_flash::image_tag_none */ {0, 0, 0, 0},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
{0, 0, 0, 0},
0x00000000,
};
}
} // namespace ui::external_app::breakout
-105
View File
@@ -1,105 +0,0 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#ifndef __UI_mbed_H__
#define __UI_mbed_H__
using Callback = void (*)(void);
#define wait_us(x) (void)0
#define wait(x) chThdSleepMilliseconds(x * 1000)
#define PullUp 1
#include "ui_navigation.hpp"
enum {
dp0,
dp1,
dp2,
dp3,
dp4,
dp5,
dp6,
dp7,
dp8,
dp9,
dp10,
dp11,
dp12,
dp13,
dp14,
dp15,
dp16,
dp17,
dp18,
dp19,
dp20,
dp21,
dp22,
dp23,
dp24,
dp25,
};
static bool but_RIGHT;
static bool but_LEFT;
static bool but_SELECT;
class Timer {
public:
Timer() { (void)0; };
void reset() { (void)0; };
void start() { (void)0; }
uint32_t read_ms() { return 1000; };
private:
};
static Callback game_update_callback;
static uint32_t game_update_timeout;
static uint32_t game_update_counter;
static void check_game_timer() {
if (game_update_callback) {
if (++game_update_counter >= game_update_timeout) {
game_update_counter = 0;
game_update_callback();
}
}
}
class Ticker {
public:
Ticker() { (void)0; };
void attach(Callback func, double delay_sec) {
game_update_callback = func;
game_update_timeout = delay_sec * 60;
}
void detach() {
game_update_callback = nullptr;
}
private:
};
static Callback button_callback;
class InterruptIn {
public:
InterruptIn(int reg) {
(void)reg;
};
void fall(Callback func) { button_callback = func; };
void mode(int v) { (void)v; };
private:
};
#endif /*__UI_mbed_H__*/
+475 -4
View File
@@ -10,10 +10,477 @@
namespace ui::external_app::breakout {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "breakout.cpp"
#pragma GCC diagnostic pop
Ticker game_timer;
int paddle_x = (SCREEN_WIDTH - PADDLE_WIDTH) / 2;
float ball_x = SCREEN_WIDTH / 2;
float ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
float ball_dx = 1.5f;
float ball_dy = -2.0f;
int score = 0;
int lives = 3;
int level = 1;
int game_state = STATE_MENU;
bool initialized = false;
bool ball_attached = true;
unsigned int brick_count = 0;
bool menu_initialized = false;
bool blink_state = true;
uint32_t blink_counter = 0;
int16_t prompt_x = 0;
bool gameover_initialized = false;
bool gameover_blink_state = true;
uint32_t gameover_blink_counter = 0;
int16_t restart_x = 0;
bool bricks[BRICK_ROWS][BRICK_COLS];
int brick_colors[BRICK_ROWS];
const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
Painter painter;
bool but_RIGHT = false;
bool but_LEFT = false;
bool but_SELECT = false;
static Callback game_update_callback = nullptr;
static uint32_t game_update_timeout = 0;
static uint32_t game_update_counter = 0;
void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
}
void background(int color) {
(void)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]);
}
void rect(int x1, int y1, int x2, int y2, int color) {
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
}
void check_game_timer() {
if (game_update_callback) {
if (++game_update_counter >= game_update_timeout) {
game_update_counter = 0;
game_update_callback();
}
}
}
void Ticker::attach(Callback func, double delay_sec) {
game_update_callback = func;
game_update_timeout = delay_sec * 60;
}
void Ticker::detach() {
game_update_callback = nullptr;
}
void game_timer_check() {
if (game_state == STATE_PLAYING) {
update_game();
} else if (game_state == STATE_MENU) {
show_menu();
} else if (game_state == STATE_GAME_OVER) {
show_game_over();
}
}
void init_game() {
paddle_x = (SCREEN_WIDTH - PADDLE_WIDTH) / 2;
score = 0;
lives = 3;
level = 1;
brick_colors[0] = Red;
brick_colors[1] = Orange;
brick_colors[2] = Yellow;
brick_colors[3] = Green;
brick_colors[4] = Purple;
init_level();
game_state = STATE_MENU;
menu_initialized = false;
blink_state = true;
blink_counter = 0;
}
void init_level() {
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
float speed_multiplier = (level == 1) ? 1.0f : 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
ball_dx = (ball_dx > 0 ? 1.5f : -1.5f) * speed_multiplier;
ball_dy = -2.0f * speed_multiplier;
ball_attached = true;
brick_count = 0;
for (int row = 0; row < BRICK_ROWS; row++) {
for (int col = 0; col < BRICK_COLS; col++) {
bricks[row][col] = true;
brick_count++;
}
}
}
void draw_screen() {
cls();
background(COLOR_BACKGROUND);
draw_borders();
draw_bricks();
draw_paddle();
draw_ball();
draw_score();
draw_lives();
draw_level();
}
void draw_borders() {
rect(0, GAME_AREA_TOP - 1, SCREEN_WIDTH, GAME_AREA_TOP, COLOR_BORDER);
}
void draw_bricks() {
for (int row = 0; row < BRICK_ROWS; row++) {
for (int col = 0; col < BRICK_COLS; col++) {
if (bricks[row][col]) {
int x = col * (BRICK_WIDTH + BRICK_GAP);
int y = GAME_AREA_TOP + row * (BRICK_HEIGHT + BRICK_GAP) + 5;
fillrect(x, y, x + BRICK_WIDTH, y + BRICK_HEIGHT, brick_colors[row]);
rect(x, y, x + BRICK_WIDTH, y + BRICK_HEIGHT, Black);
}
}
}
}
void draw_paddle() {
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_PADDLE);
}
void draw_ball() {
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BALL);
}
void draw_score() {
auto style = *ui::Theme::getInstance()->fg_green;
painter.draw_string({5, 10}, style, "Score: " + std::to_string(score));
}
void draw_lives() {
auto style = *ui::Theme::getInstance()->fg_red;
painter.draw_string({5, 30}, style, "Lives: " + std::to_string(lives));
}
void draw_level() {
auto style = *ui::Theme::getInstance()->fg_yellow;
painter.draw_string({80, 30}, style, "Level: " + std::to_string(level));
}
void move_paddle_left() {
if (paddle_x > 0) {
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
if (ball_attached) {
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
}
paddle_x -= 10;
if (paddle_x < 0) paddle_x = 0;
if (ball_attached) {
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
}
draw_paddle();
if (ball_attached) {
draw_ball();
}
}
}
void move_paddle_right() {
if (paddle_x < SCREEN_WIDTH - PADDLE_WIDTH) {
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
if (ball_attached) {
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
}
paddle_x += 10;
if (paddle_x > SCREEN_WIDTH - PADDLE_WIDTH) paddle_x = SCREEN_WIDTH - PADDLE_WIDTH;
if (ball_attached) {
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
}
draw_paddle();
if (ball_attached) {
draw_ball();
}
}
}
void launch_ball() {
if (ball_attached) {
ball_attached = false;
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
float speed_multiplier = (level == 1) ? 1.0f : 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
ball_dx = 1.5f * speed_multiplier;
ball_dy = -2.0f * speed_multiplier;
}
}
void update_game() {
if (ball_attached) {
return;
}
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
float next_ball_y = ball_y + ball_dy;
if (next_ball_y > GAME_AREA_BOTTOM) {
lives--;
draw_lives();
if (lives <= 0) {
handle_game_over();
} else {
ball_attached = true;
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
draw_ball();
}
return;
}
ball_x += ball_dx;
ball_y = next_ball_y;
if (ball_x < 0) {
ball_x = 0;
ball_dx = -ball_dx;
} else if (ball_x > SCREEN_WIDTH - BALL_SIZE) {
ball_x = SCREEN_WIDTH - BALL_SIZE;
ball_dx = -ball_dx;
}
if (ball_y < GAME_AREA_TOP) {
ball_y = GAME_AREA_TOP;
ball_dy = -ball_dy;
}
if (ball_y + BALL_SIZE >= PADDLE_Y && ball_y <= PADDLE_Y + PADDLE_HEIGHT) {
if (ball_x + BALL_SIZE >= paddle_x && ball_x <= paddle_x + PADDLE_WIDTH) {
ball_y = PADDLE_Y - BALL_SIZE;
float hit_position = (ball_x + (BALL_SIZE / 2)) - paddle_x;
float angle = (hit_position / PADDLE_WIDTH) - 0.5f;
ball_dx = angle * 4.0f;
if (ball_dx > -0.5f && ball_dx < 0.5f) {
ball_dx = (ball_dx > 0) ? 0.5f : -0.5f;
}
ball_dy = -ball_dy;
}
}
check_collisions();
draw_ball();
if (check_level_complete()) {
next_level();
}
}
void check_collisions() {
int grid_x = ball_x / (BRICK_WIDTH + BRICK_GAP);
int grid_y = (ball_y - GAME_AREA_TOP - 5) / (BRICK_HEIGHT + BRICK_GAP);
for (int row = grid_y - 1; row <= grid_y + 1; row++) {
for (int col = grid_x - 1; col <= grid_x + 1; col++) {
if (row >= 0 && row < BRICK_ROWS && col >= 0 && col < BRICK_COLS) {
if (bricks[row][col] && check_brick_collision(row, col)) {
return;
}
}
}
}
}
bool check_brick_collision(int row, int col) {
int brick_x = col * (BRICK_WIDTH + BRICK_GAP);
int brick_y = GAME_AREA_TOP + row * (BRICK_HEIGHT + BRICK_GAP) + 5;
if (ball_x + BALL_SIZE >= brick_x && ball_x <= brick_x + BRICK_WIDTH &&
ball_y + BALL_SIZE >= brick_y && ball_y <= brick_y + BRICK_HEIGHT) {
fillrect(brick_x, brick_y, brick_x + BRICK_WIDTH, brick_y + BRICK_HEIGHT, COLOR_BACKGROUND);
bricks[row][col] = false;
brick_count--;
score += (5 - row) * 10;
draw_score();
float center_x = brick_x + BRICK_WIDTH / 2;
float center_y = brick_y + BRICK_HEIGHT / 2;
float ball_center_x = ball_x + BALL_SIZE / 2;
float ball_center_y = ball_y + BALL_SIZE / 2;
float dx = std::abs(ball_center_x - center_x);
float dy = std::abs(ball_center_y - center_y);
if (dx * BRICK_HEIGHT > dy * BRICK_WIDTH) {
ball_dx = -ball_dx;
} else {
ball_dy = -ball_dy;
}
return true;
}
return false;
}
bool check_level_complete() {
return brick_count == 0;
}
void next_level() {
level++;
init_level();
draw_screen();
}
void handle_game_over() {
game_state = STATE_GAME_OVER;
gameover_initialized = false;
show_game_over();
}
void init_menu() {
cls();
background(COLOR_BACKGROUND);
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_blue = *ui::Theme::getInstance()->fg_blue;
auto style_cyan = *ui::Theme::getInstance()->fg_cyan;
int16_t screen_width = 240;
int16_t title_x = (screen_width - 17 * 8) / 2;
int16_t divider_width = 24 * 8;
int16_t divider_x = (screen_width - divider_width) / 2;
int16_t instruction_width = 22 * 8;
int16_t instruction_x = (screen_width - instruction_width) / 2;
int16_t prompt_width = 16 * 8;
prompt_x = (screen_width - prompt_width) / 2;
painter.fill_rectangle({0, 30, screen_width, 30}, Color::black());
painter.draw_string({title_x + 2, 42}, style_yellow, "*** BREAKOUT ***");
painter.draw_string({divider_x, 70}, style_blue, "========================");
painter.fill_rectangle({instruction_x - 5, 110, instruction_width + 10, 70}, Color::black());
painter.draw_rectangle({instruction_x - 5, 110, instruction_width + 10, 70}, Color::white());
painter.draw_string({instruction_x, 120}, style_cyan, " ROTARY: MOVE PADDLE");
painter.draw_string({instruction_x, 150}, style_cyan, " SELECT: START/LAUNCH");
painter.draw_string({divider_x, 190}, style_blue, "========================");
menu_initialized = true;
}
void show_menu() {
if (!menu_initialized) {
init_menu();
}
auto style_red = *ui::Theme::getInstance()->fg_red;
if (++blink_counter >= 30) {
blink_counter = 0;
blink_state = !blink_state;
painter.fill_rectangle({prompt_x - 2, 228, 16 * 8 + 4, 20}, Color::black());
if (blink_state) {
painter.draw_string({prompt_x, 230}, style_red, "* PRESS SELECT *");
}
}
}
void init_game_over() {
cls();
background(COLOR_BACKGROUND);
auto style_red = *ui::Theme::getInstance()->fg_red;
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
int16_t screen_width = 240;
int16_t title_width = 9 * 8;
int16_t title_x = (screen_width - title_width) / 2;
int16_t score_text_width = (16 + std::to_string(score).length()) * 8;
int16_t score_x = (screen_width - score_text_width) / 2;
painter.draw_rectangle({20, 80, screen_width - 40, 160}, Color::red());
painter.draw_rectangle({22, 82, screen_width - 44, 156}, Color::white());
painter.draw_string({title_x, 100}, style_red, "GAME OVER");
painter.fill_rectangle({40, 140, screen_width - 80, 30}, Color::black());
painter.draw_rectangle({40, 140, screen_width - 80, 30}, Color::yellow());
painter.draw_string({score_x, 150}, style_yellow, " FINAL SCORE: " + std::to_string(score));
int16_t restart_width = 12 * 8;
restart_x = (screen_width - restart_width) / 2;
gameover_initialized = true;
gameover_blink_state = true;
gameover_blink_counter = 0;
}
void show_game_over() {
if (!gameover_initialized) {
init_game_over();
}
auto style_green = *ui::Theme::getInstance()->fg_green;
if (++gameover_blink_counter >= 30) {
gameover_blink_counter = 0;
gameover_blink_state = !gameover_blink_state;
painter.fill_rectangle({restart_x - 2, 198, 12 * 8 + 4, 20}, Color::black());
if (gameover_blink_state) {
painter.draw_string({restart_x, 200}, style_green, "PRESS SELECT");
}
}
}
void reset_game() {
level = 1;
score = 0;
lives = 3;
game_state = STATE_PLAYING;
init_level();
draw_screen();
gameover_initialized = false;
gameover_blink_state = true;
gameover_blink_counter = 0;
}
BreakoutView::BreakoutView(NavigationView& nav)
: nav_{nav} {
@@ -53,6 +520,10 @@ bool BreakoutView::on_encoder(const EncoderEvent delta) {
}
bool BreakoutView::on_key(const KeyEvent key) {
but_SELECT = (key == KeyEvent::Select);
but_LEFT = (key == KeyEvent::Left);
but_RIGHT = (key == KeyEvent::Right);
if (key == KeyEvent::Select) {
if (game_state == STATE_MENU) {
game_state = STATE_PLAYING;
+107 -4
View File
@@ -9,25 +9,128 @@
#ifndef __UI_BREAKOUT_H__
#define __UI_BREAKOUT_H__
#include "ui.hpp"
#include "ui_navigation.hpp"
#include "event_m0.hpp"
#include "message.hpp"
#include "irq_controls.hpp"
#include "random.hpp"
#include "lpc43xx_cpp.hpp"
#include "limits.h"
#include "ui_widget.hpp"
namespace ui::external_app::breakout {
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
extern const Color pp_colors[];
extern Painter painter;
extern bool but_RIGHT;
extern bool but_LEFT;
extern bool but_SELECT;
void cls();
void background(int color);
void fillrect(int x1, int y1, int x2, int y2, int color);
void rect(int x1, int y1, int x2, int y2, int color);
#define wait(x) chThdSleepMilliseconds(x * 1000)
using Callback = void (*)(void);
void check_game_timer();
class Ticker {
public:
Ticker() = default;
void attach(Callback func, double delay_sec);
void detach();
};
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define PADDLE_WIDTH 40
#define PADDLE_HEIGHT 10
#define BALL_SIZE 8
#define BRICK_WIDTH 20
#define BRICK_HEIGHT 10
#define BRICK_ROWS 5
#define BRICK_COLS 10
#define BRICK_GAP 2
#define GAME_AREA_TOP 50
#define GAME_AREA_BOTTOM 310
#define PADDLE_Y (GAME_AREA_BOTTOM - PADDLE_HEIGHT)
#define BALL_SPEED_INCREASE 0.1f
#define STATE_MENU 0
#define STATE_PLAYING 1
#define STATE_GAME_OVER 3
#define COLOR_BACKGROUND Black
#define COLOR_PADDLE Blue
#define COLOR_BALL White
#define COLOR_BORDER White
#define COLOR_BRICK_COLORS \
{ Red, Orange, Yellow, Green, Purple }
extern Ticker game_timer;
extern int paddle_x;
extern float ball_x;
extern float ball_y;
extern float ball_dx;
extern float ball_dy;
extern int score;
extern int lives;
extern int level;
extern int game_state;
extern bool initialized;
extern bool ball_attached;
extern unsigned int brick_count;
extern bool bricks[BRICK_ROWS][BRICK_COLS];
extern int brick_colors[BRICK_ROWS];
void game_timer_check();
void init_game();
void init_level();
void draw_screen();
void draw_bricks();
void draw_paddle();
void draw_ball();
void draw_score();
void draw_lives();
void draw_level();
void draw_borders();
void move_paddle_left();
void move_paddle_right();
void launch_ball();
void update_game();
void check_collisions();
bool check_brick_collision(int row, int col);
void handle_game_over();
void show_menu();
void show_game_over();
bool check_level_complete();
void next_level();
void reset_game();
class BreakoutView : public View {
public:
BreakoutView(NavigationView& nav);
void on_show() override;
std::string title() const override { return "Breakout"; };
std::string title() const override { return "Breakout"; }
void focus() override { dummy.focus(); };
void focus() override { dummy.focus(); }
void paint(Painter& painter) override;
void frame_sync();
bool on_encoder(const EncoderEvent event) override;
@@ -50,4 +153,4 @@ class BreakoutView : public View {
} // namespace ui::external_app::breakout
#endif /*__UI_BREAKOUT_H__*/
#endif /* __UI_BREAKOUT_H__ */
+9 -28
View File
@@ -81,8 +81,6 @@ void CVSSpamView::start_tx(const uint32_t id) {
return;
}
const uint32_t sample_rate = 250000;
current_file = cvsfiles_dir / file_list[id].filename();
File capture_file;
@@ -99,20 +97,13 @@ void CVSSpamView::start_tx(const uint32_t id) {
return;
}
auto metadata_path = get_metadata_path(current_file);
auto metadata = read_metadata_file(metadata_path);
if (!metadata) {
metadata = capture_metadata{transmitter_model.target_frequency(), sample_rate};
}
auto file_size = capture_file.size();
capture_file.close();
replay_thread.reset();
transmitter_model.disable();
ready_signal = false;
baseband::set_sample_rate(metadata->sample_rate, get_oversample_rate(metadata->sample_rate));
baseband::set_sample_rate(SAMPLE_RATE, get_oversample_rate(SAMPLE_RATE));
auto reader = std::make_unique<FileConvertReader>();
if (auto error = reader->open(current_file)) {
@@ -120,10 +111,7 @@ void CVSSpamView::start_tx(const uint32_t id) {
"Cannot read C16 data.\n"
"Check file format/perms.\n"
"Rate: " +
to_string_dec_uint(metadata->sample_rate) +
"\n"
"Size: " +
to_string_dec_uint(file_size) +
to_string_dec_uint(SAMPLE_RATE) +
"\n"
"Error: " +
std::to_string(static_cast<uint32_t>(error)));
@@ -132,9 +120,9 @@ void CVSSpamView::start_tx(const uint32_t id) {
progressbar.set_value(0);
transmitter_model.set_sampling_rate(get_actual_sample_rate(metadata->sample_rate));
transmitter_model.set_baseband_bandwidth(metadata->sample_rate <= 500000 ? 1750000 : 2500000);
transmitter_model.set_target_frequency(metadata->center_frequency);
transmitter_model.set_sampling_rate(get_actual_sample_rate(SAMPLE_RATE));
transmitter_model.set_baseband_bandwidth(SAMPLE_RATE <= 500000 ? 1750000 : 2500000);
transmitter_model.set_target_frequency(TARGET_FREQUENCY);
transmitter_model.enable();
chThdSleepMilliseconds(100);
@@ -164,7 +152,6 @@ void CVSSpamView::start_random_tx() {
lfsr_v = lfsr_iterate(lfsr_v);
size_t random_index = lfsr_v % file_list.size();
const uint32_t sample_rate = 250000;
current_file = cvsfiles_dir / file_list[random_index].filename();
File capture_file;
@@ -174,19 +161,13 @@ void CVSSpamView::start_random_tx() {
return;
}
auto metadata_path = get_metadata_path(current_file);
auto metadata = read_metadata_file(metadata_path);
if (!metadata) {
metadata = capture_metadata{transmitter_model.target_frequency(), sample_rate};
}
capture_file.close();
replay_thread.reset();
transmitter_model.disable();
ready_signal = false;
baseband::set_sample_rate(metadata->sample_rate, get_oversample_rate(metadata->sample_rate));
baseband::set_sample_rate(SAMPLE_RATE, get_oversample_rate(SAMPLE_RATE));
auto reader = std::make_unique<FileConvertReader>();
if (auto error = reader->open(current_file)) {
@@ -196,9 +177,9 @@ void CVSSpamView::start_random_tx() {
progressbar.set_value(0);
transmitter_model.set_sampling_rate(get_actual_sample_rate(metadata->sample_rate));
transmitter_model.set_baseband_bandwidth(metadata->sample_rate <= 500000 ? 1750000 : 2500000);
transmitter_model.set_target_frequency(metadata->center_frequency);
transmitter_model.set_sampling_rate(get_actual_sample_rate(SAMPLE_RATE));
transmitter_model.set_baseband_bandwidth(SAMPLE_RATE <= 500000 ? 1750000 : 2500000);
transmitter_model.set_target_frequency(TARGET_FREQUENCY);
transmitter_model.enable();
chThdSleepMilliseconds(100);
+3
View File
@@ -16,6 +16,9 @@ using namespace portapack;
namespace ui::external_app::cvs_spam {
constexpr uint32_t SAMPLE_RATE = 250000;
constexpr uint64_t TARGET_FREQUENCY = 433920000;
class CVSSpamView : public View {
public:
explicit CVSSpamView(NavigationView& nav);
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui.hpp"
#include "ui_debug_pmem.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::debug_pmem {
void initialize_app(ui::NavigationView& nav) {
nav.push<DebugDumpView>();
}
} // namespace ui::external_app::debug_pmem
extern "C" {
__attribute__((section(".external_app.app_debug_pmem.application_information"), used)) application_information_t _application_information_debug_pmem = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::debug_pmem::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "DebugPMem",
/*.bitmap_data = */ {
0x54,
0x15,
0x54,
0x15,
0xFF,
0x7F,
0xFC,
0x1F,
0xFF,
0x7F,
0xCC,
0x19,
0xAF,
0x7A,
0x6C,
0x1B,
0xEF,
0x7B,
0xEC,
0x1B,
0xFF,
0x7F,
0xFC,
0x1F,
0xFF,
0x7F,
0x54,
0x15,
0x54,
0x15,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::cyan().v,
/*.menu_location = */ app_location_t::DEBUG,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_none */ {0, 0, 0, 0},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
@@ -0,0 +1,209 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2018 Furrtek
*
* 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_debug_pmem.hpp"
namespace ui::external_app::debug_pmem {
// Dump pmem, receiver and transmitter models internals in human readable format
bool DebugDumpView::debug_dump_func() {
std::string debug_dir = "DEBUG";
std::filesystem::path filename{};
File pmem_dump_file{};
// create new dump file name and DEBUG directory
ensure_directory(debug_dir);
filename = next_filename_matching_pattern(debug_dir + "/DEBUG_DUMP_????.TXT");
if (filename.empty()) {
dump_output.set("COULD NOT GET DUMP NAME !");
dump_output.set_style(ui::Theme::getInstance()->fg_red);
return false;
}
// dump data fo filename
auto error = pmem_dump_file.create(filename);
if (error) {
dump_output.set("ERROR DUMPING " + filename.filename().string() + " !");
dump_output.set_style(ui::Theme::getInstance()->fg_red);
return false;
}
pmem_dump_file.write_line("FW version: " VERSION_STRING);
pmem_dump_file.write_line("Ext APPS version req'd: 0x" + to_string_hex(VERSION_MD5));
pmem_dump_file.write_line("GCC version: " + to_string_dec_int(__GNUC__) + "." + to_string_dec_int(__GNUC_MINOR__) + "." + to_string_dec_int(__GNUC_PATCHLEVEL__));
// firmware checksum
pmem_dump_file.write_line("Firmware calculated checksum: 0x" + to_string_hex(simple_checksum(FLASH_STARTING_ADDRESS, FLASH_ROM_SIZE), 8));
// write persistent memory
pmem_dump_file.write_line("\n[Persistent Memory]");
// full variables
pmem_dump_file.write_line("structure_version: 0x" + to_string_hex(get_data_structure_version(), 8));
pmem_dump_file.write_line("target_frequency: " + to_string_dec_int(target_frequency()));
pmem_dump_file.write_line("correction_ppb: " + to_string_dec_int(correction_ppb()));
pmem_dump_file.write_line("modem_def_index: " + to_string_dec_uint(get_modem_def_index()));
pmem_dump_file.write_line("serial_format.data_bit: " + to_string_dec_uint(serial_format().data_bits));
pmem_dump_file.write_line("serial_format.parity: " + to_string_dec_uint(serial_format().parity));
pmem_dump_file.write_line("serial_format.stop_bits: " + to_string_dec_uint(serial_format().stop_bits));
pmem_dump_file.write_line("serial_format.bit_order: " + to_string_dec_uint(serial_format().bit_order));
pmem_dump_file.write_line("modem_bw: " + to_string_dec_int(modem_bw()));
pmem_dump_file.write_line("afsk_mark_freq: " + to_string_dec_int(afsk_mark_freq()));
pmem_dump_file.write_line("afsk_space_freq: " + to_string_dec_int(afsk_space_freq()));
pmem_dump_file.write_line("modem_baudrate: " + to_string_dec_int(modem_baudrate()));
pmem_dump_file.write_line("modem_repeat: " + to_string_dec_int(modem_repeat()));
pmem_dump_file.write_line("pocsag_last_address: " + to_string_dec_uint(pocsag_last_address()));
pmem_dump_file.write_line("pocsag_ignore_address: " + to_string_dec_uint(pocsag_ignore_address()));
pmem_dump_file.write_line("tone_mix: " + to_string_dec_uint(tone_mix()));
pmem_dump_file.write_line("hardware_config: " + to_string_dec_uint(config_cpld()));
pmem_dump_file.write_line("recon_config: 0x" + to_string_hex(get_recon_config(), 16));
pmem_dump_file.write_line("recon_repeat_nb: " + to_string_dec_int(recon_repeat_nb()));
pmem_dump_file.write_line("recon_repeat_gain: " + to_string_dec_int(recon_repeat_gain()));
pmem_dump_file.write_line("recon_repeat_delay: " + to_string_dec_int(recon_repeat_delay()));
pmem_dump_file.write_line("converter: " + to_string_dec_int(config_converter()));
pmem_dump_file.write_line("updown_converter: " + to_string_dec_int(config_updown_converter()));
pmem_dump_file.write_line("updown_frequency_rx_correction: " + to_string_dec_int(config_freq_rx_correction_updown()));
pmem_dump_file.write_line("updown_frequency_tx_correction: " + to_string_dec_int(config_freq_tx_correction_updown()));
pmem_dump_file.write_line("lcd_inverted_mode: " + to_string_dec_uint(config_lcd_inverted_mode()));
pmem_dump_file.write_line("converter_frequency_offset: " + to_string_dec_int(config_converter_freq()));
pmem_dump_file.write_line("frequency_rx_correction: " + to_string_dec_uint(config_freq_rx_correction()));
pmem_dump_file.write_line("frequency_tx_correction: " + to_string_dec_uint(config_freq_tx_correction()));
pmem_dump_file.write_line("encoder_dial_sensitivity: " + to_string_dec_uint(encoder_dial_sensitivity()));
pmem_dump_file.write_line("encoder_rate_multiplier: " + to_string_dec_uint(encoder_rate_multiplier()));
pmem_dump_file.write_line("encoder_dial_direction: " + to_string_dec_uint(encoder_dial_direction())); // 0 = normal, 1 = reverse
pmem_dump_file.write_line("config_mode_storage: 0x" + to_string_hex(config_mode_storage_direct(), 8));
pmem_dump_file.write_line("dst_config: 0x" + to_string_hex((uint32_t)config_dst().v, 8));
pmem_dump_file.write_line("fake_brightness_level: " + to_string_dec_uint(fake_brightness_level()));
pmem_dump_file.write_line("menu_color: 0x" + to_string_hex(menu_color().v, 4));
pmem_dump_file.write_line("touchscreen_threshold: " + to_string_dec_uint(touchscreen_threshold()));
// ui_config bits
const auto backlight_timer = portapack::persistent_memory::config_backlight_timer();
pmem_dump_file.write_line("ui_config clkout_freq: " + to_string_dec_uint(clkout_freq()));
pmem_dump_file.write_line("ui_config backlight_timer.timeout_enabled: " + to_string_dec_uint(backlight_timer.timeout_enabled()));
pmem_dump_file.write_line("ui_config backlight_timer.timeout_seconds: " + to_string_dec_uint(backlight_timer.timeout_seconds()));
pmem_dump_file.write_line("ui_config show_gui_return_icon: " + to_string_dec_uint(show_gui_return_icon()));
pmem_dump_file.write_line("ui_config load_app_settings: " + to_string_dec_uint(load_app_settings()));
pmem_dump_file.write_line("ui_config save_app_settings: " + to_string_dec_uint(save_app_settings()));
pmem_dump_file.write_line("ui_config disable_touchscreen: " + to_string_dec_uint(disable_touchscreen()));
pmem_dump_file.write_line("ui_config hide_clock: " + to_string_dec_uint(hide_clock()));
pmem_dump_file.write_line("ui_config clock_with_date: " + to_string_dec_uint(clock_with_date()));
pmem_dump_file.write_line("ui_config clkout_enabled: " + to_string_dec_uint(clkout_enabled()));
pmem_dump_file.write_line("ui_config apply_fake_brightness: " + to_string_dec_uint(apply_fake_brightness()));
pmem_dump_file.write_line("ui_config stealth_mode: " + to_string_dec_uint(stealth_mode()));
pmem_dump_file.write_line("ui_config config_login: " + to_string_dec_uint(config_login()));
pmem_dump_file.write_line("ui_config config_splash: " + to_string_dec_uint(config_splash()));
// ui_config2 bits
pmem_dump_file.write_line("ui_config2 hide_speaker: " + to_string_dec_uint(ui_hide_speaker()));
pmem_dump_file.write_line("ui_config2 hide_converter: " + to_string_dec_uint(ui_hide_converter()));
pmem_dump_file.write_line("ui_config2 hide_stealth: " + to_string_dec_uint(ui_hide_stealth()));
pmem_dump_file.write_line("ui_config2 hide_camera: " + to_string_dec_uint(ui_hide_camera()));
pmem_dump_file.write_line("ui_config2 hide_sleep: " + to_string_dec_uint(ui_hide_sleep()));
pmem_dump_file.write_line("ui_config2 hide_bias_tee: " + to_string_dec_uint(ui_hide_bias_tee()));
pmem_dump_file.write_line("ui_config2 hide_clock: " + to_string_dec_uint(ui_hide_clock()));
pmem_dump_file.write_line("ui_config2 hide_sd_card: " + to_string_dec_uint(ui_hide_sd_card()));
pmem_dump_file.write_line("ui_config2 hide_mute: " + to_string_dec_uint(ui_hide_mute()));
pmem_dump_file.write_line("ui_config2 hide_fake_brightness: " + to_string_dec_uint(ui_hide_fake_brightness()));
pmem_dump_file.write_line("ui_config2 hide_battery_icon: " + to_string_dec_uint(ui_hide_battery_icon()));
pmem_dump_file.write_line("ui_config2 hide_numeric_battery: " + to_string_dec_uint(ui_hide_numeric_battery()));
pmem_dump_file.write_line("ui_config2 theme_id: " + to_string_dec_uint(ui_theme_id()));
pmem_dump_file.write_line("ui_config2 override_batt_calc: " + to_string_dec_uint(ui_override_batt_calc()));
pmem_dump_file.write_line("ui_config2 button_repeat_delay: " + to_string_dec_uint(ui_button_repeat_delay()));
pmem_dump_file.write_line("ui_config2 button_repeat_speed: " + to_string_dec_uint(ui_button_repeat_speed()));
pmem_dump_file.write_line("ui_config2 button_long_press_delay: " + to_string_dec_uint(ui_button_long_press_delay()));
// misc_config bits
pmem_dump_file.write_line("misc_config config_audio_mute: " + to_string_dec_int(config_audio_mute()));
pmem_dump_file.write_line("misc_config config_speaker_disable: " + to_string_dec_int(config_speaker_disable()));
pmem_dump_file.write_line("misc_config config_disable_external_tcxo: " + to_string_dec_uint(config_disable_external_tcxo()));
pmem_dump_file.write_line("misc_config config_sdcard_high_speed_io: " + to_string_dec_uint(config_sdcard_high_speed_io()));
pmem_dump_file.write_line("misc_config config_disable_config_mode: " + to_string_dec_uint(config_disable_config_mode()));
pmem_dump_file.write_line("misc_config beep_on_packets: " + to_string_dec_int(beep_on_packets()));
// receiver_model
pmem_dump_file.write_line("\n[Receiver Model]");
pmem_dump_file.write_line("target_frequency: " + to_string_dec_uint(receiver_model.target_frequency()));
pmem_dump_file.write_line("frequency_step: " + to_string_dec_uint(receiver_model.frequency_step()));
pmem_dump_file.write_line("lna: " + to_string_dec_int(receiver_model.lna()));
pmem_dump_file.write_line("vga: " + to_string_dec_int(receiver_model.vga()));
pmem_dump_file.write_line("rf_amp: " + to_string_dec_int(receiver_model.rf_amp()));
pmem_dump_file.write_line("baseband_bandwidth: " + to_string_dec_uint(receiver_model.baseband_bandwidth()));
pmem_dump_file.write_line("sampling_rate: " + to_string_dec_uint(receiver_model.sampling_rate()));
switch (receiver_model.modulation()) {
case ReceiverModel::Mode::AMAudio:
pmem_dump_file.write_line("modulation: Mode::AMAudio");
break;
case ReceiverModel::Mode::NarrowbandFMAudio:
pmem_dump_file.write_line("modulation: Mode::NarrowbandFMAudio");
break;
case ReceiverModel::Mode::WidebandFMAudio:
pmem_dump_file.write_line("modulation: Mode::WidebandFMAudio");
break;
case ReceiverModel::Mode::SpectrumAnalysis:
pmem_dump_file.write_line("modulation: Mode::SpectrumAnalysis");
break;
case ReceiverModel::Mode::Capture:
pmem_dump_file.write_line("modulation: Mode::Capture");
break;
case ReceiverModel::Mode::AMAudioFMApt:
pmem_dump_file.write_line("modulation: Mode::AMAudioFMApt");
break;
default:
pmem_dump_file.write_line("modulation: !!unknown mode!!");
break;
}
pmem_dump_file.write_line("headphone_volume.centibel: " + to_string_dec_int(receiver_model.headphone_volume().centibel()));
pmem_dump_file.write_line("normalized_headphone_volume: " + to_string_dec_uint(receiver_model.normalized_headphone_volume()));
pmem_dump_file.write_line("am_configuration: " + to_string_dec_uint(receiver_model.am_configuration()));
pmem_dump_file.write_line("nbfm_configuration: " + to_string_dec_uint(receiver_model.nbfm_configuration()));
pmem_dump_file.write_line("wfm_configuration: " + to_string_dec_uint(receiver_model.wfm_configuration()));
// transmitter_model
pmem_dump_file.write_line("\n[Transmitter Model]");
pmem_dump_file.write_line("target_frequency: " + to_string_dec_uint(transmitter_model.target_frequency()));
pmem_dump_file.write_line("rf_amp: " + to_string_dec_int(transmitter_model.rf_amp()));
pmem_dump_file.write_line("baseband_bandwidth: " + to_string_dec_uint(transmitter_model.baseband_bandwidth()));
pmem_dump_file.write_line("sampling_rate: " + to_string_dec_uint(transmitter_model.sampling_rate()));
pmem_dump_file.write_line("tx_gain: " + to_string_dec_int(transmitter_model.tx_gain()));
pmem_dump_file.write_line("channel_bandwidth: " + to_string_dec_uint(transmitter_model.channel_bandwidth()));
// on screen information
dump_output.set(filename.filename().string() + " DUMPED !");
dump_output.set_style(ui::Theme::getInstance()->fg_green);
return true;
}
DebugDumpView::DebugDumpView(NavigationView& nav)
: nav_{nav} {
add_children({&dump_output,
&button_exit});
debug_dump_func();
button_exit.on_select = [this](Button&) {
nav_.pop();
};
}
void DebugDumpView::focus() {
button_exit.focus();
}
} // namespace ui::external_app::debug_pmem
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2018 Furrtek
*
* 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.
*/
#ifndef __UI_DEBUG_PMEM_APP_H__
#define __UI_DEBUG_PMEM_APP_H__
#include "portapack_persistent_memory.hpp"
#include "ui_flash_utility.hpp"
using namespace portapack;
using namespace portapack::persistent_memory;
namespace ui::external_app::debug_pmem {
class DebugDumpView : public View {
public:
DebugDumpView(NavigationView& nav);
void focus() override;
std::string title() const override { return "DebugPMem"; };
bool debug_dump_func();
private:
NavigationView& nav_;
Text dump_output{
{0 * 8, 19 * 8, 30 * 8, 16},
""};
Button button_exit{
{22 * 8, 34 * 8, 8 * 8, 32},
"Exit"};
};
} // namespace ui::external_app::debug_pmem
#endif /*__UI_DEBUG_PMEM_APP_H__*/
+67
View File
@@ -0,0 +1,67 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#include "ui_doom.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::doom {
void initialize_app(ui::NavigationView& nav) {
nav.push<DoomView>();
}
} // namespace ui::external_app::doom
extern "C" {
__attribute__((section(".external_app.app_doom.application_information"), used)) application_information_t _application_information_doom = {
(uint8_t*)0x00000000,
ui::external_app::doom::initialize_app,
CURRENT_HEADER_VERSION,
VERSION_MD5,
"Doom",
{
0x00,
0x00,
0x00,
0x00,
0x77,
0xDF,
0xFF,
0xDF,
0xD9,
0xFD,
0x89,
0xF8,
0x89,
0xE8,
0x89,
0xA8,
0x89,
0xA8,
0xD9,
0xAD,
0x79,
0xAF,
0x2D,
0xAA,
0x07,
0xA8,
0x03,
0xA0,
0x01,
0x80,
0x00,
0x00,
},
ui::Color::red().v,
app_location_t::GAMES,
-1,
{0, 0, 0, 0},
0x00000000,
};
}
File diff suppressed because it is too large Load Diff
+84
View File
@@ -0,0 +1,84 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#ifndef __UI_DOOM_H__
#define __UI_DOOM_H__
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "message.hpp"
namespace ui::external_app::doom {
using Callback = void (*)();
class Ticker {
public:
Ticker() {}
void attach(Callback func, double delay_sec) {
game_update_callback = func;
game_update_timeout = delay_sec * 60;
}
void detach() {
game_update_callback = nullptr;
}
private:
Callback game_update_callback = nullptr;
uint32_t game_update_timeout = 0;
};
extern ui::Painter painter;
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
static const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
class DoomView : public View {
public:
DoomView(NavigationView& nav);
void on_show() override;
std::string title() const override { return "Doom"; }
void focus() override { dummy.focus(); }
void paint(Painter& painter) override;
void frame_sync();
bool on_key(const KeyEvent key) override;
private:
NavigationView& nav_;
Button dummy{{240, 0, 0, 0}, ""};
bool initialized{false};
bool prev_velocity_moving{false};
MessageHandlerRegistration message_handler_frame_sync{
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->frame_sync();
}};
};
} // namespace ui::external_app::doom
#endif /*__UI_DOOM_H__*/
+40 -14
View File
@@ -1,17 +1,5 @@
set(EXTCPPSRC
#tetris
external/tetris/main.cpp
external/tetris/ui_tetris.cpp
#breakout
external/breakout/main.cpp
external/breakout/ui_breakout.cpp
#snake
external/snake/main.cpp
external/snake/ui_snake.cpp
#afsk_rx
external/afsk_rx/main.cpp
external/afsk_rx/ui_afsk_rx.cpp
@@ -67,6 +55,10 @@ set(EXTCPPSRC
external/keyfob/ui_keyfob.cpp
external/keyfob/ui_keyfob.hpp
#tetris
external/tetris/main.cpp
external/tetris/ui_tetris.cpp
#extsensors
external/extsensors/main.cpp
external/extsensors/ui_extsensors.cpp
@@ -115,6 +107,11 @@ set(EXTCPPSRC
external/acars_rx/main.cpp
external/acars_rx/acars_app.cpp
#wefax_rx
external/wefax_rx/main.cpp
external/wefax_rx/ui_wefax_rx.cpp
#shoppingcart_lock
external/shoppingcart_lock/main.cpp
external/shoppingcart_lock/shoppingcart_lock.cpp
@@ -179,9 +176,33 @@ set(EXTCPPSRC
external/playlist_editor/main.cpp
external/playlist_editor/ui_playlist_editor.cpp
#snake
external/snake/main.cpp
external/snake/ui_snake.cpp
#stopwatch
external/stopwatch/main.cpp
external/stopwatch/ui_stopwatch.cpp
#breakout
external/breakout/main.cpp
external/breakout/ui_breakout.cpp
#doom
external/doom/main.cpp
external/doom/ui_doom.cpp
#debug_pmem
external/debug_pmem/main.cpp
external/debug_pmem/ui_debug_pmem.cpp
#scanner
external/scanner/main.cpp
external/scanner/ui_scanner.cpp
#level
external/level/main.cpp
external/level/ui_level.cpp
)
set(EXTAPPLIST
@@ -199,8 +220,6 @@ set(EXTAPPLIST
spainter
keyfob
tetris
breakout
snake
extsensors
foxhunt_rx
audio_test
@@ -215,6 +234,7 @@ set(EXTAPPLIST
#acars_rx
ookbrute
ook_editor
wefax_rx
shoppingcart_lock
flippertx
remote
@@ -228,5 +248,11 @@ set(EXTAPPLIST
view_wav
sd_wipe
playlist_editor
snake
stopwatch
breakout
doom
debug_pmem
scanner
level
)
+85 -51
View File
@@ -26,47 +26,52 @@ MEMORY
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
ram_external_app_extsensors(rwx) : org = 0xADBF0000, len = 32k
ram_external_app_foxhunt_rx(rwx) : org = 0xADC00000, len = 32k
ram_external_app_audio_test(rwx) : org = 0xADC10000, 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
ram_external_app_extsensors (rwx) : org = 0xADBF0000, len = 32k
ram_external_app_foxhunt_rx (rwx) : org = 0xADC00000, len = 32k
ram_external_app_audio_test (rwx) : org = 0xADC10000, len = 32k
ram_external_app_wardrivemap(rwx) : org = 0xADC20000, len = 32k
ram_external_app_tpmsrx(rwx) : org = 0xADC30000, len = 32k
ram_external_app_protoview(rwx) : org = 0xADC40000, len = 32k
ram_external_app_adsbtx(rwx) : org = 0xADC50000, len = 32k
ram_external_app_morse_tx(rwx) : org = 0xADC60000, len = 32k
ram_external_app_sstvtx(rwx) : org = 0xADC70000, len = 32k
ram_external_app_random_password(rwx) : org = 0xADC80000, len = 32k
ram_external_app_acars_rx(rwx) : org = 0xADC90000, len = 32k
ram_external_app_shoppingcart_lock(rwx) : org = 0xADCA0000, len = 32k
ram_external_app_cvs_spam(rwx) : org = 0xADCB0000, len = 32k
ram_external_app_ookbrute(rwx) : org = 0xADCC0000, len = 32k
ram_external_app_flippertx(rwx) : org = 0xADCD0000, len = 32k
ram_external_app_ook_editor(rwx) : org = 0xADCE0000, len = 32k
ram_external_app_remote(rwx) : org = 0xADCF0000, len = 32k
ram_external_app_mcu_temperature(rwx) : org = 0xADD00000, len = 32k
ram_external_app_fmradio(rwx) : org = 0xADD10000, len = 32k
ram_external_app_tuner(rwx) : org = 0xADD20000, len = 32k
ram_external_app_metronome(rwx) : org = 0xADD30000, len = 32k
ram_external_app_tpmsrx (rwx) : org = 0xADC30000, len = 32k
ram_external_app_protoview (rwx) : org = 0xADC40000, len = 32k
ram_external_app_adsbtx (rwx) : org = 0xADC50000, len = 32k
ram_external_app_morse_tx (rwx) : org = 0xADC60000, len = 32k
ram_external_app_sstvtx (rwx) : org = 0xADC70000, len = 32k
ram_external_app_random_password(rwx): org = 0xADC80000, len = 32k
ram_external_app_acars_rx (rwx) : org = 0xADC90000, len = 32k
ram_external_app_shoppingcart_lock(rwx): org = 0xADCA0000, len = 32k
ram_external_app_cvs_spam (rwx) : org = 0xADCB0000, len = 32k
ram_external_app_ookbrute (rwx) : org = 0xADCC0000, len = 32k
ram_external_app_flippertx (rwx) : org = 0xADCD0000, len = 32k
ram_external_app_ook_editor (rwx) : org = 0xADCE0000, len = 32k
ram_external_app_remote (rwx) : org = 0xADCF0000, len = 32k
ram_external_app_mcu_temperature(rwx): org = 0xADD00000, len = 32k
ram_external_app_fmradio (rwx) : org = 0xADD10000, len = 32k
ram_external_app_tuner (rwx) : org = 0xADD20000, len = 32k
ram_external_app_metronome (rwx) : org = 0xADD30000, len = 32k
ram_external_app_app_manager(rwx) : org = 0xADD40000, len = 32k
ram_external_app_hopper(rwx) : org = 0xADD50000, len = 32k
ram_external_app_antenna_length(rwx) : org = 0xADD60000, len = 32k
ram_external_app_view_wav(rwx) : org = 0xADD70000, len = 32k
ram_external_app_sd_wipe(rwx) : org = 0xADD80000, len = 32k
ram_external_app_playlist_editor(rwx) : org = 0xADD90000, len = 32k
ram_external_app_breakout(rwx) : org = 0xADDA0000, len = 32k
ram_external_app_snake(rwx) : org = 0xADDB0000, len = 32k
ram_external_app_stopwatch(rwx) : org = 0xADDC0000, len = 32k
ram_external_app_hopper (rwx) : org = 0xADD50000, len = 32k
ram_external_app_antenna_length(rwx): org = 0xADD60000, len = 32k
ram_external_app_view_wav (rwx) : org = 0xADD70000, len = 32k
ram_external_app_sd_wipe (rwx) : org = 0xADD80000, len = 32k
ram_external_app_playlist_editor(rwx): org = 0xADD90000, len = 32k
ram_external_app_snake (rwx) : org = 0xADDA0000, len = 32k
ram_external_app_stopwatch (rwx) : org = 0xADDB0000, len = 32k
ram_external_app_wefax_rx (rwx) : org = 0xADDC0000, len = 32k
ram_external_app_breakout (rwx) : org = 0xADDD0000, len = 32k
ram_external_app_doom (rwx) : org = 0xADDE0000, len = 32k
ram_external_app_debug_pmem (rwx) : org = 0xADDF0000, len = 32k
ram_external_app_scanner (rwx) : org = 0xADE00000, len = 32k
ram_external_app_level (rwx) : org = 0xADE10000, len = 32k
}
SECTIONS
@@ -155,18 +160,6 @@ SECTIONS
*(*ui*external_app*tetris*);
} > ram_external_app_tetris
.external_app_breakout : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_breakout.application_information));
*(*ui*external_app*breakout*);
} > ram_external_app_breakout
.external_app_snake : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_snake.application_information));
*(*ui*external_app*snake*);
} > ram_external_app_snake
.external_app_extsensors : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_extsensors.application_information));
@@ -329,9 +322,50 @@ SECTIONS
*(*ui*external_app*playlist_editor*);
} > ram_external_app_playlist_editor
.external_app_snake : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_snake.application_information));
*(*ui*external_app*snake*);
} > ram_external_app_snake
.external_app_stopwatch : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_stopwatch.application_information));
*(*ui*external_app*stopwatch*);
} > ram_external_app_stopwatch
.external_app_wefax_rx : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_wefax_rx.application_information));
*(*ui*external_app*wefax_rx*);
} > ram_external_app_wefax_rx
.external_app_breakout : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_breakout.application_information));
*(*ui*external_app*breakout*);
} > ram_external_app_breakout
.external_app_doom : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_doom.application_information));
*(*ui*external_app*doom*);
} > ram_external_app_doom
.external_app_debug_pmem : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_debug_pmem.application_information));
*(*ui*external_app*debug_pmem*);
} > ram_external_app_debug_pmem
.external_app_scanner : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_scanner.application_information));
*(*ui*external_app*scanner*);
} > ram_external_app_scanner
.external_app_level : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_level.application_information));
*(*ui*external_app*level*);
} > ram_external_app_level
}
@@ -67,6 +67,7 @@ void DebugFontsView::paint(Painter& painter) {
line_pos = display_font(painter, 32, Theme::getInstance()->bg_darkest, "Fixed 8x16", true);
display_font(painter, line_pos + 16, Theme::getInstance()->bg_darkest_small, "Fixed 5x8", false);
paint_zoomed_text(painter);
}
void DebugFontsView::update_address_text() {
@@ -74,16 +75,29 @@ void DebugFontsView::update_address_text() {
text_address.set("0x" + to_string_hex(ascii_value, 2));
}
void DebugFontsView::paint_zoomed_text(Painter& painter) {
if (field_zoom_level.value() == 0) return;
uint8_t cursor_pos = field_cursor.value();
painter.draw_char({screen_width / 2, screen_height / 2},
*Theme::getInstance()->bg_darkest,
(char)(cursor_pos + 0x20), field_zoom_level.value());
}
DebugFontsView::DebugFontsView(NavigationView& nav)
: nav_{nav} {
add_children({&field_cursor,
&text_address});
&text_address,
&field_zoom_level});
set_focusable(true);
field_cursor.on_change = [&](int32_t) {
update_address_text();
set_dirty();
};
field_zoom_level.on_change = [&](int32_t) {
set_dirty();
};
}
void DebugFontsView::focus() {
@@ -46,10 +46,17 @@ class DebugFontsView : public View {
private:
uint16_t display_font(Painter& painter, uint16_t y_offset, const Style* font_style, std::string_view font_name, bool is_big_font);
void update_address_text();
void paint_zoomed_text(Painter& painter);
NumberField field_cursor{
{0 * 8, 0 * 8},
4,
{0, 1000},
1,
' '};
NumberField field_zoom_level{
{6 * 8, 0 * 8},
4,
{0, 1000},
1,
' '};
+84
View File
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui.hpp"
#include "ui_level.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::level {
void initialize_app(ui::NavigationView& nav) {
nav.push<LevelView>();
}
} // namespace ui::external_app::level
extern "C" {
__attribute__((section(".external_app.app_level.application_information"), used)) application_information_t _application_information_level = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::level::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "Level",
/*.bitmap_data = */
{
0x00,
0x00,
0x00,
0x00,
0x04,
0x20,
0x12,
0x48,
0x8A,
0x51,
0xCA,
0x53,
0xCA,
0x53,
0x8A,
0x51,
0x12,
0x48,
0x84,
0x21,
0xC0,
0x03,
0x40,
0x02,
0x60,
0x06,
0x20,
0x04,
0x30,
0x0C,
0xF0,
0x0F},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
// this has to be the biggest baseband used by the app. Level is using AM,WFM,NFM,AMFM,SPEC and NFM is the biggest
/*.m4_app_tag = portapack::spi_flash::image_tag_nfm */ {'P', 'N', 'F', 'M'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
@@ -33,7 +33,7 @@ using namespace portapack;
using namespace tonekey;
using portapack::memory::map::backup_ram;
namespace ui {
namespace ui::external_app::level {
// Function to map the value from one range to another
int32_t LevelView::map(int32_t value, int32_t fromLow, int32_t fromHigh, int32_t toLow, int32_t toHigh) {
@@ -130,9 +130,16 @@ LevelView::LevelView(NavigationView& nav)
freqman_set_modulation_option(field_mode);
field_mode.on_change = [this](size_t, OptionsField::value_t v) {
if (v != -1) {
change_mode(v);
static freqman_index_t last_mode = WFM_MODULATION;
if (v > SPEC_MODULATION) {
if (last_mode == SPEC_MODULATION)
v = AM_MODULATION;
else
v = SPEC_MODULATION;
field_mode.set_selected_index(v);
}
last_mode = v;
change_mode(v);
};
field_mode.set_by_value(radio_mode); // Reflect the mode into the manual selector
field_bw.set_selected_index(radio_bw);
@@ -277,15 +284,6 @@ size_t LevelView::change_mode(freqman_index_t new_mod) {
field_bw.set_by_value(0);
field_bw.on_change = [this](size_t index, OptionsField::value_t n) { radio_bw = index ; receiver_model.set_wfm_configuration(n); };
break;
case AMFM_MODULATION:
audio_sampling_rate = audio::Rate::Hz_12000;
freqman_set_bandwidth_option(new_mod, field_bw);
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
receiver_model.set_modulation(ReceiverModel::Mode::AMAudioFMApt);
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
field_bw.set_by_value(0);
field_bw.on_change = [this](size_t, OptionsField::value_t n) { (void)n; };
break;
case SPEC_MODULATION:
audio_sampling_rate = audio::Rate::Hz_24000;
freqman_set_bandwidth_option(new_mod, field_bw);
@@ -338,4 +336,4 @@ void LevelView::on_freqchg(int64_t freq) {
button_frequency.set_text("<" + to_string_short_freq(freq) + " MHz>");
}
} /* namespace ui */
} // namespace ui::external_app::level
@@ -39,7 +39,7 @@
#include "ui_receiver.hpp"
#include "ui_spectrum.hpp"
namespace ui {
namespace ui::external_app::level {
class LevelView : public View {
public:
@@ -211,6 +211,6 @@ class LevelView : public View {
}};
};
} /* namespace ui */
} // namespace ui::external_app::level
#endif
+121
View File
@@ -23,6 +23,7 @@
#include "baseband_api.hpp"
#include "audio.hpp"
#include "portapack.hpp"
#include "ui_textentry.hpp"
using namespace portapack;
@@ -42,6 +43,7 @@ MetronomeView::MetronomeView(NavigationView& nav)
&field_unaccent_beep_tune,
&field_beep_flash_duration,
&field_bpm,
&button_enter_tap_tempo,
&progressbar,
});
@@ -59,6 +61,14 @@ MetronomeView::MetronomeView(NavigationView& nav)
}
};
button_enter_tap_tempo.on_select = [this](Button&) {
auto tap_tempo_view = nav_.push<MetronomeTapTempoView>(field_bpm.value());
tap_tempo_view->on_apply = [this](uint16_t bpm) {
field_bpm.set_value(bpm);
};
};
field_volume.set_value(0); // seems that a change is required to force update, so setting to 0 first
field_volume.set_value(99);
@@ -174,4 +184,115 @@ void MetronomeView::run() {
}
}
MetronomeTapTempoView::MetronomeTapTempoView(NavigationView& nav, uint16_t bpm)
: nav_{nav},
bpm_{bpm} {
add_children({
&button_input,
&button_tap,
&button_cancel,
&button_apply,
});
bpm_when_entered_ = bpm; // save for if user cancel
// im aware that we have duplicated painter which means in this app, weo have two painter instances
// here is the reason why this is necessary:
// We need to draw the bpm big font once when enter, which would be at bad timing in constructor,
// cuz it happened before the view is pushed to nav, which casued it actually didn't draw
// which leads me have to override the paint func from father and draw inside of it.
//
// BUT I can't completely package the draw logic inside of the paint func,
// cuz set_dirty has flaw and cause screen flicker during the char changes, if i just package there and use set_dirty()
Painter painter_instance_2;
button_input.on_select = [this](Button&) {
input_buffer = to_string_dec_uint(bpm_);
text_prompt(
nav_,
input_buffer,
3,
[this](std::string& buffer) {
if (buffer.empty()) {
return;
}
bpm_ = atoi(buffer.c_str());
if (on_apply) {
on_apply(bpm_);
}
});
};
button_tap.on_select = [&](Button&) {
on_tap(painter_instance_2);
};
button_apply.on_select = [this](Button&) {
// it's dynamically applied in tap handler
// the design allow user to hear changes before apply
nav_.pop();
};
button_cancel.on_select = [this](Button&) {
bpm_ = bpm_when_entered_;
if (on_apply) {
on_apply(bpm_);
}
nav_.pop();
};
}
void MetronomeTapTempoView::focus() {
button_tap.focus();
}
void MetronomeTapTempoView::paint(Painter& painter) {
View::paint(painter);
painter.draw_char({(0 * 16) * 4 + 2 * 16, 3 * 16}, *Theme::getInstance()->fg_light, '0' + bpm_ / 100, 4);
painter.draw_char({(1 * 16) * 4 + 2 * 16, 3 * 16}, *Theme::getInstance()->fg_light, '0' + (bpm_ / 10) % 10, 4);
painter.draw_char({(2 * 16) * 4 + 2 * 16, 3 * 16}, *Theme::getInstance()->fg_light, '0' + bpm_ % 10, 4);
}
/*
NB: i don't really know if the cpu clock is 1000Hz AKA 1ms per tick for chTimeNow()
but it should be, refering to the stop watch app.
and also i compared with my real metronome and it's very close
so I assume it's 1ms per tick
*/
void MetronomeTapTempoView::on_tap(Painter& painter) {
/* ^ NB: this painter accepted from painter_instance_2*/
systime_t current_time = chTimeNow();
if (last_tap_time > 0) {
uint32_t interval_ms = current_time - last_tap_time;
if (interval_ms > 100) {
uint16_t this_time_bpm = 60000 / interval_ms;
if (this_time_bpm > 0 && this_time_bpm < 400) {
bpms_deque.push_back(this_time_bpm);
if (bpms_deque.size() > 4) { // one bar length cuz most music tempo is quarter note as 1 beat
bpms_deque.pop_front();
}
// avg
uint32_t sum = 0;
for (auto& bpm : bpms_deque) {
sum += bpm;
}
bpm_ = sum / bpms_deque.size();
if (on_apply) {
on_apply(bpm_);
}
painter.draw_char({(0 * 16) * 4 + 2 * 16, 3 * 16}, *Theme::getInstance()->fg_light, '0' + bpm_ / 100, 4);
painter.draw_char({(1 * 16) * 4 + 2 * 16, 3 * 16}, *Theme::getInstance()->fg_light, '0' + (bpm_ / 10) % 10, 4);
painter.draw_char({(2 * 16) * 4 + 2 * 16, 3 * 16}, *Theme::getInstance()->fg_light, '0' + bpm_ % 10, 4);
}
}
}
last_tap_time = current_time;
}
} // namespace ui::external_app::metronome
@@ -27,6 +27,8 @@
#include "audio.hpp"
#include "ch.h"
#include <deque>
namespace ui::external_app::metronome {
class MetronomeView : public View {
@@ -73,6 +75,11 @@ class MetronomeView : public View {
1,
' '};
Button button_enter_tap_tempo{
{(sizeof("BPM:") + 6) * 8, 1 * 16, (sizeof("Tap Tempo") + 3) * 8, 16},
"Tap Tempo",
};
NumberField field_rythm_unaccent_time{// e.g. 3 in 3/4 beat
{(sizeof("Rhythm:") + 1) * 8, 4 * 16},
2,
@@ -121,6 +128,45 @@ class MetronomeView : public View {
{0 * 16, 8 * 16, screen_width, screen_height - 14 * 16}};
};
class MetronomeTapTempoView : public View {
public:
std::function<void(uint16_t)> on_apply{};
MetronomeTapTempoView(NavigationView& nav, uint16_t bpm);
std::string title() const override { return "Tap.T"; };
void focus() override;
void paint(Painter& painter) override;
private:
void on_tap(Painter& painter);
NavigationView& nav_;
uint16_t bpm_{0};
uint16_t bpm_when_entered_{0}; // this pass from MetronomeView and need to restore if user cancel
std::deque<uint16_t> bpms_deque = {0}; // take average for recent taps to debounce
uint32_t last_tap_time{0};
std::string input_buffer{""}; // needed by text_prompt
Button button_input{
{0, 0, screen_width, 2 * 16},
"Input BPM"};
Button button_tap{
{0, 8 * 16, screen_width, 7 * 16},
"Tap BPM"};
Button button_cancel{
{1, 17 * 16, screen_width / 2 - 4, 2 * 16},
"Cancel"};
Button button_apply{
{1 + screen_width / 2 + 1, 17 * 16, screen_width / 2 - 4, 2 * 16},
"Apply"};
};
} // namespace ui::external_app::metronome
#endif /*__UI_METRONOME_H__*/
+39
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2024 HTotoo
* copyleft Whiterose of the Dark Army
*
* This file is part of PortaPack.
*
@@ -25,6 +26,7 @@
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "ui_textentry.hpp"
using namespace portapack;
using namespace ui;
@@ -39,6 +41,9 @@ OOKBruteView::OOKBruteView(NavigationView& nav)
: nav_{nav} {
add_children({
&button_startstop,
&button_input_stop_position,
&button_input_start_position,
&labels,
&field_frequency,
&tx_view,
&options_atkmode,
@@ -66,6 +71,40 @@ OOKBruteView::OOKBruteView(NavigationView& nav)
field_stop.on_change = [this](int32_t) {
validate_start_stop();
};
button_input_start_position.on_select = [this](Button&) {
stop(); // prevent mess count var up
text_input_buffer = to_string_dec_uint(field_start.value());
if (text_input_buffer == "0") {
text_input_buffer = "";
}
text_prompt(
nav_,
text_input_buffer,
8, // currently longest is princeton
[this](std::string& buffer) {
field_start.set_value(atoi(buffer.c_str()));
validate_start_stop();
});
};
button_input_stop_position.on_select = [this](Button&) {
stop(); // prevent mess count var up
text_input_buffer = to_string_dec_uint(field_stop.value());
if (text_input_buffer == "0") {
text_input_buffer = "";
}
text_prompt(
nav_,
text_input_buffer,
8, // currently longest is princeton
[this](std::string& buffer) {
field_stop.set_value(atoi(buffer.c_str()));
validate_start_stop();
});
};
update_start_stop(0);
}
+21 -4
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2024 HTotoo
* copyleft Whiterose of the Dark Army
*
* This file is part of PortaPack.
*
@@ -52,12 +53,25 @@ class OOKBruteView : public View {
app_settings::SettingsManager settings_{
"tx_ookbrute", app_settings::Mode::TX};
Labels labels{
{{0 * 8, 2 * 16}, "Start Position:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 7 * 16}, "Stop Position:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 13 * 16}, "Encoder Type:", Theme::getInstance()->fg_light->foreground}};
Button button_startstop{
{0, 3 * 16, 96, 24},
{8, screen_height - 48 - 16, screen_width - 2 * 8, 48},
LanguageHelper::currentMessages[LANG_START]};
Button button_input_start_position{
{8, 4 * 16, screen_width - 2 * 8, 24},
"Input Start Pos"};
Button button_input_stop_position{
{8, 9 * 16, screen_width - 2 * 8, 24},
"Input Stop Pos"};
NumberField field_start{
{0 * 8, 1 * 16},
{0 * 8, 3 * 16},
8,
{0, 2500},
1,
@@ -65,15 +79,16 @@ class OOKBruteView : public View {
true};
NumberField field_stop{
{11 * 8, 1 * 16},
{0, 8 * 16},
9,
{0, 2500},
1,
' ',
true};
// NB: when add new encoder here you should also change the char count limit for input range buttons by it's digits in DEC
OptionsField options_atkmode{
{0 * 8, 2 * 16},
{0, 14 * 16},
12,
{{"Came12", 0},
{"Came24", 1},
@@ -86,6 +101,8 @@ class OOKBruteView : public View {
uint32_t counter = 0; // for packet change
std::string text_input_buffer{}; // this is needed by the text_prompt func
void start();
void stop();
+51
View File
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui.hpp"
#include "ui_scanner.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::scanner {
void initialize_app(ui::NavigationView& nav) {
nav.push<ScannerView>();
}
} // namespace ui::external_app::scanner
extern "C" {
__attribute__((section(".external_app.app_scanner.application_information"), used)) application_information_t _application_information_scanner = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::scanner::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "Scanner",
/*.bitmap_data = */ {0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x01, 0x80, 0x01, 0xC3, 0x00, 0xE0, 0xFF, 0xEF, 0xFF, 0xC0, 0x00, 0x83, 0x01, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00},
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
// this has to be the biggest baseband used by the app. Scanner is using AM,WFM,NFM and NFM is the biggest
/*.m4_app_tag = portapack::spi_flash::image_tag_scanner */ {'P', 'N', 'F', 'M'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
@@ -28,10 +28,11 @@
#include "ui_freqman.hpp"
#include "file_path.hpp"
using namespace ui;
using namespace portapack;
namespace fs = std::filesystem;
namespace ui {
namespace ui::external_app::scanner {
ScannerThread::ScannerThread(std::vector<rf::Frequency> frequency_list)
: frequency_list_{std::move(frequency_list)} {
@@ -451,13 +452,14 @@ ScannerView::ScannerView(
// Mode field was changed (AM/NFM/WFM)
field_mode.on_change = [this](size_t, OptionsField::value_t v) {
static freqman_index_t last_mode = AM_MODULATION;
// initialize to a value under SPEC
static freqman_index_t last_mode = WFM_MODULATION;
// unsupported SPEC mode fix
if (v == SPEC_MODULATION) {
if (last_mode == AM_MODULATION)
v = WFM_MODULATION;
else
if (v >= SPEC_MODULATION) {
if (last_mode == WFM_MODULATION)
v = AM_MODULATION;
else
v = WFM_MODULATION;
field_mode.set_selected_index(v);
}
last_mode = v;
@@ -725,14 +727,6 @@ void ScannerView::change_mode(freqman_index_t new_mod) {
field_bw.set_by_value(receiver_model.wfm_configuration());
field_bw.on_change = [this](size_t, OptionsField::value_t n) { receiver_model.set_wfm_configuration(n); };
break;
case AMFM_MODULATION:
freqman_set_bandwidth_option(new_mod, field_bw);
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
receiver_model.set_modulation(ReceiverModel::Mode::AMAudioFMApt);
receiver_model.set_amfm_configuration(5);
field_bw.set_by_value(0);
field_bw.on_change = [this](size_t, OptionsField::value_t n) { (void)n; };
break;
default:
break;
}
@@ -773,5 +767,4 @@ void ScannerView::restart_scan() {
start_scan_thread(); // RESTART SCANNER THREAD in selected mode
}
} /* namespace ui */
} // namespace ui::external_app::scanner
@@ -35,12 +35,14 @@
#include "ui_mictx.hpp"
#include "ui_receiver.hpp"
using namespace ui;
namespace ui::external_app::scanner {
#define SCANNER_SLEEP_MS 50 // ms that Scanner Thread sleeps per loop
#define STATISTICS_UPDATES_PER_SEC 10
#define MAX_FREQ_LOCK 10 // # of 50ms cycles scanner locks into freq when signal detected, to verify signal is not spurious
namespace ui {
// TODO: There is too much duplicated data in these classes.
// ScannerThread should just use more from the View.
// Or perhaps ScannerThread should just be in the View.
@@ -314,5 +316,4 @@ class ScannerView : public View {
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
}};
};
} /* namespace ui */
} // namespace ui::external_app::scanner
+6 -4
View File
@@ -1,6 +1,8 @@
// CVS Spam app by RocketGod (@rocketgod-git) https://betaskynet.com
// Original .cu8 files by @jimilinuxguy https://github.com/jimilinuxguy/customer-assistance-buttons-sdr
// If you can read this, you're a nerd. :P
// Come join us at https://discord.gg/thepiratesreborn
// RocketGod's Shopping Cart Lock app
// https://betaskynet.com
#include "ui.hpp"
#include "shoppingcart_lock.hpp"
#include "ui_navigation.hpp"
@@ -60,7 +62,7 @@ __attribute__((section(".external_app.app_shoppingcart_lock.application_informat
/*.menu_location = */ app_location_t::UTILITIES,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_afsk_rx */ {'P', 'A', 'T', 'X'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
/*.m4_app_tag = portapack::spi_flash::image_tag_audio_tx */ {'P', 'A', 'T', 'X'},
/*.m4_app_offset = */ 0x00000000,
};
}
@@ -1,5 +1,8 @@
// RocketGod's Shopping Cart Lock app
// https://betaskynet.com
// CVS Spam app by RocketGod (@rocketgod-git) https://betaskynet.com
// Original .cu8 files by @jimilinuxguy https://github.com/jimilinuxguy/customer-assistance-buttons-sdr
// If you can read this, you're a nerd. :P
// Come join us at https://discord.gg/thepiratesreborn
#include "shoppingcart_lock.hpp"
using namespace portapack;
@@ -48,7 +51,6 @@ void ShoppingCartLock::stop() {
audio::output::stop();
log_event("... Resetting State Variables");
transmitter_model.disable();
ready_signal = false;
thread_sync_complete = false;
looping = false;
@@ -110,18 +112,24 @@ std::string ShoppingCartLock::list_wav_files() {
}
void ShoppingCartLock::wait_for_thread() {
uint32_t timeout = 100;
uint32_t timeout = 1000;
while (!ready_signal && timeout > 0) {
chThdYield();
timeout--;
}
if (!ready_signal) {
log_event("!!! Timeout waiting for ReplayThread");
}
}
void ShoppingCartLock::restart_playback() {
auto reader = std::make_unique<WAVFileReader>();
std::string file_path = (wav_dir / current_file).string();
if (!reader->open(file_path)) return;
if (!reader->open(file_path)) {
log_event("!!! Failed to reopen " + current_file + " for restart");
return;
}
replay_thread = std::make_unique<ReplayThread>(
std::move(reader),
@@ -133,9 +141,8 @@ void ShoppingCartLock::restart_playback() {
EventDispatcher::send_message(message);
});
log_event(">> SENDING <<");
log_event(">> RESTARTING AUDIO <<");
audio::output::start();
transmitter_model.enable();
}
void ShoppingCartLock::play_audio(const std::string& filename, bool loop) {
@@ -166,33 +173,24 @@ void ShoppingCartLock::play_audio(const std::string& filename, bool loop) {
wait_for_thread();
log_event("... Configuring Baseband");
const uint32_t bb_sample_rate = 1536000;
const uint32_t decimation = bb_sample_rate / wav_sample_rate;
baseband::set_sample_rate(wav_sample_rate);
audio::set_rate(wav_sample_rate <= 12000 ? audio::Rate::Hz_12000 : wav_sample_rate <= 24000 ? audio::Rate::Hz_24000
: audio::Rate::Hz_48000);
baseband::set_audiotx_config(
bb_sample_rate / decimation,
wav_sample_rate,
0.0f,
0.0f,
5.0f,
wav_bits_per_sample,
wav_bits_per_sample,
0,
true,
false,
false,
false,
false);
baseband::set_sample_rate(wav_sample_rate);
log_event("... Starting Audio Output");
audio::output::start();
log_event("... Setting Max Volume");
audio::headphone::set_volume(audio::headphone::volume_range().max);
transmitter_model.enable();
log_event(">>> Playback Started <<<");
volume_t max_volume = audio::headphone::volume_range().max;
audio::headphone::set_volume(max_volume);
}
ShoppingCartLock::ShoppingCartLock(NavigationView& nav)
@@ -232,4 +230,4 @@ ShoppingCartLock::~ShoppingCartLock() {
baseband::shutdown();
}
} // namespace ui::external_app::shoppingcart_lock
} // namespace ui::external_app::shoppingcart_lock
@@ -1,5 +1,8 @@
// RocketGod's Shopping Cart Lock app
// https://betaskynet.com
// CVS Spam app by RocketGod (@rocketgod-git) https://betaskynet.com
// Original .cu8 files by @jimilinuxguy https://github.com/jimilinuxguy/customer-assistance-buttons-sdr
// If you can read this, you're a nerd. :P
// Come join us at https://discord.gg/thepiratesreborn
#pragma once
#include "ui_widget.hpp"
@@ -27,8 +30,8 @@ class ShoppingCartLock : public View {
void focus() override;
private:
static constexpr size_t BUFFER_SIZE = 8192;
static constexpr size_t NUM_BUFFERS = 8;
static constexpr size_t BUFFER_SIZE = 512;
static constexpr size_t NUM_BUFFERS = 2;
const std::string shoppingcart_lock_file{"shopping_cart_lock.wav"};
const std::string shoppingcart_unlock_file{"shopping_cart_unlock.wav"};
-29
View File
@@ -1,29 +0,0 @@
/*
* 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.
*/
// dummy include file to avoid changing original source
#ifndef __UI_Arial12x12_H__
#define __UI_Arial12x12_H__
#define Arial12x12 (0)
#endif /*__UI_Arial12x12_H__*/
-68
View File
@@ -1,68 +0,0 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#ifndef __UI_SPI_TFT_ILI9341_H__
#define __UI_SPI_TFT_ILI9341_H__
ui::Painter painter;
static int bg_color;
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
static const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
static void claim(__FILE* x) {
(void)x;
};
static void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
};
static void background(int color) {
bg_color = color;
};
static void set_orientation(int x) {
(void)x;
};
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]);
};
#endif /*__UI_SPI_TFT_ILI9341_H__*/
+23 -22
View File
@@ -28,35 +28,36 @@ __attribute__((section(".external_app.app_snake.application_information"), used)
{
0x00,
0x00,
0x7E,
0x42,
0x42,
0x42,
0x7E,
0x00,
0x00,
0x7E,
0x42,
0x42,
0x42,
0x7E,
0xE0,
0x09,
0x70,
0xC7,
0xFC,
0xC9,
0x06,
0x00,
0x06,
0x00,
0x0C,
0x00,
0x7E,
0x42,
0x42,
0x42,
0x7E,
0xF0,
0x01,
0x00,
0x3E,
0x00,
0x7E,
0x42,
0x42,
0x42,
0x7E,
0x00,
0x40,
0xFC,
0x40,
0x02,
0x3F,
0x02,
0x00,
0x7C,
0x80,
0x80,
0x7F,
},
ui::Color::green().v,
app_location_t::GAMES,
@@ -64,4 +65,4 @@ __attribute__((section(".external_app.app_snake.application_information"), used)
{0, 0, 0, 0},
0x00000000,
};
}
} // namespace ui::external_app::snake
-98
View File
@@ -1,98 +0,0 @@
#ifndef __UI_mbed_H__
#define __UI_mbed_H__
using Callback = void (*)(void);
#define wait_us(x) (void)0
#define wait(x) chThdSleepMilliseconds(x * 1000)
#define PullUp 1
#include "ui_navigation.hpp"
enum {
dp0,
dp1,
dp2,
dp3,
dp4,
dp5,
dp6,
dp7,
dp8,
dp9,
dp10,
dp11,
dp12,
dp13,
dp14,
dp15,
dp16,
dp17,
dp18,
dp19,
dp20,
dp21,
dp22,
dp23,
dp24,
dp25,
};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
static bool but_RIGHT;
static bool but_LEFT;
#pragma GCC diagnostic pop
static bool but_SELECT;
class Timer {
public:
Timer() { (void)0; };
void reset() { (void)0; };
void start() { (void)0; }
uint32_t read_ms() { return 1000; };
private:
};
static Callback game_update_callback;
static uint32_t game_update_timeout;
static uint32_t game_update_counter;
static void check_game_timer() {
if (game_update_callback) {
if (++game_update_counter >= game_update_timeout) {
game_update_counter = 0;
game_update_callback();
}
}
}
class Ticker {
public:
Ticker() { (void)0; };
void attach(Callback func, double delay_sec) {
game_update_callback = func;
game_update_timeout = delay_sec * 60;
}
void detach() {
game_update_callback = nullptr;
}
private:
};
static Callback button_callback;
class InterruptIn {
public:
InterruptIn(int reg) {
(void)reg;
};
void fall(Callback func) { button_callback = func; };
void mode(int v) { (void)v; };
private:
};
#endif /*__UI_mbed_H__*/
-234
View File
@@ -1,234 +0,0 @@
/*
* ------------------------------------------------------------
* | Made by RocketGod |
* | Find me at https://betaskynet.com |
* | Argh matey! |
* ------------------------------------------------------------
*/
#include "mbed.h"
#include "SPI_TFT_ILI9341.h"
#include "Arial12x12.h"
#include "ui.hpp"
#include "random.hpp"
extern int game_state;
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define SNAKE_SIZE 10
#define INFO_BAR_HEIGHT 25
#define GAME_AREA_TOP (INFO_BAR_HEIGHT + 1)
#define GAME_AREA_HEIGHT (SCREEN_HEIGHT - INFO_BAR_HEIGHT - 2)
#define GRID_WIDTH ((SCREEN_WIDTH - 2) / SNAKE_SIZE)
#define GRID_HEIGHT (GAME_AREA_HEIGHT / SNAKE_SIZE)
#define STATE_MENU 0
#define STATE_PLAYING 1
#define STATE_GAME_OVER 2
#define COLOR_BACKGROUND Black
#define COLOR_SNAKE Green
#define COLOR_FOOD Red
#define COLOR_BORDER White
Ticker game_timer;
int snake_x[GRID_WIDTH * GRID_HEIGHT];
int snake_y[GRID_WIDTH * GRID_HEIGHT];
int snake_length = 1;
int snake_dx = 1, snake_dy = 0;
int food_x, food_y;
int score = 0;
int game_state = STATE_MENU;
bool initialized = false;
extern ui::Painter painter;
void init_game();
void update_game();
void draw_screen();
void draw_snake();
void draw_full_snake();
void erase_tail(int x, int y);
void draw_food();
void erase_food();
void draw_score();
void draw_borders();
void spawn_food();
bool check_collision();
void show_menu();
void show_game_over();
void game_timer_check() {
if (game_state == STATE_PLAYING) {
update_game();
}
}
void init_game() {
claim(stdout);
set_orientation(2);
set_font((unsigned char*)Arial12x12);
snake_x[0] = GRID_WIDTH / 2;
snake_y[0] = GRID_HEIGHT / 2;
snake_length = 1;
snake_dx = 1;
snake_dy = 0;
score = 0;
spawn_food();
if (game_state == STATE_MENU) {
show_menu();
} else if (game_state == STATE_PLAYING) {
draw_screen();
}
}
void spawn_food() {
bool valid;
do {
food_x = rand() % GRID_WIDTH;
food_y = rand() % GRID_HEIGHT;
valid = true;
for (int i = 0; i < snake_length; i++) {
if (snake_x[i] == food_x && snake_y[i] == food_y) {
valid = false;
break;
}
}
} while (!valid);
}
void update_game() {
int new_x = snake_x[0] + snake_dx;
int new_y = snake_y[0] + snake_dy;
bool ate_food = (new_x == food_x && new_y == food_y);
int tail_x = snake_x[snake_length - 1];
int tail_y = snake_y[snake_length - 1];
for (int i = snake_length - 1; i > 0; i--) {
snake_x[i] = snake_x[i - 1];
snake_y[i] = snake_y[i - 1];
}
snake_x[0] = new_x;
snake_y[0] = new_y;
if (ate_food) {
snake_x[snake_length] = tail_x;
snake_y[snake_length] = tail_y;
snake_length++;
score += 10;
spawn_food();
draw_food();
} else {
erase_tail(tail_x, tail_y);
}
draw_snake();
draw_score();
if (check_collision()) {
draw_borders();
game_state = STATE_GAME_OVER;
show_game_over();
return;
}
}
bool check_collision() {
if (snake_x[0] < 0 || snake_x[0] >= GRID_WIDTH || snake_y[0] < 0 || snake_y[0] >= GRID_HEIGHT) {
return true;
}
for (int i = 1; i < snake_length; i++) {
if (snake_x[0] == snake_x[i] && snake_y[0] == snake_y[i]) {
return true;
}
}
return false;
}
void draw_screen() {
cls();
background(COLOR_BACKGROUND);
draw_borders();
draw_full_snake();
draw_food();
draw_score();
}
void draw_snake() {
fillrect(1 + snake_x[0] * SNAKE_SIZE, GAME_AREA_TOP + snake_y[0] * SNAKE_SIZE,
1 + snake_x[0] * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + snake_y[0] * SNAKE_SIZE + SNAKE_SIZE, COLOR_SNAKE);
}
void draw_full_snake() {
for (int i = 0; i < snake_length; i++) {
fillrect(1 + snake_x[i] * SNAKE_SIZE, GAME_AREA_TOP + snake_y[i] * SNAKE_SIZE,
1 + snake_x[i] * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + snake_y[i] * SNAKE_SIZE + SNAKE_SIZE, COLOR_SNAKE);
}
}
void erase_tail(int x, int y) {
fillrect(1 + x * SNAKE_SIZE, GAME_AREA_TOP + y * SNAKE_SIZE,
1 + x * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + y * SNAKE_SIZE + SNAKE_SIZE, COLOR_BACKGROUND);
}
void draw_food() {
fillrect(1 + food_x * SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE,
1 + food_x * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE + SNAKE_SIZE, COLOR_FOOD);
}
void erase_food() {
fillrect(1 + food_x * SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE,
1 + food_x * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE + SNAKE_SIZE, COLOR_BACKGROUND);
}
void draw_score() {
auto style = *ui::Theme::getInstance()->fg_blue;
painter.draw_string({5, 5}, style, "Score: " + std::to_string(score));
}
void draw_borders() {
rect(0, GAME_AREA_TOP - 1, SCREEN_WIDTH, GAME_AREA_TOP, COLOR_BORDER);
rect(0, GAME_AREA_TOP, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_BORDER);
}
void show_menu() {
cls();
background(COLOR_BACKGROUND);
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_green = *ui::Theme::getInstance()->fg_green;
auto style_blue = *ui::Theme::getInstance()->fg_blue;
painter.draw_string({50, 40}, style_yellow, "* * * SNAKE * * *");
painter.draw_string({0, 120}, style_blue, "USE THE D-PAD TO MOVE");
painter.draw_string({0, 150}, style_blue, "EAT THE RED SQUARES TO GROW");
painter.draw_string({0, 180}, style_blue, "DON'T HIT THE WALLS OR SELF");
painter.draw_string({15, 240}, style_green, "** PRESS SELECT TO START **");
}
void show_game_over() {
cls();
background(COLOR_BACKGROUND);
auto style_red = *ui::Theme::getInstance()->fg_red;
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_green = *ui::Theme::getInstance()->fg_green;
painter.draw_string({75, 90}, style_red, "GAME OVER");
painter.draw_string({74, 150}, style_yellow, "SCORE: " + std::to_string(score));
painter.draw_string({20, 220}, style_green, "PRESS SELECT TO RESTART");
wait(1);
}
int main() {
if (!initialized) {
initialized = true;
game_timer.attach(&game_timer_check, 1.0 / 5.0);
init_game();
}
while (1) {
if (but_SELECT && (game_state == STATE_MENU || game_state == STATE_GAME_OVER)) {
game_state = STATE_PLAYING;
init_game();
}
}
}
+224 -1
View File
@@ -10,7 +10,230 @@
namespace ui::external_app::snake {
#include "snake.cpp"
Ticker game_timer;
int snake_x[GRID_WIDTH * GRID_HEIGHT];
int snake_y[GRID_WIDTH * GRID_HEIGHT];
int snake_length = 1;
int snake_dx = 1;
int snake_dy = 0;
int food_x, food_y;
int score = 0;
int game_state = STATE_MENU;
bool initialized = false;
const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
Painter painter;
bool but_RIGHT = false;
bool but_LEFT = false;
bool but_SELECT = false;
static Callback game_update_callback = nullptr;
static uint32_t game_update_timeout = 0;
static uint32_t game_update_counter = 0;
void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
}
void background(int color) {
(void)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]);
}
void rect(int x1, int y1, int x2, int y2, int color) {
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
}
void check_game_timer() {
if (game_update_callback) {
if (++game_update_counter >= game_update_timeout) {
game_update_counter = 0;
game_update_callback();
}
}
}
void Ticker::attach(Callback func, double delay_sec) {
game_update_callback = func;
game_update_timeout = delay_sec * 60;
}
void Ticker::detach() {
game_update_callback = nullptr;
}
void game_timer_check() {
if (game_state == STATE_PLAYING) {
update_game();
}
}
void init_game() {
snake_x[0] = GRID_WIDTH / 2;
snake_y[0] = GRID_HEIGHT / 2;
snake_length = 1;
snake_dx = 1;
snake_dy = 0;
score = 0;
spawn_food();
if (game_state == STATE_MENU) {
show_menu();
} else if (game_state == STATE_PLAYING) {
draw_screen();
}
}
void spawn_food() {
bool valid;
do {
food_x = rand() % GRID_WIDTH;
food_y = rand() % GRID_HEIGHT;
valid = true;
for (int i = 0; i < snake_length; i++) {
if (snake_x[i] == food_x && snake_y[i] == food_y) {
valid = false;
break;
}
}
} while (!valid);
}
void update_game() {
int new_x = snake_x[0] + snake_dx;
int new_y = snake_y[0] + snake_dy;
bool ate_food = (new_x == food_x && new_y == food_y);
int tail_x = snake_x[snake_length - 1];
int tail_y = snake_y[snake_length - 1];
for (int i = snake_length - 1; i > 0; i--) {
snake_x[i] = snake_x[i - 1];
snake_y[i] = snake_y[i - 1];
}
snake_x[0] = new_x;
snake_y[0] = new_y;
if (ate_food) {
snake_x[snake_length] = tail_x;
snake_y[snake_length] = tail_y;
snake_length++;
score += 10;
spawn_food();
draw_food();
} else {
erase_tail(tail_x, tail_y);
}
draw_snake();
draw_score();
if (check_collision()) {
draw_borders();
game_state = STATE_GAME_OVER;
show_game_over();
return;
}
}
bool check_collision() {
if (snake_x[0] < 0 || snake_x[0] >= GRID_WIDTH || snake_y[0] < 0 || snake_y[0] >= GRID_HEIGHT) {
return true;
}
for (int i = 1; i < snake_length; i++) {
if (snake_x[0] == snake_x[i] && snake_y[0] == snake_y[i]) {
return true;
}
}
return false;
}
void draw_screen() {
cls();
background(COLOR_BACKGROUND);
draw_borders();
draw_full_snake();
draw_food();
draw_score();
}
void draw_snake() {
fillrect(1 + snake_x[0] * SNAKE_SIZE, GAME_AREA_TOP + snake_y[0] * SNAKE_SIZE,
1 + snake_x[0] * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + snake_y[0] * SNAKE_SIZE + SNAKE_SIZE, COLOR_SNAKE);
}
void draw_full_snake() {
for (int i = 0; i < snake_length; i++) {
fillrect(1 + snake_x[i] * SNAKE_SIZE, GAME_AREA_TOP + snake_y[i] * SNAKE_SIZE,
1 + snake_x[i] * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + snake_y[i] * SNAKE_SIZE + SNAKE_SIZE, COLOR_SNAKE);
}
}
void erase_tail(int x, int y) {
fillrect(1 + x * SNAKE_SIZE, GAME_AREA_TOP + y * SNAKE_SIZE,
1 + x * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + y * SNAKE_SIZE + SNAKE_SIZE, COLOR_BACKGROUND);
}
void draw_food() {
fillrect(1 + food_x * SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE,
1 + food_x * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE + SNAKE_SIZE, COLOR_FOOD);
}
void erase_food() {
fillrect(1 + food_x * SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE,
1 + food_x * SNAKE_SIZE + SNAKE_SIZE, GAME_AREA_TOP + food_y * SNAKE_SIZE + SNAKE_SIZE, COLOR_BACKGROUND);
}
void draw_score() {
auto style = *ui::Theme::getInstance()->fg_blue;
painter.draw_string({5, 5}, style, "Score: " + std::to_string(score));
}
void draw_borders() {
rect(0, GAME_AREA_TOP - 1, SCREEN_WIDTH, GAME_AREA_TOP, COLOR_BORDER);
rect(0, GAME_AREA_TOP, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_BORDER);
}
void show_menu() {
cls();
background(COLOR_BACKGROUND);
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_green = *ui::Theme::getInstance()->fg_green;
auto style_blue = *ui::Theme::getInstance()->fg_blue;
painter.draw_string({50, 40}, style_yellow, "* * * SNAKE * * *");
painter.draw_string({0, 120}, style_blue, "USE THE D-PAD TO MOVE");
painter.draw_string({0, 150}, style_blue, "EAT THE RED SQUARES TO GROW");
painter.draw_string({0, 180}, style_blue, "DON'T HIT THE WALLS OR SELF");
painter.draw_string({15, 240}, style_green, "** PRESS SELECT TO START **");
}
void show_game_over() {
cls();
background(COLOR_BACKGROUND);
auto style_red = *ui::Theme::getInstance()->fg_red;
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
auto style_green = *ui::Theme::getInstance()->fg_green;
painter.draw_string({75, 90}, style_red, "GAME OVER");
painter.draw_string({74, 150}, style_yellow, "SCORE: " + std::to_string(score));
painter.draw_string({20, 220}, style_green, "PRESS SELECT TO RESTART");
wait(1);
}
SnakeView::SnakeView(NavigationView& nav)
: nav_{nav} {
+88 -4
View File
@@ -9,23 +9,105 @@
#ifndef __UI_SNAKE_H__
#define __UI_SNAKE_H__
#include "ui.hpp"
#include "ui_navigation.hpp"
#include "event_m0.hpp"
#include "message.hpp"
#include "irq_controls.hpp"
#include "random.hpp"
#include "lpc43xx_cpp.hpp"
#include "limits.h"
#include "ui_widget.hpp"
namespace ui::external_app::snake {
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
extern const Color pp_colors[];
extern Painter painter;
extern bool but_RIGHT;
extern bool but_LEFT;
extern bool but_SELECT;
void cls();
void background(int color);
void fillrect(int x1, int y1, int x2, int y2, int color);
void rect(int x1, int y1, int x2, int y2, int color);
#define wait(x) chThdSleepMilliseconds(x * 1000)
using Callback = void (*)(void);
class Ticker {
public:
Ticker() = default;
void attach(Callback func, double delay_sec);
void detach();
};
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define SNAKE_SIZE 10
#define INFO_BAR_HEIGHT 25
#define GAME_AREA_TOP (INFO_BAR_HEIGHT + 1)
#define GAME_AREA_HEIGHT (SCREEN_HEIGHT - INFO_BAR_HEIGHT - 2)
#define GRID_WIDTH ((SCREEN_WIDTH - 2) / SNAKE_SIZE)
#define GRID_HEIGHT (GAME_AREA_HEIGHT / SNAKE_SIZE)
#define STATE_MENU 0
#define STATE_PLAYING 1
#define STATE_GAME_OVER 2
#define COLOR_BACKGROUND Black
#define COLOR_SNAKE Green
#define COLOR_FOOD Red
#define COLOR_BORDER White
extern Ticker game_timer;
extern int snake_x[GRID_WIDTH * GRID_HEIGHT];
extern int snake_y[GRID_WIDTH * GRID_HEIGHT];
extern int snake_length;
extern int snake_dx;
extern int snake_dy;
extern int food_x;
extern int food_y;
extern int score;
extern int game_state;
extern bool initialized;
void game_timer_check();
void init_game();
void update_game();
void draw_screen();
void draw_snake();
void draw_full_snake();
void erase_tail(int x, int y);
void draw_food();
void erase_food();
void draw_score();
void draw_borders();
void spawn_food();
bool check_collision();
void show_menu();
void show_game_over();
class SnakeView : public View {
public:
SnakeView(NavigationView& nav);
void on_show() override;
std::string title() const override { return "Snake"; };
void focus() override { dummy.focus(); };
std::string title() const override { return "Snake"; }
void focus() override { dummy.focus(); }
void paint(Painter& painter) override;
void frame_sync();
bool on_key(KeyEvent key) override;
@@ -33,9 +115,11 @@ class SnakeView : public View {
private:
bool initialized = false;
NavigationView& nav_;
Button dummy{
{240, 0, 0, 0},
""};
MessageHandlerRegistration message_handler_frame_sync{
Message::ID::DisplayFrameSync,
[this](const Message* const) {
@@ -45,4 +129,4 @@ class SnakeView : public View {
} // namespace ui::external_app::snake
#endif /*__UI_SNAKE_H__*/
#endif /* __UI_SNAKE_H__ */
+220 -12
View File
@@ -1,5 +1,6 @@
/*
* Copyright 2025 Mark Thompson
* copyleft Mr. Robot of F.Society
*
* This file is part of PortaPack.
*
@@ -27,14 +28,46 @@ using namespace portapack;
namespace ui::external_app::stopwatch {
StopwatchView::StopwatchView(NavigationView& nav) {
// clang-format off
// clang-format doesn't allow use as this way but it's not worth to have const var for this thing. too expensive
// minute
#define TOTAL_M1_POS {0 * 8 * 4, 3 * 16}
#define TOTAL_M2_POS {1 * 8 * 4, 3 * 16}
// sec
#define TOTAL_S1_POS {2 * 8 * 4 + 24, 3 * 16}
#define TOTAL_S2_POS {3 * 8 * 4 + 24, 3 * 16}
// ms
#define TOTAL_MS1_POS {4 * 8 * 4 + 7 * 8, 3 * 16 + 24}
#define TOTAL_MS2_POS {5 * 8 * 4 + 5 * 8, 3 * 16 + 24}
#define TOTAL_MS3_POS {6 * 8 * 4 + 3 * 8, 3 * 16 + 24}
#define LAP_Y 9 * 16
//lap min
#define LAP_M1_POS {0 * 8 * 4, LAP_Y}
#define LAP_M2_POS {1 * 8 * 4, LAP_Y}
//lap sec
#define LAP_S1_POS {2 * 8 * 4 + 24, LAP_Y}
#define LAP_S2_POS {3 * 8 * 4 + 24, LAP_Y}
//lap ms
#define LAP_MS1_POS {4 * 8 * 4 + 7 * 8, LAP_Y + 24}
#define LAP_MS2_POS {5 * 8 * 4 + 5 * 8, LAP_Y + 24}
#define LAP_MS3_POS {6 * 8 * 4 + 3 * 8, LAP_Y + 24}
// clang-format on
StopwatchView::StopwatchView(NavigationView& nav)
: painter{} {
add_children({
&labels,
&button_run_stop,
&button_reset_lap,
&button_done,
&big_display,
&lap_display,
&options_ms_display_level,
});
button_run_stop.on_select = [this](Button&) {
@@ -54,6 +87,14 @@ StopwatchView::StopwatchView(NavigationView& nav) {
button_done.on_select = [&nav](Button&) {
nav.pop();
};
options_ms_display_level.on_change = [&](size_t, ui::OptionsField::value_t) {
clean_ms_display(options_ms_display_level.selected_index());
};
options_ms_display_level.set_selected_index(0);
refresh_painting();
}
void StopwatchView::focus() {
@@ -61,6 +102,10 @@ void StopwatchView::focus() {
}
void StopwatchView::run() {
options_ms_display_level.hidden(true);
// ^ this won't take efferts if don't set_dirty, but needed to let user can't change during ticking
if (!paused) refresh_painting();
paused = false;
running = true;
start_time = chTimeNow() - previously_elapsed;
button_run_stop.set_text("STOP");
@@ -68,7 +113,9 @@ void StopwatchView::run() {
}
void StopwatchView::stop() {
options_ms_display_level.hidden(false);
running = false;
paused = true;
end_time = chTimeNow();
previously_elapsed = end_time - start_time;
button_run_stop.set_text("START");
@@ -77,25 +124,186 @@ void StopwatchView::stop() {
void StopwatchView::reset() {
lap_time = end_time = start_time = previously_elapsed = 0;
big_display.set(0);
lap_display.set(0);
for (uint8_t i = 0; i < 7; i++) {
refresh_painting();
}
refresh_painting();
set_dirty();
}
void StopwatchView::lap() {
lap_time = chTimeNow();
lap_display.set((lap_time - start_time) * 1000); // convert elapsed time in ms to MHz for BigFrequency widget
}
void StopwatchView::paint(Painter& painter) {
(void)painter;
if (running) {
end_time = chTimeNow();
big_display.set((end_time - start_time) * 1000); // convert elapsed time in ms to MHz for BigFrequency widget
void StopwatchView::paint(Painter&) {
}
void StopwatchView::refresh_painting() {
// minute
painter.draw_char(TOTAL_M1_POS, *Theme::getInstance()->fg_light, ' ', 4);
painter.draw_char(TOTAL_M2_POS, *Theme::getInstance()->fg_light, ' ', 4);
// sec
painter.draw_char(TOTAL_S1_POS, *Theme::getInstance()->fg_light, ' ', 4);
painter.draw_char(TOTAL_S2_POS, *Theme::getInstance()->fg_light, ' ', 4);
// ms
painter.draw_char(TOTAL_MS1_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(TOTAL_MS2_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(TOTAL_MS3_POS, *Theme::getInstance()->fg_light, ' ', 2);
// lap min
painter.draw_char(LAP_M1_POS, *Theme::getInstance()->fg_light, ' ', 4);
painter.draw_char(LAP_M2_POS, *Theme::getInstance()->fg_light, ' ', 4);
// lap sec
painter.draw_char(LAP_S1_POS, *Theme::getInstance()->fg_light, ' ', 4);
painter.draw_char(LAP_S2_POS, *Theme::getInstance()->fg_light, ' ', 4);
// lap ms
painter.draw_char(LAP_MS1_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(LAP_MS2_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(LAP_MS3_POS, *Theme::getInstance()->fg_light, ' ', 2);
}
/*when user seted it to display more, then display less later, this prevent the remain value exist on screen*/
void StopwatchView::clean_ms_display(uint8_t level) {
level++;
switch (level) {
case 0:
painter.draw_char(TOTAL_MS1_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(TOTAL_MS2_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(TOTAL_MS3_POS, *Theme::getInstance()->fg_light, ' ', 2);
break;
case 1:
painter.draw_char(TOTAL_MS2_POS, *Theme::getInstance()->fg_light, ' ', 2);
painter.draw_char(TOTAL_MS3_POS, *Theme::getInstance()->fg_light, ' ', 2);
break;
case 2:
painter.draw_char(TOTAL_MS3_POS, *Theme::getInstance()->fg_light, ' ', 2);
break;
}
}
void StopwatchView::resume_last() {
// minute
painter.draw_char(TOTAL_M1_POS, *Theme::getInstance()->fg_light, last_displayed[0], 4);
painter.draw_char(TOTAL_M2_POS, *Theme::getInstance()->fg_light, last_displayed[1], 4);
// sec
painter.draw_char(TOTAL_S1_POS, *Theme::getInstance()->fg_light, last_displayed[2], 4);
painter.draw_char(TOTAL_S2_POS, *Theme::getInstance()->fg_light, last_displayed[3], 4);
// ms
painter.draw_char(TOTAL_MS1_POS, *Theme::getInstance()->fg_light, last_displayed[4], 2);
painter.draw_char(TOTAL_MS2_POS, *Theme::getInstance()->fg_light, last_displayed[5], 2);
painter.draw_char(TOTAL_MS3_POS, *Theme::getInstance()->fg_light, last_displayed[6], 2);
}
/* NB:
* Due to the flaw of dirty management, it's using work around, to reduce screen flickering:
*
* for example when xx:15:xxx turn to xx:16:xxx, it actually only paint 6, the 1 is old,
* but not dirty, so we can see without flikering.
*
* So with these work around, it won't show false info, but bare in mind that it could be, if you add more things.
*/
void StopwatchView::frame_sync() {
set_dirty();
uint32_t elapsed_ticks = 0;
if (running) {
end_time = chTimeNow();
elapsed_ticks = end_time - start_time;
} else if (previously_elapsed > 0) {
elapsed_ticks = previously_elapsed;
}
constexpr uint32_t TICKS_PER_SECOND = CH_FREQUENCY;
constexpr uint32_t TICKS_PER_MINUTE = TICKS_PER_SECOND * 60;
uint32_t minutes = elapsed_ticks / TICKS_PER_MINUTE;
uint32_t seconds = (elapsed_ticks % TICKS_PER_MINUTE) / TICKS_PER_SECOND;
uint32_t milliseconds = ((elapsed_ticks % TICKS_PER_SECOND) * 1000) / TICKS_PER_SECOND;
// minute
if (last_displayed[0] != (minutes / 10) % 10)
painter.draw_char(TOTAL_M1_POS, *Theme::getInstance()->fg_red, '0' + (minutes / 10) % 10, 4);
if (last_displayed[1] != minutes % 10)
painter.draw_char(TOTAL_M2_POS, *Theme::getInstance()->fg_red, '0' + minutes % 10, 4);
// sec
if (last_displayed[2] != (seconds / 10) % 10)
painter.draw_char(TOTAL_S1_POS, *Theme::getInstance()->fg_green, '0' + (seconds / 10) % 10, 4);
if (last_displayed[3] != seconds % 10)
painter.draw_char(TOTAL_S2_POS, *Theme::getInstance()->fg_green, '0' + seconds % 10, 4);
// ms
/* v place holder to aligh logic*/
if ((true) && last_displayed[4] != (milliseconds / 100) % 10)
painter.draw_char(TOTAL_MS1_POS, *Theme::getInstance()->fg_yellow, '0' + (milliseconds / 100) % 10, 2);
if ((options_ms_display_level.selected_index() >= 1) && last_displayed[5] != (milliseconds / 10) % 10)
painter.draw_char(TOTAL_MS2_POS, *Theme::getInstance()->fg_yellow, '0' + (milliseconds / 10) % 10, 2);
if ((options_ms_display_level.selected_index() >= 2) && last_displayed[6] != milliseconds % 10)
painter.draw_char(TOTAL_MS3_POS, *Theme::getInstance()->fg_yellow, '0' + milliseconds % 10, 2);
// min
last_displayed[0] = (minutes / 10) % 10;
last_displayed[1] = minutes % 10;
// sec
last_displayed[2] = (seconds / 10) % 10;
last_displayed[3] = seconds % 10;
// ms
last_displayed[4] = (milliseconds / 100) % 10;
last_displayed[5] = (milliseconds / 10) % 10;
last_displayed[6] = milliseconds % 10;
if (lap_time > 0) {
uint32_t lap_elapsed = lap_time - start_time;
uint32_t lap_minutes = lap_elapsed / TICKS_PER_MINUTE;
uint32_t lap_seconds = (lap_elapsed % TICKS_PER_MINUTE) / TICKS_PER_SECOND;
uint32_t lap_milliseconds = ((lap_elapsed % TICKS_PER_SECOND) * 1000) / TICKS_PER_SECOND;
// lap min
if (lap_last_displayed[0] == (lap_minutes / 10) % 10) {
painter.draw_char(LAP_M1_POS, *Theme::getInstance()->fg_light, '0' + (lap_minutes / 10) % 10, 4);
}
if (lap_last_displayed[1] == lap_minutes % 10) {
painter.draw_char(LAP_M2_POS, *Theme::getInstance()->fg_light, '0' + lap_minutes % 10, 4);
}
// lap sec
if (lap_last_displayed[2] == (lap_seconds / 10) % 10) {
painter.draw_char(LAP_S1_POS, *Theme::getInstance()->fg_light, '0' + (lap_seconds / 10) % 10, 4);
}
if (lap_last_displayed[3] == lap_seconds % 10) {
painter.draw_char(LAP_S2_POS, *Theme::getInstance()->fg_light, '0' + lap_seconds % 10, 4);
}
// lap ms
if (lap_last_displayed[4] == (lap_milliseconds / 100) % 10) {
painter.draw_char(LAP_MS1_POS, *Theme::getInstance()->fg_light, '0' + (lap_milliseconds / 100) % 10, 2);
}
if (lap_last_displayed[5] == (lap_milliseconds / 10) % 10) {
painter.draw_char(LAP_MS2_POS, *Theme::getInstance()->fg_light, '0' + (lap_milliseconds / 10) % 10, 2);
}
if (lap_last_displayed[6] == lap_milliseconds % 10) {
painter.draw_char(LAP_MS3_POS, *Theme::getInstance()->fg_light, '0' + lap_milliseconds % 10, 2);
}
// lp m
lap_last_displayed[0] = (lap_minutes / 10) % 10;
lap_last_displayed[1] = lap_minutes % 10;
// lp s
lap_last_displayed[2] = (lap_seconds / 10) % 10;
lap_last_displayed[3] = lap_seconds % 10;
// lp mss
lap_last_displayed[4] = (lap_milliseconds / 100) % 10;
lap_last_displayed[5] = (lap_milliseconds / 10) % 10;
lap_last_displayed[6] = lap_milliseconds % 10;
}
}
} // namespace ui::external_app::stopwatch
+17 -6
View File
@@ -1,5 +1,6 @@
/*
* Copyright 2025 Mark Thompson
* copyleft Mr. Robot of F.Society
*
* This file is part of PortaPack.
*
@@ -39,25 +40,35 @@ class StopwatchView : public View {
void stop();
void reset();
void lap();
void cover_display_area_with_0();
void refresh_painting();
void resume_last();
void clean_ms_display(uint8_t level = 0);
bool running{false};
bool paused{false};
long long start_time{0};
long long end_time{0};
long long lap_time{0};
long long previously_elapsed{0};
uint8_t last_displayed[7] = {0, 0, 0, 0, 0, 0, 0};
/* m m s s ms ms ms*/
uint8_t lap_last_displayed[7] = {0, 0, 0, 0, 0, 0, 0};
/* m m s s ms ms ms*/
Labels labels{
{{0 * 8, 1 * 16}, "TOTAL:", Theme::getInstance()->fg_light->foreground},
{{0 * 8, 7 * 16}, "LAP:", Theme::getInstance()->fg_light->foreground},
};
BigFrequency big_display{
{4, 2 * 16 + 4, 28 * 8, 52},
0};
OptionsField options_ms_display_level{
{4 * 8 * 4 + 7 * 8 + 4, 2 * 16},
5,
{{"& - -", 0},
{"& & -", 1},
{"& & &", 2}}};
BigFrequency lap_display{
{4, 8 * 16 + 4, 28 * 8, 52},
0};
Painter painter;
Button button_run_stop{
{72, 210, 96, 24},
-29
View File
@@ -1,29 +0,0 @@
/*
* 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.
*/
// dummy include file to avoid changing original source
#ifndef __UI_Arial12x12_H__
#define __UI_Arial12x12_H__
#define Arial12x12 (0)
#endif /*__UI_Arial12x12_H__*/
-110
View File
@@ -1,110 +0,0 @@
/*
* 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.
*/
// "HAL" display layer for Tetris code to run on PortaPack without its original ILI9341 functions
#ifndef __UI_SPI_TFT_ILI9341_H__
#define __UI_SPI_TFT_ILI9341_H__
ui::Painter painter;
static int x_pos{0};
static int y_pos{0};
static int fg_color;
static int bg_color;
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
// pp_colors must be in same order as enums above
static const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
// NB: ELIMINATED SPI_TFT_ILI9341 DISPLAY CLASS DUE TO GLOBAL OBJECT INITIALIZATION ISSUE WITH EXTERNAL APPS
static void claim(__FILE* x) {
(void)x;
};
static void cls() {
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
};
static void background(int color) {
bg_color = color;
};
static void foreground(int color) {
fg_color = color;
};
static void locate(int x, int y) {
x_pos = x;
y_pos = y;
};
static void set_orientation(int x) {
(void)x;
};
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) {
auto style = (fg_color == White) ? *ui::Theme::getInstance()->bg_darkest : *ui::Theme::getInstance()->bg_lightest;
painter.draw_string({x_pos, y_pos - 1}, style, str);
};
static void printf(std::string str, int v) {
if (str.find_first_of("%") != std::string::npos) {
str.resize(str.find_first_of("%")); // remove %d from end of string
}
printf(str + to_string_dec_uint(v));
};
#endif /*__UI_SPI_TFT_ILI9341_H__*/
+1 -1
View File
@@ -73,7 +73,7 @@ __attribute__((section(".external_app.app_tetris.application_information"), used
0xFF,
0xF1,
},
/*.icon_color = */ ui::Color::orange().v,
/*.icon_color = */ ui::Color::green().v,
/*.menu_location = */ app_location_t::GAMES,
/*.desired_menu_position = */ -1,
-220
View File
@@ -1,220 +0,0 @@
/*
* 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.
*/
// "HAL" layer for Tetris code to run on PortaPack without its original mbed OS
// (the dream here was to avoid modifying the original code)
#ifndef __UI_mbed_H__
#define __UI_mbed_H__
using Callback = void (*)(void);
#define wait_us(x) (void)0
#define wait(x) chThdSleepMilliseconds(x * 1000)
#define PullUp 1
enum {
dp0,
dp1,
dp2,
dp3,
dp4,
dp5,
dp6,
dp7,
dp8,
dp9,
dp10,
dp11,
dp12,
dp13,
dp14,
dp15,
dp16,
dp17,
dp18,
dp19,
dp20,
dp21,
dp22,
dp23,
dp24,
dp25,
};
static bool but_RIGHT;
static bool but_LEFT;
static bool but_UP;
static bool but_DOWN;
static bool but_SELECT;
//
// 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
// dp11 = joystick x --> left & right buttons
// dp13 = random number generator
//
//
// class AnalogIn {
// public:
// AnalogIn(uint32_t analog_input) {
// // FIXME - THIS CODE NEVER GETS EXECUTED!
// analog_input_ = analog_input;
// };
//
// // Tetris code only uses this function for dp13 - supposed to be a random number
// uint16_t read_u16() {
// return std::rand();
// };
//
// // Tetris code uses read() function for direction buttons only
// float read() {
// float retval = 0.5;
// switch (analog_input_) {
// case dp11:
// if (but_LEFT)
// retval = 0.0;
// else if (but_RIGHT)
// retval = 1.0;
// break;
//
// case dp10:
// if (but_UP)
// retval = 0.0;
// else if (but_DOWN)
// retval = 1.0;
// break;
// }
// return retval;
// };
//
// operator float() {
// return read();
// };
//
// private:
// uint32_t analog_input_{INT_MAX};
// };
//
// Timer Class
// (Timer object was used for unneeded button debouncing, so just returning 1000ms to indicate we've waited long enough)
//
class Timer {
public:
// NOTE: INITIALIZER CODE WON'T RUN
Timer() { (void)0; };
void reset() { (void)0; };
void start() { (void)0; }
uint32_t read_ms() { return 1000; };
private:
};
//
// Ticker Class
// (Ticker is timed callback, used for checking "joystick" directional switches and when time to move piece down a row)
//
// NB: Only one callback is supported per Ticker class instantiation
static Callback fall_timer_callback;
static uint32_t fall_timer_timeout;
static uint32_t fall_timer_counter;
static Callback dir_button_callback;
static void check_fall_timer() {
if (fall_timer_callback) {
if (++fall_timer_counter >= fall_timer_timeout) {
fall_timer_counter = 0;
fall_timer_callback();
}
}
}
class Ticker {
public:
// NOTE: INITIALIZER CODE WON'T RUN
Ticker() { (void)0; };
void attach(Callback func, double delay_sec) {
// 0.3 sec is requested only for button check -- kludge to use on_key callback for this one instead of timer
if (delay_sec == 0.3) {
dir_button_callback = func;
} else {
fall_timer_callback = func;
fall_timer_timeout = delay_sec * 60; // timer interrupts at 60 Hz
}
}
void detach() {
// shouldn't detach both, but don't know how to tell which object is which
dir_button_callback = nullptr;
fall_timer_callback = nullptr;
}
private:
};
//
// InterruptIn Class
// (just used for the Select button)
//
static Callback sel_button_callback;
static bool check_encoder(const EncoderEvent delta) {
(void)delta;
// TODO: consider adding ability to rotate Tetronimo via encoder too
return false;
}
static bool check_key(const KeyEvent key) {
auto switches_debounced = get_switches_state().to_ulong();
but_RIGHT = (switches_debounced & 0x01) != 0;
but_LEFT = (switches_debounced & 0x02) != 0;
but_DOWN = (switches_debounced & 0x04) != 0;
but_UP = (switches_debounced & 0x08) != 0;
but_SELECT = (switches_debounced & 0x10) != 0;
if (key == KeyEvent::Select) {
if (sel_button_callback)
sel_button_callback();
} else {
if (dir_button_callback)
dir_button_callback();
}
return true;
}
class InterruptIn {
public:
InterruptIn(int reg) {
// NOTE: INITIALIZER CODE WON'T RUN
(void)reg;
};
void fall(Callback func) { sel_button_callback = func; };
void mode(int v) { (void)v; };
private:
};
#endif /*__UI_mbed_H__*/
-548
View File
@@ -1,548 +0,0 @@
// Projekat Tetris
// by Vrnjak Lamija & Selimović Denis
// Elektrotehnički fakultet Sarajevo
// clang-format off
//////// 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"
#include "SPI_TFT_ILI9341.h"
#include "Arial12x12.h"
#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");
//
//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);
//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 - DELETED UNNEEDED JOYSTICK HYSTERESIS VARIABLES
//char leftBoundary = 1, rightBoundary = 5, downBoundary = 1, upBoundary = 5;// sada je ovo tipa char
//////// PORTAPACK
unsigned int score = 0; //stavio sam ovo unsigned int za veći opseg, mada je jako teško da se i int premaši, ali nmvz
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
//T - PURPLE
//S - GREEN
//Z - RED
//J - MAROON
//L - ORANGE
const int colors[8] = {White, Blue, Yellow, Purple, Green, Red, Maroon, Orange};
const short DIMENSION = 16;
const short DIMENSION_NEXT = 12;
short board[20][10] = {0}; //matrica boja, 0 - 7 indeksi boja
short figuresX[7][4] = {{0,0,0,0}, {0,0,1,1}, {0,1,1,1}, {1,1,0,0}, {0,1,0,1}, {1,1,1,0}, {1,1,1,0}};
short figuresY[7][4] = {{0,1,2,3}, {1,0,0,1}, {1,1,2,0}, {0,1,1,2}, {0,1,1,2}, {2,1,0,0}, {0,1,2,2}};
unsigned int GenerateRandomSeed() {
//////// PORTAPACK - USE RTC FOR SEED
return LPC_RTC->CTIME0;
//////// 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
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
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
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];
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) {
fillrect(60, lev * 70 + 50, 72, lev * 70 + 50 + 12, color);
}
// PORTAPACK - ADDED EXTRA LEVEL:
void ShowLevelMenu() {
//ovdje inicijalizujemo display
cls(); // brišemo prethodno
background(Black);
foreground(White);
locate(80, 50);
printf("LEVEL 1");
locate(80, 120);
printf("LEVEL 2");
locate(80, 190);
printf("LEVEL 3");
locate(80, 260);
printf("LEVEL 4");
DrawCursor(White, level);
}
//////// PORTAPACK
//////// PORTAPACK - USE BUTTONS VS JOYSTICK:
void ReadJoystickForLevel(){
unsigned char old = level;
if(but_UP){
(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
level = (level + 1) % 4;
}
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
}
//////// PORTAPACK
void EndPlay() {
joystick.detach();
score = 0;
firstTime = true;
gameStarted = false;
for(int i = 0; i < 20; i++) {
for(int j = 0; j < 10; j++) {
board[i][j] = 0;
}
}
//////// PORTAPACK - FIX TO REINITIALIZE SCREEN
// ShowLevelMenu();
// joystick.attach(&ReadJoystickForLevel, 0.3);
main();
//////// PORTAPACK
}
void StartGame()
{
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();
}
void copyCoordinates(short X[], short Y[], unsigned char index)
{
//umjesto one prošle metode za kopiranje, ova prima index, čisto da nam olakša život
for(int i = 0; i < 4; i++) {
X[i] = figuresX[index][i];
Y[i] = figuresY[index][i];
}
}
bool BottomEdge(int x){
return x > 19;
}
bool LeftEdge(int y){
return y < 0;
}
bool RightEdge(int y){
return y > 9;
}
bool OutOfBounds(int y, int x){
return y < 0 || y > 9 || x > 19;
}
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;
rect(i * DIMENSION, j * DIMENSION, (i + 1) * DIMENSION, (j + 1) * DIMENSION, Black);
}
}
}
//////// 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(){
// unsigned char r = rand() % 7 + 1;
// Initialize(r);
// }
void Tetromino(unsigned char c) {
Initialize(c);
}
void Initialize(unsigned char c) {
colorIndex = c;
boardX = 0;
boardY = 4; //3,4 ili 5 najbolje da vidimo kad imamo display
copyCoordinates(X, Y, c - 1);
}
void Rotate(){
short pivotX = X[1], pivotY = Y[1];
//prvi elemnti u matrici su pivoti oko koje rotiramo
short newX[4]; //pozicije blokova nakon rotiranja ako sve bude ok
short newY[4];
for(int i = 0; i < 4; i++){
short tmp = X[i], tmp2 = Y[i];
newX[i] = pivotX + pivotY - tmp2;
newY[i] = tmp + pivotX - pivotY;
if(OutOfBounds(boardY + newY[i], boardX + newX[i]) || board[boardX + newX[i]][boardY + newY[i]] != 0) return;
}
DeleteFigure();
for(int i = 0; i < 4; i++){
X[i] = newX[i];
Y[i] = newY[i];
}
DrawFigure();
}
void DrawFigure() {
for(int i = 0; i < 4; i++) {
//display je deklarisani display logy iz biblioteke one
//računamo gornji lijevi pixel po x i y
//donji desni dobijemo kad dodamo DIMENZIJU
//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;
fillrect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, colors[colorIndex]);
//ovo boji granice blokova u crno, možemo skloniti ako ti se ne sviđa
rect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, Black);
}
}
void DeleteFigure() {
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;
fillrect( upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, White);
PutBorders(upperLeftY, upperLeftX);
}
}
void OnAttached() {
//metoda se poziva kad figura prestanje da se krece
//popunimo matricu indeksom boje
for(int i = 0; i < 4; i++) {
board[boardX + X[i]][boardY + Y[i]] = colorIndex;
//btw board bi mogao biti niz tipa unsigned char, ali to ćemo vidjet kasnije
}
}
bool MoveDown(char delta = 1){
if(!InCollisionDown(delta)){
DeleteFigure();
boardX+=delta;
DrawFigure();
return true;
}
return false;
}
void MoveLeft(){
if(!InCollisionLeft()){
DeleteFigure();
boardY--;
DrawFigure();
}
}
void MoveRight(){
if(!InCollisionRight()){
DeleteFigure();
boardY++;
DrawFigure();
}
}
void SoftDrop() {
//ovo je funkcija za soft drop
//obrisemo figuru, postavimo novu poziciju dva reda ispod, nacrtamo figuru
DeleteFigure();
MoveDown(2);
DrawFigure();
//treba još vidjeti koje izmjene u tickeru trebaju
score += 2 * (level +1); //prema igrici koju smo igrali, dobije se 14 poena kad se uradi hard drop
ShowScore();
}
bool InCollisionDown(char delta = 1){
int newX, newY; //da bi bilo citljivije
for(int i = 0; i < 4; i++){
newX = boardX + X[i] + delta;
newY = boardY + Y[i];
if(BottomEdge(newX) || board[newX][newY] != 0){
return true;
}
//jedna figura je u koliziji ako
//pozicija na koju zelimo da pomjerimo bilo koji blok dotakne dno ili lijevu ili desnu ivicu ekrana
//ili ako je pozicija na koju zelimo da pomjerimo bilo koji od blokova vec zauzeta a da nije dio figure prije pomijeranja
}
return false;
}
bool InCollisionLeft(){
int newX, newY;
for(int i = 0; i < 4; i++){
newX = boardX + X[i];
newY = boardY + Y[i] - 1;
if(LeftEdge(newY) || board[newX][newY] != 0){
return true;
}
}
return false;
}
bool InCollisionRight(){
int newX, newY;
for(int i = 0; i < 4; i++){
newX = boardX + X[i];
newY = boardY + Y[i] + 1;
if(RightEdge(newY) || board[newX][newY] != 0){
return true;
}
}
return false;
}
// };
// Tetromino currentTetromino;
//////// PORTAPACK - USE BUTTONS VS JOYSTICK, AND ADDED PAUSE FEATURE:
void ReadJoystickForFigure() {
if(but_LEFT) {
MoveLeft();
}
else if(but_RIGHT) {
MoveRight();
}
else if(but_UP) {
pause_game();
}
else if(but_DOWN) {
SoftDrop();
}
}
//////// PORTAPACK
void CheckLines(short &firstLine, short &numberOfLines)
{
//vraća preko reference prvu liniju koja je popunjena do kraja, kao i takvih linija
firstLine = -1; //postavljen na -1 jer ako nema linija koje treba brisati ispod u UpdateBoard neće se ući u petlju
numberOfLines = 0;
for(int i = 19; i >= 0; i--) {
short temp = 0;
for(int j = 0; j < 10; j++) {
if(board[i][j] == 0) {
if(numberOfLines > 0) return;
break;
}//ako je makar jedna bijela, prekida se brojanje
temp++;
}
if(temp == 10) { //ako je temo došao do 10, niti jedna bijela - puna linija
numberOfLines++;
if(firstLine == -1) firstLine = i; //ovo mijenjamo samo prvi put
}
}
}
unsigned int UpdateScore (short numOfLines){
unsigned int newIncrement = 0;
switch(numOfLines) {
case 1 : newIncrement = 40; break;
case 2 : newIncrement = 100; break;
case 3 : newIncrement = 300; break;
case 4 : newIncrement = 1200; break;
default : newIncrement = 0; break; //update funkcije za score, još sam vratio ovo na 0
}
return newIncrement * (level + 1);
}
void UpdateBoard()
{
short firstLine, numberOfLines;
//pozivamo funkciju
do {
CheckLines(firstLine, numberOfLines);
for(int i = firstLine; i >= numberOfLines; i--) {
for(int j = 0; j < 10; j++) {
board[i][j] = board[i - numberOfLines][j];
board[i - numberOfLines][j] = 0;
short tmp = i - numberOfLines;
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)
rect( j * DIMENSION,i * DIMENSION, (j + 1) * DIMENSION , (i + 1) * DIMENSION , Black);
}
}
score += UpdateScore(numberOfLines);
}
while(numberOfLines != 0); //ovdje se mijenja globalna varijabla score
}
bool IsOver() {
for(int i = 0; i < 10; i++) {
if(board[0][i] != 0) return true;
}
return false;
}
void ShowGameOverScreen() {
//////// PORTAPACK - SKIP CLS
// cls();
// background(Black);
// foreground(White);
background(White);
foreground(Black);
//////// PORTAPACK
locate(60, 120);
printf("GAME OVER");
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) {
Tetromino(rand() % 7 + 1);
DrawFigure();
nextFigure = rand() % 7 + 1;
ShowNextFigure();
firstTime = false;
}
}
void PlayGame(){
InitGame();
if(!MoveDown()){
OnAttached();
UpdateBoard();
ShowScore();
Tetromino(nextFigure);
DrawFigure();
nextFigure = rand() % 7 + 1;
ShowNextFigure();
if(IsOver()) {
//ako je igra završena brišemo sve sa displey-a, prikazujemo poruku i score
//takođe moramo dettach-at ticker
game.detach();
ShowGameOverScreen(); //prikaz da je kraj igre, ima wait od 3s
EndPlay();
}
}
}
void OnTasterPressed(){
if(debounceTaster.read_ms() > 200) {
if(gameStarted){
Rotate();
}
else{
joystick.detach();
gameStarted = true;
StartGame(); //pocinje igra, prikazuje se tabla
joystick.attach(&ReadJoystickForFigure, 0.3);
game.attach(&PlayGame, delays[level]); //svakih nekoliko spusta figuru jedan red nize
}
debounceTaster.reset();
}
}
void SetTaster() {
taster.mode(PullUp); //mora se aktivirati pull up otpornik na tasteru joystick-a
taster.fall(&OnTasterPressed);
debounceTaster.reset();
debounceTaster.start();
}
int main() {
srand(GenerateRandomSeed());
Init();
ShowLevelMenu();
joystick.attach(&ReadJoystickForLevel, 0.3);
SetTaster();
//////// PORTAPACK: CAN'T HANG HERE IN MAYHEM OR WE WON'T GET ANY CALLBACKS
// while(1);
return 0;
//////// PORTAPACK
}
//////// PORTAPACK - ADDED PAUSE FEATURE:
void pause_game() {
game.detach();
joystick.detach();
locate(180, 200);
printf("PAUSED");
while ((get_switches_state().to_ulong() & 0x10) == 0); // wait for SELECT button to resume
printf(" ");
joystick.attach(&ReadJoystickForFigure, 0.3);
game.attach(&PlayGame, delays[level]); //svakih nekoliko spusta figuru jedan red nize
};
//////// PORTAPACK
+590 -11
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2024 Mark Thompson
* 2025 updates by RocketGod (https://betaskynet.com/)
*
* This file is part of PortaPack.
*
@@ -23,23 +24,567 @@
namespace ui::external_app::tetris {
#pragma GCC diagnostic push
// external code, so ignore warnings
#pragma GCC diagnostic ignored "-Weffc++"
#include "tetris.cpp"
#pragma GCC diagnostic pop
Ticker game;
Ticker joystick;
unsigned char level = 0;
const float delays[4] = {1.2, 0.7, 0.4, 0.25};
unsigned int score = 0;
bool firstTime = true;
bool gameStarted = false;
unsigned char nextFigure = 1;
short board[20][10] = {0};
const int colors[8] = {White, Blue, Yellow, Purple, Green, Red, Maroon, Orange};
const short DIMENSION = 16;
const short DIMENSION_NEXT = 12;
short figuresX[7][4] = {{0, 0, 0, 0}, {0, 0, 1, 1}, {0, 1, 1, 1}, {1, 1, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 0}, {1, 1, 1, 0}};
short figuresY[7][4] = {{0, 1, 2, 3}, {1, 0, 0, 1}, {1, 1, 2, 0}, {0, 1, 1, 2}, {0, 1, 1, 2}, {2, 1, 0, 0}, {0, 1, 2, 2}};
const Color pp_colors[] = {
Color::white(),
Color::blue(),
Color::yellow(),
Color::purple(),
Color::green(),
Color::red(),
Color::magenta(),
Color::orange(),
Color::black(),
};
Painter painter;
bool but_RIGHT = false;
bool but_LEFT = false;
bool but_UP = false;
bool but_DOWN = false;
bool but_SELECT = false;
static int x_pos{0};
static int y_pos{0};
static int rotation_state = 0;
static int fg_color;
static int bg_color;
static Callback fall_timer_callback = nullptr;
static uint32_t fall_timer_timeout = 0;
static uint32_t fall_timer_counter = 0;
static Callback dir_button_callback = nullptr;
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;
}
void locate(int x, int y) {
x_pos = x;
y_pos = y;
}
void fillrect(int x1, int y1, int x2, int y2, int color) {
painter.fill_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
}
void rect(int x1, int y1, int x2, int y2, int color) {
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
}
void printf(std::string str) {
auto style = (fg_color == White) ? *ui::Theme::getInstance()->bg_darkest : *ui::Theme::getInstance()->fg_light;
painter.draw_string({x_pos, y_pos - 1}, style, str);
}
void printf(std::string str, int v) {
if (str.find_first_of("%") != std::string::npos) {
str.resize(str.find_first_of("%"));
}
printf(str + to_string_dec_uint(v));
}
void check_fall_timer() {
if (fall_timer_callback) {
if (++fall_timer_counter >= fall_timer_timeout) {
fall_timer_counter = 0;
fall_timer_callback();
}
}
}
void Ticker::attach(Callback func, double delay_sec) {
if (delay_sec == 0.3) {
dir_button_callback = func;
} else {
fall_timer_callback = func;
fall_timer_timeout = delay_sec * 60;
}
}
void Ticker::detach() {
dir_button_callback = nullptr;
fall_timer_callback = nullptr;
}
unsigned int GenerateRandomSeed() {
return LPC_RTC->CTIME0;
}
void Init() {
}
void ShowScore() {
fillrect(165, 10, 235, 60, Black);
rect(165, 10, 235, 60, White);
locate(200, 35);
printf("%d", score);
}
void ShowNextFigure() {
fillrect(165, 70, 235, 130, Black);
rect(165, 70, 235, 130, 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];
fillrect(x, y, x + DIMENSION_NEXT, y + DIMENSION_NEXT, colors[nextFigure]);
rect(x, y, x + DIMENSION_NEXT, y + DIMENSION_NEXT, Black);
}
}
void DrawCursor(int color, unsigned char lev) {
fillrect(60, lev * 70 + 50, 72, lev * 70 + 50 + 12, color);
}
void ShowLevelMenu() {
cls();
background(Black);
foreground(White);
locate(80, 50);
printf("LEVEL 1");
locate(80, 120);
printf("LEVEL 2");
locate(80, 190);
printf("LEVEL 3");
locate(80, 260);
printf("LEVEL 4");
DrawCursor(White, level);
}
void ReadJoystickForLevel() {
unsigned char old = level;
if (but_UP) {
(level == 0) ? level = 3 : level--;
} else if (but_DOWN) {
level = (level + 1) % 4;
}
if (old != level) {
DrawCursor(Black, old);
DrawCursor(White, level);
}
}
void EndPlay() {
joystick.detach();
game.detach();
score = 0;
firstTime = true;
gameStarted = false;
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) {
board[i][j] = 0;
}
}
ShowLevelMenu();
joystick.attach(&ReadJoystickForLevel, 0.3);
}
void StartGame() {
cls();
background(Black);
foreground(White);
fillrect(0, 0, 162, 320, Black);
rect(162, 0, 164, 320, White);
fillrect(164, 0, 240, 320, Black);
ShowScore();
ShowNextFigure();
}
void copyCoordinates(short X[], short Y[], unsigned char index) {
for (int i = 0; i < 4; i++) {
X[i] = figuresX[index][i];
Y[i] = figuresY[index][i];
}
}
bool BottomEdge(int x) {
return x > 19;
}
bool LeftEdge(int y) {
return y < 0;
}
bool RightEdge(int y) {
return y > 9;
}
bool OutOfBounds(int y, int x) {
return y < 0 || y > 9 || x > 19;
}
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;
rect(i * DIMENSION, j * DIMENSION, (i + 1) * DIMENSION, (j + 1) * DIMENSION, Black);
}
}
}
short X[4];
short Y[4];
short boardX, boardY;
unsigned char colorIndex;
void Tetromino(unsigned char c) {
Initialize(c);
}
void Initialize(unsigned char c) {
colorIndex = c;
boardX = 0;
boardY = 4;
copyCoordinates(X, Y, c - 1);
rotation_state = 0;
}
void Rotate() {
short newX[4], newY[4];
int next_state = (rotation_state + 1) % 4;
if (colorIndex == 2) {
return;
}
const short kick_tests_I[4][5][2] = {
{{0, 0}, {-2, 0}, {1, 0}, {-2, -1}, {1, 2}},
{{0, 0}, {-1, 0}, {2, 0}, {-1, 2}, {2, -1}},
{{0, 0}, {2, 0}, {-1, 0}, {2, 1}, {-1, -2}},
{{0, 0}, {1, 0}, {-2, 0}, {1, -2}, {-2, 1}}};
const short kick_tests_other[4][5][2] = {
{{0, 0}, {-1, 0}, {-1, 1}, {0, -2}, {-1, -2}},
{{0, 0}, {1, 0}, {1, -1}, {0, 2}, {1, 2}},
{{0, 0}, {1, 0}, {1, 1}, {0, -2}, {1, -2}},
{{0, 0}, {-1, 0}, {-1, -1}, {0, 2}, {-1, 2}}};
bool is_I_tetromino = (colorIndex == 1);
const short(*kick_tests)[5][2] = is_I_tetromino ? kick_tests_I : kick_tests_other;
for (int test = 0; test < 5; test++) {
short kickX = kick_tests[rotation_state][test][0];
short kickY = kick_tests[rotation_state][test][1];
for (int i = 0; i < 4; i++) {
short tmpX = X[i] - X[1];
short tmpY = Y[i] - Y[1];
newX[i] = X[1] - tmpY;
newY[i] = Y[1] + tmpX;
int testX = boardX + newX[i] + kickX;
int testY = boardY + newY[i] + kickY;
if (OutOfBounds(testY, testX) || (testX >= 0 && board[testX][testY] != 0)) {
goto next_test;
}
}
DeleteFigure();
for (int i = 0; i < 4; i++) {
X[i] = newX[i];
Y[i] = newY[i];
}
boardX += kickX;
boardY += kickY;
rotation_state = next_state;
DrawFigure();
return;
next_test:
continue;
}
}
void DrawFigure() {
for (int i = 0; i < 4; i++) {
int upperLeftX = (boardX + X[i]) * DIMENSION, upperLeftY = (boardY + Y[i]) * DIMENSION;
fillrect(upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, colors[colorIndex]);
rect(upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, Black);
}
}
void DeleteFigure() {
for (int i = 0; i < 4; i++) {
short upperLeftX = (boardX + X[i]) * DIMENSION, upperLeftY = (boardY + Y[i]) * DIMENSION;
fillrect(upperLeftY, upperLeftX, upperLeftY + DIMENSION, upperLeftX + DIMENSION, Black);
PutBorders(upperLeftY, upperLeftX);
}
}
void OnAttached() {
for (int i = 0; i < 4; i++) {
board[boardX + X[i]][boardY + Y[i]] = colorIndex;
}
}
bool MoveDown(char delta) {
if (!InCollisionDown(delta)) {
DeleteFigure();
boardX += delta;
DrawFigure();
return true;
}
return false;
}
void MoveLeft() {
if (!InCollisionLeft()) {
DeleteFigure();
boardY--;
DrawFigure();
}
}
void MoveRight() {
if (!InCollisionRight()) {
DeleteFigure();
boardY++;
DrawFigure();
}
}
void SoftDrop() {
DeleteFigure();
MoveDown(2);
DrawFigure();
score += 2 * (level + 1);
ShowScore();
}
bool InCollisionDown(char delta) {
int newX, newY;
for (int i = 0; i < 4; i++) {
newX = boardX + X[i] + delta;
newY = boardY + Y[i];
if (BottomEdge(newX) || board[newX][newY] != 0) {
return true;
}
}
return false;
}
bool InCollisionLeft() {
int newX, newY;
for (int i = 0; i < 4; i++) {
newX = boardX + X[i];
newY = boardY + Y[i] - 1;
if (LeftEdge(newY) || board[newX][newY] != 0) {
return true;
}
}
return false;
}
bool InCollisionRight() {
int newX, newY;
for (int i = 0; i < 4; i++) {
newX = boardX + X[i];
newY = boardY + Y[i] + 1;
if (RightEdge(newY) || board[newX][newY] != 0) {
return true;
}
}
return false;
}
void ReadJoystickForFigure() {
if (but_LEFT) {
MoveLeft();
} else if (but_RIGHT) {
MoveRight();
} else if (but_UP) {
pause_game();
} else if (but_DOWN) {
SoftDrop();
} else if (but_SELECT) {
Rotate();
}
}
void CheckLines(short& firstLine, short& numberOfLines) {
firstLine = -1;
numberOfLines = 0;
for (int i = 19; i >= 0; i--) {
short temp = 0;
for (int j = 0; j < 10; j++) {
if (board[i][j] == 0) {
if (numberOfLines > 0) return;
break;
}
temp++;
}
if (temp == 10) {
numberOfLines++;
if (firstLine == -1) firstLine = i;
}
}
}
unsigned int UpdateScore(short numOfLines) {
unsigned int newIncrement = 0;
switch (numOfLines) {
case 1:
newIncrement = 40;
break;
case 2:
newIncrement = 100;
break;
case 3:
newIncrement = 300;
break;
case 4:
newIncrement = 1200;
break;
default:
newIncrement = 0;
break;
}
return newIncrement * (level + 1);
}
void UpdateBoard() {
short firstLine, numberOfLines;
do {
CheckLines(firstLine, numberOfLines);
for (int i = firstLine; i >= numberOfLines; i--) {
for (int j = 0; j < 10; j++) {
board[i][j] = board[i - numberOfLines][j];
board[i - numberOfLines][j] = 0;
}
}
fillrect(0, 0, 162, 320, Black);
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) {
if (board[i][j] != 0) {
fillrect(j * DIMENSION, i * DIMENSION, (j + 1) * DIMENSION, (i + 1) * DIMENSION, colors[board[i][j]]);
rect(j * DIMENSION, i * DIMENSION, (j + 1) * DIMENSION, (i + 1) * DIMENSION, Black);
}
}
}
score += UpdateScore(numberOfLines);
DrawFigure();
} while (numberOfLines != 0);
}
bool IsOver() {
for (int i = 0; i < 10; i++) {
if (board[0][i] != 0) return true;
}
return false;
}
void ShowGameOverScreen() {
background(Black);
foreground(White);
locate(60, 120);
printf("GAME OVER");
locate(40, 150);
printf("YOUR SCORE IS %d", score);
wait(5);
}
void InitGame() {
if (firstTime) {
Tetromino(rand() % 7 + 1);
DrawFigure();
nextFigure = rand() % 7 + 1;
ShowNextFigure();
firstTime = false;
}
}
void PlayGame() {
InitGame();
if (!MoveDown(1)) {
OnAttached();
UpdateBoard();
ShowScore();
Tetromino(nextFigure);
DrawFigure();
nextFigure = rand() % 7 + 1;
ShowNextFigure();
if (IsOver()) {
game.detach();
ShowGameOverScreen();
EndPlay();
}
}
}
void OnTasterPressed() {
static uint32_t debounce_counter = 0;
const uint32_t debounce_threshold = 12;
if (debounce_counter == 0) {
if (!gameStarted) {
joystick.detach();
gameStarted = true;
StartGame();
joystick.attach(&ReadJoystickForFigure, 0.3);
game.attach(&PlayGame, delays[level]);
}
debounce_counter = debounce_threshold;
} else if (debounce_counter > 0) {
debounce_counter--;
}
}
void pause_game() {
game.detach();
joystick.detach();
locate(180, 200);
printf("PAUSED");
while ((get_switches_state().to_ulong() & 0x10) == 0)
;
printf(" ");
joystick.attach(&ReadJoystickForFigure, 0.3);
game.attach(&PlayGame, delays[level]);
}
int main() {
std::srand(GenerateRandomSeed());
Init();
ShowLevelMenu();
joystick.attach(&ReadJoystickForLevel, 0.3);
return 0;
}
TetrisView::TetrisView(NavigationView& nav)
: nav_(nav) {
: nav_{nav} {
add_children({&dummy});
}
void TetrisView::on_show() {
}
void TetrisView::paint(Painter& painter) {
(void)painter;
if (!initialized) {
initialized = true;
std::srand(LPC_RTC->CTIME0);
main();
}
}
@@ -50,11 +595,45 @@ void TetrisView::frame_sync() {
}
bool TetrisView::on_encoder(const EncoderEvent delta) {
return check_encoder(delta);
if (!gameStarted) {
unsigned char old = level;
if (delta > 0) {
level = (level + 1) % 4;
} else if (delta < 0) {
(level == 0) ? level = 3 : level--;
}
if (old != level) {
DrawCursor(Black, old);
DrawCursor(White, level);
}
} else if (gameStarted && delta != 0) {
Rotate();
}
set_dirty();
return true;
}
bool TetrisView::on_key(const KeyEvent key) {
return check_key(key);
auto switches_debounced = get_switches_state().to_ulong();
but_RIGHT = (switches_debounced & 0x01) != 0;
but_LEFT = (switches_debounced & 0x02) != 0;
but_DOWN = (switches_debounced & 0x04) != 0;
but_UP = (switches_debounced & 0x08) != 0;
but_SELECT = (switches_debounced & 0x10) != 0;
if (key == KeyEvent::Select) {
if (!gameStarted) {
OnTasterPressed();
} else {
Rotate();
}
} else if (gameStarted) {
ReadJoystickForFigure();
} else {
ReadJoystickForLevel();
}
set_dirty();
return true;
}
} // namespace ui::external_app::tetris
} // namespace ui::external_app::tetris
+102 -3
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2024 Mark Thompson
* 2025 updates by RocketGod (https://betaskynet.com/)
*
* This file is part of PortaPack.
*
@@ -22,6 +23,7 @@
#ifndef __UI_TETRIS_H__
#define __UI_TETRIS_H__
#include "ui.hpp"
#include "ui_navigation.hpp"
#include "event_m0.hpp"
#include "message.hpp"
@@ -29,16 +31,113 @@
#include "random.hpp"
#include "lpc43xx_cpp.hpp"
#include "limits.h"
#include "ui_widget.hpp"
namespace ui::external_app::tetris {
enum {
White,
Blue,
Yellow,
Purple,
Green,
Red,
Maroon,
Orange,
Black,
};
extern const Color pp_colors[];
extern Painter painter;
extern bool but_RIGHT;
extern bool but_LEFT;
extern bool but_UP;
extern bool but_DOWN;
extern bool but_SELECT;
void cls();
void background(int color);
void foreground(int color);
void locate(int x, int y);
void fillrect(int x1, int y1, int x2, int y2, int color);
void rect(int x1, int y1, int x2, int y2, int color);
void printf(std::string str);
void printf(std::string str, int v);
#define wait(x) chThdSleepMilliseconds(x * 1000)
using Callback = void (*)(void);
class Ticker {
public:
Ticker() = default;
void attach(Callback func, double delay_sec);
void detach();
};
extern Ticker game;
extern Ticker joystick;
extern unsigned char level;
extern const float delays[4];
extern unsigned int score;
extern bool firstTime;
extern bool gameStarted;
extern unsigned char nextFigure;
extern short board[20][10];
extern const int colors[8];
extern const short DIMENSION;
extern const short DIMENSION_NEXT;
extern short figuresX[7][4];
extern short figuresY[7][4];
unsigned int GenerateRandomSeed();
void Init();
void ShowScore();
void ShowNextFigure();
void DrawCursor(int color, unsigned char lev);
void ShowLevelMenu();
void ReadJoystickForLevel();
void EndPlay();
void StartGame();
void copyCoordinates(short X[], short Y[], unsigned char index);
bool BottomEdge(int x);
bool LeftEdge(int y);
bool RightEdge(int y);
bool OutOfBounds(int y, int x);
void PutBorders(short x, short y);
void Tetromino(unsigned char c);
void Initialize(unsigned char c);
void Rotate();
void DrawFigure();
void DeleteFigure();
void OnAttached();
bool MoveDown(char delta);
void MoveLeft();
void MoveRight();
void SoftDrop();
bool InCollisionDown(char delta);
bool InCollisionLeft();
bool InCollisionRight();
void ReadJoystickForFigure();
void CheckLines(short& firstLine, short& numberOfLines);
unsigned int UpdateScore(short numOfLines);
void UpdateBoard();
bool IsOver();
void ShowGameOverScreen();
void InitGame();
void PlayGame();
void OnTasterPressed();
void pause_game();
class TetrisView : public View {
public:
TetrisView(NavigationView& nav);
void on_show() override;
std::string title() const override { return "Tetris"; };
std::string title() const override { return "Tetris"; }
void focus() override { dummy.focus(); };
void focus() override { dummy.focus(); }
void paint(Painter& painter) override;
void frame_sync();
bool on_encoder(const EncoderEvent event) override;
@@ -61,4 +160,4 @@ class TetrisView : public View {
} // namespace ui::external_app::tetris
#endif /*__UI_TETRIS_H__*/
#endif /* __UI_TETRIS_H__ */
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2025 HTotoo
*
* 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.hpp"
#include "ui_wefax_rx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::wefax_rx {
void initialize_app(ui::NavigationView& nav) {
nav.push<WeFaxRxView>();
}
} // namespace ui::external_app::wefax_rx
extern "C" {
__attribute__((section(".external_app.app_wefax_rx.application_information"), used)) application_information_t _application_information_wefax_rx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::wefax_rx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "WeFax",
/*.bitmap_data = */ {
0x00,
0x00,
0xFC,
0x07,
0x04,
0x0C,
0x04,
0x1C,
0x04,
0x3C,
0x84,
0x21,
0x84,
0x21,
0x84,
0x21,
0xF4,
0x2F,
0xF4,
0x2F,
0x84,
0x21,
0x84,
0x21,
0x84,
0x21,
0x04,
0x20,
0xFC,
0x3F,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::orange().v,
/*.menu_location = */ app_location_t::RX,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_wefaxrx */ {'P', 'W', 'F', 'X'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+152
View File
@@ -0,0 +1,152 @@
/*
* Copyright (C) 2025 HTotoo
*
* 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.
*/
/*
TODOS LATER:
- add load data from wav file (maybe to a separate app, not this)
- AGC?!?
- fix and enable sync detection
- auto start / stop bmp save on each image
*/
#include "ui_wefax_rx.hpp"
#include "audio.hpp"
#include "rtc_time.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "lcd_ili9341.hpp"
using namespace portapack;
using namespace modems;
using namespace ui;
namespace ui::external_app::wefax_rx {
void WeFaxRxView::focus() {
field_frequency.focus();
}
WeFaxRxView::WeFaxRxView(NavigationView& nav)
: nav_{nav} {
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({&rssi,
&field_rf_amp,
&field_lna,
&field_vga,
&field_volume,
&field_frequency,
&txt_status,
&labels,
&options_lpm,
&options_ioc,
&button_ss});
options_lpm.on_change = [this](size_t index, int32_t v) {
lpm_index = (uint8_t)index;
(void)v;
on_settings_changed();
};
options_ioc.on_change = [this](size_t index, int32_t v) {
ioc_index = (uint8_t)index;
(void)v;
on_settings_changed();
};
field_frequency.set_step(100);
field_frequency.on_edit_shown = [this]() {
paused = true;
};
field_frequency.on_edit_hidden = [this]() {
paused = false;
};
audio::output::start();
receiver_model.set_hidden_offset(WEFAX_FREQ_OFFSET);
receiver_model.enable();
txt_status.set("Waiting for signal.");
button_ss.on_select = [this](Button&) {
if (bmp.is_loaded()) {
bmp.close();
button_ss.set_text(LanguageHelper::currentMessages[LANG_START]);
return;
}
ensure_directory("/BMP");
bmp.create("/BMP/wefax_" + to_string_timestamp(rtc_time::now()) + ".bmp", WEFAX_PX_SIZE, 1);
button_ss.set_text(LanguageHelper::currentMessages[LANG_STOP]);
};
options_lpm.set_selected_index(lpm_index, false);
options_ioc.set_selected_index(ioc_index, true);
}
WeFaxRxView::~WeFaxRxView() {
stopping = true;
receiver_model.set_hidden_offset(0);
bmp.close();
receiver_model.disable();
baseband::shutdown();
audio::output::stop();
}
void WeFaxRxView::on_settings_changed() {
baseband::set_wefax_config(options_lpm.selected_index_value(), options_ioc.selected_index_value());
}
void WeFaxRxView::on_status(WeFaxRxStatusDataMessage msg) {
(void)msg;
std::string tmp = "";
if (msg.state == 0) {
tmp = "Waiting for signal.";
} else if (msg.state == 1) {
tmp = "Synced.";
} else if (msg.state == 2) {
tmp = "Image arriving.";
}
txt_status.set(tmp);
}
// this stores and displays the image. keep it as simple as you can. a bit more complexity will kill the sync
void WeFaxRxView::on_image(WeFaxRxImageDataMessage msg) {
if ((line_num) >= 320 - 4 * 16) line_num = 0; // for draw reset
for (uint16_t i = 0; i < msg.cnt; i += 1) {
Color pxl = {msg.image[i], msg.image[i], msg.image[i]};
bmp.write_next_px(pxl);
line_in_part++;
if (line_in_part == WEFAX_PX_SIZE) {
line_in_part = 0;
line_num++;
bmp.expand_y_delta(1);
}
uint16_t xpos = line_in_part / (WEFAX_PX_SIZE / 240);
if (xpos >= 240) xpos = 239;
line_buffer[xpos] = pxl;
if ((line_in_part == 0)) {
portapack::display.render_line({0, line_num + 4 * 16}, 240, line_buffer);
}
}
}
} // namespace ui::external_app::wefax_rx
+153
View File
@@ -0,0 +1,153 @@
/*
* Copyright (C) 2025 HTotoo
*
* 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.
*/
#ifndef __UI_WEFAX_RX_H__
#define __UI_WEFAX_RX_H__
#include "ui.hpp"
#include "ui_language.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "ui_geomap.hpp"
#include "ui_freq_field.hpp"
#include "ui_record_view.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "log_file.hpp"
#include "utility.hpp"
#include "ui_fileman.hpp"
#include "bmpfile.hpp"
#include "file_path.hpp"
using namespace ui;
namespace ui::external_app::wefax_rx {
#define WEFAX_PX_SIZE 840
// 1.900Hz is the usual center FM freq. , but as I added 300-Hz margin, + the truncated filter extended effect , in our case, we got better S/N if we use -2200 offset area. @Brumi
#define WEFAX_FREQ_OFFSET -2200
class WeFaxRxView : public View {
public:
WeFaxRxView(NavigationView& nav);
~WeFaxRxView();
void focus() override;
std::string title() const override { return "WeFax"; };
private:
void on_settings_changed();
void on_status(WeFaxRxStatusDataMessage msg);
void on_image(WeFaxRxImageDataMessage msg);
bool stopping = false;
uint8_t ioc_index{0};
uint8_t lpm_index{0};
uint16_t line_num = 0; // nth line
uint16_t line_in_part = 0; // got multiple parts of a line, so keep track of it
uint8_t delayer = 0;
ui::Color line_buffer[240];
std::filesystem::path filetohandle = "";
bool paused = false; // when freq field is shown for example, we need to pause
BMPFile bmp{};
NavigationView& nav_;
RxRadioState radio_state_{};
app_settings::SettingsManager settings_{
"rx_wefax",
app_settings::Mode::RX,
{
{"ioc_index"sv, &ioc_index},
{"lpm_index"sv, &lpm_index},
}};
RFAmpField field_rf_amp{
{13 * 8, 0 * 16}};
LNAGainField field_lna{
{15 * 8, 0 * 16}};
VGAGainField field_vga{
{18 * 8, 0 * 16}};
RSSI rssi{
{21 * 8, 0, 6 * 8, 4}};
AudioVolumeField field_volume{
{28 * 8, 0 * 16}};
RxFrequencyField field_frequency{
{0 * 8, 0 * 16},
nav_};
Labels labels{
{{1 * 8, 1 * 16}, "LPM:", Theme::getInstance()->fg_light->foreground},
{{13 * 8, 1 * 16}, "IOC:", Theme::getInstance()->fg_light->foreground},
};
OptionsField options_lpm{
{6 * 8, 1 * 16},
4,
{
{"60", 60},
{"90", 90},
{"100", 100},
{"120", 120},
{"180", 180},
{"240", 240},
}};
OptionsField options_ioc{
{18 * 8, 1 * 16},
4,
{
{"576", 0},
{"228", 1},
}};
Text txt_status{
{0 * 8, 2 * 16, 20 * 8, 16},
};
Button button_ss{
{190, 2 * 16, 5 * 8, 16},
LanguageHelper::currentMessages[LANG_START]};
MessageHandlerRegistration message_handler_stats{
Message::ID::WeFaxRxStatusData,
[this](const Message* const p) {
if (stopping || paused) return;
const auto message = *reinterpret_cast<const WeFaxRxStatusDataMessage*>(p);
on_status(message);
}};
MessageHandlerRegistration message_handler_image{
Message::ID::WeFaxRxImageData,
[this](const Message* const p) {
if (stopping || paused) return;
const auto message = *reinterpret_cast<const WeFaxRxImageDataMessage*>(p);
on_image(message);
}};
};
} // namespace ui::external_app::wefax_rx
#endif /*__UI_WEFAX_RX_H__*/
+3 -3
View File
@@ -84,7 +84,7 @@ bool Debounce::feed(const uint8_t bit) {
// (by toggling reported state every 1/2 of the delay time)
if (--repeat_ctr_ == 0) {
state_to_report_ = !state_to_report_;
repeat_ctr_ = REPEAT_SUBSEQUENT_DELAY / 2;
repeat_ctr_ = portapack::persistent_memory::ui_button_repeat_speed() ? REPEAT_SUBSEQUENT_DELAY_FAST / 2 : REPEAT_SUBSEQUENT_DELAY_NORMAL / 2;
return true;
}
}
@@ -96,7 +96,7 @@ bool Debounce::feed(const uint8_t bit) {
// if LONG_PRESS_DELAY is reached then finally report that switch is pressed and set flag
// indicating it was a LONG press
// (note that repeat_support and long_press support are mutually exclusive)
if (held_time_ >= LONG_PRESS_DELAY) {
if (held_time_ >= (portapack::persistent_memory::ui_button_long_press_delay() ? LONG_PRESS_DELAY_FAST : LONG_PRESS_DELAY_NORMAL)) {
pulse_upon_release_ = false;
long_press_occurred_ = true;
state_to_report_ = 1;
@@ -104,7 +104,7 @@ bool Debounce::feed(const uint8_t bit) {
}
} else if (repeat_enabled_ && !long_press_enabled_) {
// Repeat support -- 4 directional buttons only (unless long_press is enabled)
if (held_time_ >= REPEAT_INITIAL_DELAY) {
if (held_time_ >= (portapack::persistent_memory::ui_button_repeat_delay() ? REPEAT_INITIAL_DELAY_FAST : REPEAT_INITIAL_DELAY_NORMAL)) {
// Delay reached; trigger repeat code on NEXT tick
repeat_ctr_ = 1;
held_time_ = 0;
+7 -3
View File
@@ -30,9 +30,13 @@
#define DEBOUNCE_MASK ((1 << DEBOUNCE_COUNT) - 1)
// # of timer0 ticks before a held button starts being counted as repeated presses
#define REPEAT_INITIAL_DELAY 250
#define REPEAT_SUBSEQUENT_DELAY 92
#define LONG_PRESS_DELAY 800
#define REPEAT_INITIAL_DELAY_NORMAL 250
#define REPEAT_SUBSEQUENT_DELAY_NORMAL 92
#define LONG_PRESS_DELAY_NORMAL 800
#define REPEAT_INITIAL_DELAY_FAST 188
#define REPEAT_SUBSEQUENT_DELAY_FAST 66
#define LONG_PRESS_DELAY_FAST 555
class Debounce {
public:
+21 -8
View File
@@ -39,14 +39,22 @@ using namespace portapack;
namespace {
static constexpr std::array<baseband::AMConfig, 6> am_configs{{
static constexpr std::array<baseband::AMConfig, 12> am_configs{{
// we config here all the non COMMON parameters to each AM modulation type in RX.
{taps_9k0_decim_2, taps_9k0_dsb_channel, AMConfigureMessage::Modulation::DSB, audio_12k_hpf_300hz_config}, // AM DSB-C BW 9khz (+-4k5) commercial EU bandwidth .
{taps_6k0_decim_2, taps_6k0_dsb_channel, AMConfigureMessage::Modulation::DSB, audio_12k_hpf_300hz_config}, // AM DSB-C BW 6khz (+-3k0) narrow AM , ham equipments.
{taps_6k0_decim_2, taps_2k8_usb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config}, // SSB USB BW 2K8 (+ 2K8) SSB ham equipments.
{taps_6k0_decim_2, taps_2k8_lsb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config}, // SSB LSB BW 2K8 (- 2K8) SSB ham equipments.
{taps_6k0_decim_2, taps_0k7_usb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config}, // SSB USB BW 0K7 (+ 0K7) To get audio tone from CW Morse, assuming tx shifted +700hz aprox
{taps_6k0_decim_2, taps_2k6_usb_wefax_channel, AMConfigureMessage::Modulation::SSB_FM, audio_12k_lpf_1500hz_config}, // SSB USB+FM to demod. Subcarrier FM Audio Tones to get APT Weather Fax.
{taps_6k0_decim_1, taps_9k0_decim_2, taps_9k0_dsb_channel, AMConfigureMessage::Modulation::DSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_1}, // AM DSB-C BW 9khz (+-4k5) commercial EU bandwidth .
{taps_6k0_decim_1, taps_6k0_decim_2, taps_6k0_dsb_channel, AMConfigureMessage::Modulation::DSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_1}, // AM DSB-C BW 6khz (+-3k0) narrow AM , ham equipments.
{taps_6k0_decim_1, taps_6k0_decim_2, taps_2k8_usb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_1}, // SSB USB BW 2K8 (+ 2K8) SSB ham equipments.
{taps_6k0_decim_1, taps_6k0_decim_2, taps_2k8_lsb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_1}, // SSB LSB BW 2K8 (- 2K8) SSB ham equipments.
{taps_6k0_decim_1, taps_6k0_decim_2, taps_0k7_usb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_1}, // SSB USB BW 0K7 (+ 0K7) To get audio tone from CW Morse, assuming tx shifted +700hz aprox
{taps_6k0_decim_1, taps_6k0_decim_2, taps_2k6_usb_wefax_channel, AMConfigureMessage::Modulation::SSB_FM, audio_12k_lpf_1500hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_1}, // SSB USB+FM to demod. Subcarrier FM Audio Tones to get APT Weather Fax.
// below options for Waterfall zoom x 2
{taps_6k0_narrow_decim_1, taps_9k0_decim_2, taps_9k0_dsb_channel, AMConfigureMessage::Modulation::DSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_2}, // AM DSB-C BW 9khz (+-4k5) commercial EU bandwidth .
{taps_6k0_narrow_decim_1, taps_6k0_decim_2, taps_6k0_dsb_channel, AMConfigureMessage::Modulation::DSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_2}, // AM DSB-C BW 6khz (+-3k0) narrow AM , ham equipments.
{taps_6k0_narrow_decim_1, taps_6k0_decim_2, taps_2k8_usb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_2}, // SSB USB BW 2K8 (+ 2K8) SSB ham equipments.
{taps_6k0_narrow_decim_1, taps_6k0_decim_2, taps_2k8_lsb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_2}, // SSB LSB BW 2K8 (- 2K8) SSB ham equipments.
{taps_6k0_narrow_decim_1, taps_6k0_decim_2, taps_0k7_usb_channel, AMConfigureMessage::Modulation::SSB, audio_12k_hpf_300hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_2}, // SSB USB BW 0K7 (+ 0K7) To get audio tone from CW Morse, assuming tx shifted +700hz aprox
{taps_6k0_narrow_decim_1, taps_6k0_decim_2, taps_2k6_usb_wefax_channel, AMConfigureMessage::Modulation::SSB_FM, audio_12k_lpf_1500hz_config, (int)AMConfigureMessage::Zoom_waterfall::ZOOM_x_2}, // SSB USB+FM to demod. Subcarrier FM Audio Tones to get APT Weather Fax with waterfall zoom x 2 (we need taps_6k0_narrow_decim_1 to minimize aliasing)
}};
static constexpr std::array<baseband::NBFMConfig, 3> nbfm_configs{{
@@ -279,7 +287,12 @@ int32_t ReceiverModel::tuning_offset() {
void ReceiverModel::update_tuning_frequency() {
// TODO: use positive offset if freq < offset.
radio::set_tuning_frequency(target_frequency() + tuning_offset());
radio::set_tuning_frequency(target_frequency() + hidden_offset + tuning_offset());
}
void ReceiverModel::set_hidden_offset(rf::Frequency offset) {
hidden_offset = offset;
update_tuning_frequency();
}
void ReceiverModel::update_baseband_bandwidth() {
+3
View File
@@ -110,6 +110,8 @@ class ReceiverModel {
uint8_t normalized_headphone_volume() const;
void set_normalized_headphone_volume(uint8_t v);
void set_hidden_offset(rf::Frequency offset);
void enable();
void disable();
@@ -133,6 +135,7 @@ class ReceiverModel {
private:
settings_t settings_{};
bool enabled_ = false;
rf::Frequency hidden_offset = 0; // when we need to hide the offset from user, we set this. like when WeFax needs -300Hz.
int32_t tuning_offset();
@@ -53,13 +53,21 @@ class BoundFrequencyField : public FrequencyField {
};
on_edit = [this, &nav]() {
if (on_edit_shown)
on_edit_shown();
auto freq_view = nav.push<FrequencyKeypadView>(model->target_frequency());
freq_view->on_changed = [this](rf::Frequency f) {
set_value(f);
};
nav.set_on_pop([this]() {
if (on_edit_hidden)
on_edit_hidden();
});
};
}
std::function<void(void)> on_edit_shown{}; // fired, when the FrequencyKeypadView pops up
std::function<void(void)> on_edit_hidden{}; // fired, when the FrequencyKeypadView ended
// TODO: override set_step and update the rx model then call base.
};
+14 -16
View File
@@ -24,8 +24,6 @@
#include "ui_navigation.hpp"
#include "bmp_modal_warning.hpp"
#include "bmp_splash.hpp"
#include "event_m0.hpp"
#include "portapack_persistent_memory.hpp"
#include "portapack_shared_memory.hpp"
@@ -44,7 +42,6 @@
#include "ui_font_fixed_8x16.hpp"
#include "ui_freqman.hpp"
#include "ui_iq_trim.hpp"
#include "ui_level.hpp"
#include "ui_looking_glass_app.hpp"
#include "ui_mictx.hpp"
@@ -52,7 +49,7 @@
#include "ui_pocsag_tx.hpp"
#include "ui_rds.hpp"
#include "ui_recon.hpp"
#include "ui_scanner.hpp"
// #include "ui_scanner.hpp"
#include "ui_sd_over_usb.hpp"
#include "ui_search.hpp"
#include "ui_settings.hpp"
@@ -126,29 +123,20 @@ const NavigationView::AppList NavigationView::appList = {
{"microphone", "Microphone", HOME, Color::green(), &bitmap_icon_microphone, new ViewFactory<MicTXView>()},
{"lookingglass", "Looking Glass", HOME, Color::green(), &bitmap_icon_looking, new ViewFactory<GlassView>()},
{nullptr, "Utilities", HOME, Color::cyan(), &bitmap_icon_utilities, new ViewFactory<UtilitiesMenuView>()},
{nullptr, "Games", HOME, Color::purple(), &bitmap_icon_games, new ViewFactory<GamesMenuView>()},
{nullptr, "Games", HOME, Color::cyan(), &bitmap_icon_games, new ViewFactory<GamesMenuView>()},
{nullptr, "Settings", HOME, Color::cyan(), &bitmap_icon_setup, new ViewFactory<SettingsMenuView>()},
/* RX ********************************************************************/
{"adsbrx", "ADS-B", RX, Color::green(), &bitmap_icon_adsb, new ViewFactory<ADSBRxView>()},
{"ais", "AIS Boats", RX, Color::green(), &bitmap_icon_ais, new ViewFactory<AISAppView>()},
{"aprsrx", "APRS", RX, Color::green(), &bitmap_icon_aprs, new ViewFactory<APRSRXView>()},
{"audio", "Audio", RX, Color::green(), &bitmap_icon_speaker, new ViewFactory<AnalogAudioView>()},
//{"blecomm", "BLE Comm", RX, ui::Color::orange(), &bitmap_icon_btle, new ViewFactory<BLECommView>()},
{"blerx", "BLE Rx", RX, Color::green(), &bitmap_icon_btle, new ViewFactory<BLERxView>()},
{"ert", "ERT Meter", RX, Color::green(), &bitmap_icon_ert, new ViewFactory<ERTAppView>()},
{"level", "Level", RX, Color::green(), &bitmap_icon_options_radio, new ViewFactory<LevelView>()},
{"pocsag", "POCSAG", RX, Color::green(), &bitmap_icon_pocsag, new ViewFactory<POCSAGAppView>()},
{"radiosonde", "Radiosnde", RX, Color::green(), &bitmap_icon_sonde, new ViewFactory<SondeView>()},
{"scanner", "Scanner", RX, Color::green(), &bitmap_icon_scanner, new ViewFactory<ScannerView>()},
{"search", "Search", RX, Color::yellow(), &bitmap_icon_search, new ViewFactory<SearchView>()},
{"subghzd", "SubGhzD", RX, Color::yellow(), &bitmap_icon_remote, new ViewFactory<SubGhzDView>()},
{"weather", "Weather", RX, Color::green(), &bitmap_icon_thermometer, new ViewFactory<WeatherView>()},
//{"fskrx", "FSK RX", RX, Color::yellow(), &bitmap_icon_remote, new ViewFactory<FskxRxMainView>()}, //for JT
//{"dmr", "DMR", RX, Color::dark_grey(), &bitmap_icon_dmr, new ViewFactory<NotImplementedView>()},
//{"sigfox", "SIGFOX", RX, Color::dark_grey(), &bitmap_icon_fox, new ViewFactory<NotImplementedView>()},
//{"lora", "LoRa", RX, Color::dark_grey(), &bitmap_icon_lora, new ViewFactory<NotImplementedView>()},
//{"sstv", "SSTV", RX, Color::dark_grey(), &bitmap_icon_sstv, new ViewFactory<NotImplementedView>()},
//{"tetra", "TETRA", RX, Color::dark_grey(), &bitmap_icon_tetra, new ViewFactory<NotImplementedView>()},
/* TX ********************************************************************/
{"aprstx", "APRS TX", TX, ui::Color::green(), &bitmap_icon_aprs, new ViewFactory<APRSTXView>()},
{"bht", "BHT Xy/EP", TX, ui::Color::green(), &bitmap_icon_bht, new ViewFactory<BHTView>()},
@@ -1049,7 +1037,12 @@ SplashScreenView::SplashScreenView(NavigationView& nav)
void SplashScreenView::paint(Painter&) {
if (!portapack::display.draw_bmp_from_sdcard_file({0, 0}, splash_dot_bmp))
// ^ try draw bmp file from sdcard at (0,0), and the (0,0) already bypassed the status bar, so actual pos is (0, STATUS_BAR_HEIGHT)
portapack::display.draw_bmp_from_bmp_hex_arr({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, (const uint8_t[]){0x29, 0x18, 0x16});
portapack::display.draw_bitmap({screen_width / 2 - 120,
screen_height / 2},
bitmap_titlebar_image.size,
bitmap_titlebar_image.data,
Theme::getInstance()->bg_darkest->foreground,
Theme::getInstance()->bg_darkest->background, 3);
// ^ draw BMP HEX arr in firmware, note that the BMP HEX arr only cover the image part (instead of fill the screen with background, this position is located it in the center)
}
@@ -1144,7 +1137,12 @@ ModalMessageView::ModalMessageView(
}
void ModalMessageView::paint(Painter& painter) {
if (!compact) portapack::display.draw_bmp_from_bmp_hex_arr({100, 48}, modal_warning_bmp, (const uint8_t[]){0, 0, 0});
if (!compact) portapack::display.draw_bitmap({screen_width / 2 - 3 * 16 / 2,
screen_height / 2 - 3 * 16 / 2 - 100},
bitmap_icon_utilities.size,
bitmap_icon_utilities.data,
Theme::getInstance()->bg_darkest->foreground,
Theme::getInstance()->bg_darkest->background, 3);
// Break lines.
auto lines = split_string(message_, '\n');
+8
View File
@@ -668,6 +668,14 @@ DeclareTargets(POSK ookstream)
### WeFax Rx
set(MODE_CPPSRC
proc_wefaxrx.cpp
)
DeclareTargets(PWFX wefaxrx)
### HackRF "factory" firmware
add_custom_command(
+3 -3
View File
@@ -112,9 +112,9 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& message) {
channel_filter_low_f = message.channel_filter.low_frequency_normalized * channel_filter_input_fs;
channel_filter_high_f = message.channel_filter.high_frequency_normalized * channel_filter_input_fs;
channel_filter_transition = message.channel_filter.transition_normalized * channel_filter_input_fs;
channel_spectrum.set_decimation_factor(1.0f);
// modulation_ssb = (message.modulation == AMConfigureMessage::Modulation::SSB); // originally we had just 2 AM types of demod. (DSB , SSB)
modulation_ssb = (int)message.modulation; // now sending by message , 3 types of AM demod : enum class Modulation : int32_t {DSB = 0, SSB = 1, SSB_FM = 2}
modulation_ssb = (int)message.modulation; // now sending by message , 3 types of AM demod : enum class Modulation : int32_t {DSB = 0, SSB = 1, SSB_FM = 2}
channel_spectrum.set_decimation_factor(message.channel_spectrum_decimation_factor);
audio_output.configure(message.audio_hpf_lpf_config); // hpf in all AM demod modes (AM-6K/9K, USB/LSB,DSB), except Wefax (lpf there).
configured = true;
+186
View File
@@ -0,0 +1,186 @@
/*
* Copyright (C) 2025 Brumi, HTotoo
*
* 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 "proc_wefaxrx.hpp"
#include "sine_table_int8.hpp"
#include "portapack_shared_memory.hpp"
#include "audio_dma.hpp"
#include "math.h"
#include "event_m4.hpp"
#include "fxpt_atan2.hpp"
#include <cstdint>
#include <cstddef>
#define STARTSIGNAL_TH 0.33
#define STARTSIGNAL_NEEDCNT 110
#define STARTSIGNAL_MAXBAD 20
#define WEFAX_PX_SIZE 840.0
// updates the per pixel timers
void WeFaxRx::update_params() {
switch (ioc_mode) {
case 1:
freq_start_tone = 675;
break;
default:
case 0:
freq_start_tone = 300;
break;
}
// 840 px / line with line start
pxRem = (double)channel_filter_input_fs / ((lpm / 60.0) * WEFAX_PX_SIZE);
samples_per_pixel = pxRem;
pxRem -= samples_per_pixel;
pxRoll = 0;
status_message.state = 0;
shared_memory.application_queue.push(status_message);
}
void WeFaxRx::execute(const buffer_c8_t& buffer) {
// This is called at 3072000 / 2048 = 1500Hz
if (!configured) return;
const auto decim_0_out = decim_0.execute(buffer, dst_buffer);
const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer);
channel_spectrum.feed(decim_1_out, channel_filter_low_f, channel_filter_high_f, channel_filter_transition);
const auto decim_2_out = decim_2.execute(decim_1_out, dst_buffer);
const auto channel_out = channel_filter.execute(decim_2_out, dst_buffer);
feed_channel_stats(channel_out);
auto audio = demod_ssb_fm.execute(channel_out, audio_buffer);
audio_compressor.execute_in_place(audio);
audio_output.write(audio);
for (size_t c = 0; c < audio.count; c++) {
if (status_message.state == 0 && false) { // disabled this due to so sensitive to noise
// first look for the sync!
if (audio.p[c] <= STARTSIGNAL_TH && audio.p[c] >= 0.0001) {
sync_cnt++;
if (sync_cnt >= STARTSIGNAL_NEEDCNT) {
status_message.state = 1;
shared_memory.application_queue.push(status_message);
sync_cnt = 0;
syncnot_cnt = 0;
}
} else {
syncnot_cnt++;
if (syncnot_cnt >= STARTSIGNAL_MAXBAD) {
sync_cnt = 0;
syncnot_cnt = 0;
}
}
} else {
cnt++;
if (cnt >= (samples_per_pixel + (uint32_t)pxRoll)) { // got a pixel
cnt = 0;
if (pxRoll >= 1) pxRoll -= 1.0;
pxRoll += pxRem;
if (image_message.cnt < 400) {
if (audio.p[c] >= 0.68) {
image_message.image[image_message.cnt++] = 255;
} else if (audio.p[c] >= 0.45) {
image_message.image[image_message.cnt++] = (uint8_t)(((audio.p[c] - 0.45f) * 1108));
} else {
image_message.image[image_message.cnt++] = 0;
}
}
if (image_message.cnt >= 399) {
shared_memory.application_queue.push(image_message);
image_message.cnt = 0;
if (status_message.state != 2) {
status_message.state = 2;
shared_memory.application_queue.push(status_message);
}
}
}
}
}
}
void WeFaxRx::on_message(const Message* const message) {
switch (message->id) {
case Message::ID::UpdateSpectrum:
case Message::ID::SpectrumStreamingConfig:
channel_spectrum.on_message(message);
break;
case Message::ID::WeFaxRxConfigure:
configure(*reinterpret_cast<const WeFaxRxConfigureMessage*>(message));
break;
case Message::ID::CaptureConfig:
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
break;
default:
break;
}
}
void WeFaxRx::configure(const WeFaxRxConfigureMessage& message) {
constexpr size_t decim_0_input_fs = baseband_fs;
constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0.decimation_factor;
constexpr size_t decim_1_input_fs = decim_0_output_fs;
constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1.decimation_factor;
constexpr size_t decim_2_input_fs = decim_1_output_fs;
constexpr size_t decim_2_output_fs = decim_2_input_fs / decim_2_decimation_factor;
channel_filter_input_fs = decim_2_output_fs;
// const size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor;
decim_0.configure(taps_6k0_decim_0.taps);
decim_1.configure(taps_6k0_decim_1.taps);
decim_2.configure(taps_6k0_decim_2.taps, decim_2_decimation_factor);
channel_filter.configure(taps_2k6_usb_wefax_channel.taps, channel_filter_decimation_factor);
channel_filter_low_f = taps_2k6_usb_wefax_channel.low_frequency_normalized * channel_filter_input_fs;
channel_filter_high_f = taps_2k6_usb_wefax_channel.high_frequency_normalized * channel_filter_input_fs;
channel_filter_transition = taps_2k6_usb_wefax_channel.transition_normalized * channel_filter_input_fs;
channel_spectrum.set_decimation_factor(1.0f);
audio_output.configure(audio_12k_lpf_1500hz_config); // hpf in all AM demod modes (AM-6K/9K, USB/LSB,DSB), except Wefax (lpf there).
lpm = message.lpm;
ioc_mode = message.ioc;
update_params();
configured = true;
}
void WeFaxRx::capture_config(const CaptureConfigMessage& message) {
if (message.config) {
audio_output.set_stream(std::make_unique<StreamInput>(message.config));
} else {
audio_output.set_stream(nullptr);
}
}
int main() {
audio::dma::init_audio_out();
EventDispatcher event_dispatcher{std::make_unique<WeFaxRx>()};
event_dispatcher.run();
return 0;
}
+104
View File
@@ -0,0 +1,104 @@
/*
* Copyright (C) 2025 Brumi, HTotoo
*
* 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.
*/
#ifndef __PROC_WEFAXRX_H__
#define __PROC_WEFAXRX_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include "rssi_thread.hpp"
#include "dsp_decimate.hpp"
#include "dsp_demodulate.hpp"
#include "dsp_iir.hpp"
#include "audio_compressor.hpp"
#include "audio_output.hpp"
#include "spectrum_collector.hpp"
#include <cstdint>
class WeFaxRx : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const message) override;
private:
void update_params();
// todo rethink
uint8_t lpm = 120; // 60, 90, 100, 120, 180, 240 lpm
uint8_t ioc_mode = 0; // 0 - ioc576, 1 - ioc 288, 2 - colour fax
uint32_t samples_per_pixel = 0;
// not yet used:
uint32_t time_start_tone = 3000; // 3s - 5s
uint32_t freq_start_tone = 300; // 300hz for ioc576 675hz for ioc288, 200hz for colour fax
uint32_t freq_stop_tone = 450; // 450hz for the 3-5s stop tone
// to exactly match the pixel / samples.
double pxRem = 0; // if has remainder, it'll store it
double pxRoll = 0; // summs remainders, so won't misalign
uint32_t cnt = 0; // signal counter
uint16_t sync_cnt = 0;
uint16_t syncnot_cnt = 0;
static constexpr size_t baseband_fs = 3072000;
static constexpr size_t decim_2_decimation_factor = 4;
static constexpr size_t channel_filter_decimation_factor = 1;
std::array<complex16_t, 512> dst{};
const buffer_c16_t dst_buffer{
dst.data(),
dst.size()};
std::array<float, 32> audio{};
const buffer_f32_t audio_buffer{
audio.data(),
audio.size()};
size_t channel_filter_input_fs = 0;
dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0{};
dsp::decimate::FIRC16xR16x32Decim8 decim_1{};
dsp::decimate::FIRAndDecimateComplex decim_2{};
dsp::decimate::FIRAndDecimateComplex channel_filter{};
int32_t channel_filter_low_f = 0;
int32_t channel_filter_high_f = 0;
int32_t channel_filter_transition = 0;
bool configured{false};
dsp::demodulate::SSB_FM demod_ssb_fm{}; // added for Wfax mode.
FeedForwardCompressor audio_compressor{};
AudioOutput audio_output{};
SpectrumCollector channel_spectrum{};
void configure(const WeFaxRxConfigureMessage& message);
void capture_config(const CaptureConfigMessage& message);
WeFaxRxStatusDataMessage status_message{0};
WeFaxRxImageDataMessage image_message{};
/* NB: Threads should be the last members in the class definition. */
BasebandThread baseband_thread{baseband_fs, this, baseband::Direction::Receive};
RSSIThread rssi_thread{};
};
#endif /*__PROC_WEFAXRX_H__*/
+1 -1
View File
@@ -282,4 +282,4 @@ bool BMPFile::expand_y(uint32_t new_y) {
seek(0, curry + 1); // seek to the begin of the new chunk
}
return true;
}
}
+45
View File
@@ -512,6 +512,51 @@ constexpr fir_taps_real<32> taps_6k0_decim_1{
}},
};
// IFIR prototype filter: fs=384000, pass=3000, stop=33000, decim=8, fout=48000
// Narrower taps_6k0_decim_1IFIR version to avoid LCD waterfall aliasing in AMFM Wefax in ZOOM X 2 (means spectrum decimation factor x2)
// It has BW -3dB's of +-9Khz, Stop band from 33khz onwards -60 dB's , then we can use in all AM modes (DSB, SSB,CW )
constexpr fir_taps_real<32> taps_6k0_narrow_decim_1{
.low_frequency_normalized = -3000.0f / 384000.0f,
.high_frequency_normalized = 3000.0f / 384000.0f,
.transition_normalized = 30000.0f / 384000.0f,
.taps = {{
58,
80,
138,
219,
326,
461,
622,
807,
1011,
1224,
1438,
1640,
1820,
1966,
2069,
2122,
2122,
2069,
1966,
1820,
1640,
1438,
1224,
1011,
807,
622,
461,
326,
219,
138,
80,
58,
}},
};
// IFIR prototype filter: fs=48000, pass=3000, stop=6700, decim=4, fout=12000
constexpr fir_taps_real<32> taps_6k0_decim_2{
.low_frequency_normalized = -3000.0f / 48000.0f,
+54 -25
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* copyleft 2025 Whiterose of the Dark Army
*
* This file is part of PortaPack.
*
@@ -646,31 +647,58 @@ void ILI9341::draw_bitmap(
const ui::Size size,
const uint8_t* const pixels,
const ui::Color foreground,
const ui::Color background) {
// Not a transparent background
if (ui::Color::magenta().v != background.v) {
lcd_start_ram_write(p, size);
const ui::Color background,
uint8_t zoom_level) {
if (zoom_level <= 1) {
// Not a transparent background
if (ui::Color::magenta().v != background.v) {
lcd_start_ram_write(p, size);
const size_t count = size.width() * size.height();
for (size_t i = 0; i < count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
io.lcd_write_pixel(pixel ? foreground : background);
}
} else {
int x = p.x();
int y = p.y();
int maxX = x + size.width();
const size_t count = size.width() * size.height();
for (size_t i = 0; i < count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
if (pixel) {
draw_pixel(ui::Point(x, y), foreground);
const size_t count = size.width() * size.height();
for (size_t i = 0; i < count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
io.lcd_write_pixel(pixel ? foreground : background);
}
// Move to the next pixel
x++;
if (x >= maxX) {
x = p.x();
y++;
} else {
// transparent bg
int x = p.x();
int y = p.y();
int maxX = x + size.width();
const size_t count = size.width() * size.height();
for (size_t i = 0; i < count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
if (pixel) {
draw_pixel(ui::Point(x, y), foreground);
}
// move to next px
x++;
if (x >= maxX) {
x = p.x();
y++;
}
}
}
} else { // zoom
// dot to square
for (int y = 0; y < size.height(); y++) {
for (int x = 0; x < size.width(); x++) {
// pos
size_t bit_index = y * size.width() + x;
int byte_index = bit_index >> 3;
int bit_pos = bit_index & 0x7;
// val
const auto pixel = pixels[byte_index] & (1U << bit_pos);
/* ^ the byte_index-th bit AKA current bit
^ current px in current byte*/
if (pixel || background.v != ui::Color::magenta().v) {
fill_rectangle(
{p.x() + x * zoom_level, p.y() + y * zoom_level,
zoom_level, zoom_level},
pixel ? foreground : background);
}
}
}
}
@@ -680,8 +708,9 @@ void ILI9341::draw_glyph(
const ui::Point p,
const ui::Glyph& glyph,
const ui::Color foreground,
const ui::Color background) {
draw_bitmap(p, glyph.size(), glyph.pixels(), foreground, background);
const ui::Color background,
uint8_t zoom_level) {
draw_bitmap(p, glyph.size(), glyph.pixels(), foreground, background, zoom_level);
}
void ILI9341::scroll_set_area(
+4 -2
View File
@@ -86,13 +86,15 @@ class ILI9341 {
const ui::Size size,
const uint8_t* const data,
const ui::Color foreground,
const ui::Color background);
const ui::Color background,
uint8_t zoom_level = 1);
void draw_glyph(
const ui::Point p,
const ui::Glyph& glyph,
const ui::Color foreground,
const ui::Color background);
const ui::Color background,
uint8_t zoom_level = 1);
/*** Scrolling ***
* Scrolling support is implemented in the ILI9341 driver. Basically a region
+42 -2
View File
@@ -127,6 +127,10 @@ class Message {
FreqChangeCommand = 70,
I2CDevListChanged = 71,
LightData = 72,
WeFaxRxConfigure = 73,
WeFaxRxStatusData = 74,
WeFaxRxImageData = 75,
MAX
};
@@ -587,6 +591,10 @@ class AMConfigureMessage : public Message {
SSB = 1,
SSB_FM = 2, // Added new for RX Wefax mode, to demodulate APT signal ,FM modulated inside audio subcarrier tones, and then up broadcasted in SSB USB .
};
enum class Zoom_waterfall : size_t {
ZOOM_x_1 = 1,
ZOOM_x_2 = 2,
};
constexpr AMConfigureMessage(
const fir_taps_real<24> decim_0_filter,
@@ -594,14 +602,17 @@ class AMConfigureMessage : public Message {
const fir_taps_real<32> decim_2_filter,
const fir_taps_complex<64> channel_filter,
const Modulation modulation,
const iir_biquad_config_t audio_hpf_lpf_config)
const iir_biquad_config_t audio_hpf_lpf_config,
const size_t channel_spectrum_decimation_factor)
: Message{ID::AMConfigure},
decim_0_filter(decim_0_filter),
decim_1_filter(decim_1_filter),
decim_2_filter(decim_2_filter),
channel_filter(channel_filter),
modulation{modulation},
audio_hpf_lpf_config(audio_hpf_lpf_config) {
audio_hpf_lpf_config(audio_hpf_lpf_config),
channel_spectrum_decimation_factor(channel_spectrum_decimation_factor) {
}
const fir_taps_real<24> decim_0_filter;
@@ -610,6 +621,7 @@ class AMConfigureMessage : public Message {
const fir_taps_complex<64> channel_filter;
const Modulation modulation;
const iir_biquad_config_t audio_hpf_lpf_config;
const size_t channel_spectrum_decimation_factor;
};
// TODO: Put this somewhere else, or at least the implementation part.
@@ -1438,4 +1450,32 @@ class I2CDevListChangedMessage : public Message {
: Message{ID::I2CDevListChanged} {}
};
class WeFaxRxConfigureMessage : public Message {
public:
constexpr WeFaxRxConfigureMessage(uint8_t lpm, uint8_t ioc)
: Message{ID::WeFaxRxConfigure},
lpm{lpm},
ioc{ioc} {
}
uint8_t lpm = 120;
uint8_t ioc = 0;
};
class WeFaxRxStatusDataMessage : public Message {
public:
constexpr WeFaxRxStatusDataMessage(uint8_t state)
: Message{ID::WeFaxRxStatusData},
state{state} {
}
uint8_t state = 0;
};
class WeFaxRxImageDataMessage : public Message {
public:
constexpr WeFaxRxImageDataMessage()
: Message{ID::WeFaxRxImageData} {}
uint8_t image[400]{0};
uint32_t cnt = 0;
};
#endif /*__MESSAGE_H__*/
+42 -181
View File
@@ -103,7 +103,7 @@ struct ui_config_t {
uint8_t show_gui_return_icon : 1;
uint8_t load_app_settings : 1;
uint8_t save_app_settings : 1;
uint8_t show_large_qr_code : 1;
uint8_t UNUSED_7 : 1; // Deprecated, but bit can be set by older firmware
bool disable_touchscreen : 1;
bool hide_clock : 1;
@@ -134,9 +134,9 @@ struct ui_config2_t {
bool hide_numeric_battery : 1;
bool hide_battery_icon : 1;
bool override_batt_calc : 1;
bool UNUSED_4 : 1;
bool UNUSED_5 : 1;
bool UNUSED_6 : 1;
bool button_repeat_delay : 1;
bool button_repeat_speed : 1;
bool button_long_press_delay : 1;
uint8_t theme_id;
uint8_t PLACEHOLDER_3;
@@ -480,6 +480,10 @@ void persist() {
} /* namespace cache */
uint32_t get_data_structure_version() {
return data->structure_version;
}
uint32_t pmem_data_word(uint32_t index) {
return backup_ram->pmem_data_word(index);
}
@@ -562,6 +566,10 @@ void set_afsk_space(const int32_t new_value) {
data->afsk_space_freq = afsk_freq_range.clip(new_value);
}
uint32_t get_modem_def_index() {
return data->modem_def_index;
}
int32_t modem_baudrate() {
modem_baudrate_range.reset_if_outside(data->modem_baudrate, modem_baudrate_reset_value);
return data->modem_baudrate;
@@ -571,13 +579,11 @@ void set_modem_baudrate(const int32_t new_value) {
data->modem_baudrate = modem_baudrate_range.clip(new_value);
}
/*
int32_t modem_bw() {
modem_bw_range.reset_if_outside(data->modem_bw, modem_bw_reset_value);
return data->modem_bw;
}
void set_modem_bw(const int32_t new_value) {
/*void set_modem_bw(const int32_t new_value) {
data->modem_bw = modem_bw_range.clip(new_value);
}
*/
@@ -603,10 +609,6 @@ bool show_gui_return_icon() { // add return icon in touchscreen menu
return data->ui_config.show_gui_return_icon != 0;
}
bool show_bigger_qr_code() { // show bigger QR code
return data->ui_config.show_large_qr_code != 0;
}
bool disable_touchscreen() { // Option to disable touch screen
return data->ui_config.disable_touchscreen;
}
@@ -676,16 +678,20 @@ void set_gui_return_icon(bool v) {
data->ui_config.show_gui_return_icon = v ? 1 : 0;
}
bool load_app_settings() {
return data->ui_config.load_app_settings;
}
void set_load_app_settings(bool v) {
data->ui_config.load_app_settings = v ? 1 : 0;
}
void set_save_app_settings(bool v) {
data->ui_config.save_app_settings = v ? 1 : 0;
bool save_app_settings() {
return data->ui_config.save_app_settings;
}
void set_show_bigger_qr_code(bool v) {
data->ui_config.show_large_qr_code = v ? 1 : 0;
void set_save_app_settings(bool v) {
data->ui_config.save_app_settings = v ? 1 : 0;
}
void set_disable_touchscreen(bool v) {
@@ -817,6 +823,9 @@ void set_recon_config_bit(uint8_t rc_bit, bool v) {
auto bit_mask = 1LL << rc_bit;
data->recon_config = v ? (data->recon_config | bit_mask) : (data->recon_config & ~bit_mask);
}
uint64_t get_recon_config() {
return data->recon_config;
}
bool recon_autosave_freqs() {
return check_recon_config_bit(RC_AUTOSAVE_FREQS);
}
@@ -963,6 +972,15 @@ uint8_t ui_theme_id() {
bool ui_override_batt_calc() {
return data->ui_config2.override_batt_calc;
}
bool ui_button_repeat_delay() {
return data->ui_config2.button_repeat_delay;
}
bool ui_button_repeat_speed() {
return data->ui_config2.button_repeat_speed;
}
bool ui_button_long_press_delay() {
return data->ui_config2.button_long_press_delay;
}
void set_ui_hide_speaker(bool v) {
data->ui_config2.hide_speaker = v;
@@ -1008,6 +1026,15 @@ void set_ui_theme_id(uint8_t theme_id) {
void set_ui_override_batt_calc(bool v) {
data->ui_config2.override_batt_calc = v;
}
void set_ui_button_repeat_delay(bool v) {
data->ui_config2.button_repeat_delay = v;
}
void set_ui_button_repeat_speed(bool v) {
data->ui_config2.button_repeat_speed = v;
}
void set_ui_button_long_press_delay(bool v) {
data->ui_config2.button_long_press_delay = v;
}
/* Converter */
bool config_converter() {
@@ -1189,171 +1216,5 @@ size_t data_size() {
return sizeof(data_t);
}
// Dump pmem, receiver and transmitter models internals in human readable format
bool debug_dump() {
ui::Painter painter{};
std::string debug_dir = "DEBUG";
std::filesystem::path filename{};
File pmem_dump_file{};
// create new dump file name and DEBUG directory
ensure_directory(debug_dir);
filename = next_filename_matching_pattern(debug_dir + "/DEBUG_DUMP_????.TXT");
if (filename.empty()) {
painter.draw_string({0, 320 - 16}, *ui::Theme::getInstance()->fg_red, "COULD NOT GET DUMP NAME !");
return false;
}
// dump data fo filename
auto error = pmem_dump_file.create(filename);
if (error) {
painter.draw_string({0, 320 - 16}, *ui::Theme::getInstance()->fg_red, "ERROR DUMPING " + filename.filename().string() + " !");
return false;
}
pmem_dump_file.write_line("FW version: " VERSION_STRING);
pmem_dump_file.write_line("Ext APPS version req'd: 0x" + to_string_hex(VERSION_MD5));
pmem_dump_file.write_line("GCC version: " + to_string_dec_int(__GNUC__) + "." + to_string_dec_int(__GNUC_MINOR__) + "." + to_string_dec_int(__GNUC_PATCHLEVEL__));
// firmware checksum
pmem_dump_file.write_line("Firmware calculated checksum: 0x" + to_string_hex(simple_checksum(FLASH_STARTING_ADDRESS, FLASH_ROM_SIZE), 8));
// write persistent memory
pmem_dump_file.write_line("\n[Persistent Memory]");
// full variables
pmem_dump_file.write_line("structure_version: 0x" + to_string_hex(data->structure_version, 8));
pmem_dump_file.write_line("target_frequency: " + to_string_dec_int(data->target_frequency));
pmem_dump_file.write_line("correction_ppb: " + to_string_dec_int(data->correction_ppb));
pmem_dump_file.write_line("modem_def_index: " + to_string_dec_uint(data->modem_def_index));
pmem_dump_file.write_line("serial_format.data_bit: " + to_string_dec_uint(data->serial_format.data_bits));
pmem_dump_file.write_line("serial_format.parity: " + to_string_dec_uint(data->serial_format.parity));
pmem_dump_file.write_line("serial_format.stop_bits: " + to_string_dec_uint(data->serial_format.stop_bits));
pmem_dump_file.write_line("serial_format.bit_order: " + to_string_dec_uint(data->serial_format.bit_order));
pmem_dump_file.write_line("modem_bw: " + to_string_dec_int(data->modem_bw));
pmem_dump_file.write_line("afsk_mark_freq: " + to_string_dec_int(data->afsk_mark_freq));
pmem_dump_file.write_line("afsk_space_freq: " + to_string_dec_int(data->afsk_space_freq));
pmem_dump_file.write_line("modem_baudrate: " + to_string_dec_int(data->modem_baudrate));
pmem_dump_file.write_line("modem_repeat: " + to_string_dec_int(data->modem_repeat));
pmem_dump_file.write_line("pocsag_last_address: " + to_string_dec_uint(data->pocsag_last_address));
pmem_dump_file.write_line("pocsag_ignore_address: " + to_string_dec_uint(data->pocsag_ignore_address));
pmem_dump_file.write_line("tone_mix: " + to_string_dec_uint(data->tone_mix));
pmem_dump_file.write_line("hardware_config: " + to_string_dec_uint(data->hardware_config));
pmem_dump_file.write_line("recon_config: 0x" + to_string_hex(data->recon_config, 16));
pmem_dump_file.write_line("recon_repeat_nb: " + to_string_dec_int(data->recon_repeat_nb));
pmem_dump_file.write_line("recon_repeat_gain: " + to_string_dec_int(data->recon_repeat_gain));
pmem_dump_file.write_line("recon_repeat_delay: " + to_string_dec_int(data->recon_repeat_delay));
pmem_dump_file.write_line("converter: " + to_string_dec_int(data->converter));
pmem_dump_file.write_line("updown_converter: " + to_string_dec_int(data->updown_converter));
pmem_dump_file.write_line("updown_frequency_rx_correction: " + to_string_dec_int(data->updown_frequency_rx_correction));
pmem_dump_file.write_line("updown_frequency_tx_correction: " + to_string_dec_int(data->updown_frequency_tx_correction));
pmem_dump_file.write_line("lcd_inverted_mode: " + to_string_dec_uint(data->lcd_inverted_mode));
// pmem_dump_file.write_line("UNUSED_5: " + to_string_dec_int(data->UNUSED_5));
// pmem_dump_file.write_line("UNUSED_6: " + to_string_dec_int(data->UNUSED_6));
// pmem_dump_file.write_line("UNUSED_7: " + to_string_dec_int(data->UNUSED_7));
pmem_dump_file.write_line("converter_frequency_offset: " + to_string_dec_int(data->converter_frequency_offset));
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("encoder_rate_multiplier: " + to_string_dec_uint(data->encoder_rate_multiplier));
pmem_dump_file.write_line("encoder_dial_direction: " + to_string_dec_uint(data->encoder_dial_direction)); // 0 = normal, 1 = reverse
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));
pmem_dump_file.write_line("touchscreen_threshold: " + to_string_dec_uint(data->touchscreen_threshold));
// ui_config bits
const auto backlight_timer = portapack::persistent_memory::config_backlight_timer();
pmem_dump_file.write_line("ui_config clkout_freq: " + to_string_dec_uint(clkout_freq()));
pmem_dump_file.write_line("ui_config backlight_timer.timeout_enabled: " + to_string_dec_uint(backlight_timer.timeout_enabled()));
pmem_dump_file.write_line("ui_config backlight_timer.timeout_seconds: " + to_string_dec_uint(backlight_timer.timeout_seconds()));
pmem_dump_file.write_line("ui_config show_gui_return_icon: " + to_string_dec_uint(data->ui_config.show_gui_return_icon));
pmem_dump_file.write_line("ui_config load_app_settings: " + to_string_dec_uint(data->ui_config.load_app_settings));
pmem_dump_file.write_line("ui_config save_app_settings: " + to_string_dec_uint(data->ui_config.save_app_settings));
pmem_dump_file.write_line("ui_config show_bigger_qr_code: " + to_string_dec_uint(data->ui_config.show_large_qr_code));
pmem_dump_file.write_line("ui_config disable_touchscreen: " + to_string_dec_uint(data->ui_config.disable_touchscreen));
pmem_dump_file.write_line("ui_config hide_clock: " + to_string_dec_uint(data->ui_config.hide_clock));
pmem_dump_file.write_line("ui_config clock_with_date: " + to_string_dec_uint(data->ui_config.clock_show_date));
pmem_dump_file.write_line("ui_config clkout_enabled: " + to_string_dec_uint(data->ui_config.clkout_enabled));
pmem_dump_file.write_line("ui_config apply_fake_brightness: " + to_string_dec_uint(data->ui_config.apply_fake_brightness));
pmem_dump_file.write_line("ui_config stealth_mode: " + to_string_dec_uint(data->ui_config.stealth_mode));
pmem_dump_file.write_line("ui_config config_login: " + to_string_dec_uint(data->ui_config.config_login));
pmem_dump_file.write_line("ui_config config_splash: " + to_string_dec_uint(data->ui_config.config_splash));
// ui_config2 bits
pmem_dump_file.write_line("ui_config2 hide_speaker: " + to_string_dec_uint(data->ui_config2.hide_speaker));
pmem_dump_file.write_line("ui_config2 hide_converter: " + to_string_dec_uint(data->ui_config2.hide_converter));
pmem_dump_file.write_line("ui_config2 hide_stealth: " + to_string_dec_uint(data->ui_config2.hide_stealth));
pmem_dump_file.write_line("ui_config2 hide_camera: " + to_string_dec_uint(data->ui_config2.hide_camera));
pmem_dump_file.write_line("ui_config2 hide_sleep: " + to_string_dec_uint(data->ui_config2.hide_sleep));
pmem_dump_file.write_line("ui_config2 hide_bias_tee: " + to_string_dec_uint(data->ui_config2.hide_bias_tee));
pmem_dump_file.write_line("ui_config2 hide_clock: " + to_string_dec_uint(data->ui_config2.hide_clock));
pmem_dump_file.write_line("ui_config2 hide_sd_card: " + to_string_dec_uint(data->ui_config2.hide_sd_card));
pmem_dump_file.write_line("ui_config2 hide_mute: " + to_string_dec_uint(data->ui_config2.hide_mute));
pmem_dump_file.write_line("ui_config2 hide_fake_brightness: " + to_string_dec_uint(data->ui_config2.hide_fake_brightness));
pmem_dump_file.write_line("ui_config2 hide_battery_icon: " + to_string_dec_uint(data->ui_config2.hide_battery_icon));
pmem_dump_file.write_line("ui_config2 hide_numeric_battery: " + to_string_dec_uint(data->ui_config2.hide_numeric_battery));
pmem_dump_file.write_line("ui_config2 theme_id: " + to_string_dec_uint(data->ui_config2.theme_id));
pmem_dump_file.write_line("ui_config2 override_batt_calc: " + to_string_dec_uint(data->ui_config2.override_batt_calc));
// misc_config bits
pmem_dump_file.write_line("misc_config config_audio_mute: " + to_string_dec_int(config_audio_mute()));
pmem_dump_file.write_line("misc_config config_speaker_disable: " + to_string_dec_int(config_speaker_disable()));
pmem_dump_file.write_line("misc_config config_disable_external_tcxo: " + to_string_dec_uint(config_disable_external_tcxo()));
pmem_dump_file.write_line("misc_config config_sdcard_high_speed_io: " + to_string_dec_uint(config_sdcard_high_speed_io()));
pmem_dump_file.write_line("misc_config config_disable_config_mode: " + to_string_dec_uint(config_disable_config_mode()));
pmem_dump_file.write_line("misc_config beep_on_packets: " + to_string_dec_int(beep_on_packets()));
// receiver_model
pmem_dump_file.write_line("\n[Receiver Model]");
pmem_dump_file.write_line("target_frequency: " + to_string_dec_uint(receiver_model.target_frequency()));
pmem_dump_file.write_line("frequency_step: " + to_string_dec_uint(receiver_model.frequency_step()));
pmem_dump_file.write_line("lna: " + to_string_dec_int(receiver_model.lna()));
pmem_dump_file.write_line("vga: " + to_string_dec_int(receiver_model.vga()));
pmem_dump_file.write_line("rf_amp: " + to_string_dec_int(receiver_model.rf_amp()));
pmem_dump_file.write_line("baseband_bandwidth: " + to_string_dec_uint(receiver_model.baseband_bandwidth()));
pmem_dump_file.write_line("sampling_rate: " + to_string_dec_uint(receiver_model.sampling_rate()));
switch (receiver_model.modulation()) {
case ReceiverModel::Mode::AMAudio:
pmem_dump_file.write_line("modulation: Mode::AMAudio");
break;
case ReceiverModel::Mode::NarrowbandFMAudio:
pmem_dump_file.write_line("modulation: Mode::NarrowbandFMAudio");
break;
case ReceiverModel::Mode::WidebandFMAudio:
pmem_dump_file.write_line("modulation: Mode::WidebandFMAudio");
break;
case ReceiverModel::Mode::SpectrumAnalysis:
pmem_dump_file.write_line("modulation: Mode::SpectrumAnalysis");
break;
case ReceiverModel::Mode::Capture:
pmem_dump_file.write_line("modulation: Mode::Capture");
break;
case ReceiverModel::Mode::AMAudioFMApt:
pmem_dump_file.write_line("modulation: Mode::AMAudioFMApt");
break;
default:
pmem_dump_file.write_line("modulation: !!unknown mode!!");
break;
}
pmem_dump_file.write_line("headphone_volume.centibel: " + to_string_dec_int(receiver_model.headphone_volume().centibel()));
pmem_dump_file.write_line("normalized_headphone_volume: " + to_string_dec_uint(receiver_model.normalized_headphone_volume()));
pmem_dump_file.write_line("am_configuration: " + to_string_dec_uint(receiver_model.am_configuration()));
pmem_dump_file.write_line("nbfm_configuration: " + to_string_dec_uint(receiver_model.nbfm_configuration()));
pmem_dump_file.write_line("wfm_configuration: " + to_string_dec_uint(receiver_model.wfm_configuration()));
// transmitter_model
pmem_dump_file.write_line("\n[Transmitter Model]");
pmem_dump_file.write_line("target_frequency: " + to_string_dec_uint(transmitter_model.target_frequency()));
pmem_dump_file.write_line("rf_amp: " + to_string_dec_int(transmitter_model.rf_amp()));
pmem_dump_file.write_line("baseband_bandwidth: " + to_string_dec_uint(transmitter_model.baseband_bandwidth()));
pmem_dump_file.write_line("sampling_rate: " + to_string_dec_uint(transmitter_model.sampling_rate()));
pmem_dump_file.write_line("tx_gain: " + to_string_dec_int(transmitter_model.tx_gain()));
pmem_dump_file.write_line("channel_bandwidth: " + to_string_dec_uint(transmitter_model.channel_bandwidth()));
// on screen information
painter.draw_string({0, 320 - 16}, *ui::Theme::getInstance()->fg_green, filename.filename().string() + " DUMPED !");
return true;
}
} /* namespace persistent_memory */
} /* namespace portapack */
@@ -183,9 +183,13 @@ void set_afsk_mark(const int32_t new_value);
int32_t afsk_space_freq();
void set_afsk_space(const int32_t new_value);
uint32_t get_modem_def_index();
int32_t modem_baudrate();
void set_modem_baudrate(const int32_t new_value);
int32_t modem_bw();
uint8_t modem_repeat();
void set_modem_repeat(const uint32_t new_value);
@@ -205,7 +209,6 @@ bool config_converter();
bool config_updown_converter();
int64_t config_converter_freq();
bool show_gui_return_icon();
bool show_bigger_qr_code();
bool hide_clock();
bool clock_with_date();
bool config_login();
@@ -215,9 +218,10 @@ backlight_config_t config_backlight_timer();
bool disable_touchscreen();
void set_gui_return_icon(bool v);
bool load_app_settings();
void set_load_app_settings(bool v);
bool save_app_settings();
void set_save_app_settings(bool v);
void set_show_bigger_qr_code(bool v);
void set_config_disable_external_tcxo(bool v);
void set_config_sdcard_high_speed_io(bool v, bool save);
void set_config_disable_config_mode(bool v);
@@ -292,6 +296,7 @@ Color menu_color();
void set_menu_color(Color v);
/* Recon app */
uint64_t get_recon_config();
bool recon_autosave_freqs();
bool recon_autostart_recon();
bool recon_continuous();
@@ -342,6 +347,9 @@ bool ui_hide_battery_icon();
bool ui_hide_sd_card();
uint8_t ui_theme_id();
bool ui_override_batt_calc();
bool ui_button_repeat_delay();
bool ui_button_repeat_speed();
bool ui_button_long_press_delay();
void set_ui_hide_speaker(bool v);
void set_ui_hide_mute(bool v);
void set_ui_hide_converter(bool v);
@@ -356,20 +364,22 @@ void set_ui_hide_battery_icon(bool v);
void set_ui_hide_sd_card(bool v);
void set_ui_theme_id(uint8_t v);
void set_ui_override_batt_calc(bool v);
void set_ui_button_repeat_delay(bool v);
void set_ui_button_repeat_speed(bool v);
void set_ui_button_long_press_delay(bool v);
// sd persisting settings
bool should_use_sdcard_for_pmem();
int save_persistent_settings_to_file();
int load_persistent_settings_from_file();
uint32_t get_data_structure_version();
uint32_t pmem_data_word(uint32_t index);
uint32_t pmem_stored_checksum(void);
uint32_t pmem_calculated_checksum(void);
size_t data_size();
bool debug_dump();
} /* namespace persistent_memory */
} /* namespace portapack */
+1
View File
@@ -118,6 +118,7 @@ constexpr image_tag_t image_tag_usb_sd{'P', 'U', 'S', 'B'};
constexpr image_tag_t image_tag_weather{'P', 'W', 'T', 'H'};
constexpr image_tag_t image_tag_subghzd{'P', 'S', 'G', 'D'};
constexpr image_tag_t image_tag_protoview{'P', 'P', 'V', 'W'};
constexpr image_tag_t image_tag_wefaxrx{'P', 'W', 'F', 'X'};
constexpr image_tag_t image_tag_noop{'P', 'N', 'O', 'P'};
+6 -3
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* copyleft Mr. Robot
*
* This file is part of PortaPack.
*
@@ -35,10 +36,12 @@ Style Style::invert() const {
.foreground = background};
}
int Painter::draw_char(Point p, const Style& style, char c) {
int Painter::draw_char(Point p, const Style& style, char c, uint8_t zoom_level) {
const auto glyph = style.font.glyph(c);
display.draw_glyph(p, glyph, style.foreground, style.background);
return glyph.advance().x();
display.draw_glyph(p, glyph, style.foreground, style.background, zoom_level);
return glyph.advance().x() * zoom_level;
}
int Painter::draw_string(Point p, const Style& style, std::string_view text) {
+2 -1
View File
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* copyleft Mr. Robot
*
* This file is part of PortaPack.
*
@@ -69,7 +70,7 @@ class Painter {
Painter(const Painter&) = delete;
Painter(Painter&&) = delete;
int draw_char(Point p, const Style& style, char c);
int draw_char(Point p, const Style& style, char c, uint8_t zoom_factor = 1);
int draw_string(Point p, const Style& style, std::string_view text);
int draw_string(Point p, const Font& font, Color foreground, Color background, std::string_view text);
Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

+1
View File
@@ -0,0 +1 @@
bitmap.hpp
+127
View File
@@ -0,0 +1,127 @@
#!/usr/bin/env python3
# Copyright (C) 2016 Furrtek
#
# 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
import struct
from PIL import Image
from os import listdir
from os import path
from os import makedirs
usage_message = f"""
1BPP PortaPack bitmap.hpp generator
Usage: {sys.argv[0]} <directory>
"""
if len(sys.argv) < 2:
print(usage_message)
sys.exit(-1)
graphics_path = path.join(sys.argv[1], '')
hex_output_dir = path.join(graphics_path, 'hex_files')
# Create hex output directory if it doesn't exist
if not path.exists(hex_output_dir):
makedirs(hex_output_dir)
def convert_png(file):
c = 0
data = 0
rgb_im = Image.open(file).convert('RGBA')
if rgb_im.size[0] % 8 or rgb_im.size[1] % 8:
print((file + ": Size is not a multiple of 8. Image is not included in bitmap.hpp."))
sys.exit(-1)
name = path.basename(file).split(".")[0].lower();
# Prepare data for both hpp and hex file
hpp_lines = []
hex_data = bytearray()
for i in range(rgb_im.size[1]):
for j in range(rgb_im.size[0]):
r, g, b, a = rgb_im.getpixel((j, i))
data >>= 1
if r > 127 and g > 127 and b > 127 and a > 127:
data += 128
if j % 8 == 7:
hpp_lines.append(" 0x%0.2X,\n" % data)
hex_data.append(data)
data = 0
# Write to hpp file
f.write("static constexpr uint8_t bitmap_" + name + "_data[] = {\n")
f.writelines(hpp_lines)
f.write("};\n")
f.write("static constexpr Bitmap bitmap_" + name + " {\n")
f.write(" {" + str(rgb_im.size[0]) + ", " + str(rgb_im.size[1]) + "},\n bitmap_" + name + "_data};\n\n")
# Write to hex file
hex_filename = path.join(hex_output_dir, name + ".hex")
with open(hex_filename, 'wb') as hex_file:
hex_file.write(hex_data)
return
count = 0
f = open('bitmap.hpp', 'w')
f.write("/*\n"
" * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.\n"
" * Copyright (C) 2016 Furrtek\n"
" *\n"
" * This file is part of PortaPack.\n"
" *\n"
" * This program is free software; you can redistribute it and/or modify\n"
" * it under the terms of the GNU General Public License as published by\n"
" * the Free Software Foundation; either version 2, or (at your option)\n"
" * any later version.\n"
" *\n"
" * This program is distributed in the hope that it will be useful,\n"
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
" * GNU General Public License for more details.\n"
" *\n"
" * You should have received a copy of the GNU General Public License\n"
" * along with this program; see the file COPYING. If not, write to\n"
" * the Free Software Foundation, Inc., 51 Franklin Street,\n"
" * Boston, MA 02110-1301, USA.\n"
" */\n\n"
"// This file was generated by make_bitmap.py\n\n"
"#ifndef __BITMAP_HPP__\n"
"#define __BITMAP_HPP__\n\n"
"#include \"ui.hpp\"\n\n"
"namespace ui {\n\n")
for file in listdir(graphics_path):
if file.endswith(".png") and path.isfile(graphics_path + file):
convert_png(graphics_path + file)
count += 1
f.write("} /* namespace ui */\n\n")
f.write("#endif/*__BITMAP_HPP__*/\n")
print(("Converted " + str(count) + " files"))

Some files were not shown because too many files have changed in this diff Show More