View Source pmod_mtds (grisp v2.8.0)

GRiSP device driver for Digilent Pmod MTDS.

NOTE: This driver does not replicate all of the functionality found in the reference C++ driver. I hope it replicates enough that interested developers have templates for any further features they might want to add! Also, a warning: the C++ driver defines some constants (and even commands??) which are not supported by the device firmware.

For manuals and a C++ reference driver, see https://github.com/Digilent/vivado-library/tree/master/ip/Pmods/PmodMTDS_v1_0

Summary

Functions

Allocate a new bitmap (usually to back a surface).

Write the contents of one bitmap onto another.

Release a bitmap.

Blanks the MTDS to the indicated color.

Set the background draw color of a surface.

Set the foreground draw color of a surface.

Set the bitwise operator used to combine pen + bitmap when drawing.

Retrieve the current font of a surface.

Set the active font for a surface.

Draw a line on a surface from the current cursor position to a new one.

Move the cursor position on a surface.

Registers the caller for touch events for the indicated window.

Launch the MTDS driver.

Convert a human-readable font atom to a font() instance.

Generate a new surface (with no underlying bitmap).

Tether a surface to a backing bitmap.

Retrieve a surface handle to the global display.

Release a surface handle.

Write text on a surface at a given position.

Types

bitmap()

-type bitmap() :: 3238002688..3238002688 + 16777215.

color()

-type color() :: {R :: float(), G :: float(), B :: float()}.

font()

-type font() :: 3271557120..3271557120 + 16777215.

position()

-type position() :: {X :: integer(), Y :: integer()}.

stock_font()

-type stock_font() :: console.

surface()

-type surface() :: 3221225472..3221225472 + 16777215.

window()

-type window() :: 3288334336..3288334336 + 16777215.

Functions

bitmap(X, Y, Color)

-spec bitmap(integer(), integer(), monochrome | color) -> {ok, bitmap()}.

Allocate a new bitmap (usually to back a surface).

bitmap_draw/5

-spec bitmap_draw(surface(), position(), surface(), position(), {integer(), integer()}) -> ok.

Write the contents of one bitmap onto another.

bitmap_release(Handle)

-spec bitmap_release(bitmap()) -> ok.

Release a bitmap.

clear(Color)

-spec clear(Color :: color()) -> ok.

Blanks the MTDS to the indicated color.

color_bg/2

-spec color_bg(surface(), color()) -> ok.

Set the background draw color of a surface.

color_fg/2

-spec color_fg(surface(), color()) -> ok.

Set the foreground draw color of a surface.

draw_rop(Handle, OpCode)

-spec draw_rop(surface(), integer()) -> ok.

Set the bitwise operator used to combine pen + bitmap when drawing.

font(Handle)

-spec font(surface()) -> {ok, font()}.

Retrieve the current font of a surface.

font(Handle, Font)

-spec font(surface(), font()) -> ok.

Set the active font for a surface.

line_to/2

-spec line_to(surface(), position()) -> ok.

Draw a line on a surface from the current cursor position to a new one.

move_to/2

-spec move_to(surface(), position()) -> ok.

Move the cursor position on a surface.

register()

Registers the caller for touch events for the indicated window.

register(Window)

-spec register(window()) -> ok.

start_link(Interface, Opts)

-spec start_link(grisp_spi:bus(), any()) -> {ok, pid()} | ignore | {error, term()}.

Launch the MTDS driver.

stock_font(Font)

-spec stock_font(stock_font()) -> font().

Convert a human-readable font atom to a font() instance.

surface()

-spec surface() -> {ok, surface()}.

Generate a new surface (with no underlying bitmap).

surface_bitmap(DSHandle, BitmapHandle)

-spec surface_bitmap(surface(), bitmap()) -> ok.

Tether a surface to a backing bitmap.

surface_display()

-spec surface_display() -> {ok, surface()}.

Retrieve a surface handle to the global display.

surface_release(Handle)

-spec surface_release(surface()) -> ok.

Release a surface handle.

text/3

-spec text(surface(), iolist(), position()) -> ok.

Write text on a surface at a given position.