diff --git a/applications/subghz/subghz_i.h b/applications/subghz/subghz_i.h index 0d7d35da..876fbe5a 100644 --- a/applications/subghz/subghz_i.h +++ b/applications/subghz/subghz_i.h @@ -6,6 +6,7 @@ #include "subghz_static.h" #include +#include #include #include #include @@ -24,6 +25,20 @@ static const uint32_t subghz_frequencies[] = { 925000000, }; +static const ApiHalSubGhzPath subghz_frequencies_paths[] = { + ApiHalSubGhzPath2, + ApiHalSubGhzPath2, + ApiHalSubGhzPath2, + ApiHalSubGhzPath2, + ApiHalSubGhzPath1, + ApiHalSubGhzPath1, + ApiHalSubGhzPath1, + ApiHalSubGhzPath3, + ApiHalSubGhzPath3, + ApiHalSubGhzPath3, + ApiHalSubGhzPath3, +}; + static const uint32_t subghz_frequencies_count = sizeof(subghz_frequencies) / sizeof(uint32_t); struct SubGhz { diff --git a/applications/subghz/subghz_static.c b/applications/subghz/subghz_static.c index d4be3e16..bdebafc4 100644 --- a/applications/subghz/subghz_static.c +++ b/applications/subghz/subghz_static.c @@ -22,6 +22,7 @@ typedef enum { } SubghzStaticStatus; typedef struct { + uint8_t frequency; uint32_t real_frequency; ApiHalSubGhzPath path; uint8_t button; @@ -71,18 +72,28 @@ bool subghz_static_input(InputEvent* event, void* context) { with_view_model( subghz_static->view, (SubghzStaticModel * model) { + bool reconfigure = false; if(event->type == InputTypeShort) { if(event->key == InputKeyLeft) { - if(model->button > 0) model->button--; + if(model->frequency > 0) model->frequency--; + reconfigure = true; } else if(event->key == InputKeyRight) { - if(model->button < 2) model->button++; - + if(model->frequency < subghz_frequencies_count - 1) model->frequency++; + reconfigure = true; } else if(event->key == InputKeyDown) { - if(model->path > 0) model->path--; + if(model->button > 0) model->button--; } else if(event->key == InputKeyUp) { - if(model->path < ApiHalSubGhzPath3) model->path++; + if(model->button < 2) model->button++; } + model->path = subghz_frequencies_paths[model->frequency]; + } + + if(reconfigure) { + api_hal_subghz_idle(); + model->real_frequency = + api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); api_hal_subghz_set_path(model->path); + api_hal_subghz_tx(); } if(event->key == InputKeyOk) { @@ -138,9 +149,12 @@ void subghz_static_enter(void* context) { with_view_model( subghz_static->view, (SubghzStaticModel * model) { - model->real_frequency = api_hal_subghz_set_frequency(433920000); - model->path = ApiHalSubGhzPathIsolate; // isolate + model->frequency = 4; + model->real_frequency = + api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]); + model->path = subghz_frequencies_paths[model->frequency]; model->button = 0; + api_hal_subghz_set_path(model->path); return true; });