Skip to content

Commit

Permalink
Method and fields for storing pointer for ArduinoNvs class.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 21, 2024
1 parent 1b33a55 commit 664c000
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rishka_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ fabgl::BaseDisplayController* RishkaVM::getDisplay() const {
return this->display;
}

ArduinoNvs* RishkaVM::getNvsStorage() const {
return this->nvsStorage;
}

uint8_t RishkaVM::getArgCount() const {
return this->argc;
}
Expand Down
19 changes: 19 additions & 0 deletions src/rishka_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#ifndef RISHKA_VM_H
#define RISHKA_VM_H

#include <ArduinoNvs.h>
#include <fabgl.h>
#include <List.hpp>
#include <rishka_types.h>
Expand All @@ -48,6 +49,7 @@ class RishkaVM final {
int64_t pc; ///< Program counter
fabgl::Terminal* terminal; ///< Terminal for input/output operations
fabgl::BaseDisplayController* display; ///< Base display controller of the VM
ArduinoNvs* nvsStorage; ///< Non-volatile Storage class pointer

bool running; ///< Flag indicating whether the VM is running
int64_t exitCode; ///< Exit code of the VM after execution
Expand Down Expand Up @@ -203,11 +205,13 @@ class RishkaVM final {
*
* @param stream A pointer to the Terminal object for input/output operations.
* @param displayCtrl The base display controller of the VM
* @param nvsStorage Non-volatile Storage class pointer for the VM
* @param directory The path to the new working directory.
*/
void initialize(
fabgl::Terminal* terminal,
fabgl::BaseDisplayController* displayCtrl,
ArduinoNvs* nvsStorage,
String workingDirectory = "/"
);

Expand Down Expand Up @@ -290,6 +294,21 @@ class RishkaVM final {
*/
String getWorkingDirectory() const;

/**
* @brief Retrieves the NVS (Non-Volatile Storage)
* instance associated with the RishkaVM.
*
* This method returns a pointer to the ArduinoNvs instance
* that is used by the RishkaVM for non-volatile storage.
* Non-volatile storage allows for data persistence across
* reboots and power cycles, making it useful for storing
* configuration settings, user preferences, and other
* data that needs to be retained between sessions.
*
* @return A pointer to the ArduinoNvs instance used by the RishkaVM.
*/
ArduinoNvs* getNvsStorage() const;

/**
* @brief Retrieves the current output stream of the virtual machine.
*
Expand Down

0 comments on commit 664c000

Please sign in to comment.