A simple demonstration of the DISCO-F746NG LCD, TouchScreen and MCP3221 I2C ADC.

Dependencies:   BSP_DISCO_F746NG LCD_DISCO_F746NG MCP3221 TS_DISCO_F746NG mbed

Fork of DISCO-F746NG_LCD_demo by ST

Committer:
pampt
Date:
Wed Feb 01 23:07:47 2017 +0000
Revision:
4:16afa8576091
Parent:
0:b045ca817e2c
Child:
5:59021306be0f
First PA commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:b045ca817e2c 1 #include "mbed.h"
bcostm 0:b045ca817e2c 2 #include "LCD_DISCO_F746NG.h"
pampt 4:16afa8576091 3 #include "TS_DISCO_F746NG.h"
pampt 4:16afa8576091 4 #include "MCP3221.h"
pampt 4:16afa8576091 5 #include "Peter.h"
bcostm 0:b045ca817e2c 6
bcostm 0:b045ca817e2c 7 LCD_DISCO_F746NG lcd;
pampt 4:16afa8576091 8 TS_DISCO_F746NG ts;
pampt 4:16afa8576091 9 MCP3221 adc(PB_9, PB_8, 4.096); // sda, scl, supply voltage
bcostm 0:b045ca817e2c 10 DigitalOut led1(LED1);
bcostm 0:b045ca817e2c 11
bcostm 0:b045ca817e2c 12 int main()
pampt 4:16afa8576091 13 {
pampt 4:16afa8576091 14 TS_StateTypeDef TS_State;
pampt 4:16afa8576091 15 uint8_t text[30];
pampt 4:16afa8576091 16
bcostm 0:b045ca817e2c 17 led1 = 1;
bcostm 0:b045ca817e2c 18
pampt 4:16afa8576091 19 // Display bitmap image
pampt 4:16afa8576091 20 lcd.Clear(LCD_COLOR_WHITE);
pampt 4:16afa8576091 21 lcd.SetBackColor(LCD_COLOR_WHITE);
pampt 4:16afa8576091 22 lcd.DrawBitmap(0, 0, (uint8_t *)peter_file);
pampt 4:16afa8576091 23
pampt 4:16afa8576091 24 // Set display text colours
pampt 4:16afa8576091 25 lcd.SetBackColor(LCD_COLOR_ORANGE);
pampt 4:16afa8576091 26 lcd.SetTextColor(LCD_COLOR_CYAN);
bcostm 0:b045ca817e2c 27
pampt 4:16afa8576091 28 while(1) {
pampt 4:16afa8576091 29 // Display touch message
pampt 4:16afa8576091 30 ts.GetState(&TS_State);
pampt 4:16afa8576091 31 if (TS_State.touchDetected) {
pampt 4:16afa8576091 32 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCH DETECTED! ", CENTER_MODE);
pampt 4:16afa8576091 33 } else {
pampt 4:16afa8576091 34 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"NO TOUCH DETECTED", CENTER_MODE);
pampt 4:16afa8576091 35 }
bcostm 0:b045ca817e2c 36
pampt 4:16afa8576091 37 // Display ADC reading
pampt 4:16afa8576091 38 sprintf((char*)text, "ADC=%f ", adc.read());
pampt 4:16afa8576091 39 lcd.DisplayStringAt(0, LINE(8), (uint8_t *)&text, CENTER_MODE);
bcostm 0:b045ca817e2c 40
pampt 4:16afa8576091 41 led1 = !led1;
bcostm 0:b045ca817e2c 42 }
bcostm 0:b045ca817e2c 43 }