forked from seawarrior181/PasswordPump
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (66 loc) · 2.08 KB
/
Copy pathmain.cpp
File metadata and controls
89 lines (66 loc) · 2.08 KB
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
#include "SSD1306Ascii.h" // OLED fonts
#include "src/auth.hpp"
#include "src/cli.hpp"
#include "src/model.hpp"
#include "src/model_storage.hpp"
#include "src/ssd1306_oled.hpp"
#include "src/version.hpp"
#include "src/display_ui.hpp"
#include "src/board.hpp"
#include "src/accounts_menu.hpp"
#include "src/settings_menu.hpp"
#include "src/settings.hpp"
#include "src/auth_form.hpp"
#include "src/ssd1306_oled.hpp"
#include "src/model_storage.hpp"
#include "src/eeprom_storage.hpp"
#include "src/encrypted_block_storage.hpp"
// Baud rate for serial port
#define SERIAL_BAUD_RATE 38400
#define SHOW_SPLASHSCREEN 1000 // ms
Settings settings;
// Use OLED_NO_BUFFER to keep RAM for another code
SSD1306oled oled;
DeviceUserInputs userInputs;
PasswordWandAuth authenticator;
EepromStorage eepromStore(EXT_EEPROM_CS_PIN);
EncryptedBlockStorage ebs(eepromStore);
// TODO: move to callback
// assertTrue(ebs.init(encStoreKey, encStoreKeyLen));
ModelStorage<Account> modelStore(ebs);
// Create on demand ???
AuthForm authForm(oled, userInputs, authenticator);
AccountsMenu accMenu(oled, userInputs, settings, modelStore);
SettingsMenu settingsMenu(oled, userInputs, settings);
DisplayUI ui(oled, userInputs, authForm, accMenu, settingsMenu);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
setup()
{
pinMode(4, INPUT_PULLUP); // DEBUG
// TODO: check return value
eepromStore.init(EEPROM_KBITS_256, EEPROM_PAGE_SIZE_64);
userInputs.setup();
oled.setup();
oled.setFont(System5x7); // perfect, slightly smaller than Arial14
oled.clear();
// enable Serial after init CLI to avoid racing between CLI init and CLI usage
Serial.begin(SERIAL_BAUD_RATE);
while (!Serial);
print_welcome(oled);
delay(SHOW_SPLASHSCREEN);
print_welcome(Serial);
ui.ui_setup();
cli_init(settings.cli_turn_on_);
}
void
loop()
{
static bool startup_delay_done = false;
if (!startup_delay_done) {
delay(750);
startup_delay_done = true;
}
cli_loop_step();
userInputs.loop_step();
}