HW LED blink integration (#1310)
This commit is contained in:
		| @@ -6,16 +6,47 @@ | ||||
| #include <toolbox/path.h> | ||||
| #include <flipper_format/flipper_format.h> | ||||
|  | ||||
| static const NotificationSequence sequence_blink_start_cyan = { | ||||
|     &message_blink_start_10, | ||||
|     &message_blink_set_color_cyan, | ||||
|     &message_do_not_reset, | ||||
|     NULL, | ||||
| }; | ||||
|  | ||||
| static const NotificationSequence sequence_blink_start_magenta = { | ||||
|     &message_blink_start_10, | ||||
|     &message_blink_set_color_magenta, | ||||
|     &message_do_not_reset, | ||||
|     NULL, | ||||
| }; | ||||
|  | ||||
| static const NotificationSequence sequence_blink_set_yellow = { | ||||
|     &message_blink_set_color_yellow, | ||||
|     NULL, | ||||
| }; | ||||
|  | ||||
| static const NotificationSequence sequence_blink_set_magenta = { | ||||
|     &message_blink_set_color_magenta, | ||||
|     NULL, | ||||
| }; | ||||
|  | ||||
| static const NotificationSequence sequence_blink_stop = { | ||||
|     &message_blink_stop, | ||||
|     NULL, | ||||
| }; | ||||
|  | ||||
| static const NotificationSequence* ibutton_notification_sequences[] = { | ||||
|     &sequence_error, | ||||
|     &sequence_success, | ||||
|     &sequence_blink_cyan_10, | ||||
|     &sequence_blink_magenta_10, | ||||
|     &sequence_blink_yellow_10, | ||||
|     &sequence_blink_start_cyan, | ||||
|     &sequence_blink_start_magenta, | ||||
|     &sequence_blink_set_yellow, | ||||
|     &sequence_blink_set_magenta, | ||||
|     &sequence_set_red_255, | ||||
|     &sequence_reset_red, | ||||
|     &sequence_set_green_255, | ||||
|     &sequence_reset_green, | ||||
|     &sequence_blink_stop, | ||||
| }; | ||||
|  | ||||
| static void ibutton_make_app_folder(iButton* ibutton) { | ||||
|   | ||||
| @@ -64,13 +64,15 @@ typedef enum { | ||||
| typedef enum { | ||||
|     iButtonNotificationMessageError, | ||||
|     iButtonNotificationMessageSuccess, | ||||
|     iButtonNotificationMessageRead, | ||||
|     iButtonNotificationMessageEmulate, | ||||
|     iButtonNotificationMessageReadStart, | ||||
|     iButtonNotificationMessageEmulateStart, | ||||
|     iButtonNotificationMessageYellowBlink, | ||||
|     iButtonNotificationMessageEmulateBlink, | ||||
|     iButtonNotificationMessageRedOn, | ||||
|     iButtonNotificationMessageRedOff, | ||||
|     iButtonNotificationMessageGreenOn, | ||||
|     iButtonNotificationMessageGreenOff, | ||||
|     iButtonNotificationMessageBlinkStop, | ||||
| } iButtonNotificationMessage; | ||||
|  | ||||
| bool ibutton_file_select(iButton* ibutton); | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| #include "../ibutton_i.h" | ||||
| #include "furi/log.h" | ||||
| #include <dolphin/dolphin.h> | ||||
| #include <toolbox/path.h> | ||||
|  | ||||
| @@ -85,6 +86,8 @@ void ibutton_scene_emulate_on_enter(void* context) { | ||||
|     ibutton_worker_emulate_start(ibutton->key_worker, key); | ||||
|  | ||||
|     string_clear(key_name); | ||||
|  | ||||
|     ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart); | ||||
| } | ||||
|  | ||||
| bool ibutton_scene_emulate_on_event(void* context, SceneManagerEvent event) { | ||||
| @@ -93,7 +96,6 @@ bool ibutton_scene_emulate_on_event(void* context, SceneManagerEvent event) { | ||||
|  | ||||
|     if(event.type == SceneManagerEventTypeTick) { | ||||
|         consumed = true; | ||||
|         ibutton_notification_message(ibutton, iButtonNotificationMessageEmulate); | ||||
|     } else if(event.type == SceneManagerEventTypeCustom) { | ||||
|         consumed = true; | ||||
|         if(event.event == iButtonCustomEventWorkerEmulated) { | ||||
| @@ -111,4 +113,5 @@ void ibutton_scene_emulate_on_exit(void* context) { | ||||
|     popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); | ||||
|     popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); | ||||
|     popup_set_icon(popup, 0, 0, NULL); | ||||
|     ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop); | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,8 @@ void ibutton_scene_read_on_enter(void* context) { | ||||
|  | ||||
|     ibutton_worker_read_set_callback(worker, ibutton_scene_read_callback, ibutton); | ||||
|     ibutton_worker_read_start(worker, key); | ||||
|  | ||||
|     ibutton_notification_message(ibutton, iButtonNotificationMessageReadStart); | ||||
| } | ||||
|  | ||||
| bool ibutton_scene_read_on_event(void* context, SceneManagerEvent event) { | ||||
| @@ -31,7 +33,6 @@ bool ibutton_scene_read_on_event(void* context, SceneManagerEvent event) { | ||||
|  | ||||
|     if(event.type == SceneManagerEventTypeTick) { | ||||
|         consumed = true; | ||||
|         ibutton_notification_message(ibutton, iButtonNotificationMessageRead); | ||||
|     } else if(event.type == SceneManagerEventTypeCustom) { | ||||
|         consumed = true; | ||||
|         if(event.event == iButtonCustomEventWorkerRead) { | ||||
| @@ -69,4 +70,6 @@ void ibutton_scene_read_on_exit(void* context) { | ||||
|     popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); | ||||
|     popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); | ||||
|     popup_set_icon(popup, 0, 0, NULL); | ||||
|  | ||||
|     ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop); | ||||
| } | ||||
|   | ||||
| @@ -80,14 +80,14 @@ void ibutton_scene_write_on_enter(void* context) { | ||||
|  | ||||
|     popup_set_icon(popup, 2, 10, &I_iButtonKey_49x44); | ||||
|  | ||||
|     scene_manager_set_scene_state( | ||||
|         ibutton->scene_manager, iButtonSceneWrite, iButtonSceneWriteStateDefault); | ||||
|     view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup); | ||||
|  | ||||
|     ibutton_worker_write_set_callback(worker, ibutton_scene_write_callback, ibutton); | ||||
|     ibutton_worker_write_start(worker, key); | ||||
|  | ||||
|     string_clear(key_name); | ||||
|  | ||||
|     ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart); | ||||
| } | ||||
|  | ||||
| bool ibutton_scene_write_on_event(void* context, SceneManagerEvent event) { | ||||
| @@ -100,21 +100,13 @@ bool ibutton_scene_write_on_event(void* context, SceneManagerEvent event) { | ||||
|         if((event.event == iButtonWorkerWriteOK) || (event.event == iButtonWorkerWriteSameKey)) { | ||||
|             scene_manager_next_scene(scene_manager, iButtonSceneWriteSuccess); | ||||
|         } else if(event.event == iButtonWorkerWriteNoDetect) { | ||||
|             scene_manager_set_scene_state( | ||||
|                 scene_manager, iButtonSceneWrite, iButtonSceneWriteStateDefault); | ||||
|             ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateBlink); | ||||
|         } else if(event.event == iButtonWorkerWriteCannotWrite) { | ||||
|             scene_manager_set_scene_state( | ||||
|                 scene_manager, iButtonSceneWrite, iButtonSceneWriteStateBlinkYellow); | ||||
|             ibutton_notification_message(ibutton, iButtonNotificationMessageYellowBlink); | ||||
|         } | ||||
|  | ||||
|     } else if(event.type == SceneManagerEventTypeTick) { | ||||
|         consumed = true; | ||||
|         if(scene_manager_get_scene_state(scene_manager, iButtonSceneWrite) == | ||||
|            iButtonSceneWriteStateBlinkYellow) { | ||||
|             ibutton_notification_message(ibutton, iButtonNotificationMessageYellowBlink); | ||||
|         } else { | ||||
|             ibutton_notification_message(ibutton, iButtonNotificationMessageEmulate); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     return consumed; | ||||
| @@ -127,4 +119,6 @@ void ibutton_scene_write_on_exit(void* context) { | ||||
|     popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); | ||||
|     popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); | ||||
|     popup_set_icon(popup, 0, 0, NULL); | ||||
|  | ||||
|     ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user