Shows how to use a display and the touch controller. A very basic calculator. Note that for some displays the LANDSCAPE define must be set for the layout to be correct.
Dependencies: DmTftLibrary mbed
Diff: main.cpp
- Revision:
- 2:b17b19212e5a
- Parent:
- 1:9a3ae682a75e
--- a/main.cpp Fri Jul 04 10:33:40 2014 +0000 +++ b/main.cpp Wed Jul 09 08:34:25 2014 +0000 @@ -68,8 +68,6 @@ * Local variables *****************************************************************************/ -//DmTftHX8353C tft; /* DM_TFT18_101 */ -//DmTftS6D0164 tft; /* DM_TFT22_102 */ //DmTftIli9325 tft; /* DM_TFT28_103 and DM_TFT24_104 */ DmTftIli9341 tft; /* DM_TFT28_105 */ //DmTftSsd2119 tft; /* DM_TFT35_107 */ @@ -124,12 +122,6 @@ static bool redrawResult = true; static bool clearResult = true; -#ifdef DEBUG - static char debug[25] = {0}; - static char debug2[25] = {0}; - static int debug_pos = 0; -#endif - /****************************************************************************** * Global variables *****************************************************************************/ @@ -147,13 +139,6 @@ static calc_mode_t mode = MODE_WANT_ARG1; static int strpos = 0; -#ifdef DEBUG - debug2[debug_pos] = '0'+mode; - debug[debug_pos] = arg; - debug_pos++; - debug[debug_pos] = '\0'; - debug_pos = debug_pos%25; -#endif switch (arg) { case '0': @@ -258,6 +243,18 @@ while(true) { touch.readTouchData(x, y, down); + /* The following printouts are for some unexplainable reason needed + on the LPC4088 QuickStart Board in combination with the MBED online compiler. + The printouts are not needed when using an external compiler, e.g. Keil uVision + or LPCXpresso IDE. */ +#if defined(__LPC407x_8x_177x_8x_H__) + if (down) { + printf("DOWN %4d, %4d\n", x, y); + } else { + printf("UP %4d, %4d\n", x, y); + } +#endif + for (int i = 0; i < NUM_BUTTONS; i++) { if (buttons[i]->handle(x, y, down)) { buttons[i]->draw(&tft); @@ -270,13 +267,6 @@ if (redrawResult) { redrawResult = false; tft.drawStringCentered(RESULT_MARGIN_X, RESULT_MARGIN_Y, w-RESULT_MARGIN_X, yoff-RESULT_MARGIN_Y, &buff[0]); -#ifdef DEBUG - tft.drawString(5, 5, &debug[0]); - tft.drawString(5, 25, &debug2[0]); - tft.drawNumber(5, 45, val1, 6); - tft.drawNumber(5, 65, val2, 6); - tft.drawString(5, 25, &debug2[0]); -#endif } wait(0.02); }