☦️ 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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user