Sensorian  1.0
C API Reference Guide Library
CapacitiveTouch.c
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2015 Sensorian
3  * *
4  * This file is part of Sensorian. *
5  * *
6  * Sensorian is free software: you can redistribute it and/or modify it *
7  * under the terms of the GNU Lesser General Public License as published *
8  * by the Free Software Foundation, either version 3 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * Sensorian is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with Sensorian. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  ****************************************************************************/
20 
29 #include <stdio.h>
30 #include <unistd.h>
31 #include "bcm2835.h"
32 #include "SPI.h"
33 #include "TFT.h"
34 #include "GFX.h"
35 #include "i2c.h"
36 #include "CAP1203.h"
37 
38 extern const unsigned char FontASCII8X16[] ;
39 
40 int main(void)
41 {
42  SPI_Initialize(); //Initialize SPI peripheral
46 
47  unsigned char button = 0x00;
48 
50  TFT_Circle(80,35,20,RED); //Button 1
51  TFT_Circle(80,80,20,GREEN); //Button 2
52  TFT_Circle(80,125,20,BLUE); //Button 3
53 
54  while(1)
55  {
56  button = CAP1203_ReadPressedButton();
57 
58  if(button != 0)
59  {
60  switch(button)
61  {
62  case 1:
63  TFT_Disk(80,35,10,RED);
64  break;
65  case 2:
66  TFT_Disk(80,80,10,GREEN);
67  break;
68  case 3:
69  TFT_Disk(80,125,10,BLUE);
70  break;
71  default:
72  TFT_Circle(80,35,20,RED);
73  TFT_Circle(80,80,20,GREEN);
74  TFT_Circle(80,125,20,BLUE);
75  TFT_Circle(80,35,19,RED);
76  TFT_Circle(80,80,19,GREEN);
77  TFT_Circle(80,125,19,BLUE);
78  TFT_Disk(80,35,10,WHITE);
79  TFT_Disk(80,80,10,WHITE);
80  TFT_Disk(80,125,10,WHITE);
81  }
82  }
83  delay_ms(100);
84  }
85 
86  return 0;
87 }
void TFT_Background(int color)
This function paints the display background a specific color.
Definition: TFT.c:324
#define BLUE
Definition: TFT.h:113
unsigned char CAP1203_ReadPressedButton(void)
Return id indicating which button was pressed.
Definition: CAP1203.c:159
#define WHITE
Definition: TFT.h:114
void CAP1203_Initialize(void)
Basic configuration for the capacitive touch controller. Configures the sensor inactive mode and acti...
Definition: CAP1203.c:41
int main(void)
#define RED
Definition: TFT.h:111
void SPI_Initialize(void)
Initializes the SPI peripheral.
Definition: SPI.c:35
const unsigned char FontASCII8X16[]
void TFT_Disk(unsigned int CenterX, unsigned int CenterY, unsigned int Radius, unsigned int color)
This function plots a full disk on the display.
Definition: GFX.c:332
void I2C_Initialize(unsigned char address)
Initializes the I2C peripheral.
Definition: i2c.c:36
#define GREEN
Definition: TFT.h:112
void TFT_Circle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius, unsigned int color)
This function draws a circle centered a x,y with radius R and specific color.
Definition: GFX.c:297
void delay_ms(unsigned int ms)
Delay in ms.
Definition: Utilities.c:39
void TFT_Initialize(void)
This function intializes the display controller and prepares it for any subsequent operations...
Definition: TFT.c:24