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 
29 #include <stdio.h>
30 #include <unistd.h>
31 #include "bcm2835.h"
32 #include "Utilities.h"
33 #include "SPI.h"
34 #include "TFT.h"
35 #include "GFX.h"
36 
37 extern const unsigned char font[] ;
38 
39 #define BACKGROUND WHITE
40 #define FOREGROUND BLUE
41 #define DELAY 2000
42 
43 int main(void)
44 {
45 
46  SPI_Initialize(); //Initialize SPI peripheral
48 
49  char texty[] = "Sensorian-123";
50 
51  while(1)
52  {
54  TFT_SetOrientation(PORTRAIT); //Portrait mode
55  TFT_VerticalLine(5,5,90,BLUE);
56  TFT_PrintString(10,80,FOREGROUND,BACKGROUND,texty,1);
57  delay_ms(DELAY);
58 
60  TFT_SetOrientation(PORTRAIT_INV); //Portrait mode
61  TFT_VerticalLine(5,5,90,GREEN);
62  TFT_PrintString(10,80,RED,BACKGROUND,texty,1);
63  delay_ms(DELAY);
64 
66  TFT_SetOrientation(PORTRAIT_REF); //Portrait mode reflected
67  TFT_VerticalLine(5,5,90,YELLOW);
68  TFT_PrintString(10,80,GREEN,BACKGROUND,texty,1);
69  delay_ms(DELAY);
70 
73  TFT_VerticalLine(5,5,90,RED); //Portrait mode reflected
74  TFT_PrintString(10,80,PURPLE,BACKGROUND,texty,1);
75  delay_ms(DELAY);
76 
78  TFT_SetOrientation(LANDSCAPE); //Landscape mode
79  TFT_VerticalLine(5,5,80,GRAY1);
80  TFT_PrintString(10,80,GREEN,BACKGROUND,texty,1);
81  delay_ms(DELAY);
82 
84  TFT_SetOrientation(LANDSCAPE_REF); //Landscape mode reflected
85  TFT_VerticalLine(5,5,80,PURPLE);
86  TFT_PrintString(10,80,PURPLE,BACKGROUND,texty,1);
87  delay_ms(DELAY);
88 
90  TFT_SetOrientation(LANDSCAPE_INV); //Landscape mode inverted
91  TFT_VerticalLine(5,5,80,NAVY);
92  TFT_PrintString(10,80,RED,BACKGROUND,texty,1);
93  delay_ms(DELAY);
94 
97  TFT_VerticalLine(5,5,80,PURPLE);
98  TFT_PrintString(10,80,FOREGROUND,BACKGROUND,texty,1); //Landscape mode inverted reflected
99  delay_ms(DELAY);
100  }
101 
102  SPI_Close();
103 
104  return 0;
105 }
void TFT_SetOrientation(orientation_t mode)
Sets the display text orientation. Mirrored modes are also supported on top of portrait and landscape...
Definition: TFT.c:269
void TFT_Background(int color)
This function paints the display background a specific color.
Definition: TFT.c:324
#define BLUE
Definition: TFT.h:113
const unsigned char font[]
#define YELLOW
Definition: TFT.h:116
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:41
Definition: TFT.h:143
#define NAVY
Definition: TFT.h:123
#define FOREGROUND
Definition: main.c:40
#define WHITE
Definition: TFT.h:114
#define RED
Definition: TFT.h:111
void SPI_Initialize(void)
Initializes the SPI peripheral.
Definition: SPI.c:35
void TFT_PrintString(char x, char y, int color, int background, char *message, char size)
Orint a colored string at coordinates x,y with a specific font size.
Definition: TFT.c:440
#define BACKGROUND
Definition: main.c:39
Definition: TFT.h:147
TFT Driver.
void SPI_Close(void)
Close SPI bus, should not be called if another SPI device is being used.
Definition: SPI.c:95
#define GREEN
Definition: TFT.h:112
int main(int argc, char **argv)
Definition: main.c:34
void delay_ms(unsigned int ms)
Delay in ms.
Definition: Utilities.c:39
SPI library header.
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
GFX library header.
#define GRAY1
Definition: TFT.h:118