forked from LedgerHQ/app-tezos-legacy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from trilitech/palmer@functori@reintroduce-th…
…e-custom-screensaver Reintroduce the custom screensaver
- Loading branch information
Showing
12 changed files
with
390 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* Tezos Ledger application - Screen-saver UI functions | ||
Copyright 2024 TriliTech <[email protected]> | ||
Copyright 2024 Functori <[email protected]> | ||
Copyright 2023 Ledger | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#ifdef HAVE_BAGL | ||
#include "ui_screensaver.h" | ||
|
||
#include "bolos_target.h" | ||
#include "globals.h" | ||
|
||
#define G_screensaver_state global.dynamic_display.screensaver_state | ||
|
||
/** | ||
* @brief Blank screen element | ||
* | ||
*/ | ||
static const bagl_element_t blank_screen_elements[] = {{{BAGL_RECTANGLE, | ||
BAGL_NONE, | ||
0, | ||
0, | ||
BAGL_WIDTH, | ||
BAGL_HEIGHT, | ||
0, | ||
0, | ||
BAGL_FILL, | ||
0x000000, | ||
0xFFFFFF, | ||
0, | ||
0}, | ||
.text = NULL}, | ||
{}}; | ||
|
||
/** | ||
* @brief This structure represents the parameters needed for the blank layout | ||
* | ||
* No parameters required | ||
* | ||
*/ | ||
typedef struct ux_layout_blank_params_s { | ||
} ux_layout_blank_params_t; | ||
|
||
/** | ||
* @brief Initializes the blank layout | ||
* | ||
* @param stack_slot: index stack_slot | ||
*/ | ||
static void ux_layout_blank_init(unsigned int stack_slot) { | ||
ux_stack_init(stack_slot); | ||
G_ux.stack[stack_slot].element_arrays[0].element_array = blank_screen_elements; | ||
G_ux.stack[stack_slot].element_arrays[0].element_array_count = ARRAYLEN(blank_screen_elements); | ||
G_ux.stack[stack_slot].element_arrays_count = 1; | ||
G_ux.stack[stack_slot].button_push_callback = ux_flow_button_callback; | ||
ux_stack_display(stack_slot); | ||
} | ||
|
||
/** | ||
* @brief Exits the blank screen to home screen | ||
* | ||
*/ | ||
static void return_to_idle(void) { | ||
G_screensaver_state.on = false; | ||
ui_initial_screen(); | ||
} | ||
|
||
/** | ||
* @brief Blank screen flow | ||
* | ||
* On any click: return_to_idle | ||
* | ||
*/ | ||
UX_STEP_CB(blank_screen_step, blank, return_to_idle(), {}); | ||
UX_STEP_INIT(blank_screen_border, NULL, NULL, { return_to_idle(); }); | ||
UX_FLOW(ux_blank_flow, &blank_screen_step, &blank_screen_border, FLOW_LOOP); | ||
|
||
void ui_start_screensaver(void) { | ||
if (!G_screensaver_state.on) { | ||
G_screensaver_state.on = true; | ||
ux_flow_init(0, ux_blank_flow, NULL); | ||
} | ||
} | ||
|
||
#define MS 100u | ||
#define SCREENSAVER_TIMEOUT 20000u // 20u * 10u * MS | ||
|
||
void ux_screensaver_start_clock(void) { | ||
G_screensaver_state.clock.on = true; | ||
G_screensaver_state.clock.timeout = SCREENSAVER_TIMEOUT; | ||
} | ||
|
||
void ux_screensaver_stop_clock(void) { | ||
G_screensaver_state.clock.on = false; | ||
} | ||
|
||
void ux_screensaver_apply_tick(void) { | ||
if (G_screensaver_state.clock.on) { | ||
if (G_screensaver_state.clock.timeout < MS) { | ||
ui_start_screensaver(); | ||
ux_screensaver_stop_clock(); | ||
} else { | ||
G_screensaver_state.clock.timeout -= MS; | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* Tezos Ledger application - Screen-saver UI functions | ||
Copyright 2024 TriliTech <[email protected]> | ||
Copyright 2024 Functori <[email protected]> | ||
Copyright 2023 Ledger | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
#include <stdbool.h> | ||
|
||
#ifdef HAVE_BAGL | ||
|
||
typedef struct { | ||
/// Clock has started | ||
bool on; | ||
/// Timeout out before saving screen | ||
unsigned int timeout; | ||
} ux_screensaver_clock_t; | ||
|
||
typedef struct { | ||
/// Screensaver is on/off. | ||
bool on; | ||
/// Timeout out before saving screen | ||
ux_screensaver_clock_t clock; | ||
} ux_screensaver_state_t; | ||
|
||
/** | ||
* @brief Empties the screen | ||
* | ||
* Waits a click to return to home screen | ||
* | ||
* Applies only for Nanos devices | ||
* | ||
*/ | ||
void ui_start_screensaver(void); | ||
|
||
/** | ||
* @brief Start a timeout before saving screen | ||
* | ||
*/ | ||
void ux_screensaver_start_clock(void); | ||
|
||
/** | ||
* @brief Stop the clock | ||
* | ||
*/ | ||
void ux_screensaver_stop_clock(void); | ||
|
||
/** | ||
* @brief Apply one tick to the clock | ||
* | ||
* The tick is assumed to be 100 ms | ||
* | ||
*/ | ||
void ux_screensaver_apply_tick(void); | ||
|
||
#endif |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+349 Bytes
test/snapshots/nanos/test_automatic_low_cost_screensaver/home_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.