![](/media/cache/profiles/f0fcf351df4eb6786e9bb6fc4e2dee02.jpg.50x50_q85.jpg)
Several examples run on only mbed-os5.13.0 (not 5.14.0)
Dependencies: BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI
BUTTON_GROUP_F769NI/button.hpp
- Committer:
- kenjiArai
- Date:
- 2019-10-14
- Revision:
- 4:0f4affc00183
- Parent:
- 3:35ac9ee7d2d6
File content as of revision 4:0f4affc00183:
//----------------------------------------------------------- // Button class handling multi-touch -- Header // Multi-touch: Enabled (default) // // 2016/02/22, Copyright (c) 2016 MIKAMI, Naoki //----------------------------------------------------------- // Modified by JH1PJL/K.Arai Nov.27,2017 for DISCO-F469NI // Modified by JH1PJL/K.Arai Jul.25,2019 for DISCO-F769NI #ifndef F769_BUTTON_HPP #define F769_BUTTON_HPP #include "mbed.h" #include <string> #include "TS_DISCO_F769NI.h" #include "LCD_DISCO_F769NI.h" namespace Mikami { class Button { public: // Constructor Button(LCD_DISCO_F769NI &lcd, TS_DISCO_F769NI &ts, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color, uint32_t backColor, const string str = "", sFONT &fonts = Font12, uint32_t textColor = LCD_COLOR_WHITE) : lcd_(lcd), ts_(ts), X_(x), Y_(y), W_(width), H_(height), ORIGINAL_COLOR_(color), BACK_COLOR_(backColor), STR_(str), FONTS_(&fonts), FONT_WIDTH_(fonts.Width), FONT_HEIGHT_(fonts.Height) { Draw(color, textColor); } // Draw button void Draw(uint32_t color, uint32_t textColor = LCD_COLOR_WHITE); // Redraw button with original color void Redraw(uint32_t textColor = LCD_COLOR_WHITE) { Draw(ORIGINAL_COLOR_, textColor); } // Erase button void Erase() { Draw(BACK_COLOR_, BACK_COLOR_); } // Check touch detected bool Touched(); // Check touch detected and redraw button bool Touched(uint32_t color, uint32_t textColor = LCD_COLOR_WHITE); // Get original color uint32_t GetOriginalColor() { return ORIGINAL_COLOR_; } bool PanelTouched(); bool IsOnButton(); // Get previously got state static TS_StateTypeDef GottenState() { return state_; } // Set or reset multi-touch static void SetMultiTouch(bool tf) { multiTouch = tf; } private: LCD_DISCO_F769NI &lcd_; TS_DISCO_F769NI &ts_; const uint16_t X_, Y_, W_, H_; const uint32_t ORIGINAL_COLOR_; // original color const uint32_t BACK_COLOR_; // back color of screen const string STR_; sFONT *const FONTS_; const uint16_t FONT_WIDTH_; const uint16_t FONT_HEIGHT_; static TS_StateTypeDef state_; static bool multiTouch; // disallow copy constructor and assignment operator Button(const Button&); Button& operator=(const Button&); }; } #endif // F769_BUTTON_HPP