-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArduinoSeedFileManager.cpp
52 lines (45 loc) · 1.03 KB
/
ArduinoSeedFileManager.cpp
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
/*
* File: ArduinoSeedFileManager.cpp
* Author: matt
*
* Created on 17 December 2014, 13:00
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "ArduinoSeedFileManager.h"
ArduinoSeedFileManager::ArduinoSeedFileManager()
{
if(EEPROM.read(FIRST_ACCESS_ADDRESS) != 0x01)
{
fTimeAccess = true;
}
else
{
fTimeAccess = false;
}
}
uint8_t* ArduinoSeedFileManager::readSeedFile()
{
if(fTimeAccess)
{
return NULL;
}
seedData = new uint8_t[SEED_FILE_SIZE];
for(uint8_t eepromIndex = 0; eepromIndex < SEED_FILE_SIZE; eepromIndex++)
{
seedData[eepromIndex] = EEPROM.read(START_OF_SEED+eepromIndex);
}
return seedData;
}
void ArduinoSeedFileManager::writeSeedFile(uint8_t* seed)
{
if(fTimeAccess)
{
EEPROM.write(FIRST_ACCESS_ADDRESS, 0x01);
fTimeAccess = false;
}
for(uint8_t eepromIndex = 0; eepromIndex < SEED_FILE_SIZE; eepromIndex++)
{
EEPROM.write(START_OF_SEED+eepromIndex, seed[eepromIndex]);
}
}
#endif