Difference between revisions of "API"

From Badge team
Jump to navigation Jump to search
(Replaced content with "Moved to https://docs.badge.team/api-reference/")
Tag: Replaced
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page describes each of the officially supported APIs of the badge.team platform firmware.
+
Moved to https://docs.badge.team/api-reference/
 
 
= System =
 
The '''system''' API allows you to control basic features your app needs to provide a smooth experience to the user.
 
 
 
= Display =
 
The '''display''' API allows you to control the display of your badge.
 
 
 
{| class="wikitable"
 
! Command
 
! Parameters
 
! Description
 
|-
 
| flush
 
| [flags]
 
| Flush the contents of the framebuffer to the display.
 
Optionally you may provide flags (see the table down below)
 
|-
 
| size
 
| [window]
 
| Get the size (width, height) of the framebuffer or a window as a tuple
 
|-
 
| width
 
| [window]
 
| Get the width of the framebuffer or a window as an integer
 
|-
 
| height
 
| [window]
 
| Get the height of the framebuffer or a window as an integer
 
|-
 
| orientation
 
| [window], [angle]
 
| Get or set the orientation of the framebuffer or a window
 
|-
 
| getPixel
 
| [window], x, y
 
| Get the color of a pixel in the framebuffer or a window
 
|-
 
| drawRaw
 
| [window], x, y, width, height, data
 
| Copy a raw bytes buffer directly to the framebuffer or the current frame of a window.
 
The length of the bytes buffer must match the formula width*height*(bitsPerPixel//8).
 
This is a direct copy: color format (bitsPerPixel) must match the specific display of the badge this command is used on.
 
|-
 
| drawPixel
 
| [window], x, y, color
 
| Draw a pixel in the framebuffer or a window
 
|-
 
| drawFill
 
| [window], color
 
| Fill the framebuffer or a window
 
|-
 
| drawLine
 
| [window], x0, y0, x1, y1, color
 
| Draw a line from (x0, y0) to (x1, y1)
 
|-
 
| drawRect
 
| [window], x, y, width, height, color
 
| Draw a rectangle at (x, y) with size (width, height)
 
|-
 
| drawCircle
 
| [window], x0, y0, radius, a0, a1, fill, color
 
| Draw a circle with center point (x0, y0) with the provided radius from angle a0 to angle a1, optionally filled (boolean)
 
|-
 
| drawText
 
| [window], x, y, text, [color], [font], [x-scale], [y-scale]
 
| Draw text at (x, y) with a certain color and font. Can be scaled (drawn with rects instead of pixels) in both the x and y direction
 
|-
 
| drawPng
 
| [window], x, y, [data or filename]
 
| Draw a PNG image at (x, y) from either a bytes buffer or a file
 
|-
 
| getTextWidth
 
| text, [font]
 
| Get the width a string would take if drawn with a certain font
 
|-
 
| getTextHeight
 
| text, [font]
 
| Get the height a string would take if drawn with a certain font
 
|-
 
| pngInfo
 
| [data or filename]
 
| Get information about a PNG image
 
|-
 
| windowCreate
 
| name, width, height
 
|
 
|-
 
| windowRemove
 
| name
 
|
 
|-
 
| windowMove
 
| name, x, y
 
|
 
|-
 
| windowResize
 
| name, width, height
 
|
 
|-
 
| windowVisibility
 
| name, [visible]
 
|
 
|-
 
| windowShow
 
| name
 
|
 
|-
 
| windowHide
 
| name
 
|
 
|-
 
| windowFocus
 
| name
 
|
 
|-
 
| windowList
 
| -
 
|
 
|-
 
| windowLoop
 
| *DO NOT USE*
 
|
 
|-
 
| frameAdd
 
| *DO NOT USE*
 
|
 
|-
 
| frameRemove
 
| *DO NOT USE*
 
|
 
|-
 
| frameStep
 
| *DO NOT USE*
 
|
 
|-
 
| frameSeek
 
| *DO NOT USE*
 
|
 
|-
 
| frameCurrent
 
| *DO NOT USE*
 
|
 
|-
 
| frameCount
 
| *DO NOT USE*
 
|
 
|}
 
 
 
= WiFi =
 
The '''wifi''' API allows you to connect to WiFi networks.
 
{| class="wikitable"
 
! Command
 
! Parameters
 
! Description
 
|-
 
| connect
 
| [ssid], [password]
 
| Connect to a WiFi network.
 
By default the stored credentials are used, but you can optionally provide the SSID (and password) of the network to connect to.
 
|-
 
| disconnect
 
| -
 
| Disconnect from the WiFi network.
 
|-
 
| status
 
| -
 
| Returns True if connected and False if not connected.
 
|-
 
| wait
 
| [timeout]
 
| Wait until a connection with the WiFi network has been made or until the timeout time is reached.
 
Timeout is in seconds but may be provided in 10ths of seconds. If no timeout is provided the default timeout is used.
 
Returns True if connected after waiting and False if a connection could not be made before the timeout.
 
|-
 
| ntp
 
| [only-if-needed], [server]
 
| Synchronize the Real-Time-Clock with the network. Normally the synchronisation is only started when the system clock has not yet been set since the last reset.
 
This can be overruled by setting the only-if-needed parameter to False. By default the "'pool.ntp.org" server pool is used.
 
|}
 
 
 
= Terminal =
 
The '''term''' API allows you to make more advanced use of the serial console.
 

Latest revision as of 03:02, 27 August 2019