Aa

Dependents:   EMBEED_III_zad_4 mbed3 mbed_3 MBED3_zad4

Files at this revision

API Documentation at this revision

Comitter:
krzysiek99
Date:
Sat Jun 13 13:28:40 2020 +0000
Parent:
0:4f8b6df8e235
Commit message:
Keyboard;

Changed in this revision

Keyboard.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard.h Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F429ZI.cpp Show diff for this revision Revisions of this file
TS_DISCO_F429ZI.h Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard.cpp	Sat Jun 13 13:28:40 2020 +0000
@@ -0,0 +1,32 @@
+#include "Keyboard.h"
+
+Keyboard::Keyboard(unsigned char ucColumnMode)
+{
+    ts.Init(240, 320);
+    ucTouchscreenColumn = 80*ucColumnMode;
+}
+
+enum KeyboardState Keyboard::eRead()
+{
+    ts.GetState(&TS_State);
+    if(TS_State.TouchDetected)
+    {
+        if((TS_State.X > ucTouchscreenColumn) && (TS_State.X < ucTouchscreenColumn+80))
+        {   
+            if(TS_State.Y < 80)
+                return BUTTON_0;
+            else if((TS_State.Y > 80) && (TS_State.Y < 160))
+                return BUTTON_1;               
+            else if((TS_State.Y > 160) && (TS_State.Y < 240))
+                return BUTTON_2;                      
+            else if(TS_State.Y > 240)
+                return BUTTON_3;
+            else
+                return RELEASED;
+        }
+        else
+            return RELEASED;
+    }
+    else
+        return RELEASED;  
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard.h	Sat Jun 13 13:28:40 2020 +0000
@@ -0,0 +1,24 @@
+#ifndef KEYBOARD_H
+    #define KEYBOARD_H
+    #include "TS_DISCO_F429ZI.h"
+    enum KeyboardState
+    {
+        BUTTON_0 = 0,
+        BUTTON_1 = 1,
+        BUTTON_2 = 2,
+        BUTTON_3 = 3,
+        RELEASED = 4
+    }; 
+    class Keyboard
+    {
+        public:
+            Keyboard(unsigned char ucColumnMode);
+            enum KeyboardState eRead(void);
+        private:
+            TS_DISCO_F429ZI ts;
+            TS_StateTypeDef TS_State;
+            unsigned char ucTouchscreenColumn;
+    };
+#else
+    #error "This class was definied previously"
+#endif
--- a/TS_DISCO_F429ZI.cpp	Fri Dec 18 12:58:29 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/* Copyright (c) 2010-2011 mbed.org, MIT License
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-* and associated documentation files (the "Software"), to deal in the Software without
-* restriction, including without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in all copies or
-* substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "TS_DISCO_F429ZI.h"
-
-// Constructor
-TS_DISCO_F429ZI::TS_DISCO_F429ZI()
-{
-  // X = ILI9341_LCD_PIXEL_WIDTH
-  // Y = ILI9341_LCD_PIXEL_HEIGHT
-  BSP_TS_Init(240, 320);
-}
-
-// Destructor
-TS_DISCO_F429ZI::~TS_DISCO_F429ZI()
-{
-
-}
-
-//=================================================================================================================
-// Public methods
-//=================================================================================================================
-
-uint8_t TS_DISCO_F429ZI::Init(uint16_t XSize, uint16_t YSize)
-{
-  return BSP_TS_Init(XSize, YSize);
-}
-
-uint8_t TS_DISCO_F429ZI::ITConfig(void)
-{
-  return BSP_TS_ITConfig();
-}
-
-uint8_t TS_DISCO_F429ZI::ITGetStatus(void)
-{
-  return BSP_TS_ITGetStatus();
-}
-
-void TS_DISCO_F429ZI::GetState(TS_StateTypeDef* TsState)
-{
-  BSP_TS_GetState(TsState);
-}
-
-void TS_DISCO_F429ZI::ITClear(void)
-{
-  BSP_TS_ITClear();
-}
-
-//=================================================================================================================
-// Private methods
-//=================================================================================================================
--- a/TS_DISCO_F429ZI.h	Fri Dec 18 12:58:29 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* Copyright (c) 2010-2011 mbed.org, MIT License
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-* and associated documentation files (the "Software"), to deal in the Software without
-* restriction, including without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in all copies or
-* substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef __TS_DISCO_F429ZI_H
-#define __TS_DISCO_F429ZI_H
-
-#ifdef TARGET_DISCO_F429ZI
-
-#include "mbed.h"
-#include "stm32f429i_discovery_ts.h"
-
-/*
-  This class drives the touch screen module of the LCD display
-  present on DISCO_F429ZI board.
-
-  Usage:
-
-  #include "mbed.h"
-  #include "TS_DISCO_F429ZI.h"
-
-  TS_DISCO_F429ZI ts;
-
-  DigitalOut led1(LED1);
-
-  int main()
-  {
-      TS_StateTypeDef TS_State;
-    
-      ts.Init(420, 272);
-    
-      while(1)
-      {
-        ts.GetState(&TS_State);
-        if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240))
-        {
-          led1 = 1;
-        }
-        else
-        {
-          led1 = 0;
-        }
-      }
-  }
-*/
-class TS_DISCO_F429ZI
-{
-  
-public:
-  //! Constructor
-  TS_DISCO_F429ZI();
-
-  //! Destructor
-  ~TS_DISCO_F429ZI();
-
-  /**
-    * @brief  Initializes and configures the touch screen functionalities and 
-    *         configures all necessary hardware resources (GPIOs, clocks..);.
-    * @param  XSize: The maximum X size of the TS area on LCD
-    * @param  YSize: The maximum Y size of the TS area on LCD  
-    * @retval TS_OK: if all initializations are OK. Other value if error.
-    */
-  uint8_t Init(uint16_t XSize, uint16_t YSize);
-
-  /**
-    * @brief  Configures and enables the touch screen interrupts.
-    * @param  None
-    * @retval TS_OK: if ITconfig is OK. Other value if error.
-    */
-  uint8_t ITConfig(void);
-
-  /**
-    * @brief  Gets the TS IT status.
-    * @param  None
-    * @retval Interrupt status.
-    */  
-  uint8_t ITGetStatus(void);
-
-  /**
-    * @brief  Returns status and positions of the touch screen.
-    * @param  TsState: Pointer to touch screen current state structure
-    * @retval None.
-    */
-  void GetState(TS_StateTypeDef* TsState);
-
-  /**
-    * @brief  Clears all touch screen interrupts.
-    * @param  None
-    * @retval None
-    */  
-  void ITClear(void);
-  
-private:
-
-};
-
-#else
-#error "This class must be used with DISCO_F429ZI board only."
-#endif // TARGET_DISCO_F429ZI
-
-#endif