File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 21
21
* from the SD card, runs the loaded program, and resets the virtual machine.
22
22
*/
23
23
24
+ #include < ArduinoNvs.h>
24
25
#include < fabgl.h>
25
26
#include < rishka.h>
26
27
#include < SD.h>
42
43
fabgl::ILI9341Controller DisplayController;
43
44
fabgl::Terminal Terminal;
44
45
46
+ // Non-volatile Storage class
47
+ ArduinoNvs NvsStorage;
48
+
45
49
// SPI instance for SD card
46
50
SPIClass sdSpi (HSPI);
47
51
@@ -62,10 +66,16 @@ void setup() {
62
66
return ;
63
67
}
64
68
69
+ // Initialize the NVS storage
70
+ if (!NvsStorage.begin ()) {
71
+ Terminal.println (" Unable to \e[94initialize\e[97m non-volatile storage." );
72
+ return ;
73
+ }
74
+
65
75
// Rishka virtual machine instance
66
76
RishkaVM* vm = new RishkaVM ();
67
77
// Initialize Rishka VM
68
- vm->initialize (&Terminal, &DisplayController);
78
+ vm->initialize (&Terminal, &DisplayController, &NvsStorage );
69
79
70
80
if (!vm->loadFile (" /sysinfo.bin" ))
71
81
vm->panic (" Failed to \e[94mload\e[97m specified file." );
@@ -74,6 +84,9 @@ void setup() {
74
84
vm->run (0 , NULL );
75
85
// Reset VM after program execution
76
86
vm->reset ();
87
+
88
+ // Close the NVS storage
89
+ NvsStorage.close ();
77
90
}
78
91
79
92
void loop () {
Original file line number Diff line number Diff line change 21
21
* file into the Rishka VM, executes it, and then waits for the next input.
22
22
*/
23
23
24
+ #include < ArduinoNvs.h>
24
25
#include < fabgl.h>
25
26
#include < rishka.h>
26
27
#include < SD.h>
@@ -44,6 +45,9 @@ fabgl::ILI9341Controller DisplayController;
44
45
fabgl::PS2Controller PS2Controller;
45
46
fabgl::Terminal Terminal;
46
47
48
+ // Non-volatile Storage class
49
+ ArduinoNvs NvsStorage;
50
+
47
51
// SPI instance for SD card
48
52
SPIClass sdSpi (HSPI);
49
53
@@ -131,14 +135,21 @@ void setup() {
131
135
Terminal.clear ();
132
136
}
133
137
138
+ // Initialize the NVS storage
139
+ if (!NvsStorage.begin ()) {
140
+ Terminal.println (" Unable to \e[94initialize\e[97m non-volatile storage." );
141
+ return ;
142
+ }
143
+
144
+ // Initialize the PSRAM
134
145
if (!psramInit ()) {
135
146
Terminal.println (" \e[94mCannot\e[97m initialize PSRAM." );
136
147
while (true );
137
148
}
138
149
139
150
// Initialize the Rishka VM instance.
140
151
vm = new RishkaVM ();
141
- vm->initialize (&Terminal, &DisplayController);
152
+ vm->initialize (&Terminal, &DisplayController, &NvsStorage );
142
153
143
154
// Virtual key listener to halt program
144
155
Terminal.onVirtualKeyItem = [&](VirtualKeyItem * vkItem) {
Original file line number Diff line number Diff line change 21
21
* file into the Rishka VM, executes it, and then waits for the next input.
22
22
*/
23
23
24
+ #include < ArduinoNvs.h>
24
25
#include < fabgl.h>
25
26
#include < rishka.h>
26
27
#include < SD.h>
@@ -37,6 +38,9 @@ fabgl::VGAController DisplayController;
37
38
fabgl::PS2Controller PS2Controller;
38
39
fabgl::Terminal Terminal;
39
40
41
+ // Non-volatile Storage class
42
+ ArduinoNvs NvsStorage;
43
+
40
44
// SPI instance for SD card
41
45
SPIClass sdSpi (HSPI);
42
46
@@ -120,6 +124,12 @@ void setup() {
120
124
Terminal.clear ();
121
125
}
122
126
127
+ // Initialize the NVS storage
128
+ if (!NvsStorage.begin ()) {
129
+ Terminal.println (" Unable to \e[94initialize\e[97m non-volatile storage." );
130
+ return ;
131
+ }
132
+
123
133
// Initialize PSRAM
124
134
if (!psramInit ()) {
125
135
Terminal.println (" \e[94mCannot\e[97m initialize PSRAM." );
@@ -128,7 +138,7 @@ void setup() {
128
138
129
139
// Initialize the Rishka VM instance.
130
140
vm = new RishkaVM ();
131
- vm->initialize (&Terminal, &DisplayController);
141
+ vm->initialize (&Terminal, &DisplayController, &NvsStorage );
132
142
133
143
// Virtual key listener to halt program
134
144
Terminal.onVirtualKeyItem = [&](VirtualKeyItem * vkItem) {
You can’t perform that action at this time.
0 commit comments