Sensorian  1.0
C API Reference Guide Library
main.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 
28 #include <stdio.h>
29 #include <unistd.h>
30 #include "bcm2835.h"
31 #include "Utilities.h"
32 #include "SPI.h"
33 #include "TFT.h"
34 #include "GFX.h"
35 
36 extern const unsigned char font[] ;
37 
38 #define BACKGROUND WHITE
39 #define FOREGROUND BLUE
40 #define DELAY 1200
41 
42 int main(void)
43 {
44 
45  SPI_Initialize(); //Initialize SPI peripheral
47 
48  while(1)
49  {
50  /***************Lines ****************************************/
52  TFT_HorizontalLine(4,40,80,RED); //Horizontal Line , length 40 pixels
53  delay_ms(DELAY);
54 
56  TFT_VerticalLine(20,20,60,MAROON); //Vertical Line , length 60 pixels
57  delay_ms(DELAY);
58 
60  TFT_Line(5,5,100,30,GRAY1); //Line from (5,5) to (100,30)
61  delay_ms(DELAY);
62 
64  TFT_SlantyLine(8,8,50,40,GRAY0); //Slanty line of length 40 pixels
65  delay_ms(DELAY);
66 
67  /************************************** Rectangles ************************************/
68 
70  TFT_EmptyRectangle(10,30,50,60,GRAY0); //Hollow rectangle
71  delay_ms(DELAY);
72 
74  TFT_FullRectangle(10,30,50,60,MAROON); //Filled rectangle
75  delay_ms(DELAY);
76 
78  TFT_RoundRectangle(10,10,50,60,10,GRAY1); //rectangle with rounded corners
79  delay_ms(DELAY);
80 
82  TFT_FullRectangle(80,40,100,120,NAVY); //Filled rectangle
83  delay_ms(DELAY);
84 
85  /******************************** Circles **************************************************/
86 
88  TFT_Circle(70,60,30,RED); //Red circle
89  delay_ms(DELAY);
90 
92  TFT_Disk(50,50,20,PURPLE); //Purple disk
93  delay_ms(DELAY);
94 
96  TFT_Ellipse(80,40,30,40,BLUE); //Blue ellipse
97  delay_ms(DELAY);
98 
99  /********************************** Triangles **************************************************/
100 
102  TFT_RightTriangle(50,20,40,80,BLACK); //Right angle triangle
103  delay_ms(DELAY);
104 
105  }
106 
107  SPI_Close();
108 
109  return 0;
110 }
void TFT_Background(int color)
This function paints the display background a specific color.
Definition: TFT.c:324
#define BLUE
Definition: TFT.h:113
void TFT_RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color)
This function draws a rectangle with round corners.
Definition: GFX.c:256
const unsigned char font[]
SPI library header.
void TFT_VerticalLine(unsigned int Xaxis, unsigned int Yaxis, unsigned int height, unsigned int color)
Draw a vertical line on the display.
Definition: GFX.c:53
#define DELAY
Definition: main.c:40
void TFT_SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2, unsigned int lY2, unsigned int color)
Plot a slanty line from x1,y1 to x2,y2 on the display.
Definition: GFX.c:126
#define NAVY
Definition: TFT.h:123
void TFT_FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2, unsigned int Yaxis2, unsigned int color)
This function paints a filled rectangle on the screen.
Definition: GFX.c:205
#define WHITE
Definition: TFT.h:114
#define BLACK
Definition: TFT.h:120
void TFT_EmptyRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2, unsigned int Yaxis2, unsigned int color)
This function paints an empty rectangle on the screen. The width of the contour is 1 pixel...
Definition: GFX.c:227
#define GRAY0
Definition: TFT.h:117
TFT library header.
void TFT_RightTriangle(int topx, int topy, int rightx, int righty, unsigned int color)
This function paints a right angled triangle.
Definition: GFX.c:482
#define RED
Definition: TFT.h:111
void SPI_Initialize(void)
Initializes the SPI peripheral.
Definition: SPI.c:35
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
#define MAROON
Definition: TFT.h:121
void SPI_Close(void)
Close SPI bus, should not be called if another SPI device is being used.
Definition: SPI.c:95
void TFT_Ellipse(long CX, long CY, long XRadius, long YRadius, unsigned int color)
This function paints a.
Definition: GFX.c:399
int main(int argc, char **argv)
Definition: main.c:34
void TFT_HorizontalLine(unsigned int Xaxis, unsigned int Yaxis, unsigned int width, unsigned int color)
Draw a horizontal line on the display.
Definition: GFX.c:40
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
GFX library header.
void TFT_Line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color)
This function paints a.
Definition: GFX.c:67
Utilities library header.
void TFT_Initialize(void)
This function intializes the display controller and prepares it for any subsequent operations...
Definition: TFT.c:24
#define PURPLE
Definition: TFT.h:124
#define GRAY1
Definition: TFT.h:118