-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into delete_old_stuff
- Loading branch information
Showing
12 changed files
with
1,309 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (C) 2024 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_fmradio.hpp" | ||
#include "ui_navigation.hpp" | ||
#include "external_app.hpp" | ||
|
||
namespace ui::external_app::fmradio { | ||
void initialize_app(ui::NavigationView& nav) { | ||
nav.push<FmRadioView>(); | ||
} | ||
} // namespace ui::external_app::fmradio | ||
|
||
extern "C" { | ||
|
||
__attribute__((section(".external_app.app_fmradio.application_information"), used)) application_information_t _application_information_fmradio = { | ||
/*.memory_location = */ (uint8_t*)0x00000000, | ||
/*.externalAppEntry = */ ui::external_app::fmradio::initialize_app, | ||
/*.header_version = */ CURRENT_HEADER_VERSION, | ||
/*.app_version = */ VERSION_MD5, | ||
|
||
/*.app_name = */ "FM Radio", | ||
/*.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, | ||
|
||
/*.m4_app_tag = portapack::spi_flash::image_tag_wfm_audio */ {'P', 'W', 'F', 'M'}, | ||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* | ||
* Copyright (C) 2024 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_fmradio.hpp" | ||
|
||
#include "audio.hpp" | ||
#include "rtc_time.hpp" | ||
#include "baseband_api.hpp" | ||
#include "string_format.hpp" | ||
#include "portapack_persistent_memory.hpp" | ||
|
||
using namespace portapack; | ||
using namespace modems; | ||
using namespace ui; | ||
|
||
namespace ui::external_app::fmradio { | ||
|
||
void FmRadioView::focus() { | ||
field_frequency.focus(); | ||
} | ||
|
||
FmRadioView::FmRadioView(NavigationView& nav) | ||
: nav_{nav} { | ||
baseband::run_image(portapack::spi_flash::image_tag_wfm_audio); | ||
|
||
add_children({&rssi, | ||
&field_rf_amp, | ||
&field_lna, | ||
&field_vga, | ||
&field_volume, | ||
&field_frequency, | ||
&btn_fav_save, | ||
&txt_save_help, | ||
&btn_fav_0, | ||
&btn_fav_1, | ||
&btn_fav_2, | ||
&btn_fav_3, | ||
&btn_fav_4, | ||
&btn_fav_5, | ||
&btn_fav_6, | ||
&btn_fav_7, | ||
&btn_fav_8, | ||
&btn_fav_9, | ||
&audio, | ||
&waveform}); | ||
|
||
txt_save_help.visible(false); | ||
for (uint8_t i = 0; i < 12; ++i) { | ||
if (freq_fav_list[i] == 0) { | ||
freq_fav_list[i] = 87000000; | ||
} | ||
} | ||
|
||
if (field_frequency.value() == 0) { | ||
field_frequency.set_value(87000000); | ||
} | ||
|
||
receiver_model.set_modulation(ReceiverModel::Mode::WidebandFMAudio); | ||
|
||
field_frequency.set_step(25000); | ||
receiver_model.enable(); | ||
audio::output::start(); | ||
|
||
btn_fav_0.on_select = [this](Button&) { | ||
on_btn_clicked(0); | ||
}; | ||
btn_fav_1.on_select = [this](Button&) { | ||
on_btn_clicked(1); | ||
}; | ||
btn_fav_2.on_select = [this](Button&) { | ||
on_btn_clicked(2); | ||
}; | ||
btn_fav_3.on_select = [this](Button&) { | ||
on_btn_clicked(3); | ||
}; | ||
btn_fav_4.on_select = [this](Button&) { | ||
on_btn_clicked(4); | ||
}; | ||
btn_fav_5.on_select = [this](Button&) { | ||
on_btn_clicked(5); | ||
}; | ||
btn_fav_6.on_select = [this](Button&) { | ||
on_btn_clicked(6); | ||
}; | ||
btn_fav_7.on_select = [this](Button&) { | ||
on_btn_clicked(7); | ||
}; | ||
btn_fav_8.on_select = [this](Button&) { | ||
on_btn_clicked(8); | ||
}; | ||
btn_fav_9.on_select = [this](Button&) { | ||
on_btn_clicked(9); | ||
}; | ||
|
||
btn_fav_save.on_select = [this](Button&) { | ||
save_fav = !save_fav; | ||
txt_save_help.set_text(save_fav ? "Select slot" : ""); | ||
txt_save_help.visible(save_fav); | ||
txt_save_help.set_dirty(); | ||
}; | ||
|
||
update_fav_btn_texts(); | ||
} | ||
|
||
void FmRadioView::on_btn_clicked(uint8_t i) { | ||
if (save_fav) { | ||
save_fav = false; | ||
freq_fav_list[i] = field_frequency.value(); | ||
update_fav_btn_texts(); | ||
txt_save_help.visible(save_fav); | ||
txt_save_help.set_text(""); | ||
txt_save_help.set_dirty(); | ||
return; | ||
} | ||
field_frequency.set_value(freq_fav_list[i]); | ||
} | ||
|
||
std::string FmRadioView::to_nice_freq(rf::Frequency freq) { | ||
std::string nice = to_string_dec_uint(freq / 1000000); | ||
nice += "."; | ||
nice += to_string_dec_uint((freq / 10000) % 100); | ||
return nice; | ||
} | ||
|
||
void FmRadioView::update_fav_btn_texts() { | ||
btn_fav_0.set_text(to_nice_freq(freq_fav_list[0])); | ||
btn_fav_1.set_text(to_nice_freq(freq_fav_list[1])); | ||
btn_fav_2.set_text(to_nice_freq(freq_fav_list[2])); | ||
btn_fav_3.set_text(to_nice_freq(freq_fav_list[3])); | ||
btn_fav_4.set_text(to_nice_freq(freq_fav_list[4])); | ||
btn_fav_5.set_text(to_nice_freq(freq_fav_list[5])); | ||
btn_fav_6.set_text(to_nice_freq(freq_fav_list[6])); | ||
btn_fav_7.set_text(to_nice_freq(freq_fav_list[7])); | ||
btn_fav_8.set_text(to_nice_freq(freq_fav_list[8])); | ||
btn_fav_9.set_text(to_nice_freq(freq_fav_list[9])); | ||
} | ||
|
||
FmRadioView::~FmRadioView() { | ||
receiver_model.disable(); | ||
baseband::shutdown(); | ||
audio::output::stop(); | ||
} | ||
|
||
void FmRadioView::on_audio_spectrum() { | ||
for (size_t i = 0; i < audio_spectrum_data->db.size(); i++) | ||
audio_spectrum[i] = ((int16_t)audio_spectrum_data->db[i] - 127) * 256; | ||
waveform.set_dirty(); | ||
} | ||
|
||
} // namespace ui::external_app::fmradio |
Oops, something went wrong.