Project structure

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

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 terms of lines.

LCD_BITS_PER_PIXEL

Count of bits used to set a pixels colour, 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.

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 to 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 to emitted to the lcd screen, stored in rgb565.

  • void lcd_server(chanend client, lcd_ports &ports)

    The LCD server thread.

    Parameters

    • 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 terms of lines.

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.

User Define

TOUCH_LIB_TIME_OUT

This define is used to set the time in seconds for the time-out message to display.

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.

  • {unsigned,unsigned} get_touch_coordinates(r_i2c &i2c_ports)

    Get touch coordinates from the result registers of touch controller.

    Parameters

    • i2c_ports

      The structure containing the I2C port details.

  • select touch_lib_req_next_coord(touch_controller_ports &ports, unsigned &ts_x, unsigned &ts_y)

    The function to fetch the next touch coordinates from the touch screen controller.

    Parameters

    • ports

      The structure containing the touch controller port details.

    • ts_x

      The X coordinate of point of touch.

    • ts_y

      The Y coordinate of point of touch.

  • void touch_lib_req_next_coord_timed(touch_controller_ports &ports, unsigned &ts_x, unsigned &ts_y, unsigned &time, timer t)

    The function to fetch the next touch coordinates from the touch screen controller.

    The delay in touch event is also computed.

    Parameters

    • ports

      The structure carrying the LCD port details.

    • ts_x

      The X coordinate of point of touch.

    • ts_y

      The Y coordinate of point of touch.

    • time

      The delay in touch event in seconds.

    • t

      The timer used to compute the delay in touch event.

  • select touch_lib_next_coord_timed(touch_controller_ports &ports, unsigned &ts_x, unsigned &ts_y, unsigned &nSec, timer t, unsigned &timerCount, unsigned &touched)

    The function called by another function to fetch the next touch coordinates from the touch screen controller.

    The delay in touch event is also computed.

    Parameters

    • ports

      The structure carrying the LCD port details.

    • ts_x

      The X coordinate of point of touch.

    • ts_y

      The Y coordinate of point of touch.

    • time

      The delay in touch event in seconds.

    • t

      The timer used to compute the delay in touch event.

    • timerCount

      A counter variable.

    • touched

      The flag that records the touch status.

  • void 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 X coordinate value

    • y

      The Y coordinate value

module_touch_controller_server

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

Configuration Defines

TOUCH_SERVER_LCD_WIDTH

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

TOUCH_SERVER_LCD_HEIGHT

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

TOUCH_SERVER_TS_WIDTH

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

TOUCH_SERVER_TS_HEIGHT

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

User Define

TOUCH_SERVER_TIME_OUT

This define is used to set the time in seconds for the time-out message to display.

API

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

where the following functions can be found:

doxygenfunction: Cannot find function “touch_server_init” in doxygen xml output

  • {unsigned,unsigned} get_touch_coordinates(r_i2c &i2c_ports)

    Get touch coordinates from the result registers of touch controller.

    Parameters

    • i2c_ports

      The structure containing the I2C port details.

  • void touch_controller_server(chanend c_server, touch_controller_ports &ports)

    The touch controller server function.

    Parameters

    • c_server

      The channel connecting the client API and the server.

    • ports

      The structure containing the touch controller port details.

  • select process_interrupt(touch_controller_ports &ports, unsigned presentTimeSec, t_status &touched, unsigned &x, unsigned &y, unsigned &touchTime)

    The function that processes the pen-down interrupt generated by touching the screen.

    Parameters

    • ports

      The structure containing the touch controller port details.

    • presentTimeSec

      The current time in seconds relative to the call of touch controller server function.

    • touched

      The flag that records the touch status.

    • x

      The X coordinate value.

    • y

      The Y coordinate value.

    • touchTime

      The time of touch in seconds relative to the call of touch controller server function.

  • t_status touch_server_get_last_coord(chanend c_ts, unsigned &x, unsigned &y)

    The function to get the last touch coordinates from the touch controller server function.

    Parameters

    • c_ts

      The channel connecting this client API and the server.

    • x

      The X coordinate value.

    • y

      The Y coordinate value.

  • void touch_server_get_next_coord(chanend c_ts, unsigned &x, unsigned &y)

    The function to get the next touch coordinates from the touch controller server function.

    Parameters

    • c_ts

      The channel connecting this client API and the server.

    • x

      The X coordinate value.

    • y

      The Y coordinate value.

  • t_status touch_server_get_last_coord_timed(chanend c_ts, unsigned &t, unsigned &x, unsigned &y)

    The function to get the last touch coordinates from the touch controller server function.

    The time elapsed from the last touch event is also computed.

    Parameters

    • c_ts

      The channel connecting this client API and the server.

    • t

      The time elapsed from the last touch event in seconds.

    • x

      The X coordinate value.

    • y

      The Y coordinate value.

  • void 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 X coordinate value

    • y

      The Y coordinate value

See Also