text

yzheka-m/nokia-5510-display/text

No description
text
@/text
DISPLAY@/display
Display object
POSITION@/point
position of tpo left of the text
SIZEnumber
Text size
TEXTstring
Text string
BLACKboolean
Black or white color
ROTATIONnumber
Text rotation (coordinates are rotated too) 0 - 0 degrees 1 - 90 degrees ccw 2 - 180 degrees ccw 3 - 270 degrees ccw
text
DISPLAY
POSITION
SIZE
TEXT
BLACK
ROTATION
DONE
DONEpulse
Pulse when text is placed on screen
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);
}