To use the node in your project you should have the yzheka-m/nokia-5510-display library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
struct State {
int size,x,y,rotation;
bool black,set=false;
char* text;
};
{{ GENERATED_CODE }}
char* toString(XString text){
int count=length(text);
char* t = malloc((count + 1) * sizeof(char));
dump(text, t);
t[count]=0;
return t;
}
void evaluate(Context ctx) {
auto display = getValue<input_DISPLAY>(ctx);
auto state=getState(ctx);
if(state->set){
display->setTextSize(state->size);
display->setTextColor(state->black?WHITE:BLACK);
display->setCursor(state->x,state->y);
display->setRotation(state->rotation);
display->print(state->text);
}
auto point = getValue<input_POSITION>(ctx);
state->text=toString(getValue<input_TEXT>(ctx));
state->x=point->x; state->y=point->y;
state->size=getValue<input_SIZE>(ctx);
state->rotation=getValue<input_ROTATION>(ctx);
state->black=getValue<input_BLACK>(ctx);
state->set=true;
display->setTextSize(state->size);
display->setTextColor(state->black?BLACK:WHITE);
display->setCursor(state->x,state->y);
display->setRotation(state->rotation);
display->print(state->text);
display->display();
display->setRotation(0);
emitValue<output_DONE>(ctx, 1);
}