IDisplayController

class

Abstract Interface for display controllers like ILITEK chip etc.

This interface a simple set of function that display interface must implement.

Mono dislpay system build upon this interface, and all drawing is done through these functions.

You must override all the defined methods in this interface. The interface does not define or depend on a communication protocol, like parrallel or SPI.

Author
Kristoffer Andersen

Public Functions

mono::display::IDisplayController::IDisplayController(int, int)

Setup the display controller object, init vaiables and the screen size. The width is the horizontal measure, when mono is held in portrait mode.

This constructor should not transfer any data or initialize the display. You must do that in the init method.

Return
The display controller instance.
Parameters
  • width -

    The display width (horizontal) in pixels

  • height -

    The display height (vertical) in pixels

virtual void mono::display::IDisplayController::init()
= 0

Initializes the hardware display controller.

Initalizing the hardware display controller means setting up the power, gamma control and sync options. The display should be ready to draw graphics when this method returns.

It is not nessasary to do any draw commands from this method, other classes will take care of clearing the screen to black, etc.

virtual void mono::display::IDisplayController::setWindow(int x, int y, int width, int height)
= 0

Changes the current active window to a new rectangle.

The display controller must support windowing in software or in hardware. The window is the acrtive painting area of the screen, where you can paint. Upon drawing a single pixel the dispay cursor increments inside the window. This means you can sometime skip calls to the setCursor method.

Parameters
  • x -

    X-coordinate of the new windows upper left corner

  • y -

    Y-coordinate of the new windows upper left corner

  • width -

    The window width

  • height -

    The window height

void mono::display::IDisplayController::setRefreshHandler(mbed::FunctionPointer *handler)

Set the callback for display refreshes.

Set the callback function, that is called whenever the display has just repainted itself. This means it is time to repaint any dirty views, that needs to be updated.

IMPORTANT: You should re-paint graphics from within this callback, since it might run inside a hardware interrupt. It is better to just schedule the repaint from here.

Parameters
  • obj -

    The owner object of the callback method (the this context)

  • memPtr -

    A pointer to the owner objects callback member function

virtual void mono::display::IDisplayController::setCursor(int x, int y)
= 0

Set the drawing cursor to a new absolute position.

Sets the current drawing cursor to a new position (must be within the cuurently active window).

When setting the cursor you must use absolute coordinates (screen coordinates), not coordinates inside the active window.

Parameters
  • x -

    The new X position (screen coordinates)

  • y -

    The new X position (screen coordinates)

virtual void mono::display::IDisplayController::write(Color pixelColor)
= 0

Draw a pixel with the given color, at cursor position.

Write a pixel color to the display, at the cursor position. This method will automatically increment the cursor position.

If the increment happens automatically in hardware, the controller implementation must keep its own cursor in sync.

Parameters
  • pixelColor -

    The 16-bit 5-6-5 RGB color to draw

virtual void mono::display::IDisplayController::setBrightness(uint8_t value)
= 0

Set the display backlight brightness. Higher values means more brightness. The display controller implementation might use a PWM to switch backlight LED’s.

Parameters
  • value -

    The brightness 0: off, 255: max brightness

virtual void mono::display::IDisplayController::setBrightnessPercent(float percent)

Set the display backlight brightness. Higher values means more brightness. The display controller implementation might use a PWM to switch backlight LED’s.

Parameters
  • percent -

    The brightness percentage, 0.00: off, 1.00: max brightness

virtual uint8_t mono::display::IDisplayController::Brightness()
const = 0

Gets the current LES backlight brightness The display controller implementation might use a PWM to dim the display, this method returns the PWM duty cycle.

Return
The current brightness level in 8-bit format: 0: off, 255: max brightness

Public Members

uint32_t mono::display::IDisplayController::LastTearningEffectTime

The last tearning effect interrupt time (us_ticker_read())

To calculate the time since the last tearning effect interrupt (display refresh), you can use this member variable. On each interrupt this value is updated.

If too much time has passed between the interrupt occured and you handle the painting, you might want to skip the painting. THis is to avoid artifacts, when drawing on a refreshing display.

Any implementation of the IDisplayController must update this value in its tearning effect interrupt handler.