diff --git a/firmware/Makefile b/firmware/Makefile index 54cadbf1..7e2c998e 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -22,7 +22,7 @@ PATH_BOOTSTRAP=bootstrap PATH_APPLICATION=application PATH_BASEBAND=baseband -PATH_BASEBAND_TX=baseband-tx +# PATH_BASEBAND_TX=baseband-tx TARGET=portapack-h1-firmware @@ -30,7 +30,7 @@ TARGET_BOOTSTRAP=$(PATH_BOOTSTRAP)/bootstrap TARGET_HACKRF_FIRMWARE=hackrf_one_usb_ram TARGET_APPLICATION=$(PATH_APPLICATION)/build/application TARGET_BASEBAND=$(PATH_BASEBAND)/build/baseband -TARGET_BASEBAND_TX=$(PATH_BASEBAND_TX)/build/baseband-tx +# TARGET_BASEBAND_TX=$(PATH_BASEBAND_TX)/build/baseband-tx MAKE_SPI_IMAGE=tools/make_spi_image.py MAKE_MODULES_FILE=tools/make_baseband_file.py @@ -59,13 +59,13 @@ program: $(TARGET).bin modules sleep 1s hackrf_spiflash -w $(TARGET).bin -modules: $(TARGET_BASEBAND).bin $(TARGET_BASEBAND_TX).bin +modules: $(TARGET_BASEBAND).bin # $(TARGET_BASEBAND_TX).bin $(MAKE_MODULES_FILE) $(MODULES) cp $(PATH_BASEBAND).bin ../sdcard/$(PATH_BASEBAND).bin - cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin + # cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin -$(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_BASEBAND_TX).bin $(TARGET_APPLICATION).bin - $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX).bin $(TARGET_APPLICATION).bin $(TARGET).bin +$(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_APPLICATION).bin + $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_APPLICATION).bin $(TARGET).bin $(TARGET_BOOTSTRAP).bin: $(TARGET_BOOTSTRAP).elf $(CP) -O binary $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP).bin diff --git a/firmware/application/touch.hpp b/firmware/application/touch.hpp index eee2bbe1..0402243a 100644 --- a/firmware/application/touch.hpp +++ b/firmware/application/touch.hpp @@ -172,9 +172,6 @@ private: NoTouch, TouchDetected, }; - - static float cmx; - static float cmy; static constexpr uint32_t width_pixels = 240; static constexpr uint32_t height_pixels = 320; @@ -183,12 +180,12 @@ private: static constexpr size_t touch_count_threshold { 4 }; static constexpr uint32_t touch_stable_bound { 4 }; - static constexpr float calib_x_low = 0.15f; - static constexpr float calib_x_high = 0.93f; + static constexpr float calib_x_low = 0.07f; + static constexpr float calib_x_high = 0.94f; static constexpr float calib_x_range = calib_x_high - calib_x_low; - static constexpr float calib_y_low = 0.05f; - static constexpr float calib_y_high = 0.84f; + static constexpr float calib_y_low = 0.04f; + static constexpr float calib_y_high = 0.91f; static constexpr float calib_y_range = calib_y_high - calib_y_low; // Ensure filter length is equal or less than touch_count_threshold, @@ -212,8 +209,6 @@ private: }; } - ui::Point raw_point() const ; - void touch_started() { fire_event(ui::TouchEvent::Type::Start); } @@ -228,7 +223,7 @@ private: void fire_event(ui::TouchEvent::Type type) { if( on_event ) { - on_event({ filtered_point(), type, raw_point() }); + on_event({ filtered_point(), type }); } } }; diff --git a/firmware/application/ui_about.cpp b/firmware/application/ui_about.cpp index 235d7294..aa924c42 100644 --- a/firmware/application/ui_about.cpp +++ b/firmware/application/ui_about.cpp @@ -26,6 +26,7 @@ #include "ymdata.hpp" #include "portapack.hpp" +#include "audio.hpp" #include "event_m0.hpp" #include "ui_about.hpp" @@ -73,7 +74,7 @@ void AboutView::on_show() { transmitter_model.set_tuning_frequency(92200000); // 92.2MHz, change ! - portapack::audio_codec.set_headphone_volume(volume_t::decibel(0 - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max); transmitter_model.enable(); } @@ -350,7 +351,7 @@ void AboutView::update() { // Slowly increase volume to avoid jumpscare if (headphone_vol < (70<<2)) { - portapack::audio_codec.set_headphone_volume(volume_t::decibel((headphone_vol/4) - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel((headphone_vol/4) - 99) + audio::headphone::volume_range().max); headphone_vol++; } } diff --git a/firmware/application/ui_loadmodule.hpp b/firmware/application/ui_loadmodule.hpp index 605e1314..5c5e7e52 100644 --- a/firmware/application/ui_loadmodule.hpp +++ b/firmware/application/ui_loadmodule.hpp @@ -25,7 +25,7 @@ #include "ui_painter.hpp" #include "ui_menu.hpp" #include "ui_navigation.hpp" -#include "m4_startup.hpp" +#include "core_control.hpp" #include "ui_font_fixed_8x16.hpp" namespace ui { diff --git a/firmware/application/ui_menu.cpp b/firmware/application/ui_menu.cpp index 9f45a468..4b79cbb1 100644 --- a/firmware/application/ui_menu.cpp +++ b/firmware/application/ui_menu.cpp @@ -52,20 +52,10 @@ void MenuItemView::paint(Painter& painter) { r, paint_style.background ); - - ui::Color final_item_color = item.color; - - if (final_item_color.v == paint_style.background.v) final_item_color = paint_style.foreground; - - Style text_style { - .font = paint_style.font, - .background = paint_style.background, - .foreground = final_item_color - }; - + painter.draw_string( - { static_cast(r.pos.x + 8), static_cast(r.pos.y + (r.size.h - font_height) / 2) }, - text_style, + { r.pos.x + 8, r.pos.y + (r.size.h - font_height) / 2 }, + paint_style, item.text ); } diff --git a/firmware/application/ui_menu.hpp b/firmware/application/ui_menu.hpp index 9740bc1f..0bd19c11 100644 --- a/firmware/application/ui_menu.hpp +++ b/firmware/application/ui_menu.hpp @@ -34,7 +34,6 @@ namespace ui { struct MenuItem { std::string text; - ui::Color color; std::function on_select; // TODO: Prevent default-constructed MenuItems. diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 3ccaacbb..62d8c29a 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -23,7 +23,7 @@ #include "portapack.hpp" #include "event_m0.hpp" - +#include "portapack_persistent_memory.hpp" #include "splash.hpp" #include "ui_about.hpp" @@ -299,7 +299,7 @@ BMPView::BMPView(NavigationView& nav) { button_done.on_select = [this,&nav](Button&){ nav.pop(); - nav.push(new SystemMenuView { nav }); + nav.push(); }; } @@ -316,7 +316,7 @@ void PlayDeadView::focus() { PlayDeadView::PlayDeadView(NavigationView& nav, bool booting) { _booting = booting; - persistent_memory::set_playing_dead(0x59); + portapack::persistent_memory::set_playing_dead(0x59); add_children({ { &text_playdead1, @@ -329,8 +329,8 @@ PlayDeadView::PlayDeadView(NavigationView& nav, bool booting) { }; button_done.on_select = [this,&nav](Button&){ - if (sequence == persistent_memory::playdead_sequence()) { - persistent_memory::set_playing_dead(0); + if (sequence == portapack::persistent_memory::playdead_sequence()) { + portapack::persistent_memory::set_playing_dead(0); if (_booting) { nav.pop(); nav.push(); diff --git a/firmware/application/ui_setup.cpp b/firmware/application/ui_setup.cpp index baa50c44..3b7445a6 100644 --- a/firmware/application/ui_setup.cpp +++ b/firmware/application/ui_setup.cpp @@ -187,8 +187,8 @@ void SetTouchCalibView::focus() { bool SetTouchCalibView::on_touch(const TouchEvent event) { if (event.type == ui::TouchEvent::Type::Start) { - text_debugx.set(to_string_dec_uint(round(event.rawpoint.x), 4)); - text_debugy.set(to_string_dec_uint(round(event.rawpoint.y), 4)); + text_debugx.set(to_string_dec_uint(round(event.point.x), 4)); + text_debugy.set(to_string_dec_uint(round(event.point.y), 4)); } return true; } @@ -441,6 +441,15 @@ void ModInfoView::focus() { SetupMenuView::SetupMenuView(NavigationView& nav) { add_items<7>({ { + { "SD card modules", [&nav](){ nav.push(); } }, + { "Date/Time", [&nav](){ nav.push(); } }, + { "Frequency correction", [&nav](){ nav.push(); } }, + { "Antenna Bias Voltage", [&nav](){ nav.push(); } }, + { "Touch screen", [&nav](){ nav.push(); } }, + { "Play dead", [&nav](){ nav.push(); } }, + { "UI", [&nav](){ nav.push(); } }, + } }); + /*add_items<7>({ { { "SD card modules", ui::Color::white(), [&nav](){ nav.push(); } }, { "Date/Time", ui::Color::white(), [&nav](){ nav.push(); } }, { "Frequency correction", ui::Color::white(), [&nav](){ nav.push(); } }, @@ -448,7 +457,7 @@ SetupMenuView::SetupMenuView(NavigationView& nav) { { "Touch screen", ui::Color::white(), [&nav](){ nav.push(); } }, { "Play dead", ui::Color::red(), [&nav](){ nav.push(); } }, { "UI", ui::Color::white(), [&nav](){ nav.push(); } }, - } }); + } });*/ on_left = [&nav](){ nav.pop(); }; } diff --git a/firmware/application/ui_xylos.cpp b/firmware/application/ui_xylos.cpp index d80164c8..22ff1b17 100644 --- a/firmware/application/ui_xylos.cpp +++ b/firmware/application/ui_xylos.cpp @@ -26,6 +26,7 @@ #include "hackrf_hal.hpp" #include "event_m0.hpp" +#include "audio.hpp" #include "ui_alphanum.hpp" #include "ff.h" #include "hackrf_gpio.hpp" @@ -204,7 +205,7 @@ void XylosView::journuit() { upd_message(); - portapack::audio_codec.set_headphone_volume(volume_t::decibel(90 - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max); shared_memory.xylos_transmit_done = false; memcpy(shared_memory.xylosdata, ccirmessage, 21); transmitter_model.enable(); @@ -326,7 +327,7 @@ XylosView::XylosView( [this,&transmitter_model](Message* const p) { const auto message = static_cast(p); if (message->n == 25) { - portapack::audio_codec.set_headphone_volume(volume_t::decibel(0 - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max); transmitter_model.disable(); txing = false; button_txtest.set_style(&style_val); @@ -341,7 +342,7 @@ XylosView::XylosView( transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]); - portapack::audio_codec.set_headphone_volume(volume_t::decibel(90 - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max); txing = true; button_txtest.set_style(&style_cancel); @@ -362,7 +363,7 @@ XylosView::XylosView( char progress[21]; const auto message = static_cast(p); if (message->n == 25) { - portapack::audio_codec.set_headphone_volume(volume_t::decibel(0 - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max); transmitter_model.disable(); for (c=0;c<20;c++) progress[c] = ' '; @@ -390,7 +391,7 @@ XylosView::XylosView( transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]); - portapack::audio_codec.set_headphone_volume(volume_t::decibel(90 - 99) + wolfson::wm8731::headphone_gain_range.max); + audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max); txing = true; button_transmit.set_style(&style_cancel); diff --git a/firmware/baseband-tx.bin b/firmware/baseband-tx.bin index 575f9871..bbf75555 100644 Binary files a/firmware/baseband-tx.bin and b/firmware/baseband-tx.bin differ diff --git a/firmware/baseband-tx/main.cpp b/firmware/baseband-tx/main.cpp index 3222755d..a1940851 100755 --- a/firmware/baseband-tx/main.cpp +++ b/firmware/baseband-tx/main.cpp @@ -42,7 +42,6 @@ #include "debug.hpp" -#include "audio.hpp" #include "audio_dma.hpp" #include "gcc.hpp" diff --git a/firmware/baseband.bin b/firmware/baseband.bin index 3be4fca0..7cdb6776 100644 Binary files a/firmware/baseband.bin and b/firmware/baseband.bin differ diff --git a/firmware/baseband/baseband_thread.cpp b/firmware/baseband/baseband_thread.cpp index 7ebfa912..88d77ef0 100644 --- a/firmware/baseband/baseband_thread.cpp +++ b/firmware/baseband/baseband_thread.cpp @@ -120,8 +120,6 @@ void BasebandThread::run() { ); } } - - delete baseband_buffer; } BasebandProcessor* BasebandThread::create_processor(const int32_t mode) { diff --git a/firmware/common/modules.h b/firmware/common/modules.h index cdb0cc9c..d005b3f0 100644 --- a/firmware/common/modules.h +++ b/firmware/common/modules.h @@ -1,2 +1 @@ -const char md5_baseband[16] = {0x03,0x77,0xc0,0x0b,0x13,0x5b,0x84,0x72,0x8f,0x4b,0xbb,0x51,0x48,0x54,0x82,0xd3,}; -const char md5_baseband_tx[16] = {0xa3,0xb9,0xd4,0x35,0xb5,0xe0,0x66,0x82,0xac,0x61,0x59,0xa1,0x27,0x36,0x0b,0xfe,}; +const char md5_baseband[16] = {0x4a,0x99,0xbe,0xec,0x29,0x7c,0x61,0xd2,0x1d,0xc1,0xb5,0x5e,0xb4,0x16,0xae,0x5d,}; diff --git a/firmware/common/ui.hpp b/firmware/common/ui.hpp index e04db97e..fa2f0fa5 100644 --- a/firmware/common/ui.hpp +++ b/firmware/common/ui.hpp @@ -255,7 +255,6 @@ struct TouchEvent { Point point; Type type; - Point rawpoint; }; } /* namespace ui */ diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 12169334..31d03ebf 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -301,7 +301,7 @@ Checkbox::Checkbox( ) : Widget { { parent_pos, { static_cast((8 * length) + 24), 24 } } }, text_ { text } { - flags.focusable = true; + set_focusable(true); } void Checkbox::set_text(const std::string value) { @@ -325,7 +325,7 @@ bool Checkbox::value() const { void Checkbox::paint(Painter& painter) { const auto r = screen_rect(); - const auto paint_style = (has_focus() || flags.highlighted) ? style().invert() : style(); + const auto paint_style = (has_focus() || highlighted()) ? style().invert() : style(); painter.draw_rectangle({ r.pos.x, r.pos.y, 24, 24 }, style().foreground); @@ -377,12 +377,12 @@ bool Checkbox::on_key(const KeyEvent key) { bool Checkbox::on_touch(const TouchEvent event) { switch(event.type) { case TouchEvent::Type::Start: - flags.highlighted = true; + set_highlighted(true); set_dirty(); return true; case TouchEvent::Type::End: - flags.highlighted = false; + set_highlighted(false); value_ = not value_; set_dirty(); if( on_select ) { @@ -393,37 +393,6 @@ bool Checkbox::on_touch(const TouchEvent event) { default: return false; } -#if 0 - switch(event.type) { - case TouchEvent::Type::Start: - flags.highlighted = true; - set_dirty(); - return true; - - case TouchEvent::Type::Move: - { - const bool new_highlighted = screen_rect().contains(event.point); - if( flags.highlighted != new_highlighted ) { - flags.highlighted = new_highlighted; - set_dirty(); - } - } - return true; - - case TouchEvent::Type::End: - if( flags.highlighted ) { - flags.highlighted = false; - set_dirty(); - if( on_select ) { - on_select(*this); - } - } - return true; - - default: - return false; - } -#endif } /* Button ****************************************************************/ diff --git a/firmware/portapack-h1-firmware.bin b/firmware/portapack-h1-firmware.bin index 853c9cce..b58bd15d 100644 Binary files a/firmware/portapack-h1-firmware.bin and b/firmware/portapack-h1-firmware.bin differ diff --git a/sdcard/baseband-tx.bin b/sdcard/baseband-tx.bin index 575f9871..bbf75555 100644 Binary files a/sdcard/baseband-tx.bin and b/sdcard/baseband-tx.bin differ diff --git a/sdcard/baseband.bin b/sdcard/baseband.bin index 3be4fca0..7cdb6776 100644 Binary files a/sdcard/baseband.bin and b/sdcard/baseband.bin differ