This commit is contained in:
HTotoo 2023-12-08 13:32:28 +01:00
parent b45638f9ed
commit 30b4e43794
8 changed files with 22 additions and 7 deletions

View File

@ -92,7 +92,7 @@ SubGhzDView::SubGhzDView(NavigationView& nav)
recent_entries_view.on_select = [this](const SubGhzDRecentEntry& entry) { recent_entries_view.on_select = [this](const SubGhzDRecentEntry& entry) {
nav_.push<SubGhzDRecentEntryDetailView>(entry); nav_.push<SubGhzDRecentEntryDetailView>(entry);
}; };
baseband::set_weather(); baseband::set_subghzd(0);
receiver_model.enable(); receiver_model.enable();
signal_token_tick_second = rtc_time::signal_tick_second += [this]() { signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
on_tick_second(); on_tick_second();

View File

@ -324,6 +324,11 @@ void set_weather() {
send_message(&message); send_message(&message);
} }
void set_subghzd(uint8_t modulation = 0) {
const SubGhzFPRxConfigureMessage message{modulation, 1};
send_message(&message);
}
static bool baseband_image_running = false; static bool baseband_image_running = false;
void run_image(const spi_flash::image_tag_t image_tag) { void run_image(const spi_flash::image_tag_t image_tag) {

View File

@ -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_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_spectrum_painter_config(const uint16_t width, const uint16_t height, bool update, int32_t bw);
void set_weather(); void set_weather();
void set_subghzd(uint8_t modulation);
void request_beep(); void request_beep();
void run_image(const portapack::spi_flash::image_tag_t image_tag); void run_image(const portapack::spi_flash::image_tag_t image_tag);

View File

@ -1,6 +1,8 @@
#ifndef __FPROTO_GENERAL_H__ #ifndef __FPROTO_GENERAL_H__
#define __FPROTO_GENERAL_H__ #define __FPROTO_GENERAL_H__
// useful methods for both weather and subghzd
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>

View File

@ -7,6 +7,10 @@ class FProtoListGeneral {
FProtoListGeneral() {} FProtoListGeneral() {}
virtual ~FProtoListGeneral() {} virtual ~FProtoListGeneral() {}
virtual void feed(bool level, uint32_t duration) = 0; virtual void feed(bool level, uint32_t duration) = 0;
void setModulation(uint8_t modulation) { modulation_ = modulation; }
protected:
uint8_t modulation_ = 0;
}; };
#endif #endif

View File

@ -26,7 +26,7 @@ class FProtoSubGhzDBase {
uint8_t getSensorType() { return sensorType; } uint8_t getSensorType() { return sensorType; }
uint32_t getSensorId() { return id; } uint32_t getSensorId() { return id; }
FPROTO_SUBGHZD_MODULATION modulation = FPM_AM; // override this, if FM
protected: protected:
// Helper functions to keep it as compatible with flipper as we can, so adding new protos will be easy. // 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) { void subghz_protocol_blocks_add_bit(uint8_t bit) {
@ -37,7 +37,6 @@ class FProtoSubGhzDBase {
// General weather data holder // General weather data holder
uint8_t sensorType = FPS_Invalid; uint8_t sensorType = FPS_Invalid;
uint32_t id = SD_NO_ID; uint32_t id = SD_NO_ID;
FPROTO_SUBGHZD_MODULATION modulation = FPM_AM; // override this, if FM
// inner logic stuff, also for flipper compatibility. // inner logic stuff, also for flipper compatibility.
SubGhzDProtocolDecoderBaseRxCallback callback = NULL; SubGhzDProtocolDecoderBaseRxCallback callback = NULL;

View File

@ -34,7 +34,7 @@ class SubGhzDProtos : public FProtoListGeneral {
void feed(bool level, uint32_t duration) { void feed(bool level, uint32_t duration) {
for (const auto& obj : protos) { for (const auto& obj : protos) {
obj->feed(level, duration); if (obj->modulation == modulation_) obj->feed(level, duration);
} }
} }

View File

@ -59,9 +59,6 @@ void WeatherProcessor::on_message(const Message* const message) {
void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) { void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) {
(void)message; (void)message;
modulation = message.modulation; // NIY
if (protoMode != message.protoMode) { if (protoMode != message.protoMode) {
// change it. // change it.
FProtoListGeneral* tmp = protoList; FProtoListGeneral* tmp = protoList;
@ -71,6 +68,13 @@ void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) {
if (protoMode == 0) protoList = new WeatherProtos(); if (protoMode == 0) protoList = new WeatherProtos();
if (protoMode == 1) protoList = new SubGhzDProtos(); if (protoMode == 1) protoList = new SubGhzDProtos();
} }
modulation = message.modulation; // NIY
if (protoList != NULL) {
protoList->setModulation(modulation);
}
configured = true; configured = true;
} }