mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-23 19:00:43 +03:00
☦️ Rpc: implement SystemPlayAudiovisualAlert (#937)
* Rpc: update protobuf sources * Notification: allow user settings override * Notification: add audiovisual alert sequence * Rpc: implement SystemPlayAudiovisualAlert
This commit is contained in:
parent
c036ac6f18
commit
475fa91ba6
@ -165,6 +165,9 @@ void notification_process_notification_message(
|
||||
bool led_active = false;
|
||||
uint8_t led_values[NOTIFICATION_LED_COUNT] = {0x00, 0x00, 0x00};
|
||||
bool reset_notifications = true;
|
||||
float speaker_volume_setting = app->settings.speaker_volume;
|
||||
bool vibro_setting = app->settings.vibro_on;
|
||||
float display_brightness_setting = app->settings.display_brightness;
|
||||
|
||||
uint8_t reset_mask = 0;
|
||||
|
||||
@ -177,8 +180,7 @@ void notification_process_notification_message(
|
||||
if(notification_message->data.led.value > 0x00) {
|
||||
notification_apply_notification_led_layer(
|
||||
&app->display,
|
||||
notification_settings_get_display_brightness(
|
||||
app, notification_message->data.led.value));
|
||||
notification_message->data.led.value * display_brightness_setting);
|
||||
} else {
|
||||
notification_reset_notification_led_layer(&app->display);
|
||||
if(osTimerIsRunning(app->display_timer)) {
|
||||
@ -207,7 +209,7 @@ void notification_process_notification_message(
|
||||
break;
|
||||
case NotificationMessageTypeVibro:
|
||||
if(notification_message->data.vibro.on) {
|
||||
if(app->settings.vibro_on) notification_vibro_on();
|
||||
if(vibro_setting) notification_vibro_on();
|
||||
} else {
|
||||
notification_vibro_off();
|
||||
}
|
||||
@ -215,7 +217,7 @@ void notification_process_notification_message(
|
||||
break;
|
||||
case NotificationMessageTypeSoundOn:
|
||||
notification_sound_on(
|
||||
notification_message->data.sound.pwm * app->settings.speaker_volume,
|
||||
notification_message->data.sound.pwm * speaker_volume_setting,
|
||||
notification_message->data.sound.frequency);
|
||||
reset_mask |= reset_sound_mask;
|
||||
break;
|
||||
@ -243,6 +245,15 @@ void notification_process_notification_message(
|
||||
case NotificationMessageTypeDoNotReset:
|
||||
reset_notifications = false;
|
||||
break;
|
||||
case NotificationMessageTypeForceSpeakerVolumeSetting:
|
||||
speaker_volume_setting = notification_message->data.forced_settings.speaker_volume;
|
||||
break;
|
||||
case NotificationMessageTypeForceVibroSetting:
|
||||
vibro_setting = notification_message->data.forced_settings.vibro;
|
||||
break;
|
||||
case NotificationMessageTypeForceDisplayBrightnessSetting:
|
||||
display_brightness_setting =
|
||||
notification_message->data.forced_settings.display_brightness;
|
||||
}
|
||||
notification_message_index++;
|
||||
notification_message = (*message->sequence)[notification_message_index];
|
||||
|
@ -109,6 +109,27 @@ const NotificationMessage message_do_not_reset = {
|
||||
.type = NotificationMessageTypeDoNotReset,
|
||||
};
|
||||
|
||||
// Override user settings
|
||||
const NotificationMessage message_force_speaker_volume_setting_1f = {
|
||||
.type = NotificationMessageTypeForceSpeakerVolumeSetting,
|
||||
.data.forced_settings.speaker_volume = 1.0f,
|
||||
};
|
||||
|
||||
const NotificationMessage message_force_vibro_setting_on = {
|
||||
.type = NotificationMessageTypeForceVibroSetting,
|
||||
.data.forced_settings.vibro = true,
|
||||
};
|
||||
|
||||
const NotificationMessage message_force_vibro_setting_off = {
|
||||
.type = NotificationMessageTypeForceVibroSetting,
|
||||
.data.forced_settings.vibro = false,
|
||||
};
|
||||
|
||||
const NotificationMessage message_force_display_brightness_setting_1f = {
|
||||
.type = NotificationMessageTypeForceDisplayBrightnessSetting,
|
||||
.data.forced_settings.display_brightness = 1.0f,
|
||||
};
|
||||
|
||||
/****************************** Message sequences ******************************/
|
||||
|
||||
// Reset
|
||||
@ -361,3 +382,38 @@ const NotificationSequence sequence_error = {
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
|
||||
const NotificationSequence sequence_audiovisual_alert = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_force_vibro_setting_on,
|
||||
&message_force_display_brightness_setting_1f,
|
||||
&message_vibro_on,
|
||||
|
||||
&message_display_on,
|
||||
&message_note_c7,
|
||||
&message_delay_250,
|
||||
|
||||
&message_display_off,
|
||||
&message_note_c4,
|
||||
&message_delay_250,
|
||||
|
||||
&message_display_on,
|
||||
&message_note_c7,
|
||||
&message_delay_250,
|
||||
|
||||
&message_display_off,
|
||||
&message_note_c4,
|
||||
&message_delay_250,
|
||||
|
||||
&message_display_on,
|
||||
&message_note_c7,
|
||||
&message_delay_250,
|
||||
|
||||
&message_display_off,
|
||||
&message_note_c4,
|
||||
&message_delay_250,
|
||||
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
NULL,
|
||||
};
|
@ -42,6 +42,12 @@ extern const NotificationMessage message_vibro_off;
|
||||
// Reset
|
||||
extern const NotificationMessage message_do_not_reset;
|
||||
|
||||
// Override user settings
|
||||
extern const NotificationMessage message_force_speaker_volume_setting_1f;
|
||||
extern const NotificationMessage message_force_vibro_setting_on;
|
||||
extern const NotificationMessage message_force_vibro_setting_off;
|
||||
extern const NotificationMessage message_force_display_brightness_setting_1f;
|
||||
|
||||
/****************************** Message sequences ******************************/
|
||||
|
||||
// Reset
|
||||
@ -93,6 +99,7 @@ extern const NotificationSequence sequence_single_vibro;
|
||||
extern const NotificationSequence sequence_double_vibro;
|
||||
extern const NotificationSequence sequence_success;
|
||||
extern const NotificationSequence sequence_error;
|
||||
extern const NotificationSequence sequence_audiovisual_alert;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -24,11 +24,18 @@ typedef struct {
|
||||
uint32_t length;
|
||||
} NotificationMessageDataDelay;
|
||||
|
||||
typedef struct {
|
||||
float speaker_volume;
|
||||
bool vibro;
|
||||
float display_brightness;
|
||||
} NotificationMessageDataForcedSettings;
|
||||
|
||||
typedef union {
|
||||
NotificationMessageDataSound sound;
|
||||
NotificationMessageDataLed led;
|
||||
NotificationMessageDataVibro vibro;
|
||||
NotificationMessageDataDelay delay;
|
||||
NotificationMessageDataForcedSettings forced_settings;
|
||||
} NotificationMessageData;
|
||||
|
||||
typedef enum {
|
||||
@ -41,6 +48,9 @@ typedef enum {
|
||||
NotificationMessageTypeDelay,
|
||||
NotificationMessageTypeLedDisplay,
|
||||
NotificationMessageTypeDoNotReset,
|
||||
NotificationMessageTypeForceSpeakerVolumeSetting,
|
||||
NotificationMessageTypeForceVibroSetting,
|
||||
NotificationMessageTypeForceDisplayBrightnessSetting,
|
||||
} NotificationMessageType;
|
||||
|
||||
typedef struct {
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <furi-hal.h>
|
||||
#include <power/power_service/power.h>
|
||||
#include <notification/notification-messages.h>
|
||||
|
||||
void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) {
|
||||
furi_assert(msg_request);
|
||||
@ -157,6 +158,19 @@ void rpc_system_system_factory_reset_process(const PB_Main* request, void* conte
|
||||
power_reboot(PowerBootModeNormal);
|
||||
}
|
||||
|
||||
void rpc_system_system_play_audiovisual_alert_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_play_audiovisual_alert_request_tag);
|
||||
furi_assert(context);
|
||||
Rpc* rpc = context;
|
||||
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &sequence_audiovisual_alert);
|
||||
furi_record_close("notification");
|
||||
|
||||
rpc_send_and_release_empty(rpc, request->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
|
||||
void* rpc_system_system_alloc(Rpc* rpc) {
|
||||
RpcHandler rpc_handler = {
|
||||
.message_handler = NULL,
|
||||
@ -182,5 +196,8 @@ void* rpc_system_system_alloc(Rpc* rpc) {
|
||||
rpc_handler.message_handler = rpc_system_system_set_datetime_process;
|
||||
rpc_add_handler(rpc, PB_Main_system_set_datetime_request_tag, &rpc_handler);
|
||||
|
||||
rpc_handler.message_handler = rpc_system_system_play_audiovisual_alert_process;
|
||||
rpc_add_handler(rpc, PB_Main_system_play_audiovisual_alert_request_tag, &rpc_handler);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ typedef struct _PB_Main {
|
||||
PB_System_GetDateTimeRequest system_get_datetime_request;
|
||||
PB_System_GetDateTimeResponse system_get_datetime_response;
|
||||
PB_System_SetDateTimeRequest system_set_datetime_request;
|
||||
PB_System_PlayAudiovisualAlertRequest system_play_audiovisual_alert_request;
|
||||
} content;
|
||||
} PB_Main;
|
||||
|
||||
@ -155,6 +156,7 @@ extern "C" {
|
||||
#define PB_Main_system_get_datetime_request_tag 35
|
||||
#define PB_Main_system_get_datetime_response_tag 36
|
||||
#define PB_Main_system_set_datetime_request_tag 37
|
||||
#define PB_Main_system_play_audiovisual_alert_request_tag 38
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define PB_Empty_FIELDLIST(X, a) \
|
||||
@ -204,7 +206,8 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,system_device_info_response,content.
|
||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_factory_reset_request,content.system_factory_reset_request), 34) \
|
||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_get_datetime_request,content.system_get_datetime_request), 35) \
|
||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_get_datetime_response,content.system_get_datetime_response), 36) \
|
||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_set_datetime_request,content.system_set_datetime_request), 37)
|
||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_set_datetime_request,content.system_set_datetime_request), 37) \
|
||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_play_audiovisual_alert_request,content.system_play_audiovisual_alert_request), 38)
|
||||
#define PB_Main_CALLBACK NULL
|
||||
#define PB_Main_DEFAULT NULL
|
||||
#define PB_Main_content_empty_MSGTYPE PB_Empty
|
||||
@ -241,6 +244,7 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,system_set_datetime_request,content.
|
||||
#define PB_Main_content_system_get_datetime_request_MSGTYPE PB_System_GetDateTimeRequest
|
||||
#define PB_Main_content_system_get_datetime_response_MSGTYPE PB_System_GetDateTimeResponse
|
||||
#define PB_Main_content_system_set_datetime_request_MSGTYPE PB_System_SetDateTimeRequest
|
||||
#define PB_Main_content_system_play_audiovisual_alert_request_MSGTYPE PB_System_PlayAudiovisualAlertRequest
|
||||
|
||||
extern const pb_msgdesc_t PB_Empty_msg;
|
||||
extern const pb_msgdesc_t PB_StopSession_msg;
|
||||
|
@ -36,5 +36,8 @@ PB_BIND(PB_System_SetDateTimeRequest, PB_System_SetDateTimeRequest, AUTO)
|
||||
PB_BIND(PB_System_DateTime, PB_System_DateTime, AUTO)
|
||||
|
||||
|
||||
PB_BIND(PB_System_PlayAudiovisualAlertRequest, PB_System_PlayAudiovisualAlertRequest, AUTO)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -41,6 +41,10 @@ typedef struct _PB_System_PingResponse {
|
||||
pb_bytes_array_t *data;
|
||||
} PB_System_PingResponse;
|
||||
|
||||
typedef struct _PB_System_PlayAudiovisualAlertRequest {
|
||||
char dummy_field;
|
||||
} PB_System_PlayAudiovisualAlertRequest;
|
||||
|
||||
typedef struct _PB_System_DateTime {
|
||||
/* Time */
|
||||
uint8_t hour; /* *< Hour in 24H format: 0-23 */
|
||||
@ -89,6 +93,7 @@ extern "C" {
|
||||
#define PB_System_GetDateTimeResponse_init_default {false, PB_System_DateTime_init_default}
|
||||
#define PB_System_SetDateTimeRequest_init_default {false, PB_System_DateTime_init_default}
|
||||
#define PB_System_DateTime_init_default {0, 0, 0, 0, 0, 0, 0}
|
||||
#define PB_System_PlayAudiovisualAlertRequest_init_default {0}
|
||||
#define PB_System_PingRequest_init_zero {NULL}
|
||||
#define PB_System_PingResponse_init_zero {NULL}
|
||||
#define PB_System_RebootRequest_init_zero {_PB_System_RebootRequest_RebootMode_MIN}
|
||||
@ -99,6 +104,7 @@ extern "C" {
|
||||
#define PB_System_GetDateTimeResponse_init_zero {false, PB_System_DateTime_init_zero}
|
||||
#define PB_System_SetDateTimeRequest_init_zero {false, PB_System_DateTime_init_zero}
|
||||
#define PB_System_DateTime_init_zero {0, 0, 0, 0, 0, 0, 0}
|
||||
#define PB_System_PlayAudiovisualAlertRequest_init_zero {0}
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define PB_System_DeviceInfoResponse_key_tag 1
|
||||
@ -176,6 +182,11 @@ X(a, STATIC, SINGULAR, UINT32, weekday, 7)
|
||||
#define PB_System_DateTime_CALLBACK NULL
|
||||
#define PB_System_DateTime_DEFAULT NULL
|
||||
|
||||
#define PB_System_PlayAudiovisualAlertRequest_FIELDLIST(X, a) \
|
||||
|
||||
#define PB_System_PlayAudiovisualAlertRequest_CALLBACK NULL
|
||||
#define PB_System_PlayAudiovisualAlertRequest_DEFAULT NULL
|
||||
|
||||
extern const pb_msgdesc_t PB_System_PingRequest_msg;
|
||||
extern const pb_msgdesc_t PB_System_PingResponse_msg;
|
||||
extern const pb_msgdesc_t PB_System_RebootRequest_msg;
|
||||
@ -186,6 +197,7 @@ extern const pb_msgdesc_t PB_System_GetDateTimeRequest_msg;
|
||||
extern const pb_msgdesc_t PB_System_GetDateTimeResponse_msg;
|
||||
extern const pb_msgdesc_t PB_System_SetDateTimeRequest_msg;
|
||||
extern const pb_msgdesc_t PB_System_DateTime_msg;
|
||||
extern const pb_msgdesc_t PB_System_PlayAudiovisualAlertRequest_msg;
|
||||
|
||||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||
#define PB_System_PingRequest_fields &PB_System_PingRequest_msg
|
||||
@ -198,6 +210,7 @@ extern const pb_msgdesc_t PB_System_DateTime_msg;
|
||||
#define PB_System_GetDateTimeResponse_fields &PB_System_GetDateTimeResponse_msg
|
||||
#define PB_System_SetDateTimeRequest_fields &PB_System_SetDateTimeRequest_msg
|
||||
#define PB_System_DateTime_fields &PB_System_DateTime_msg
|
||||
#define PB_System_PlayAudiovisualAlertRequest_fields &PB_System_PlayAudiovisualAlertRequest_msg
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
/* PB_System_PingRequest_size depends on runtime parameters */
|
||||
@ -208,6 +221,7 @@ extern const pb_msgdesc_t PB_System_DateTime_msg;
|
||||
#define PB_System_FactoryResetRequest_size 0
|
||||
#define PB_System_GetDateTimeRequest_size 0
|
||||
#define PB_System_GetDateTimeResponse_size 24
|
||||
#define PB_System_PlayAudiovisualAlertRequest_size 0
|
||||
#define PB_System_RebootRequest_size 2
|
||||
#define PB_System_SetDateTimeRequest_size 24
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f5365c36aa458eb344280560440d6e27232a5667
|
||||
Subproject commit 5409d34a29073f5b51acad1cb5c24663f4e625e2
|
Loading…
Reference in New Issue
Block a user