From 30b4e43794adb99b819c1f96d9561dcf6b478e26 Mon Sep 17 00:00:00 2001 From: HTotoo Date: Fri, 8 Dec 2023 13:32:28 +0100 Subject: [PATCH] More SGD --- firmware/application/apps/ui_subghzd.cpp | 2 +- firmware/application/baseband_api.cpp | 5 +++++ firmware/application/baseband_api.hpp | 1 + firmware/baseband/fprotos/fprotogeneral.hpp | 2 ++ firmware/baseband/fprotos/fprotolistgeneral.hpp | 4 ++++ firmware/baseband/fprotos/subghzdbase.hpp | 3 +-- firmware/baseband/fprotos/subghzdprotos.hpp | 2 +- firmware/baseband/proc_weather.cpp | 10 +++++++--- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/firmware/application/apps/ui_subghzd.cpp b/firmware/application/apps/ui_subghzd.cpp index ad12ccca..141608ca 100644 --- a/firmware/application/apps/ui_subghzd.cpp +++ b/firmware/application/apps/ui_subghzd.cpp @@ -92,7 +92,7 @@ SubGhzDView::SubGhzDView(NavigationView& nav) recent_entries_view.on_select = [this](const SubGhzDRecentEntry& entry) { nav_.push(entry); }; - baseband::set_weather(); + baseband::set_subghzd(0); receiver_model.enable(); signal_token_tick_second = rtc_time::signal_tick_second += [this]() { on_tick_second(); diff --git a/firmware/application/baseband_api.cpp b/firmware/application/baseband_api.cpp index 63e0237f..201802a0 100644 --- a/firmware/application/baseband_api.cpp +++ b/firmware/application/baseband_api.cpp @@ -324,6 +324,11 @@ void set_weather() { send_message(&message); } +void set_subghzd(uint8_t modulation = 0) { + const SubGhzFPRxConfigureMessage message{modulation, 1}; + send_message(&message); +} + static bool baseband_image_running = false; void run_image(const spi_flash::image_tag_t image_tag) { diff --git a/firmware/application/baseband_api.hpp b/firmware/application/baseband_api.hpp index 6979bfb8..9963ef5c 100644 --- a/firmware/application/baseband_api.hpp +++ b/firmware/application/baseband_api.hpp @@ -89,6 +89,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_weather(); +void set_subghzd(uint8_t modulation); void request_beep(); void run_image(const portapack::spi_flash::image_tag_t image_tag); diff --git a/firmware/baseband/fprotos/fprotogeneral.hpp b/firmware/baseband/fprotos/fprotogeneral.hpp index 96484ea3..d23ac95a 100644 --- a/firmware/baseband/fprotos/fprotogeneral.hpp +++ b/firmware/baseband/fprotos/fprotogeneral.hpp @@ -1,6 +1,8 @@ #ifndef __FPROTO_GENERAL_H__ #define __FPROTO_GENERAL_H__ +// useful methods for both weather and subghzd + #include #include diff --git a/firmware/baseband/fprotos/fprotolistgeneral.hpp b/firmware/baseband/fprotos/fprotolistgeneral.hpp index 61d5b4ca..14bbee34 100644 --- a/firmware/baseband/fprotos/fprotolistgeneral.hpp +++ b/firmware/baseband/fprotos/fprotolistgeneral.hpp @@ -7,6 +7,10 @@ class FProtoListGeneral { FProtoListGeneral() {} virtual ~FProtoListGeneral() {} virtual void feed(bool level, uint32_t duration) = 0; + void setModulation(uint8_t modulation) { modulation_ = modulation; } + + protected: + uint8_t modulation_ = 0; }; #endif \ No newline at end of file diff --git a/firmware/baseband/fprotos/subghzdbase.hpp b/firmware/baseband/fprotos/subghzdbase.hpp index 109f06c2..f9b4c4f9 100644 --- a/firmware/baseband/fprotos/subghzdbase.hpp +++ b/firmware/baseband/fprotos/subghzdbase.hpp @@ -26,7 +26,7 @@ class FProtoSubGhzDBase { uint8_t getSensorType() { return sensorType; } uint32_t getSensorId() { return id; } - + FPROTO_SUBGHZD_MODULATION modulation = FPM_AM; // override this, if FM protected: // Helper functions to keep it as compatible with flipper as we can, so adding new protos will be easy. void subghz_protocol_blocks_add_bit(uint8_t bit) { @@ -37,7 +37,6 @@ class FProtoSubGhzDBase { // General weather data holder uint8_t sensorType = FPS_Invalid; uint32_t id = SD_NO_ID; - FPROTO_SUBGHZD_MODULATION modulation = FPM_AM; // override this, if FM // inner logic stuff, also for flipper compatibility. SubGhzDProtocolDecoderBaseRxCallback callback = NULL; diff --git a/firmware/baseband/fprotos/subghzdprotos.hpp b/firmware/baseband/fprotos/subghzdprotos.hpp index 6710d010..b7469e23 100644 --- a/firmware/baseband/fprotos/subghzdprotos.hpp +++ b/firmware/baseband/fprotos/subghzdprotos.hpp @@ -34,7 +34,7 @@ class SubGhzDProtos : public FProtoListGeneral { void feed(bool level, uint32_t duration) { for (const auto& obj : protos) { - obj->feed(level, duration); + if (obj->modulation == modulation_) obj->feed(level, duration); } } diff --git a/firmware/baseband/proc_weather.cpp b/firmware/baseband/proc_weather.cpp index 45570499..ee78fbbb 100644 --- a/firmware/baseband/proc_weather.cpp +++ b/firmware/baseband/proc_weather.cpp @@ -59,9 +59,6 @@ void WeatherProcessor::on_message(const Message* const message) { void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) { (void)message; - - modulation = message.modulation; // NIY - if (protoMode != message.protoMode) { // change it. FProtoListGeneral* tmp = protoList; @@ -71,6 +68,13 @@ void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) { if (protoMode == 0) protoList = new WeatherProtos(); if (protoMode == 1) protoList = new SubGhzDProtos(); } + + modulation = message.modulation; // NIY + + if (protoList != NULL) { + protoList->setModulation(modulation); + } + configured = true; }