Skip to content

Commands Clock

captncode edited this page Apr 24, 2021 · 4 revisions

The following commands accept a JSON document for their parameters. They each perform a clock 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).

Clock

URL: /api/IoTDisplay/Clock
Add a clock to the screen.

Sample:

POST /api/IoTDisplay/Clock
{
    "timezone": "America/New_York"
}

Parameters:

  • timezone (string) Optional
    Time zone to use for the clock. This can be an IANA, Windows, or Rails time zone name.
    default: Device default
    example: America/New_York

ClockImage

URL: /api/IoTDisplay/ClockImage
Add an image from a file to a clock.

Sample:

POST /api/IoTDisplay/ClockImage
{
    "timezone": "America/New_York",
    "x": 10,
    "y": 100,
    "filename": "/home/pi/nyc.png"
}

Parameters:

  • timezone (string) Optional
    Time zone of the clock. This must match an existing clock.
    default: Device default
    example: America/New_York

  • 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/nyc.png

ClockDraw

URL: /api/IoTDisplay/ClockDraw
Add a drawing to a clock.

Sample:

POST /api/IoTDisplay/ClockDraw
{
    "timezone": "America/New_York",
    "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">{0:ddd MM/dd/yy h:mm tt}</text>'
}

Parameters:

  • timezone (string) Optional
    Time zone of the clock. This must match an existing clock.
    default: Device default
    example: America/New_York

  • 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.
     
    You can also embed a dotnet standard or custom DateTime format string in your SVG as a format string (example provided).
     
    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.
    default: Foreground Color
    example: <circle cx="150" cy="100" r="80" fill="green" /> <text x="150" y="120" font-size="60" text-anchor="middle" fill="white">{0:ddd MM/dd/yy h:mm tt}</text>

ClockTime

URL: /api/IoTDisplay/ClockTime
Add a time area to a clock.

Sample:

POST /api/IoTDisplay/ClockTime
{
    "timezone": "America/New_York",
    "x": 10,
    "y": 100,
    "formatstring": "ddd MM/dd/yy h:mm tt",
    "horizAlign": 0,
    "vertAlign": 0,
    "font": "/home/pi/NotoSans-Black.ttf",
    "fontSize": 60,
    "fontWeight": 400,
    "fontWidth": 5,
    "textColor": "#000000",
    "backgroundColor": "#ffffff"
}

Parameters:

  • timezone (string) Optional
    Time zone of the clock. This must match an existing clock.
    default: Device default
    example: America/New_York

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

  • y (integer) Required
    Y coordinate to place the bottom of the time.
    example: 100

  • formatstring (string) Optional
    Date/Time format string. This is a dotnet standard or custom DateTime format string.
    default: t
    example: ddd MM/dd/yy h:mm tt

  • horizAlign (integer) Optional
    Time text horizontal alignment.
    values:

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

    example: 0

  • vertAlign (integer) Optional
    Time 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 time.
    default: 32
    example: 60

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

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

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

  • backgroundColor (string) Optional
    HexColor to use for the clock's background. This is used to erase the previous time.
    default: Screen background color
    example: #ffffff

ClockDelete

URL: /api/IoTDisplay/ClockDelete
Delete a clock.

Sample:

POST /api/IoTDisplay/ClockDelete
{
    "timezone": "America/New_York"
}

Parameters:

  • timezone (string) Optional
    Time zone of the clock.
    default: Device default
    example: America/New_York