Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSG <who.just.the.doctor@gmail.com>2021-05-24 16:44:14 +0300
committerGitHub <noreply@github.com>2021-05-24 16:44:14 +0300
commit2daf65b62b496c5ba7a2aabfc8c9ed323ac27c41 (patch)
treee8c7474bd796a8a6611ba239103ea1e9fde8c8dd /applications/ibutton
parenteac8626c8c3ef9ba68f5cc2b0912b9d5ff15a061 (diff)
[FL-1237] Notifications app (#476)
* Notification app: init * Notification app: separate message sequences * Notification app: rename notifications to notification * Notification app: rework api * Notification app: new sequences for charger * Power app: add state for better led handling * Power app: NotificationSequence type, notification led process * Blink app: use notifications * Notification app: sound and vibro notifications * Notification app: note messages * Notification app: more messages * Notification app: update note message generator * Blink app: fix state counter * Notification app: fix delay event * App sd-filesystem: notifications * App notifications: headers c++ compatibility * App notifications: Cmaj success chord sequence * App iButton: use notifications * App notification: display backlight notifications * App notification: add "display on" message to success and error sequences * App accessor: use notifications * App ibutton: guard onewire key read * Lib-RFAL: remove api_hal_light usage * App notification: add blocking mode, rework display api * Cli led command: use internal notification instead of direc access to leds. * App unit test: use notifications * App lfrfid: use notifications * Apps: close notification record * App subghz: rough use of notifications * App notificaton: ignore reset flag * App strobe: removed * Lib irda decoder: fix nec decoding * App irda: fix assert, use notifications * Apps: use notifications * Fix IRDA tests * Cli: better var naming * App notification: readable sources Co-authored-by: Albert Kharisov <albert@flipperdevices.com> Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/ibutton')
-rw-r--r--applications/ibutton/helpers/key-reader.cpp6
-rw-r--r--applications/ibutton/ibutton-app.cpp71
-rw-r--r--applications/ibutton/ibutton-app.h13
-rw-r--r--applications/ibutton/scene/ibutton-scene-read-crc-error.cpp3
-rw-r--r--applications/ibutton/scene/ibutton-scene-read-not-key-error.cpp3
-rw-r--r--applications/ibutton/scene/ibutton-scene-read-success.cpp4
-rw-r--r--applications/ibutton/scene/ibutton-scene-write-success.cpp5
7 files changed, 43 insertions, 62 deletions
diff --git a/applications/ibutton/helpers/key-reader.cpp b/applications/ibutton/helpers/key-reader.cpp
index 1b3a9b85..f5885870 100644
--- a/applications/ibutton/helpers/key-reader.cpp
+++ b/applications/ibutton/helpers/key-reader.cpp
@@ -61,6 +61,7 @@ bool KeyReader::read_key(iButtonKeyType* key_type, uint8_t* data, uint8_t data_s
switch(read_mode) {
case ReadMode::DALLAS:
+ __disable_irq();
if(onewire_master->search(data)) {
onewire_master->reset_search();
readed = true;
@@ -68,6 +69,7 @@ bool KeyReader::read_key(iButtonKeyType* key_type, uint8_t* data, uint8_t data_s
} else {
onewire_master->reset_search();
}
+ __enable_irq();
break;
case ReadMode::CYFRAL_METAKOM:
if(cyfral_decoder.read(data, 2)) {
@@ -89,7 +91,7 @@ bool KeyReader::verify_key(iButtonKeyType key_type, const uint8_t* const data, u
switch(key_type) {
case iButtonKeyType::KeyDallas:
switch_to(ReadMode::DALLAS);
-
+ __disable_irq();
if(onewire_master->reset()) {
onewire_master->write(DS1990::CMD_READ_ROM);
for(uint8_t i = 0; i < data_size; i++) {
@@ -101,7 +103,7 @@ bool KeyReader::verify_key(iButtonKeyType key_type, const uint8_t* const data, u
result = false;
break;
}
-
+ __enable_irq();
break;
default:
diff --git a/applications/ibutton/ibutton-app.cpp b/applications/ibutton/ibutton-app.cpp
index c2663d62..5d8e0297 100644
--- a/applications/ibutton/ibutton-app.cpp
+++ b/applications/ibutton/ibutton-app.cpp
@@ -178,7 +178,6 @@ void iButtonApp::cli_send_event(iButtonApp::CliEvent scene) {
}
iButtonApp::iButtonApp() {
- notify_init();
api_hal_power_insomnia_enter();
cli_event_result = osMessageQueueNew(1, sizeof(iButtonApp::Scene), NULL);
@@ -186,6 +185,8 @@ iButtonApp::iButtonApp() {
sd_ex_api = static_cast<SdCard_Api*>(furi_record_open("sdcard-ex"));
fs_api = static_cast<FS_Api*>(furi_record_open("sdcard"));
cli = static_cast<Cli*>(furi_record_open("cli"));
+ notification = static_cast<NotificationApp*>(furi_record_open("notification"));
+
auto callback = cbc::obtain_connector(this, &iButtonApp::cli_cmd_callback);
cli_add_command(cli, "tm", callback, cli);
@@ -194,10 +195,13 @@ iButtonApp::iButtonApp() {
}
iButtonApp::~iButtonApp() {
+ cli_delete_command(cli, "tm");
+
furi_record_close("sdcard-ex");
furi_record_close("sdcard");
- cli_delete_command(cli, "tm");
furi_record_close("cli");
+ furi_record_close("notification");
+
osMessageQueueDelete(cli_event_result);
for(std::map<Scene, iButtonScene*>::iterator it = scenes.begin(); it != scenes.end(); ++it) {
@@ -294,73 +298,40 @@ uint8_t iButtonApp::get_file_name_size() {
return file_name_size;
}
-void iButtonApp::notify_init() {
- // TODO open record
- const GpioPin* vibro_record = &vibro_gpio;
- hal_gpio_init(vibro_record, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
- hal_gpio_write(vibro_record, false);
-}
-
void iButtonApp::notify_green_blink() {
- notify_green_on();
- delay(10);
- notify_green_off();
+ notification_message(notification, &sequence_blink_green_10);
}
void iButtonApp::notify_yellow_blink() {
- notify_red_on();
- notify_green_on();
- delay(10);
- notify_green_off();
- notify_red_off();
+ notification_message(notification, &sequence_blink_yellow_10);
}
void iButtonApp::notify_red_blink() {
- notify_red_on();
- delay(10);
- notify_red_off();
-}
-
-void iButtonApp::notify_green_on() {
- api_hal_light_set(LightGreen, 0xFF);
-}
-
-void iButtonApp::notify_green_off() {
- api_hal_light_set(LightGreen, 0x00);
+ notification_message(notification, &sequence_blink_red_10);
}
-void iButtonApp::notify_red_on() {
- api_hal_light_set(LightRed, 0xFF);
+void iButtonApp::notify_error() {
+ notification_message(notification, &sequence_error);
}
-void iButtonApp::notify_red_off() {
- api_hal_light_set(LightRed, 0x00);
+void iButtonApp::notify_success() {
+ notification_message(notification, &sequence_success);
}
-void iButtonApp::notify_error() {
- notify_vibro_on();
- delay(50);
- notify_vibro_off();
- delay(100);
- notify_vibro_on();
- delay(50);
- notify_vibro_off();
+void iButtonApp::notify_green_on() {
+ notification_message_block(notification, &sequence_set_green_255);
}
-void iButtonApp::notify_success() {
- notify_vibro_on();
- hal_pwm_set(0.5, 1760, &SPEAKER_TIM, SPEAKER_CH);
- delay(50);
- hal_pwm_stop(&SPEAKER_TIM, SPEAKER_CH);
- notify_vibro_off();
+void iButtonApp::notify_green_off() {
+ notification_message(notification, &sequence_reset_green);
}
-void iButtonApp::notify_vibro_on() {
- hal_gpio_write(&vibro_gpio, true);
+void iButtonApp::notify_red_on() {
+ notification_message_block(notification, &sequence_set_red_255);
}
-void iButtonApp::notify_vibro_off() {
- hal_gpio_write(&vibro_gpio, false);
+void iButtonApp::notify_red_off() {
+ notification_message(notification, &sequence_reset_red);
}
void iButtonApp::set_text_store(const char* text...) {
diff --git a/applications/ibutton/ibutton-app.h b/applications/ibutton/ibutton-app.h
index a32d4abd..48db20f8 100644
--- a/applications/ibutton/ibutton-app.h
+++ b/applications/ibutton/ibutton-app.h
@@ -36,6 +36,8 @@
#include "maxim_crc.h"
#include "ibutton-key.h"
+#include <notification/notification-messages.h>
+
class iButtonApp {
public:
void run(void);
@@ -92,17 +94,13 @@ public:
void notify_yellow_blink();
void notify_red_blink();
+ void notify_error();
+ void notify_success();
void notify_green_on();
void notify_green_off();
void notify_red_on();
void notify_red_off();
- void notify_error();
- void notify_success();
-
- void notify_vibro_on();
- void notify_vibro_off();
-
void set_text_store(const char* text...);
char* get_text_store();
uint8_t get_text_store_size();
@@ -160,7 +158,8 @@ private:
static const uint8_t text_store_size = 128;
char text_store[text_store_size + 1];
- void notify_init();
+ NotificationApp* notification;
+
bool read_hex_byte(string_t arg, uint8_t* byte);
void print_key_data(void);
}; \ No newline at end of file
diff --git a/applications/ibutton/scene/ibutton-scene-read-crc-error.cpp b/applications/ibutton/scene/ibutton-scene-read-crc-error.cpp
index 00d03845..c86ae32a 100644
--- a/applications/ibutton/scene/ibutton-scene-read-crc-error.cpp
+++ b/applications/ibutton/scene/ibutton-scene-read-crc-error.cpp
@@ -33,6 +33,7 @@ void iButtonSceneReadCRCError::on_enter(iButtonApp* app) {
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx);
app->notify_error();
+ app->notify_red_on();
}
bool iButtonSceneReadCRCError::on_event(iButtonApp* app, iButtonEvent* event) {
@@ -62,6 +63,8 @@ void iButtonSceneReadCRCError::on_exit(iButtonApp* app) {
dialog_ex_set_left_button_text(dialog_ex, NULL);
dialog_ex_set_result_callback(dialog_ex, NULL);
dialog_ex_set_context(dialog_ex, NULL);
+
+ app->notify_red_off();
}
void iButtonSceneReadCRCError::dialog_ex_callback(DialogExResult result, void* context) {
diff --git a/applications/ibutton/scene/ibutton-scene-read-not-key-error.cpp b/applications/ibutton/scene/ibutton-scene-read-not-key-error.cpp
index 8cd3cd00..b0cea3e7 100644
--- a/applications/ibutton/scene/ibutton-scene-read-not-key-error.cpp
+++ b/applications/ibutton/scene/ibutton-scene-read-not-key-error.cpp
@@ -33,6 +33,7 @@ void iButtonSceneReadNotKeyError::on_enter(iButtonApp* app) {
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx);
app->notify_error();
+ app->notify_red_on();
}
bool iButtonSceneReadNotKeyError::on_event(iButtonApp* app, iButtonEvent* event) {
@@ -62,6 +63,8 @@ void iButtonSceneReadNotKeyError::on_exit(iButtonApp* app) {
dialog_ex_set_left_button_text(dialog_ex, NULL);
dialog_ex_set_result_callback(dialog_ex, NULL);
dialog_ex_set_context(dialog_ex, NULL);
+
+ app->notify_red_off();
}
void iButtonSceneReadNotKeyError::dialog_ex_callback(DialogExResult result, void* context) {
diff --git a/applications/ibutton/scene/ibutton-scene-read-success.cpp b/applications/ibutton/scene/ibutton-scene-read-success.cpp
index 28b38e61..5e037a96 100644
--- a/applications/ibutton/scene/ibutton-scene-read-success.cpp
+++ b/applications/ibutton/scene/ibutton-scene-read-success.cpp
@@ -42,8 +42,9 @@ void iButtonSceneReadSuccess::on_enter(iButtonApp* app) {
dialog_ex_set_context(dialog_ex, app);
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx);
- app->notify_green_on();
+
app->notify_success();
+ app->notify_green_on();
}
bool iButtonSceneReadSuccess::on_event(iButtonApp* app, iButtonEvent* event) {
@@ -74,6 +75,7 @@ void iButtonSceneReadSuccess::on_exit(iButtonApp* app) {
dialog_ex_set_result_callback(dialog_ex, NULL);
dialog_ex_set_context(dialog_ex, NULL);
dialog_ex_set_icon(dialog_ex, -1, -1, I_ButtonCenter_7x7);
+
app->notify_green_off();
}
diff --git a/applications/ibutton/scene/ibutton-scene-write-success.cpp b/applications/ibutton/scene/ibutton-scene-write-success.cpp
index 2c5e77ee..f66181a4 100644
--- a/applications/ibutton/scene/ibutton-scene-write-success.cpp
+++ b/applications/ibutton/scene/ibutton-scene-write-success.cpp
@@ -19,8 +19,9 @@ void iButtonSceneWriteSuccess::on_enter(iButtonApp* app) {
popup_enable_timeout(popup);
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewPopup);
- app->notify_green_on();
+
app->notify_success();
+ app->notify_green_on();
}
bool iButtonSceneWriteSuccess::on_event(iButtonApp* app, iButtonEvent* event) {
@@ -44,7 +45,6 @@ void iButtonSceneWriteSuccess::on_exit(iButtonApp* app) {
popup_disable_timeout(popup);
popup_set_context(popup, NULL);
popup_set_callback(popup, NULL);
- app->notify_green_off();
}
void iButtonSceneWriteSuccess::popup_callback(void* context) {
@@ -52,4 +52,5 @@ void iButtonSceneWriteSuccess::popup_callback(void* context) {
iButtonEvent event;
event.type = iButtonEvent::Type::EventTypeBack;
app->get_view_manager()->send_event(&event);
+ app->notify_green_off();
} \ No newline at end of file