-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea3f237
commit 46a414a
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* storage.cpp | ||
* | ||
* Created on: Dec 10, 2013 | ||
* Author: Ryler Hockenbury | ||
* | ||
* Read and write from EEPROM | ||
*/ | ||
|
||
|
||
void readEEPROM() { | ||
|
||
} | ||
|
||
void writeEEPROM() { | ||
|
||
} | ||
|
||
|
||
float readFloat(int address) { | ||
union floatStore { | ||
byte floatByte[4]; | ||
unsigned short floatUShort[2]; | ||
float floatVal; | ||
} floatOut; | ||
|
||
|
||
for (int i = 0; i < 4; i++) { | ||
floatOut.floatByte[i] = EEPROM.read(address + i); | ||
} | ||
|
||
return floatOut.floatVal; | ||
} | ||
|
||
void writeFloat(float value, int address) { | ||
union floatStore { | ||
byte floatByte[4]; | ||
unsigned short floatUShort[2]; | ||
float floatVal; | ||
} floatIn; | ||
|
||
floatIn.floatVal = value; | ||
|
||
for (int i = 0; i < 4; i++) { | ||
EEPROM.write(address + i, floatIn.floatByte[i]); | ||
} | ||
} | ||
|
||
void updateFloat(float value, int address) { | ||
|
||
} | ||
|
||
|
||
long readLong(int address) { | ||
union longStore { | ||
byte longByte[4]; | ||
unsigned short longUShort[2]; | ||
long longVal; | ||
} longOut; | ||
|
||
for (byte i = 0; i < 4; i++) { | ||
longOut.longByte[i] = EEPROM.read(address + i); | ||
} | ||
|
||
return longOut.longVal; | ||
} | ||
|
||
void writeLong(long value, int address) { | ||
union longStore { | ||
byte longByte[4]; | ||
unsigned short longUShort[2]; | ||
long longVal; | ||
} longIn; | ||
|
||
longIn.longVal = value; | ||
|
||
for (int i = 0; i < 4; i++) { | ||
EEPROM.write(address + i, longIn.longByte[i]); | ||
} | ||
|
||
} | ||
|
||
void updateLong(long vaue, int address) { | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* storage.h | ||
* | ||
* Created on: Dec 10, 2013 | ||
* Author: Ryler Hockenbury | ||
* | ||
* Read and write from EEPROM | ||
*/ | ||
|
||
#ifndef STORAGE_h | ||
#define STORAGE_h | ||
|
||
#define EEPROM_START_ADDRESSS 0 | ||
#define EEPROM_END_ADDRESS 1023 | ||
|
||
#define PID_P_ADDRESS 0 | ||
#define PID_I_ADDRESS 4 | ||
#define PID_D_ADDRESS 8 | ||
|
||
#define TAKEOFF_THROTTLE_ADDRESS 5 | ||
|
||
#define RADIO_SMOOTH_FACTOR_ADDRESS 5 | ||
#define MAX_COMMAND_ANGLE_ADDRESS 5 | ||
#define MIN_COMMAND_ANGLE_ADDRESS 5 | ||
|
||
|
||
class Storage { | ||
|
||
public: | ||
|
||
Storage(); | ||
|
||
static void writePidPValue(float value, int address=PID_P_ADDRESS); | ||
static void writePidIValue(float value, int address=PID_I_ADDRESS); | ||
static void writePidDValue(float value, int address=PID_D_ADDRESS); | ||
|
||
//void writeTakeoffThrottleValue(float value, int address); | ||
|
||
static float readPidPValue(int address=PID_P_ADDRESS); | ||
static float readPidIValue(int address=PID_I_ADDRESS); | ||
static float readPidDValue(int address=PID_D_ADDRESS); | ||
|
||
|
||
private: | ||
|
||
|
||
}; | ||
|
||
|
||
|
||
|
||
#endif /* STORAGE_h */ |