diff --git a/include/config.sample.h b/include/config.sample.h index 1d9cae4..23ad9a4 100644 --- a/include/config.sample.h +++ b/include/config.sample.h @@ -96,22 +96,18 @@ Serial.println(buffer);\ } while (0); #else - #define LOG(msg, ...) do { \ - char buffer[128]; \ - snprintf_P(buffer, 128, PSTR(msg), ##__VA_ARGS__);\ - Serial.print(buffer);\ - } while (0); - #define LOGln(msg, ...) do { \ - char buffer[128]; \ - snprintf_P(buffer, 128, PSTR(msg), ##__VA_ARGS__);\ - Serial.println(buffer);\ - } while (0); + #define LOG(x, ...) Serial.printf(x, ##__VA_ARGS__); + #define LOGln(x, ...) Serial.printf(x, ##__VA_ARGS__); Serial.println(); #endif + #define DBG(msg, ...) Serial.printf(msg, ##__VA_ARGS__); Serial.println(); #else - #define LOG(msg, ...) do {} while(0); - #define LOGln(msg, ...) do {} while(0); + #define LOG(x) do {} while(0); + #define LOGln(x) do {} while(0); + #define DBG(msg, ...) do {} while(0); #endif + + #if !defined( ESP8266 ) && !defined( ESP32 ) #error "Neither ESP8266 nor ESP32 are set. Maybe you are compiling this for another platform...?" #endif diff --git a/src/Animation.cpp b/src/Animation.cpp index fbcf1f0..61b458b 100644 --- a/src/Animation.cpp +++ b/src/Animation.cpp @@ -84,16 +84,16 @@ bool Animation::_load_from_file(const char* filename) { // Now we can be sure to have the right amount of bytes available for reading _width = file.read(); - LOGln("Animation * width: %d", _width); + DBG("Animation * width: %d", _width); _height = file.read(); - LOGln("Animation * height: %d", _height); + DBG("Animation * height: %d", _height); _frame_count = file.read(); - LOGln("Animation * frame_count: %d", _frame_count); + DBG("Animation * frame_count: %d", _frame_count); _color_count = file.read(); - LOGln("Animation * color_count: %d", _color_count); + DBG("Animation * color_count: %d", _color_count); - LOGln("Animation * Loading colors..."); + DBG("Animation * Loading colors..."); _colors = new CRGB*[_color_count]; char* temp = new char[_color_count*3]; int bytes_read = file.readBytes(temp, _color_count*3); @@ -102,36 +102,33 @@ bool Animation::_load_from_file(const char* filename) { _colors[i] = new CRGB(temp[i*3], temp[i*3+1], temp[i*3+2]); } delete [] temp; - LOGln("Animation * Color loading done."); + DBG("Animation * Color loading done."); - LOG("Animation * Loading frame times..."); + DBG("Animation * Loading frame times..."); _frame_times = new uint16_t[_frame_count]; for (int i=0; i<_frame_count; i++) { _frame_times[i] = (file.read() << 8) | file.read(); } - LOGln(" done."); + DBG(" done."); - LOGln("Animation * Loading frame lengths..."); + DBG("Animation * Loading frame lengths..."); _frame_data_lengths = new uint16_t[_frame_count]; temp = new char[_frame_count*2]; bytes_read = file.readBytes(temp, _frame_count*2); - LOGln("Animation * Read %d bytes.", bytes_read); + DBG("Animation * Read %d bytes.", bytes_read); for (int i=0; i<_frame_count; i++) { //LOGln("Animation * Raw frame lengths: %d, %d", temp[i*2], temp[i*2+1]); _frame_data_lengths[i] = (temp[i*2]<<8) | temp[i*2+1]; } delete [] temp; - LOGln("Animation * Frame length loading done."); + DBG("Animation * Frame length loading done."); - LOGln("Animation * Loading frame data..."); + DBG("Animation * Loading frame data..."); _frame_data = new uint8_t*[_frame_count]; for (int i=0; i<_frame_count; i++) { uint16_t fl = _frame_data_lengths[i]; - LOGln("Animation * Loading frame %d with %d bytes...", i, fl); + DBG("Animation * Loading frame %d/%d with %d bytes...", i, _frame_count, fl); _frame_data[i] = new uint8_t[fl]; - /*for (int b=0; b