Simple integer calculator using FRDM-KL25Z and Adafruit 2.8" TFT with touch \\ "Dentaku" means "Desktop Calculator" in Japanese \\ On 5-Dec-2015, Support for FRDM-K64F, FRDM-K22F, NUCLEO-F411RE added.

Dependencies:   SPI_STMPE610 UniGraphic mbed vt100

Yet another simple desktop calculator program, only for integer.
As usual I used FRDM-KL25Z, Adafruit 2.8" TFT with touch and UniGraphic library.
Now works with FRDM-K64F, FRDM-K22F, and NUCLEO-F411RE.

整数計算のみの簡単な電卓プログラムです。
例によって、FRDM-KL25Z, Adafruit 2.8" TFT with touch, そして UniGraphic を使用しています。
FRDM-K64F, FRDM-K22F, NUCLEO-F411RE でも動くようになりました。

/media/uploads/Rhyme/img_1194.jpg

Committer:
Rhyme
Date:
Tue Apr 11 06:06:25 2017 +0000
Revision:
4:d4c937bcc469
Parent:
0:659a74b77279
Support of MAX32600 added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:659a74b77279 1 /** mbed oscilloscope my implementation of a oscillo scope
Rhyme 0:659a74b77279 2 * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab
Rhyme 0:659a74b77279 3 *
Rhyme 0:659a74b77279 4 * TFTMenu.h
Rhyme 0:659a74b77279 5 *
Rhyme 0:659a74b77279 6 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Rhyme 0:659a74b77279 7 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Rhyme 0:659a74b77279 8 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Rhyme 0:659a74b77279 9 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Rhyme 0:659a74b77279 10 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Rhyme 0:659a74b77279 11 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Rhyme 0:659a74b77279 12 * THE SOFTWARE.
Rhyme 0:659a74b77279 13 */
Rhyme 0:659a74b77279 14 #ifndef _TFT_MENU_H_
Rhyme 0:659a74b77279 15 #define _TFT_MENU_H_ defined
Rhyme 0:659a74b77279 16
Rhyme 0:659a74b77279 17 typedef void (*FuncPtr)(void) ;
Rhyme 0:659a74b77279 18
Rhyme 0:659a74b77279 19 class TFTMenuItem {
Rhyme 0:659a74b77279 20 public:
Rhyme 0:659a74b77279 21 TFTMenuItem(int x1, int y1, int x2, int y2, FuncPtr fnc,
Rhyme 0:659a74b77279 22 char *name, uint16_t mc, uint16_t fc,
Rhyme 0:659a74b77279 23 int l_margin = 7, int t_margin = 10) ;
Rhyme 0:659a74b77279 24 ~TFTMenuItem() ;
Rhyme 0:659a74b77279 25 virtual bool hit(int x, int y) ;
Rhyme 0:659a74b77279 26 virtual void draw(int offset_x = 0, int offset_y = 0) ;
Rhyme 0:659a74b77279 27 virtual void font_margin(int x, int y) ;
Rhyme 0:659a74b77279 28 void highlight(int offset_x = 0, int offset_y = 0) ;
Rhyme 0:659a74b77279 29 uint16_t getColor(void) ;
Rhyme 0:659a74b77279 30 void doIt(void) ;
Rhyme 0:659a74b77279 31 const char *name(void) { return label ; }
Rhyme 0:659a74b77279 32
Rhyme 0:659a74b77279 33 protected:
Rhyme 0:659a74b77279 34 char *label ;
Rhyme 0:659a74b77279 35 uint16_t font_color ;
Rhyme 0:659a74b77279 36 uint16_t menu_color ;
Rhyme 0:659a74b77279 37 int top ;
Rhyme 0:659a74b77279 38 int bottom ;
Rhyme 0:659a74b77279 39 int left ;
Rhyme 0:659a74b77279 40 int right ;
Rhyme 0:659a74b77279 41 int left_margin ;
Rhyme 0:659a74b77279 42 int top_margin ;
Rhyme 0:659a74b77279 43 FuncPtr func ;
Rhyme 0:659a74b77279 44 private:
Rhyme 0:659a74b77279 45 } ;
Rhyme 0:659a74b77279 46
Rhyme 0:659a74b77279 47 class TFTRadioButton : public TFTMenuItem {
Rhyme 0:659a74b77279 48 public:
Rhyme 0:659a74b77279 49 TFTRadioButton(int x1, int y1, int x2, int y2, FuncPtr fnc,
Rhyme 0:659a74b77279 50 char *name, uint16_t mc, uint16_t fc,
Rhyme 0:659a74b77279 51 char *altname = 0, uint16_t altmc = 0, uint16_t altfc = 0,
Rhyme 0:659a74b77279 52 bool sel = false) ;
Rhyme 0:659a74b77279 53 ~TFTRadioButton() ;
Rhyme 0:659a74b77279 54
Rhyme 0:659a74b77279 55 virtual bool hit(int x, int y) ;
Rhyme 0:659a74b77279 56 virtual void draw(int offset_x = 0, int offset_y = 0) ;
Rhyme 0:659a74b77279 57
Rhyme 0:659a74b77279 58 void select(bool value) ;
Rhyme 0:659a74b77279 59
Rhyme 0:659a74b77279 60 protected:
Rhyme 0:659a74b77279 61 bool selected ;
Rhyme 0:659a74b77279 62 char *alt_label ;
Rhyme 0:659a74b77279 63 uint16_t alt_font_color ;
Rhyme 0:659a74b77279 64 uint16_t alt_menu_color ;
Rhyme 0:659a74b77279 65 // FuncPtr alt_func ;
Rhyme 0:659a74b77279 66 private:
Rhyme 0:659a74b77279 67 } ;
Rhyme 0:659a74b77279 68
Rhyme 0:659a74b77279 69 class TFTMenu {
Rhyme 0:659a74b77279 70 public:
Rhyme 0:659a74b77279 71 TFTMenu() ; // constructor
Rhyme 0:659a74b77279 72 ~TFTMenu() ; // destructor
Rhyme 0:659a74b77279 73 private:
Rhyme 0:659a74b77279 74 } ;
Rhyme 0:659a74b77279 75
Rhyme 0:659a74b77279 76 #endif /* _TFT_MENU_H_ */