FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SecureGen/include/display_manager.h at master · makepkg/SecureGen · GitHub
makepkg
/
SecureGen
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
14
Star
93
Code
Issues
2
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SecureGen
/
include
/
display_manager.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
160 lines (133 loc) · 6.95 KB
Breadcrumbs
SecureGen
/
include
/
display_manager.h
Copy path
File metadata and controls
160 lines (133 loc) · 6.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#
ifndef
DISPLAY_MANAGER_H
#
define
DISPLAY_MANAGER_H
#
include
<
TFT_eSPI.h
>
#
include
"
animation_manager.h
"
#
include
"
ui_themes.h
"
//
Include new theme definitions
//
Режимы запуска устройства (AP/Offline/WiFi)
enum
class
StartupMode
{
AP_MODE
,
//
Access Point режим
OFFLINE_MODE
,
//
Полностью offline (WiFi отключен)
WIFI_MODE
//
Подключение к WiFi (default)
};
class
DisplayManager
{
public:
enum
class
HeaderState
{
INTRO
,
STATIC
,
CHARGING
};
DisplayManager
();
void
initForSplash
();
//
Early init for splash screen (PWM + TFT only, no fill)
void
init
();
void
update
();
void
updateHeader
();
void
drawLayout
(
const
String& serviceName,
int
batteryPercentage,
bool
isCharging,
bool
isWebServerOn);
void
drawPasswordLayout
(
const
String& name,
const
String& password,
int
batteryPercentage,
bool
isCharging,
bool
isWebServerOn,
uint8_t
strength =
0
,
bool
isDuplicate =
false
,
bool
isPin =
false
,
bool
isName =
false
,
bool
auto_send =
false
,
bool
send_login =
false
,
const
String& nav_mode =
"
enter
"
,
bool
isWildcard =
false
);
void
updateBatteryStatus
(
int
percentage,
bool
isCharging);
void
updateClockStatus
();
void
updateTOTPCode
(
const
String& code,
int
timeRemaining,
int
period =
30
);
void
turnOff
();
void
turnOn
();
void
setBrightness
(
uint8_t
brightness);
//
Set backlight brightness (0-255) for fade effects
bool
promptWebServerSelection
();
//
New function for user prompt
StartupMode
promptModeSelection
(StartupMode defaultMode = StartupMode::
WIFI_MODE
);
//
Промптинг выбора режима (AP/Offline/WiFi)
void
drawNoItemsPage
(
const
String& text);
void
drawBleInitLoader
(
int
progress);
#
ifdef
BOARD_HAS_USB_HID
bool
drawHidPrompt
(
bool
defaultIsBle);
void
drawUsbHidPage
(
const
String& passwordName,
const
String& status,
const
String& login,
bool
sendLogin);
void
resetUsbHidPage
();
void
setUsbHidMode
(
bool
active);
private:
String _usbHidLastStatus =
"
"
;
bool
_usbHidMode =
false
;
public:
#
endif
void
drawGenericLoader
(
int
progress,
const
String& text);
//
Новый универсальный лоадер
void
drawHOTPLoader
(
int
progress);
//
HOTP loader progress 0-100
void
hideLoader
();
//
Скрыть лоадер и сбросить состояние
void
resetLoaderState
();
//
Reset loader flags without clearing screen
void
eraseLoaderArea
();
//
Erase loader bar area and reset flags
bool
isLoaderActive
()
const
{
return
_loaderActive; }
//
Проверить активность лоадера
void
drawBleAdvertisingPage
(
const
String& deviceName,
const
String& status,
int
timeLeft);
void
drawBleConfirmPage
(
const
String& passwordName,
const
String& password,
const
String& deviceName,
const
String& login,
bool
sendLogin);
void
drawBleSendingPage
(
const
String& passwordName,
const
String& login,
bool
sendLogin);
void
drawBleResultPage
(
bool
success);
//
QR Code display
void
showQRCode
(
const
String& text,
int
timeoutSeconds =
30
);
void
hideQRCode
();
bool
isQRCodeActive
()
const
{
return
_qrCodeActive; }
void
requestShowQRCode
(
const
String& text,
int
timeoutSeconds =
30
);
//
Thread-safe request
void
updateQRTimer
(
int
secondsRemaining);
//
Update timer without full redraw
bool
consumePasswordRedrawFlag
() {
bool
f = _passwordScreenNeedsRedraw; _passwordScreenNeedsRedraw =
false
;
return
f; }
//
Test-and-clear, mirrors _totpContainerNeedsRedraw pattern
void
setKeySwitched
(
bool
switched) { _isKeySwitched = switched; }
//
<-- ADDED
bool
isCharging
()
const
{
return
_isCharging; }
void
setTheme
(Theme theme);
//
New method to set the theme
const
ThemeColors*
getCurrentThemeColors
()
const
{
return
_currentThemeColors; }
//
Get current theme colors
//
Display rotation management
void
applyRotation
();
//
Apply rotation setting from config and redraw
//
Deprecated, but kept for compatibility with other code
void
showMessage
(
const
String& text,
int
x,
int
y,
bool
isError =
false
,
int
size =
1
);
void
showMessage
(
const
String& text,
int
x,
int
y,
bool
isError,
int
size,
bool
inverted);
void
updateMessage
(
const
String& text,
int
x,
int
y,
int
size =
2
);
//
Update text without full redraw
void
clearMessageArea
(
int
x,
int
y,
int
width,
int
height);
//
Clear specific area
void
fillRect
(
int32_t
x,
int32_t
y,
int32_t
w,
int32_t
h,
uint32_t
color);
TFT_eSPI*
getTft
();
private:
//
New state machine for TOTP display
enum
class
TotpState
{
IDLE
,
SCRAMBLING
,
REVEALING
};
void
drawBatteryOnSprite
(
int
percentage,
bool
isCharging,
int
chargingValue =
0
);
void
drawClockOnSprite
();
void
drawTotpContainer
();
void
drawTotpText
(
const
String& textToDraw);
void
drawLockIcons
(
int
x,
int
y,
uint8_t
strength);
void
drawTextBadge
(
int
x,
int
y,
const
char
* label,
uint16_t
bg);
void
drawDupBadge
(
int
x,
int
y);
TFT_eSPI tft;
AnimationManager animationManager;
TFT_eSprite headerSprite;
TFT_eSprite batterySprite = TFT_eSprite(&tft);
TFT_eSprite totpContainerSprite;
TFT_eSprite totpSprite;
const
ThemeColors* _currentThemeColors;
//
Pointer to the active theme colors
//
State Machine Variables
HeaderState _headerState = HeaderState::
STATIC
;
String _currentServiceName;
int
_currentBatteryPercentage =
0
;
bool
_isCharging =
false
;
bool
_isWebServerOn =
false
;
//
Animation-specific variables
unsigned
long
_introAnimStartTime =
0
;
unsigned
long
_chargingAnimStartTime =
0
;
//
Variables for flicker-free TOTP updates
String lastDisplayedCode;
int
lastTimeRemaining;
//
--- New variables for the premium TOTP animation ---
TotpState _totpState = TotpState::
IDLE
;
unsigned
long
_totpAnimStartTime =
0
;
String _newCode;
String _currentCode;
String _lastDrawnTotpString;
unsigned
long
_lastScrambleFrameTime =
0
;
bool
_totpContainerNeedsRedraw =
true
;
bool
_isKeySwitched =
false
;
bool
_passwordScreenNeedsRedraw =
false
;
//
Mirrors _totpContainerNeedsRedraw for PASSWORD mode
//
Лоадер состояние
bool
_loaderActive =
false
;
String _lastLoaderText =
"
"
;
int
_lastLoaderProgress = -
1
;
//
Состояние для страницы "No Items"
bool
_isNoItemsPageActive =
false
;
bool
_needsFullRedraw =
false
;
//
Set by applyRotation() to force main loop redraw
public:
bool
needsFullRedraw
()
const
{
return
_needsFullRedraw; }
void
clearFullRedrawFlag
() { _needsFullRedraw =
false
; }
private:
//
QR Code состояние
bool
_qrCodeActive =
false
;
unsigned
long
_qrCodeTimeout =
0
;
int
_qrCodeTimerY =
0
;
//
Y позиция таймера
int
_lastQRTimerSeconds = -
1
;
//
Последнее значение таймера
//
QR Code request (thread-safe)
bool
_qrCodeRequested =
false
;
String _qrCodeText =
"
"
;
int
_qrCodeTimeoutSeconds =
30
;
};
#
endif
//
DISPLAY_MANAGER_H
Back
|
FazBrowse Home
|
New Git URL