EEPROM Data registers - Mickyleitor/RollerShutterControlPanel GitHub Wiki
PAGE UNDER REVIEW
| Memory Address | Function | Payload Length | CRC length |
|---|---|---|---|
| 0x0000 | Left Up Key command | 92 bytes | 1 byte |
| 0x005C | Left Stop Key command | 92 bytes | 1 byte |
| 0x00B9 | Left Down Key command | 92 bytes | 1 byte |
| 0x0115 | Center Up Key code | 92 bytes | 1 byte |
| 0x0171 | Center Stop Key command | 92 bytes | 1 byte |
| 0x01CD | Center Down Key command | 92 bytes | 1 byte |
| 0x0229 | Right Up Key command | 92 bytes | 1 byte |
| 0x0285 | Right Stop Key command | 92 bytes | 1 byte |
| 0x02E1 | Right Down Key command | 92 bytes | 1 byte |
Code to rewrite the keycode into EEPROM:
#include <EEPROM.h>
#define KEY_LENGTH 92
#define KEY_CRC_LENGTH 1
struct Tcommand {
byte Key [KEY_LENGTH];
byte CRC;
} packet;
// Put your own key codes here
byte KEYCODES [9][KEY_LENGTH] = {{}, // Key for Right Down Key command
{}, // Key for Right Stop Key command
{}, // Key for Right Up Key command
{}, // Key for Center Down Key command
{}, // Key for Center Stop Key command
{}, // Key for Center Up Key command
{}, // Key for Left Down Key command
{}, // Key for Left Stop Key command
{}}; // Key for Left Up Key command
void setup() {
Serial.begin(9600);
for( int i = 0 ; i < 9 ; i++){
memcpy(packet.Key,KEYCODES[i],KEY_LENGTH);
packet.CRC = CRC8(packet.Key,KEY_LENGTH);
EEPROM.put(i * sizeof(struct Tcommand), packet);
}
byte CRCvalue = 0;
for( int i = 1 ; i < 10 ; i++){
EEPROM.get( (i * sizeof(struct Tcommand)) - 1, CRCvalue);
Serial.println(CRCvalue,HEX);
}
}
void loop() {
}
byte CRC8(const byte *data, size_t dataLength)
{
byte crc = 0x00;
while (dataLength--)
{
byte extract = *data++;
for (byte tempI = 8; tempI; tempI--)
{
byte sum = (crc ^ extract) & 0x01;
crc >>= 1;
if (sum)
{
crc ^= 0x8C;
}
extract >>= 1;
}
}
return crc;
}