Pour Marc la mignonne

Dependencies:   BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed

Committer:
Alex_mln
Date:
Thu May 31 06:11:25 2018 +0000
Revision:
0:fcce18d01987
Tiens pd

Who changed what in which revision?

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