draw-text

wayland/arduino-tvout/draw-text

Draw text.
draw-text
@/draw-text
Draw text.
DEV@/tvout-device
A tvout device.
TEXTstring
String to print. Use \n for new line.
FONTnumber
Font. Options: 0 = font4x6; 1 = font6x8; 2 = font8x8; 3 = font8x8ext.
Xnumber
The x coordinate of the cursor.
Ynumber
The y coordinate of the cursor.
XYboolean
Set cursor position. If true cursor will be moved to the coordinates specified by X and Y. If false text will be printed at current cursor position.
UPDpulse
Update. Triggers draw text.
draw-text
DEV
TEXT
FONT
X
Y
XY
UPD
DONE
DONEpulse
Pulse on completion.
To use the node in your project you should have the wayland/arduino-tvout 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 {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // The node responds only if there is an input pulse
    if (!isInputDirty<input_UPD>(ctx))
        return;

    // Get a pointer to the `TVout` class instance
    auto tv = getValue<input_DEV>(ctx);
    auto xString = getValue<input_TEXT>(ctx);
    auto font = getValue<input_FONT>(ctx);
    uint8_t x = getValue<input_X>(ctx);
    uint8_t y = getValue<input_Y>(ctx);
    auto xy = getValue<input_XY>(ctx);

    int N=length(xString) + 1;
    char cString[N];
    for(int i=0;i<N;i++)
    cString[i]=0;
    // move the data from XString to the plain C string
    dump(xString, cString);

    if (font==0) {
        tv->select_font(font4x6);
    }
    else if(font==1) {
        tv->select_font(font6x8);
    }
    else if(font==2) {
        tv->select_font(font8x8);
    }
    else if(font==3) {
        tv->select_font(font8x8ext);
    }
    else {
      raiseError(ctx);
      return;
    }
    
    if (xy) {
        tv->println(x, y, cString);
    } else {
        tv->println(cString);
    }

    emitValue<output_DONE>(ctx, 1);
}