Strings and Text
So far values have flowed module-to-module as numbers. To send them over a serial port, display them on a screen, log them to the console, or compose them into a richer message, you need to turn those numbers into text. NodeBlue has a small but very capable group of string modules for exactly this:
- FormatText — turn a numeric value (or several) into a formatted string.
- Text — emit a fixed string, or splice variables into a template.
- StringToNumber — the reverse: parse a number out of an incoming text buffer.
The output of these modules is a Buffer (a byte sequence terminated by a newline, by default), suitable as an input for USB Serial, the Plotter, a UART, a TCP socket, an OLED display, or any other "text sink".
FormatText
FormatText is the workhorse. It takes one or more numeric inputs and produces a text representation. Its parameters are:
| Parameter | Description |
|---|---|
| Type | The numeric type of the inputs (u8, s16, f32, …). Sets how the value is interpreted. |
| Nb Inputs | How many values to format. Right-click → Add Input to grow it. |
| Sync | When to emit text — typically InputSync so a new line is produced each time an input changes. |
| Format | Format flags (hex / decimal / signed / padded / etc.). |
| Precision | Number of decimal places when the input is a float. |
| Max Len | Maximum buffer size in bytes. |
| Label | A constant prefix prepended to the value ("speed: ", for example). |
| Unit | A constant suffix appended after the value (" rpm", " °C"). |
| Clear | Reset the buffer between outputs. |
| Align Right | Right-align the number inside its field. |
A FormatText with Label = "Count: ", Unit = "\n", type u16, fed from a Counter, produces lines like Count: 42 over and over. Wire its output into a USB Serial input and you have a live numeric stream you can watch in the serial console — see Examples/08-Strings/FormatText.
Many other modules — BlinkSerial, the digital-input examples, the analog-input examples — all use FormatText in front of a USB Serial. It's the easiest way to confirm a value is what you expect.
Text
Text emits a fixed template, with optional %-style insertion points that pull values from its numeric inputs. Use it when you want a hand-crafted line — a status message, a serial protocol frame, a one-line greeting — rather than the formulaic "label + value + unit" of FormatText.
The Examples/08-Strings/Text example shows the template syntax.
StringToNumber
StringToNumber does the inverse: it scans a text buffer for a number and produces it on its output as the configured numeric type. Wire it after a USB Serial input to read commands from a host program, or after an HTTP/UDP receiver to parse incoming data.
It's commonly paired with FormatText on a partner board, giving you a simple line-based numeric protocol that's easy to debug — just open a console and type the numbers yourself.
A note on Buffers
The output of every text module is a Buffer. Buffers can be:
- routed to USB Serial / Hardware Serial / Software Serial to leave the board,
- displayed on an OLED or Nextion screen,
- written to a file by the host through
nNodeBlueInterface, - spliced with other buffers by BufferMerge / BufferSplit (see the Data Packing tutorial),
- or just printed to the console for debugging.
Now let's see how to move buffers around between boards: Communication — Serial family.