Skip to content

Commit 5d2ffdf

Browse files
committed
fixed edge case that sometimes an "old" frame or a "too new" frame gets shown
1 parent 706cdf3 commit 5d2ffdf

File tree

2 files changed

+223
-204
lines changed

2 files changed

+223
-204
lines changed

include/DMDUtil/DMD.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define DMDUTILCALLBACK
99
#endif
1010

11-
#define DMDUTIL_FRAME_BUFFER_SIZE 64
11+
#define DMDUTIL_FRAME_BUFFER_SIZE 64 // Must be a divider of 65535!
1212
#define DMDUTIL_MIN_FRAMES_BEHIND 4
1313
#define DMDUTIL_MAX_FRAMES_BEHIND 32
1414
#define DMDUTIL_MAX_NAME_SIZE 16
@@ -186,7 +186,7 @@ class DMDUTILAPI DMD
186186
Update* m_pUpdateBufferQueue[DMDUTIL_FRAME_BUFFER_SIZE];
187187
std::shared_ptr<Update> m_updateBuffered;
188188

189-
uint8_t GetNextBufferQueuePosition(uint8_t bufferPosition, const uint8_t updateBufferQueuePosition);
189+
uint8_t GetNextBufferQueuePosition(uint16_t bufferPosition, const uint16_t updateBufferQueuePosition);
190190
bool ConnectDMDServer();
191191
bool UpdatePalette(uint8_t* pPalette, uint8_t depth, uint8_t r, uint8_t g, uint8_t b);
192192
void UpdateData(const uint8_t* pData, int depth, uint16_t width, uint16_t height, uint8_t r, uint8_t g, uint8_t b,
@@ -234,7 +234,7 @@ class DMDUTILAPI DMD
234234
std::condition_variable_any m_dmdCV;
235235
std::atomic<bool> m_dmdFrameReady;
236236
std::atomic<bool> m_stopFlag;
237-
std::atomic<uint8_t> m_updateBufferQueuePosition;
237+
std::atomic<uint16_t> m_updateBufferQueuePosition;
238238
std::atomic<uint16_t> m_pupSceneId;
239239

240240
bool m_hasUpdateBuffered = false;

0 commit comments

Comments
 (0)