Skip to content

Component

Igor Usenko edited this page May 9, 2022 · 28 revisions

The part of the UI screen.
An array of the components represents the UI screen.
Maintain the state.
The state can be changed from some FreeRTOS tasks or from other components.
There are two standard components: Text and Button.

Palette

All the components use predefined palette colors only:

  • black - just black color
  • information - color for information components
  • interaction - color for interactive components
  • attention - color for components which are required user attention

Properties

  • bounding box (x, y, w, h) - x, y initially it is the relative to the parent coordinates. see mount
  • state

Screen API

  • mount(component, x, y) - mounts component to the screen by converting its relative coordinates to the real screen coordinates
  • contains(component, x, y) - returns true if (x, y) is inside component bounding box

Render API

  • newState(component) - compares the new state with previous. returns true if render needed
  • render(component, forced, tftApi) - renders the component's state. the forced flag means that the component should perform a full redraw.

Touch Event API

  • onTouch(component, x, y, tickCount) - called when user touched screen
  • onMove(component, x, y, tickCount) - called when user moving touch point
  • onRelease(component, x, y, tickCount) - called when user released touch screen
  • onGesture(component, gesture) - called when user made a gesture

Clone this wiki locally