Project structure

The component sc_lcd includes the modules module_lcd, module_text_display and module_touch_controller_lib.

module_lcd

Configuration defines

The module_lcd includes device support defines, each support header, located in the devices directory defines a number of parameters. It is sufficient for the user to specify which device to support in the lcd_conf.h for the device to be correctly supported. To do this lcd_conf.h must include the define: :: #define LCD_PART_NUMBER p

where p is the part the user requires support for. lcd_conf.h must be located in the application project and not the module. Currently, support is provided for:
  • AT043TN24V7
  • K430WQAV4F
  • K70DWN0V1F

Implementation specific defines

It is possible to override the default defines when a part number is selected. The defines available are:

LCD_WIDTH

This define is used to represent the width of the LCD panel in pixels.

LCD_HEIGHT

This define is used to represent the height of the LCD panel in pixels.

LCD_BITS_PER_PIXEL

Count of bits used to set a pixels RGB value, i.e. if the screen was wired for rgb565 then the LCD_BITS_PER_PIXEL would be 16, rgb888 would be 24. This is independant of the actual bit depth of the lcd.

LCD_HOR_FRONT_PORCH

The horizontal front porch timing requirement given in pixel clocks.

LCD_HOR_BACK_PORCH

The horizontal back porch timing requirement given in pixel clocks.

LCD_VERT_FRONT_PORCH

The vertical front porch timing requirement given in horizontal time periods.

LCD_VERT_BACK_PORCH

The vertical back porch timing requirement given in horizontal time periods.

LCD_HOR_PULSE_WIDTH

The horizontal pulse width timing requirement given in pixel clocks. This is the duration that the hsync signal should go low to denote the start of the horizontal frame. Set to 0 when hsync is not necessary.

LCD_VERT_PULSE_WIDTH

The vertical pulse width timing requirement given in vertical time periods. This is the duration that the vsync signal should go low to denote the start of the vertical frame. Set to 0 when vsync is not necessary.

LCD_FREQ_DIVIDEND

The defines FREQ_DIVIDEND and FREQ_DIVISOR are used to calculate the frequency of the clock used for LCD. The frequency configured = (FREQ_DIVIDEND / FREQ_DIVISOR) in MHz

LCD_FREQ_DIVISOR

The defines FREQ_DIVIDEND and FREQ_DIVISOR are used to calculate the frequency of the clock used for LCD. The frequency configured = (FREQ_DIVIDEND / FREQ_DIVISOR) in MHz

LCD_FAST_WRITE

The define enables a faster LCD write function, however, it produces more code. Use when a 25MHz pixel clock is required. It cannot be used with LCD_HOR_PULSE_WIDTH > 0 or LCD_VERT_PULSE_WIDTH > 0 as horizontal and veritcal sync signals are not supported in LCD_FAST_WRITE mode.

API

The LCD display module functionality is defined in
  • lcd.xc
  • lcd.h
  • lcd_defines.h
  • lcd_assembly.S
  • /devices

where the following functions can be found:

  • void lcd_init(chanend c_lcd)

    LCD init function.

    This sets the lcd into a state where it is ready to accept data.

    Parameters

    • c_lcd

      The channel end connecting to the lcd server.

  • static void lcd_req(chanend c_lcd)

    Receives the request for data from the LCD server.

    Parameters

    • c_lcd

      The channel end connecting to the lcd server.

  • static void lcd_update(chanend c_lcd, unsigned buffer[])

    LCD update function.

    This sends a buffer of data to the lcd server to to sent to the lcd.

    Note, no array bounds checking is performed.

    Parameters

    • c_lcd

      The channel end connecting to the lcd server.

    • buffer[]

      The data to be emitted to the lcd screen, stored in rgb565.

  • static void lcd_update_p(chanend c_lcd, unsigned buffer)

    C interface for LCD update function.

    This sends a buffer of data to the lcd server to to sent to the lcd.

    Note, no array bounds checking is performed.

    Parameters

    • c_lcd

      The channel end connecting to the lcd server.

    • buffer

      A pointer to data to be emitted to the lcd screen, stored in rgb565.

  • void lcd_server(chanend c_client, lcd_ports &ports)

    The LCD server thread.

    Parameters

    • c_client

      The channel end connecting to the client.

    • ports

      The structure carrying the LCD port details.

module_touch_controller_lib

The device-specific configuration defines and user defines are listed in touch_lib_conf.h.

Configuration defines

TOUCH_LIB_LCD_WIDTH

This define is used to represent the width of the LCD panel in pixels.

TOUCH_LIB_LCD_HEIGHT

This define is used to represent the height of the LCD panel in pixels.

TOUCH_LIB_TS_WIDTH

This define is used to represent the width of the touch screen in points.

TOUCH_LIB_TS_HEIGHT

This define is used to represent the height of the touch screen in points.

API

The touch screen module functionality is defined in
  • touch_controller_lib.xc
  • touch_controller_lib.h
  • /AD7879-1

where the following functions can be found:

  • void touch_lib_init(touch_controller_ports &ports)

    The touch controller initialisation.

    Parameters

    • ports

      The structure containing the touch controller port details.

  • void touch_lib_get_touch_coords(touch_controller_ports &ports, unsigned &x, unsigned &y)

    Get the current touch coordinates from the touch controller.

    The returned coordinates are not scaled.

    Parameters

    • ports

      The structure containing the touch controller port details.

    • x

      The X coordinate of point of touch.

    • y

      The Y coordinate of point of touch.

  • select touch_lib_touch_event(touch_controller_ports &ports)

    A select function that will wait until the touch controller reports a touch event.

    Parameters

    • ports

      The structure containing the touch controller port details.

  • void touch_lib_get_next_coord(touch_controller_ports &ports, unsigned &x, unsigned &y)

    This function will block until the controller reports a touch event at which point it will return the coordinates of that event.

    The coordinates are not scaled.

    Parameters

    • ports

      The structure containing the touch controller port details.

    • x

      The X coordinate of point of touch.

    • y

      The Y coordinate of point of touch.

  • void touch_lib_scale_coords(unsigned &x, unsigned &y)

    The function to scale coordinate values (from the touch point coordinates to the LCD pixel coordinates).

    Parameters

    • x

      The scaled X coordinate value

    • y

      The scaled Y coordinate value

See Also