marc le dep

Dependencies:   BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed

Committer:
Alex_mln
Date:
Thu Mar 29 07:14:46 2018 +0000
Revision:
1:59fe933886bd
Parent:
0:4910cdb3d377
sghkjlm

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Alex_mln 0:4910cdb3d377 1 #include "screen.h"
Alex_mln 0:4910cdb3d377 2 /**
Alex_mln 0:4910cdb3d377 3 * @brief global object for touchscreen events
Alex_mln 0:4910cdb3d377 4 */
Alex_mln 0:4910cdb3d377 5 TS_StateTypeDef TS_State;
Alex_mln 0:4910cdb3d377 6
Alex_mln 0:4910cdb3d377 7 /**
Alex_mln 0:4910cdb3d377 8 * @fn void screen_init()
Alex_mln 0:4910cdb3d377 9 * @brief the screen_init function checks if the LCD Touch screen is ready to use
Alex_mln 0:4910cdb3d377 10 * @return nothing
Alex_mln 0:4910cdb3d377 11 */
Alex_mln 0:4910cdb3d377 12 void screen_init()
Alex_mln 0:4910cdb3d377 13 {
Alex_mln 0:4910cdb3d377 14 BSP_LCD_SetFont(&Font20);
Alex_mln 0:4910cdb3d377 15 BSP_LCD_Init(); // Initializes the LCD
Alex_mln 0:4910cdb3d377 16 BSP_LCD_LayerDefaultInit(0, (uint32_t) LCD_FRAME_BUFFER); // Initializes the LCD layers.*/
Alex_mln 0:4910cdb3d377 17 BSP_LCD_SelectLayer(0); // Selects the LCD Layer
Alex_mln 0:4910cdb3d377 18 BSP_LCD_SetLayerVisible(1, ENABLE); // Sets a LCD Layer visible
Alex_mln 0:4910cdb3d377 19 BSP_LCD_Clear(LCD_COLOR_BLACK);
Alex_mln 0:4910cdb3d377 20 BSP_LCD_DisplayOn();
Alex_mln 0:4910cdb3d377 21 uint8_t status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
Alex_mln 0:4910cdb3d377 22 if (status != TS_OK)
Alex_mln 0:4910cdb3d377 23 {
Alex_mln 0:4910cdb3d377 24 BSP_LCD_Clear(LCD_COLOR_RED);
Alex_mln 0:4910cdb3d377 25 BSP_LCD_SetBackColor(LCD_COLOR_RED);
Alex_mln 0:4910cdb3d377 26 BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
Alex_mln 0:4910cdb3d377 27 BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
Alex_mln 0:4910cdb3d377 28 BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"INIT FAIL", CENTER_MODE);
Alex_mln 0:4910cdb3d377 29 }
Alex_mln 0:4910cdb3d377 30 else
Alex_mln 0:4910cdb3d377 31 {
Alex_mln 0:4910cdb3d377 32 BSP_LCD_Clear(LCD_COLOR_GREEN);
Alex_mln 0:4910cdb3d377 33 BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
Alex_mln 0:4910cdb3d377 34 BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
Alex_mln 0:4910cdb3d377 35 BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
Alex_mln 0:4910cdb3d377 36 BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"INIT OK", CENTER_MODE);
Alex_mln 0:4910cdb3d377 37 }
Alex_mln 0:4910cdb3d377 38 }
Alex_mln 0:4910cdb3d377 39
Alex_mln 0:4910cdb3d377 40 /**
Alex_mln 0:4910cdb3d377 41 * @fn int isScreenTouched(void)
Alex_mln 0:4910cdb3d377 42 * @brief questions whether the screen is touched or not
Alex_mln 0:4910cdb3d377 43 * @return 1 if touched, 0 otherwise
Alex_mln 0:4910cdb3d377 44 **/
Alex_mln 0:4910cdb3d377 45 int isScreenTouched(){
Alex_mln 0:4910cdb3d377 46 BSP_TS_GetState(&TS_State);
Alex_mln 0:4910cdb3d377 47 if (TS_State.TouchDetected) {
Alex_mln 0:4910cdb3d377 48 return 1;
Alex_mln 0:4910cdb3d377 49 }
Alex_mln 0:4910cdb3d377 50 return 0;
Alex_mln 0:4910cdb3d377 51 }
Alex_mln 0:4910cdb3d377 52
Alex_mln 0:4910cdb3d377 53 /**
Alex_mln 0:4910cdb3d377 54 * @fn void clearScreen()
Alex_mln 0:4910cdb3d377 55 * @brief the clearScreen function clears the screen and set a green background
Alex_mln 0:4910cdb3d377 56 * @return nothing
Alex_mln 0:4910cdb3d377 57 */
Alex_mln 0:4910cdb3d377 58 void clearScreen(){
Alex_mln 0:4910cdb3d377 59 BSP_LCD_Clear(LCD_COLOR_GREEN);
Alex_mln 0:4910cdb3d377 60 }
Alex_mln 0:4910cdb3d377 61
Alex_mln 0:4910cdb3d377 62 /**
Alex_mln 0:4910cdb3d377 63 * @fn void showIntegerScreen(int x, int nbline, int offset, Text_AlignModeTypdef mode)
Alex_mln 0:4910cdb3d377 64 * @brief the clearScreen function clears the screen and set a green background
Alex_mln 0:4910cdb3d377 65 * @param x: the integer to print on the LCD screen
Alex_mln 0:4910cdb3d377 66 * @param nbline: the line in which the number is to be printed
Alex_mln 0:4910cdb3d377 67 * @param offset: the offset with which the number is to be printed
Alex_mln 0:4910cdb3d377 68 * @param mode: the align mode
Alex_mln 0:4910cdb3d377 69 * @return nothing
Alex_mln 0:4910cdb3d377 70 */
Alex_mln 0:4910cdb3d377 71 void showIntegerScreen(int x, int nbline, int offset, Text_AlignModeTypdef mode){
Alex_mln 0:4910cdb3d377 72 TEXT t;
Alex_mln 0:4910cdb3d377 73 sprintf((char *)t, "x=%d", x);
Alex_mln 0:4910cdb3d377 74 BSP_LCD_DisplayStringAt(offset,LINE(nbline),(uint8_t*)" ",mode); //clears the line.
Alex_mln 0:4910cdb3d377 75 BSP_LCD_DisplayStringAt(offset,LINE(nbline),(uint8_t*)&t,mode);
Alex_mln 0:4910cdb3d377 76 }
Alex_mln 0:4910cdb3d377 77