-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path_dd_feedback.cpp
More file actions
29 lines (28 loc) · 1 KB
/
_dd_feedback.cpp
File metadata and controls
29 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "Arduino.h"
#include "_dd_feedback.h"
#include "__dd_cpp_include.h"
DDFeedbackManager::DDFeedbackManager(/*int8_t bufferSize*/) {
this->nextArrayIdx = 0;
this->validArrayIdx = 0;
}
const DDFeedback* DDFeedbackManager::getFeedback() {
#ifdef ENABLE_FEEDBACK
if (nextArrayIdx == validArrayIdx) return NULL;
const DDFeedback* pFeedback = &feedbackArray[validArrayIdx];
validArrayIdx = (validArrayIdx + 1) % DD_FEEDBACK_BUFFER_SIZE/*arraySize*/;
return pFeedback;
#else
return NULL;
#endif
}
void DDFeedbackManager::pushFeedback(DDFeedbackType type, int16_t x, int16_t y, const char* pText) {
#ifdef ENABLE_FEEDBACK
feedbackArray[nextArrayIdx].type = type;
feedbackArray[nextArrayIdx].x = x;
feedbackArray[nextArrayIdx].y = y;
feedbackArray[nextArrayIdx].text = pText != NULL ? pText : "";
nextArrayIdx = (nextArrayIdx + 1) % DD_FEEDBACK_BUFFER_SIZE/*arraySize*/;
if (nextArrayIdx == validArrayIdx)
validArrayIdx = (validArrayIdx + 1) % DD_FEEDBACK_BUFFER_SIZE/*arraySize*/;
#endif
}