Skip to content

Commit

Permalink
Improved liveview
Browse files Browse the repository at this point in the history
- Send new liveview frame only if data changed
- Update frequency updated to 250ms
- Fixed firmware release name
  • Loading branch information
foorschtbar committed Sep 4, 2023
1 parent ac5c8bd commit c3eab8d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@

# Rename binary according to environnement/board
# ex: firmware_esp32dev.bin or firmware_nodemcuv2.bin
env.Replace(PROGNAME=f"firmware_v{version}_{build_tag}.bin")
env.Replace(PROGNAME=f"firmware_v{version}_{build_tag}")
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ lib_deps =
ColorConverter=https://github.com/luisllamasbinaburo/Arduino-ColorConverter.git
TimeLib = https://github.com/PaulStoffregen/Time.git
marcmerlin/FastLED NeoMatrix@^1.2
bakercp/CRC32 @ 2.0.0

[env:wemos_d1_mini32]
platform = espressif32
Expand Down
13 changes: 10 additions & 3 deletions src/Liveview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ void Liveview::fillBuffer()
// set suffix
memcpy(&_liveviewBuffer[MATRIX_HEIGHT * MATRIX_WIDTH * 6 + _LIVEVIEW_PREFIX_LENGHT], _LIVEVIEW_SUFFIX, _LIVEVIEW_SUFFIX_LENGHT);

// rise callback
callbackFunction(_liveviewBuffer, _LIVEVIEW_BUFFER_LENGHT);
}
// calculate checksum
uint32_t newChecksum = CRC32::calculate((byte *)_liveviewBuffer, _LIVEVIEW_BUFFER_LENGHT);
if (_lastChecksum != newChecksum)
{
// Serial.printf("Checksum (new/old): 0x%08X/0x%08X\n", newChecksum, _lastChecksum);
_lastChecksum = newChecksum;
// rise callback
callbackFunction(_liveviewBuffer, _LIVEVIEW_BUFFER_LENGHT);
}
}
3 changes: 2 additions & 1 deletion src/Liveview.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <FastLED_NeoMatrix.h>
#include <CRC32.h>

#define _LIVEVIEW_PREFIX "{\"liveview\":\""
#define _LIVEVIEW_SUFFIX "\"}"
Expand All @@ -24,11 +25,11 @@ class Liveview
CRGB *_leds;
uint16_t _interval;
unsigned long _lastUpdate;
uint32_t _lastChecksum;
char _liveviewBuffer[_LIVEVIEW_BUFFER_LENGHT];

void (*callbackFunction)(const char *, size_t);
void fillBuffer();
char *getBuffer();
};

#endif
2 changes: 1 addition & 1 deletion src/PixelIt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#define CHECKUPDATE_INTERVAL 1000 * 60 * 6 * 8 // 8 Hours
#define CHECKUPDATESCREEN_INTERVAL 1000 * 60 * 5 // 5 Minutes
#define CHECKUPDATESCREEN_DURATION 1000 * 5 // 5 Seconds
#define SEND_LIVEVIEW_INTERVAL 500 // 0.5 Seconds, 0 to disable
#define SEND_LIVEVIEW_INTERVAL 250 // 0.5 Seconds, 0 to disable

#define VERSION "0.0.0-beta" // will be replaced by build piple with Git-Tag!

Expand Down

0 comments on commit c3eab8d

Please sign in to comment.