9090#include <furi_hal.h>
9191
9292#include <dolphin/dolphin.h>
93+ #include <notification/notification_messages.h>
9394
9495#include <gui/elements.h>
9596#include <gui/view.h>
@@ -222,6 +223,7 @@ struct trade_ctx {
222223 void * gblink_handle ;
223224 struct gblink_pins * gblink_pins ;
224225 PokemonData * pdata ;
226+ NotificationApp * notifications ;
225227};
226228
227229/* These are the needed variables for the draw callback */
@@ -320,6 +322,21 @@ static void pokemon_plist_recreate_callback(void* context, uint32_t arg) {
320322 plist_create (& (trade -> patch_list ), trade -> pdata );
321323}
322324
325+ /* Call this at any point to reset the timer on the backlight turning off.
326+ * During trade, this should get called pretty frequently so long as data
327+ * is moving in and out.
328+ *
329+ * I hesitate to force the backlight on, as I don't want to be responsible
330+ * for draining someone's battery on accident.
331+ */
332+ static void trade_backlight_bump_callback (void * context , uint32_t arg ) {
333+ furi_assert (context );
334+ UNUSED (arg );
335+ struct trade_ctx * trade = context ;
336+
337+ notification_message (trade -> notifications , & sequence_display_backlight_on );
338+ }
339+
323340static void trade_draw_bottom_bar (Canvas * const canvas ) {
324341 furi_assert (canvas );
325342
@@ -835,6 +852,9 @@ static void transferBit(void* context, uint8_t in_byte) {
835852 gblink_transfer (trade -> gblink_handle , getTradeCentreResponse (trade ));
836853 break ;
837854 }
855+
856+ /* Each byte that comes in, bump the backlight timer so it stays on during a trade */
857+ furi_timer_pending_callback (trade_backlight_bump_callback , trade , 0 );
838858}
839859
840860void trade_enter_callback (void * context ) {
@@ -915,6 +935,7 @@ void* trade_alloc(
915935 trade -> input_pdata = pokemon_data_alloc (pdata -> gen );
916936 trade -> patch_list = NULL ;
917937 trade -> gblink_pins = gblink_pins ;
938+ trade -> notifications = furi_record_open (RECORD_NOTIFICATION );
918939
919940 view_set_context (trade -> view , trade );
920941 view_allocate_model (trade -> view , ViewModelTypeLockFree , sizeof (struct trade_model ));
@@ -938,6 +959,8 @@ void trade_free(ViewDispatcher* view_dispatcher, uint32_t view_id, void* trade_c
938959
939960 view_dispatcher_remove_view (view_dispatcher , view_id );
940961
962+ furi_record_close (RECORD_NOTIFICATION );
963+
941964 view_free (trade -> view );
942965 pokemon_data_free (trade -> input_pdata );
943966 free (trade );
0 commit comments