platform for developing on SQFMI's Watchy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
993 B

#ifndef _MODULE_STORAGE_h
#define _MODULE_STORAGE_h
#include "watchos_consts.h"
#include "watchos_types.h"
#include "Task.h"
// 4kB RTC
// 4kB EEPROM
#define MODULE_STORAGE_MAX_ENTRIES 16
struct StorageEntry;
class Module_Storage : public Task
{
uint16_t m_magic;
byte m_version;
byte m_options;
StorageEntry* m_entry[MODULE_STORAGE_MAX_ENTRIES];
byte wellKnownHandleToByte(well_known_handle_t handle);
int getOffset(byte module);
public:
void initialize();
void start();
void suspend();
bool isValid();
void load();
void commit();
void reset();
bool allocate(well_known_handle_t module, uint16_t size, byte options = 0);
void write(well_known_handle_t module, uint16_t offset, byte value);
byte read(well_known_handle_t module, uint16_t offset);
bool allocate(byte module, uint16_t size, byte options = 0);
void write(byte module, uint16_t offset, byte value);
byte read(byte module, uint16_t offset);
};
#endif