#include "touch.h"#include "glcd.h"#include "power.h"#include <LPC17xx.h>#include <stdbool.h>#include <stdlib.h>Go to the source code of this file.
Classes | |
| struct | TP_CalibrationMatrix |
Macros | |
| #define | TP_CS(a) ((a) ? (LPC_GPIO0->FIOSET = (1 << 6)) : (LPC_GPIO0->FIOCLR = (1 << 6))) |
| #define | TP_INT_IN (LPC_GPIO2->FIOPIN & (1 << 13)) |
| #define | SPI_SPEED_4MHz 18 /* 4MHz */ |
| #define | SPI_SPEED_2MHz 36 /* 2MHz */ |
| #define | SPI_SPEED_1MHz 72 /* 1MHz */ |
| #define | SPI_SPEED_500kHz 144 /* 500kHz */ |
| #define | SPI_SPEED_400kHz 180 /* 400kHz */ |
| #define | THRESHOLD 2 |
| #define | SSP_SR_RECV_FIFO_NOT_EMPTY 2 |
| #define | SSP_SR_BUSY 4 |
| #define | WAIT_IF_BUSY while (LPC_SSP1->SR & (1 << SSP_SR_BUSY)) |
| #define | CHX 0x90 |
| #define | CHY 0xd0 |
| #define | ABS(x) ((x) < 0 ? -(x) : (x)) |
Functions | |
| _PRIVATE void | delay_us (u32 count) |
| Delays for the specified number of microseconds. | |
| _PRIVATE void | spi_set_speed (u8 speed) |
| Sets SPI speed to the specified value. | |
| _PRIVATE u8 | spi_send_command (u8 cmd) |
| Writes a command to the ADS7843 trough SSP1 and returns the received byte. | |
| _PRIVATE void | spi_init (void) |
| Initializes the SPI interface for ADS7843. | |
| _PRIVATE u16 | ads7843_read_adc (void) |
| Communicate (via SPI) with ADS7843 and read a 12-bit ADC (Analog to Digital Converter) value. | |
| _PRIVATE u16 | ads7843_read_x (void) |
| Reads the X coordinate from the touch panel. | |
| _PRIVATE u16 | ads7843_read_y (void) |
| Reads the Y coordinate from the touch panel. | |
| _PRIVATE void | get_xy (u16 *out_x, u16 *out_y) |
| Returns the X, Y coordinates of the touched point. | |
| _PRIVATE bool | poll_touch (TP_Coordinate *out_tp_coords) |
| _PRIVATE void | draw_calibration_cross (u16 x, u16 y) |
| _PRIVATE void | delete_calibration_cross (void) |
| _PRIVATE bool | calc_calibration_matrix (TP_CalibrationMatrix *out_matrix, const LCD_Coordinate *const lcd_3points, const TP_Coordinate *const tp_3points) |
| bool | calibrate (void) |
| void | TP_Init (bool skip_calibration) |
| Initializes the touch panel. | |
| bool | TP_IsInitialized (void) |
| bool | TP_IsCalibrated (void) |
| void | TP_Calibrate (void) |
| Blocks until calibration is completed successfully. | |
| const TP_Coordinate * | TP_WaitForTouch (void) |
| Blocks until a touch event is detected. | |
| const LCD_Coordinate * | TP_GetLCDCoordinateFor (const TP_Coordinate *const tp_point) |
| Converts the touch panel coordinates to LCD coordinates. | |
| TP_ButtonArea | TP_AssignButtonArea (LCD_Button button, LCD_Coordinate pos) |
| Assigns a button area to the given button. | |
| void | TP_WaitForButtonPress (TP_ButtonArea button) |
| Blocks until the given button area is pressed. | |
| bool | TP_HasButtonBeenPressed (TP_ButtonArea button, const TP_Coordinate *const touch_point) |
| Checks if the given button area has been pressed during the touch event which occurred at the given touch point. | |
Variables | |
| _PRIVATE TP_CalibrationMatrix | current_calib_matrix |
| Current calibration matrix. | |
| _PRIVATE bool | initialized = false |
| _PRIVATE bool | calibratated = false |
| _PRIVATE LCD_ObjID | calib_cross_obj_id |
| #define TP_CS | ( | a | ) | ((a) ? (LPC_GPIO0->FIOSET = (1 << 6)) : (LPC_GPIO0->FIOCLR = (1 << 6))) |
| #define WAIT_IF_BUSY while (LPC_SSP1->SR & (1 << SSP_SR_BUSY)) |
Communicate (via SPI) with ADS7843 and read a 12-bit ADC (Analog to Digital Converter) value.
Definition at line 128 of file touch.c.
Reads the X coordinate from the touch panel.
Definition at line 147 of file touch.c.
| _PRIVATE bool calc_calibration_matrix | ( | TP_CalibrationMatrix * | out_matrix, |
| const LCD_Coordinate *const | lcd_3points, | ||
| const TP_Coordinate *const | tp_3points | ||
| ) |
Definition at line 290 of file touch.c.
| bool calibrate | ( | void | ) |
Definition at line 322 of file touch.c.
|
inline |
Definition at line 285 of file touch.c.
Definition at line 259 of file touch.c.
Returns the X, Y coordinates of the touched point.
Definition at line 176 of file touch.c.
| _PRIVATE bool poll_touch | ( | TP_Coordinate * | out_tp_coords | ) |
Definition at line 188 of file touch.c.
|
inline |
Initializes the SPI interface for ADS7843.
Definition at line 95 of file touch.c.
Writes a command to the ADS7843 trough SSP1 and returns the received byte.
| cmd | The command to write to the ADS7843. |
Definition at line 79 of file touch.c.
| TP_ButtonArea TP_AssignButtonArea | ( | LCD_Button | button, |
| LCD_Coordinate | pos | ||
| ) |
Assigns a button area to the given button.
| button | The button to assign the area to. |
| pos | The position of the button. |
Definition at line 436 of file touch.c.
| void TP_Calibrate | ( | void | ) |
| const LCD_Coordinate * TP_GetLCDCoordinateFor | ( | const TP_Coordinate *const | tp_point | ) |
Converts the touch panel coordinates to LCD coordinates.
| tp_point | The touch panel coordinates. |
Definition at line 419 of file touch.c.
| bool TP_HasButtonBeenPressed | ( | TP_ButtonArea | button, |
| const TP_Coordinate *const | touch_point | ||
| ) |
Checks if the given button area has been pressed during the touch event which occurred at the given touch point.
| button | The button to check. |
| touch_point | The touch point to check. |
Definition at line 475 of file touch.c.
| void TP_Init | ( | bool | skip_calibration | ) |
Initializes the touch panel.
| skip_calibration | If true, calibration is skipped. |
Definition at line 373 of file touch.c.
| bool TP_IsCalibrated | ( | void | ) |
| bool TP_IsInitialized | ( | void | ) |
| void TP_WaitForButtonPress | ( | TP_ButtonArea | button | ) |
Blocks until the given button area is pressed.
| button | The button to wait for. |
Definition at line 463 of file touch.c.
| const TP_Coordinate * TP_WaitForTouch | ( | void | ) |
Blocks until a touch event is detected.
Definition at line 408 of file touch.c.
| _PRIVATE TP_CalibrationMatrix current_calib_matrix |