From 4b8653e061175245b469cb309eaa6deb4c9ff5bc Mon Sep 17 00:00:00 2001 From: Lesha Lomalkin Date: Sat, 4 Dec 2021 16:40:17 +0300 Subject: [PATCH] =?UTF-8?q?Subghz=20chat:=20add=20vibration=20on=20input?= =?UTF-8?q?=20message,=20send=20joined/left=20events=20=E2=80=A6=20(#863)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SubGhz: add vibration on input chat message, send joined/left events to room on start and exit app. * SubGhz: optimize notification api usage Co-authored-by: Aleksandr Kutuzov --- applications/subghz/subghz_cli.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index 5246e478..cd6c6ac2 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -11,6 +11,8 @@ #include #include +#include + #define SUBGHZ_FREQUENCY_RANGE_STR \ "299999755...348000000 or 386999938...464000000 or 778999847...928000000" @@ -388,14 +390,22 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) { string_init(input); string_t name; string_init(name); + string_t sysmsg; + string_init(sysmsg); char c; bool exit = false; + NotificationApp* notification = furi_record_open("notification"); + string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr()); string_set(input, name); printf("%s", string_get_cstr(input)); fflush(stdout); + string_printf(sysmsg, "\033[0;34m%s joined chat.\033[0m", furi_hal_version_get_name_ptr()); + subghz_tx_rx_worker_write( + subghz_txrx, (uint8_t*)string_get_cstr(sysmsg), strlen(string_get_cstr(sysmsg))); + while(!exit) { if(furi_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) { if(c == CliSymbolAsciiETX) { @@ -435,14 +445,23 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) { printf("%s", string_get_cstr(input)); fflush(stdout); + + notification_message(notification, &sequence_single_vibro); } osDelay(1); } + string_printf(sysmsg, "\033[0;31m%s left chat.\033[0m", furi_hal_version_get_name_ptr()); + subghz_tx_rx_worker_write( + subghz_txrx, (uint8_t*)string_get_cstr(sysmsg), strlen(string_get_cstr(sysmsg))); + osDelay(10); + printf("\r\nExit chat\r\n"); string_clear(input); string_clear(name); + string_clear(sysmsg); furi_hal_power_suppress_charge_exit(); + furi_record_close("notification"); if(subghz_tx_rx_worker_is_running(subghz_txrx)) { subghz_tx_rx_worker_stop(subghz_txrx);