Armand Coetzer / F7_TSKeyboard

Fork of F7_TSKeypad_MultiKey by Armand Coetzer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers F7_TSKeyboard.h Source File

F7_TSKeyboard.h

00001 /* F7 TS Keyboard Library v1.0
00002  * Copyright (c) 2017 Armand Coetzer
00003  * s213293048@nmmu.ac.za
00004  *
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a copy
00007  * of this software and associated documentation files (the "Software"), to deal
00008  * in the Software without restriction, including without limitation the rights
00009  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010  * copies of the Software, and to permit persons to whom the Software is
00011  * furnished to do so, subject to the following conditions:
00012  *
00013  * The above copyright notice and this permission notice shall be included in
00014  * all copies or substantial portions of the Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022  * THE SOFTWARE.
00023  */
00024  
00025 #ifndef F7_TSKeyboard_H
00026 #define F7_TSKeyboard_H
00027  
00028 #include "mbed.h"
00029 #include "LCD_DISCO_F746NG.h"
00030 #include "TS_DISCO_F746NG.h"
00031 
00032 /** Class library for a TS Keyboard, then press enter and the values are stored and the keyboard disappears.
00033  *
00034  * Example:
00035  * @code
00036  *#include "mbed.h"
00037  *#include "F7_TSKeyboard.h"
00038 
00039  *F7_TSKeyboard keyboard;
00040  *LCD_DISCO_F746NG lcd;
00041  *
00042  *uint8_t text1[30];
00043  *char s[100];
00044  *
00045  *int main() 
00046  *{    
00047  *    lcd.SetFont(&Font12);
00048  *    lcd.Clear(LCD_COLOR_BLUE);
00049  *    lcd.SetBackColor(LCD_COLOR_BLUE);
00050  *    lcd.SetTextColor(LCD_COLOR_WHITE);  
00051  * 
00052  *    while(1)
00053  *    {
00054  *        keyboard.getkeys(s);
00055  *        
00056  *        sprintf((char*)text1, "%s", s);
00057  *        lcd.DisplayStringAt(0, LINE(3), (uint8_t *)&text1, LEFT_MODE);   
00058  *         
00059  *        wait(1);  
00060  *    }
00061  *}
00062  * @endcode
00063  */
00064  
00065  class F7_TSKeyboard 
00066  {
00067    
00068   public:
00069     /** Constructor. 
00070     */
00071     F7_TSKeyboard();
00072     
00073     /** Retrieves the keys selected as a string.
00074     * @param  str[] - stores the keys selected in this array.
00075     * @retval None.
00076     */
00077     void getkeys(char str[]);
00078 
00079   private:
00080   
00081     void Detect_isr();
00082     void DrawKeyboard();
00083     
00084     Ticker ticker;
00085     sFONT *FontSize;
00086     LCD_DISCO_F746NG lcd;
00087     TS_DISCO_F746NG ts;
00088     TS_StateTypeDef TS_State;
00089         
00090     uint8_t state, btnsize;
00091     int OK; 
00092     uint32_t Bckclr, Txtclr;
00093     uint8_t correcttouch, button, key, Func, Caps;
00094     uint16_t frstprsx, frstprsy;
00095     char keypressed;
00096     int a, b, recv;
00097     int Keyboard;
00098     int KeyboardstartX[4][10];
00099     int KeyboardstartY[4][10];
00100     int KeyboardendX[4][10];
00101     int KeyboardendY[4][10];
00102     uint8_t status;
00103     int m, textx, Enter;    
00104 };
00105  
00106 #endif