Skip to content

Commands Render

captncode edited this page Dec 14, 2020 · 2 revisions

The following commands accept a JSON document for their parameters. They each perform a render function and are executed using an HTTP Post. They return one of the following HTTP responses upon completion: Accepted (202), BadRequest (400) or InternalServerError (500).

Image

URL: /api/IoTDisplay/Image
Loads an image from a file on the screen.

Sample:

POST /api/IoTDisplay/Image
{
    "x": 10,
    "y": 100,
    "filename": "/home/pi/welcome.png",
    "delay: true"
}

Parameters:

  • x (integer) Required
    X coordinate to place the image.
    example: 10

  • y (integer) Required
    Y coordinate to place the image.
    example: 100

  • filename (string) Required
    Filename of the image to place on the screen.
    example: /home/pi/welcome.png

  • delay (boolean) Optional
    Delay screen update.
    default: false
    example: false

Draw

URL: /api/IoTDisplay/Draw
Draws an SVG object(s) on the screen.

Sample:

POST /api/IoTDisplay/Draw
{
    "x": 10,
    "y": 100,
    "width": 300,
    "height": 200,
    "svgCommands": '<circle cx="150" cy="100" r="80" fill="green" /><text x="150" y="120" font-size="60" text-anchor="middle" fill="white">SVG</text>',
    "delay: true"
}

Parameters:

  • x (integer) Required
    X coordinate to place the drawing.
    example: 10

  • y (integer) Required
    Y coordinate to place the drawing.
    example: 100

  • width (integer) Required
    Drawing area width.
    example: 300

  • height (integer) Required
    Drawing area height.
    example: 200

  • svgCommands (string) Optional
    SVG command(s) used to draw the image or hexColor of square. You can supply one or more SVG drawing commands. Within the SVG, sizes must be actual and not percentage based and the X, Y coordinates are relative to the drawing area.
     
    Alternatively, a hexadecimal color string can be used for a solid fill of the rectangle, with or without a preceding '#' character formatted like: AARRGGB, RRGGBB, ARGB or RGB.
     
    example: <circle cx="150" cy="100" r="80" fill="green" /> <text x="150" y="120" font-size="60" text-anchor="middle" fill="white">SVG</text>
    default: Foreground Color

  • delay (boolean) Optional
    Delay screen update.
    default: false
    example: false

Text

URL: /api/IoTDisplay/Text
Places text on the screen.

Sample:

POST /api/IoTDisplay/Text
{
    "x": 10,
    "y": 100,
    "value": "Welcome Home",
    "horizAlign": 0,
    "vertAlign": 0,
    "font": "/home/pi/NotoSans-Black.ttf",
    "fontSize": 60,
    "fontWeight": 400,
    "fontWidth": 5,
    "hexColor": "#000000",
    "delay: true"
}

Parameters:

  • x (integer) Required
    X coordinate to place the text.
    example: 10

  • y integer Required
    Y coordinate to place the text.
    example: 100

  • value (string) Required
    Text value to place.
    example: Welcome Home

  • horizAlign (integer) Optional
    Text horizontal alignment.
    values:

    • -1 = Left
    • 0 = Center (default)
    • 1 = Right

    example: 0

  • vertAlign (integer) Optional
    Text vertical alignment.
    values:

    • -1 = Top
    • 0 = Middle (default)
    • 1 = Bottom

    example: 0

  • font (string) Optional
    Filename or font family of the font to use.
    example: /home/pi/NotoSans-Black.ttf

  • fontSize (number) Optional
    Font size of the text.
    default: 32
    example: 60

  • fontWeight (integer) Optional
    Font weight of the text.
    values: 100 - 900
    default: 400
    example: 400

  • fontWidth (integer) Optional
    Font width of the text.
    values: 1 - 9
    default: 5
    example: 5

  • hexColor (string) Optional
    Hex color string representing the color of the text.
    default: #000000
    example: #000000

  • delay (boolean) Optional
    Delay screen update.
    default: false
    example: false

Clone this wiki locally