Microchip® Advanced Software Framework

demo_qtouch.c File Reference

QTouch implementation for SAM toolkit demo.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include "demo.h"
#include "bitmaps.h"

Macros

#define GET_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER)   qt_measure_data.qt_touch_status.rotor_slider_values[ROTOR_SLIDER_NUMBER]
 
#define GET_SENSOR_STATE(SENSOR_NUMBER)   (qt_measure_data.qt_touch_status.sensor_states[(SENSOR_NUMBER / 8)] & (1 << (SENSOR_NUMBER % 8)))
 Get QTouch state. More...
 
#define QTOUCH_LIB_COMPILER_MASK   0x01
 QTouch library compiler type mask. More...
 
#define QTOUCH_LIB_COMPILER_OFFSET   2
 QTouch library compiler type offset: GCC / IAR. More...
 
#define QTOUCH_LIB_KEY_ONLY_MASK   0x01
 QTouch library supports keys only mask. More...
 
#define QTOUCH_LIB_KEY_ONLY_OFFSET   10
 QTouch library supports keys only offset. More...
 
#define QTOUCH_LIB_MAX_CHANNEL_MASK   0x7F
 QTouch library maximum channels mask. More...
 
#define QTOUCH_LIB_MAX_CHANNEL_OFFSET   3
 QTouch library maximum channels offset. More...
 
#define QTOUCH_LIB_ROTOR_NUM_MASK   0x1F
 QTouch library maximum rotors/silders mask. More...
 
#define QTOUCH_LIB_ROTOR_NUM_OFFSET   11
 QTouch library maximum rotors/silders offset. More...
 
#define QTOUCH_LIB_TPYE_MASK   0x01
 QTouch library type: QTouch / QMatrix. More...
 
#define TOTAL_SLIDER_NUM   2
 Total slider number supported. More...
 

Enumerations

enum  main_screen_icon_id {
  MAIN_SCR_AUDIO_ID = 0,
  MAIN_SCR_FFT_ID,
  MAIN_SCR_PPT_ID,
  MAIN_SCR_SETTINGS_ID,
  MAIN_SCR_QTOUCH_ID,
  MAIN_SCR_LPM_ID,
  MAIN_SCR_DUMMY_LEFT_ID,
  MAIN_SCR_INFO_ID,
  MAIN_SCR_DUMMY_RIGHT_ID,
  MAIN_SCR_MAX_ID
}
 Main screen IDs. More...
 

Functions

static void config_sensors (void)
 Configure the sensors. More...
 
void demo_qt_init (void)
 Initialize QTouch. More...
 
void demo_qtouch_event_handler (void)
 QTouch event handler. More...
 
static void qt_set_parameters (void)
 This will fill the default threshold values in the configuration data structure.But User can change the values of these parameters. More...
 

Variables

uint16_t current_time_ms_touch = 0u
 Current time, set by timer ISR. More...
 
static enum main_screen_icon_id demo_last_selected_icon_id = MAIN_SCR_INFO_ID
 
static enum main_screen_icon_id demo_selected_icon_id = MAIN_SCR_INFO_ID
 Selected icon ID; default is set to info icon. More...
 
static uint8_t dwn_pressed = 0
 QTouch down key pressed. More...
 
static uint8_t lft_pressed = 0
 QTouch left key pressed. More...
 
uint16_t qt_measurement_period_msec = 25u
 Timer period in msec. More...
 
static uint8_t rgt_pressed = 0
 QTouch right key pressed. More...
 
uint8_t time_to_measure_touch = 0u
 Flag set by timer ISR when it's time to measure touch. More...
 
static uint8_t up_pressed = 0
 QTouch up key pressed. More...
 
static uint8_t vld_pressed = 0
 QTouch enter key pressed. More...
 
static struct gfx_bitmap win_qtouch_btn_down_icon
 Bitmap for QTouch down button. More...
 
static struct gfx_bitmap win_qtouch_btn_down_press_icon
 Bitmap for QTouch pressed down button. More...
 
static struct gfx_bitmap win_qtouch_btn_enter_icon
 Bitmap for QTouch selected button. More...
 
static struct gfx_bitmap win_qtouch_btn_enter_press_icon
 Bitmap for QTouch pressed selected button. More...
 
static struct gfx_bitmap win_qtouch_btn_next_icon
 Bitmap for QTouch right button. More...
 
static struct gfx_bitmap win_qtouch_btn_next_press_icon
 Bitmap for QTouch pressed right button. More...
 
static struct gfx_bitmap win_qtouch_btn_prev_icon
 Bitmap for QTouch left button. More...
 
static struct gfx_bitmap win_qtouch_btn_prev_press_icon
 Bitmap for QTouch pressed left button. More...
 
static struct gfx_bitmap win_qtouch_btn_up_icon
 Bitmap for QTouch up button. More...
 
static struct gfx_bitmap win_qtouch_btn_up_press_icon
 Bitmap for QTouch pressed up button. More...
 

#define GET_ROTOR_SLIDER_POSITION (   ROTOR_SLIDER_NUMBER)    qt_measure_data.qt_touch_status.rotor_slider_values[ROTOR_SLIDER_NUMBER]
#define GET_SENSOR_STATE (   SENSOR_NUMBER)    (qt_measure_data.qt_touch_status.sensor_states[(SENSOR_NUMBER / 8)] & (1 << (SENSOR_NUMBER % 8)))

Get QTouch state.

Referenced by demo_qtouch_event_handler().

#define QTOUCH_LIB_COMPILER_MASK   0x01

QTouch library compiler type mask.

#define QTOUCH_LIB_COMPILER_OFFSET   2

QTouch library compiler type offset: GCC / IAR.

#define QTOUCH_LIB_KEY_ONLY_MASK   0x01

QTouch library supports keys only mask.

#define QTOUCH_LIB_KEY_ONLY_OFFSET   10

QTouch library supports keys only offset.

#define QTOUCH_LIB_MAX_CHANNEL_MASK   0x7F

QTouch library maximum channels mask.

#define QTOUCH_LIB_MAX_CHANNEL_OFFSET   3

QTouch library maximum channels offset.

#define QTOUCH_LIB_ROTOR_NUM_MASK   0x1F

QTouch library maximum rotors/silders mask.

#define QTOUCH_LIB_ROTOR_NUM_OFFSET   11

QTouch library maximum rotors/silders offset.

#define QTOUCH_LIB_TPYE_MASK   0x01

QTouch library type: QTouch / QMatrix.

#define TOTAL_SLIDER_NUM   2

Total slider number supported.

Main screen IDs.

The screen ID is used to selecte the specific icon widget through the QTouch event.

Enumerator
MAIN_SCR_AUDIO_ID 

ID for audio screen.

MAIN_SCR_FFT_ID 

ID for FFT screen.

MAIN_SCR_PPT_ID 

ID for PPT player screen.

MAIN_SCR_SETTINGS_ID 

ID for settings screen.

MAIN_SCR_QTOUCH_ID 

ID for qtouch screen.

MAIN_SCR_LPM_ID 

ID for low power mode screen.

MAIN_SCR_DUMMY_LEFT_ID 

ID for dummy left screen.

MAIN_SCR_INFO_ID 

ID for information screen.

MAIN_SCR_DUMMY_RIGHT_ID 

ID for dummy right screen.

MAIN_SCR_MAX_ID 

Max dummy screen ID.

static void config_sensors ( void  )
static

Configure the sensors.

References AKS_GROUP_1, HYST_6_25, qt_enable_key(), and RES_8_BIT.

Referenced by demo_qt_init().

void demo_qt_init ( void  )

uint16_t current_time_ms_touch = 0u

Current time, set by timer ISR.

enum main_screen_icon_id demo_last_selected_icon_id = MAIN_SCR_INFO_ID
static
enum main_screen_icon_id demo_selected_icon_id = MAIN_SCR_INFO_ID
static

Selected icon ID; default is set to info icon.

Referenced by demo_qtouch_event_handler().

uint8_t dwn_pressed = 0
static

QTouch down key pressed.

Referenced by demo_qtouch_event_handler(), and main().

uint8_t lft_pressed = 0
static

QTouch left key pressed.

Referenced by demo_qtouch_event_handler(), and main().

uint8_t rgt_pressed = 0
static

QTouch right key pressed.

Referenced by demo_qtouch_event_handler(), and main().

uint8_t time_to_measure_touch = 0u

Flag set by timer ISR when it's time to measure touch.

uint8_t up_pressed = 0
static

QTouch up key pressed.

Referenced by demo_qtouch_event_handler(), and main().

uint8_t vld_pressed = 0
static

QTouch enter key pressed.

Referenced by demo_qtouch_event_handler(), and main().

struct gfx_bitmap win_qtouch_btn_down_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
.data.custom = DEMO_BMP_BTN_QT_DOWN
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_DOWN
Definition: bitmaps.h:89

Bitmap for QTouch down button.

struct gfx_bitmap win_qtouch_btn_down_press_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_DOWN_PRESSED
Definition: bitmaps.h:94

Bitmap for QTouch pressed down button.

struct gfx_bitmap win_qtouch_btn_enter_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
.data.custom = DEMO_BMP_BTN_QT_ENTER
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_ENTER
Definition: bitmaps.h:87

Bitmap for QTouch selected button.

struct gfx_bitmap win_qtouch_btn_enter_press_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_ENTER_PRESSED
Definition: bitmaps.h:92

Bitmap for QTouch pressed selected button.

struct gfx_bitmap win_qtouch_btn_next_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
.data.custom = DEMO_BMP_BTN_QT_NEXT
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_NEXT
Definition: bitmaps.h:88

Bitmap for QTouch right button.

struct gfx_bitmap win_qtouch_btn_next_press_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_NEXT_PRESSED
Definition: bitmaps.h:93

Bitmap for QTouch pressed right button.

struct gfx_bitmap win_qtouch_btn_prev_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
.data.custom = DEMO_BMP_BTN_QT_PREV
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_PREV
Definition: bitmaps.h:86

Bitmap for QTouch left button.

struct gfx_bitmap win_qtouch_btn_prev_press_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_PREV_PRESSED
Definition: bitmaps.h:91

Bitmap for QTouch pressed left button.

struct gfx_bitmap win_qtouch_btn_up_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
.data.custom = DEMO_BMP_BTN_QT_UP
}
#define DEMO_BMP_BTN_QT_UP
Definition: bitmaps.h:85
Definition: gfx_generic.h:68

Bitmap for QTouch up button.

struct gfx_bitmap win_qtouch_btn_up_press_icon
static
Initial value:
= {
.width = 48, .height = 48,
.type = GFX_BITMAP_EXT,
}
Definition: gfx_generic.h:68
#define DEMO_BMP_BTN_QT_UP_PRESSED
Definition: bitmaps.h:90

Bitmap for QTouch pressed up button.