From d75a6cd36db515a0863a03480d8e5c589a235e22 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 21 Feb 2016 11:30:35 +0100 Subject: storage: Add hasData method --- src/storage.cc | 8 ++++++++ src/storage.h | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/storage.cc b/src/storage.cc index 7ee5f4c..98a90f0 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -190,6 +190,14 @@ void Storage::reset() i2c_write(0, 1, &num_anims); } +bool Storage::hasData() +{ + // Unprogrammed EEPROM pages always read 0xff + if (num_anims == 0xff) + return false; + return true; +} + void Storage::load(uint16_t idx, uint8_t *data) { uint8_t page_offset; diff --git a/src/storage.h b/src/storage.h index b2a4dbf..5366ed9 100644 --- a/src/storage.h +++ b/src/storage.h @@ -39,6 +39,13 @@ class Storage { */ void reset(); + /** + * Checks whether the EEPROM contains animathion data. + * + * @return true if the EEPROm contains valid-looking data + */ + bool hasData(); + /** * Load pattern from EEPROM. * -- cgit v1.2.3