NestGen2.Display (nest_gen2 v0.6.6)

Copy Markdown View Source

The 320×320 round screen, double-buffered.

Drawing calls update a back buffer; present/0 shows everything drawn since the last present in one page flip, so a partly drawn frame is never visible.

The visible area is the circle inscribed in the square: centre {160, 160}, radius 160. Backgrounds can bleed to the edge; keep text and icons inside safe_radius/0, since the bezel covers the outermost few pixels.

Summary

Functions

Returns a specification to start this module under a supervisor.

Shows everything drawn since the last present, in one page flip.

Draws an image with its top-left corner at (x, y).

Draws text with its top edge at y. Takes NestGen2.Text options plus :align — :left (x is the left edge, default), :center or :right.

Replaces the whole screen with a 320×320 image or a solid colour, given as a hex string or {r, g, b} tuple

What the screen shows: the frame as of the last present/0, as a 320×320 image. NestGen2.Image.to_png/1 turns it into a PNG.

Functions

center()

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

fill_rect(x, y, w, h, color)

@spec fill_rect(
  integer(),
  integer(),
  pos_integer(),
  pos_integer(),
  NestGen2.Image.color()
) :: :ok

height()

present()

@spec present() :: :ok

Shows everything drawn since the last present, in one page flip.

put_image(x, y, image)

@spec put_image(integer(), integer(), NestGen2.Image.t()) :: :ok

Draws an image with its top-left corner at (x, y).

put_text(x, y, text, opts \\ [])

@spec put_text(integer(), integer(), String.t(), keyword()) :: :ok | {:error, term()}

Draws text with its top edge at y. Takes NestGen2.Text options plus :align — :left (x is the left edge, default), :center or :right.

radius()

safe_radius()

set_background(image)

@spec set_background(NestGen2.Image.t() | NestGen2.Image.color()) :: :ok

Replaces the whole screen with a 320×320 image or a solid colour, given as a hex string or {r, g, b} tuple:

NestGen2.Display.set_background("#1C1C1E")

A colour fills the visible circle (radius 160) and leaves the corners black, as Nest's own screens do, so no coloured slivers show where the bezel's cut-out meets the square panel. Images are drawn as given; make their corners black for the same reason.

snapshot()

@spec snapshot() :: NestGen2.Image.t()

What the screen shows: the frame as of the last present/0, as a 320×320 image. NestGen2.Image.to_png/1 turns it into a PNG.

start_link(_)

width()