mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 20:43:07 +00:00
Show RSSI in Weather Station app (#2395)
* Show RSSI in weather station app: copy changes from main SubGHz app * WeatherStation: remove dead code * WeatherStation: sync naming schema with current code. Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
b15c4afea1
commit
0a3ff7f85a
3 changed files with 36 additions and 2 deletions
|
@ -195,6 +195,10 @@ bool weather_station_scene_receiver_on_event(void* context, SceneManagerEvent ev
|
|||
ws_hopper_update(app);
|
||||
weather_station_scene_receiver_update_statusbar(app);
|
||||
}
|
||||
// Get current RSSI
|
||||
float rssi = furi_hal_subghz_get_rssi();
|
||||
ws_view_receiver_set_rssi(app->ws_receiver, rssi);
|
||||
|
||||
if(app->txrx->txrx_state == WSTxRxStateRx) {
|
||||
notification_message(app->notifications, &sequence_blink_cyan_10);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#define MENU_ITEMS 4u
|
||||
#define UNLOCK_CNT 3
|
||||
|
||||
#define SUBGHZ_RAW_TRESHOLD_MIN -90.0f
|
||||
typedef struct {
|
||||
FuriString* item_str;
|
||||
uint8_t type;
|
||||
|
@ -59,8 +60,24 @@ typedef struct {
|
|||
uint16_t list_offset;
|
||||
uint16_t history_item;
|
||||
WSReceiverBarShow bar_show;
|
||||
uint8_t u_rssi;
|
||||
} WSReceiverModel;
|
||||
|
||||
void ws_view_receiver_set_rssi(WSReceiver* instance, float rssi) {
|
||||
furi_assert(instance);
|
||||
with_view_model(
|
||||
instance->view,
|
||||
WSReceiverModel * model,
|
||||
{
|
||||
if(rssi < SUBGHZ_RAW_TRESHOLD_MIN) {
|
||||
model->u_rssi = 0;
|
||||
} else {
|
||||
model->u_rssi = (uint8_t)(rssi - SUBGHZ_RAW_TRESHOLD_MIN);
|
||||
}
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void ws_view_receiver_set_lock(WSReceiver* ws_receiver, WSLock lock) {
|
||||
furi_assert(ws_receiver);
|
||||
ws_receiver->lock_count = 0;
|
||||
|
@ -164,13 +181,22 @@ static void ws_view_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrol
|
|||
canvas_draw_dot(canvas, scrollbar ? 121 : 126, (0 + idx * FRAME_HEIGHT) + 11);
|
||||
}
|
||||
|
||||
static void ws_view_rssi_draw(Canvas* canvas, WSReceiverModel* model) {
|
||||
for(uint8_t i = 1; i < model->u_rssi; i++) {
|
||||
if(i % 5) {
|
||||
canvas_draw_dot(canvas, 46 + i, 50);
|
||||
canvas_draw_dot(canvas, 47 + i, 51);
|
||||
canvas_draw_dot(canvas, 46 + i, 52);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
|
||||
elements_button_left(canvas, "Config");
|
||||
canvas_draw_line(canvas, 46, 51, 125, 51);
|
||||
|
||||
bool scrollbar = model->history_item > 4;
|
||||
FuriString* str_buff;
|
||||
|
@ -203,10 +229,12 @@ void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) {
|
|||
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 63, 46, "Scanning...");
|
||||
canvas_draw_line(canvas, 46, 51, 125, 51);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
}
|
||||
|
||||
// Draw RSSI
|
||||
ws_view_rssi_draw(canvas, model);
|
||||
|
||||
switch(model->bar_show) {
|
||||
case WSReceiverBarShowLock:
|
||||
canvas_draw_icon(canvas, 64, 55, &I_Lock_7x8);
|
||||
|
|
|
@ -8,6 +8,8 @@ typedef struct WSReceiver WSReceiver;
|
|||
|
||||
typedef void (*WSReceiverCallback)(WSCustomEvent event, void* context);
|
||||
|
||||
void ws_view_receiver_set_rssi(WSReceiver* instance, float rssi);
|
||||
|
||||
void ws_view_receiver_set_lock(WSReceiver* ws_receiver, WSLock keyboard);
|
||||
|
||||
void ws_view_receiver_set_callback(
|
||||
|
|
Loading…
Reference in a new issue