summaryrefslogtreecommitdiff
path: root/src/storage.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-02-17 17:17:12 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-02-17 17:17:12 +0100
commitbffcdb4987acb5a49e2756df355ae9d55fdb112d (patch)
tree406763910e23ad6ab8f9309ef97ae544687af2c0 /src/storage.cc
parentee17a71e0890d015f2aa7d7222407d85d53c0720 (diff)
more modem receive state machine logic
Diffstat (limited to 'src/storage.cc')
-rw-r--r--src/storage.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/storage.cc b/src/storage.cc
index 71265a8..4afe1d8 100644
--- a/src/storage.cc
+++ b/src/storage.cc
@@ -173,9 +173,9 @@ int8_t Storage::i2c_read(uint16_t pos, uint8_t len, uint8_t *data)
void Storage::reset()
{
- uint8_t data = 0;
- i2c_write(0, 1, &data);
first_free_page = 0;
+ num_anims = 0;
+ i2c_write(0, 1, &num_anims);
}
void Storage::load(uint16_t idx, uint8_t *data)
@@ -188,9 +188,11 @@ void Storage::load(uint16_t idx, uint8_t *data)
i2c_read(256 + (64 * (uint16_t)page_offset) + 2, (header[0] << 4) + (header[1] >> 4), data);
}
-void Storage::save(uint16_t idx, uint8_t *data)
+void Storage::save(uint8_t *data)
{
- i2c_write(1 + idx, 1, &first_free_page);
+ num_anims++;
+ i2c_write(0, 1, &num_anims);
+ i2c_write(num_anims, 1, &first_free_page);
append(data);
}