
test export
Dependencies: DmTftLibrary mbed
Fork of dm_touch by
main.cpp@1:63e25ac12708, 2014-07-04 (annotated)
- Committer:
- displaymodule
- Date:
- Fri Jul 04 10:38:42 2014 +0000
- Revision:
- 1:63e25ac12708
- Parent:
- 0:144e2312d558
- Child:
- 2:c8e477ca4276
Misc bugfixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
displaymodule | 0:144e2312d558 | 1 | /********************************************************************************************** |
displaymodule | 0:144e2312d558 | 2 | Copyright (c) 2014 DisplayModule. All rights reserved. |
displaymodule | 0:144e2312d558 | 3 | |
displaymodule | 0:144e2312d558 | 4 | Redistribution and use of this source code, part of this source code or any compiled binary |
displaymodule | 0:144e2312d558 | 5 | based on this source code is permitted as long as the above copyright notice and following |
displaymodule | 0:144e2312d558 | 6 | disclaimer is retained. |
displaymodule | 0:144e2312d558 | 7 | |
displaymodule | 0:144e2312d558 | 8 | DISCLAIMER: |
displaymodule | 0:144e2312d558 | 9 | THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES |
displaymodule | 0:144e2312d558 | 10 | NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. |
displaymodule | 0:144e2312d558 | 11 | ********************************************************************************************/ |
displaymodule | 0:144e2312d558 | 12 | |
displaymodule | 0:144e2312d558 | 13 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 14 | * Includes |
displaymodule | 0:144e2312d558 | 15 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 16 | |
displaymodule | 0:144e2312d558 | 17 | #include "mbed.h" |
displaymodule | 0:144e2312d558 | 18 | |
displaymodule | 0:144e2312d558 | 19 | #include "DmTftHX8353C.h" |
displaymodule | 0:144e2312d558 | 20 | #include "DmTftS6D0164.h" |
displaymodule | 0:144e2312d558 | 21 | #include "DmTftIli9325.h" |
displaymodule | 0:144e2312d558 | 22 | #include "DmTftIli9341.h" |
displaymodule | 0:144e2312d558 | 23 | #include "DmTftSsd2119.h" |
displaymodule | 0:144e2312d558 | 24 | #include "DmTouch.h" |
displaymodule | 0:144e2312d558 | 25 | |
displaymodule | 0:144e2312d558 | 26 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 27 | * Typedefs and defines |
displaymodule | 0:144e2312d558 | 28 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 29 | |
displaymodule | 1:63e25ac12708 | 30 | /* Note that there are restrictions on which platforms that can use printf |
displaymodule | 1:63e25ac12708 | 31 | in combinations with the DmTftLibrary. Some platforms (e.g. LPC1549 LPCXpresso) |
displaymodule | 1:63e25ac12708 | 32 | use the same pins for USBRX/USBTX and display control. Printing will |
displaymodule | 1:63e25ac12708 | 33 | cause the display to not work. Read more about this on the display's notebook |
displaymodule | 1:63e25ac12708 | 34 | page. */ |
displaymodule | 0:144e2312d558 | 35 | //#define log(...) printf(__VA_ARGS__) |
displaymodule | 0:144e2312d558 | 36 | #define log(...) |
displaymodule | 0:144e2312d558 | 37 | |
displaymodule | 1:63e25ac12708 | 38 | #if 1 |
displaymodule | 1:63e25ac12708 | 39 | /* Displays without adapter */ |
displaymodule | 1:63e25ac12708 | 40 | #define DM_PIN_SPI_MOSI D11 |
displaymodule | 1:63e25ac12708 | 41 | #define DM_PIN_SPI_MISO D12 |
displaymodule | 1:63e25ac12708 | 42 | #define DM_PIN_SPI_SCLK D13 |
displaymodule | 1:63e25ac12708 | 43 | #define DM_PIN_CS_TOUCH D4 |
displaymodule | 1:63e25ac12708 | 44 | #define DM_PIN_CS_TFT D10 |
displaymodule | 1:63e25ac12708 | 45 | #define DM_PIN_CS_SDCARD D8 |
displaymodule | 1:63e25ac12708 | 46 | #define DM_PIN_CS_FLASH D6 |
displaymodule | 1:63e25ac12708 | 47 | #else |
displaymodule | 1:63e25ac12708 | 48 | /* Displays with adapter */ |
displaymodule | 1:63e25ac12708 | 49 | #define DM_PIN_SPI_MOSI A0 |
displaymodule | 1:63e25ac12708 | 50 | #define DM_PIN_SPI_MISO D9 |
displaymodule | 1:63e25ac12708 | 51 | #define DM_PIN_SPI_SCLK A1 |
displaymodule | 1:63e25ac12708 | 52 | #define DM_PIN_CS_TOUCH D8 |
displaymodule | 1:63e25ac12708 | 53 | #define DM_PIN_CS_TFT A3 |
displaymodule | 1:63e25ac12708 | 54 | #define DM_PIN_CS_SDCARD D10 |
displaymodule | 0:144e2312d558 | 55 | #endif |
displaymodule | 0:144e2312d558 | 56 | |
displaymodule | 0:144e2312d558 | 57 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 58 | * Local variables |
displaymodule | 0:144e2312d558 | 59 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 60 | |
displaymodule | 0:144e2312d558 | 61 | //DmTftHX8353C tft; /* DM_TFT18_101 */ |
displaymodule | 0:144e2312d558 | 62 | //DmTftS6D0164 tft; /* DM_TFT22_102 */ |
displaymodule | 1:63e25ac12708 | 63 | //DmTftIli9325 tft; /* DM_TFT28_103 and DM_TFT24_104 */ |
displaymodule | 0:144e2312d558 | 64 | //DmTftIli9341 tft; /* DM_TFT28_105 */ |
displaymodule | 1:63e25ac12708 | 65 | DmTftSsd2119 tft; /* DM_TFT35_107 */ |
displaymodule | 0:144e2312d558 | 66 | |
displaymodule | 1:63e25ac12708 | 67 | //DmTouch touch(DmTouch::DM_TFT28_103, DmTouch::Software); /* For LPC4088 QuickStart Board */ |
displaymodule | 0:144e2312d558 | 68 | //DmTouch touch(DmTouch::DM_TFT28_103); |
displaymodule | 1:63e25ac12708 | 69 | //DmTouch touch(DmTouch::DM_TFT24_104, DmTouch::Software); /* For LPC4088 QuickStart Board */ |
displaymodule | 1:63e25ac12708 | 70 | //DmTouch touch(DmTouch::DM_TFT24_104); |
displaymodule | 0:144e2312d558 | 71 | //DmTouch touch(DmTouch::DM_TFT28_105); |
displaymodule | 1:63e25ac12708 | 72 | DmTouch touch(DmTouch::DM_TFT35_107); |
displaymodule | 0:144e2312d558 | 73 | |
displaymodule | 0:144e2312d558 | 74 | DigitalInOut csTouch(DM_PIN_CS_TOUCH, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 75 | DigitalInOut csDisplay(DM_PIN_CS_TFT, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 76 | DigitalInOut csSDCard(DM_PIN_CS_SDCARD, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 77 | #ifdef DM_PIN_CS_FLASH |
displaymodule | 0:144e2312d558 | 78 | DigitalInOut csFlash(DM_PIN_CS_FLASH, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 79 | #endif |
displaymodule | 0:144e2312d558 | 80 | |
displaymodule | 0:144e2312d558 | 81 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 82 | * Global variables |
displaymodule | 0:144e2312d558 | 83 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 84 | |
displaymodule | 0:144e2312d558 | 85 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 86 | * Local functions |
displaymodule | 0:144e2312d558 | 87 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 88 | |
displaymodule | 0:144e2312d558 | 89 | |
displaymodule | 0:144e2312d558 | 90 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 91 | * Main |
displaymodule | 0:144e2312d558 | 92 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 93 | |
displaymodule | 0:144e2312d558 | 94 | int main() { |
displaymodule | 0:144e2312d558 | 95 | log("init tft \r\n"); |
displaymodule | 0:144e2312d558 | 96 | tft.init(); |
displaymodule | 0:144e2312d558 | 97 | |
displaymodule | 0:144e2312d558 | 98 | uint16_t x = 0; |
displaymodule | 0:144e2312d558 | 99 | uint16_t y = 0; |
displaymodule | 0:144e2312d558 | 100 | uint16_t w = tft.width(); |
displaymodule | 0:144e2312d558 | 101 | uint16_t h = tft.height(); |
displaymodule | 0:144e2312d558 | 102 | |
displaymodule | 0:144e2312d558 | 103 | bool down = false; |
displaymodule | 0:144e2312d558 | 104 | bool lastDown = false; |
displaymodule | 0:144e2312d558 | 105 | |
displaymodule | 0:144e2312d558 | 106 | tft.drawString(20, 20, "x:"); |
displaymodule | 0:144e2312d558 | 107 | tft.drawString(100, 20, "y:"); |
displaymodule | 0:144e2312d558 | 108 | |
displaymodule | 0:144e2312d558 | 109 | touch.init(); |
displaymodule | 0:144e2312d558 | 110 | while (1) { |
displaymodule | 0:144e2312d558 | 111 | touch.readTouchData(x, y, down); |
displaymodule | 0:144e2312d558 | 112 | if (down) { |
displaymodule | 0:144e2312d558 | 113 | tft.drawNumber(40, 20, x, 5, false); |
displaymodule | 0:144e2312d558 | 114 | tft.drawNumber(120, 20, y, 5, false); |
displaymodule | 0:144e2312d558 | 115 | } else if (lastDown) { |
displaymodule | 0:144e2312d558 | 116 | // no longer pressed, clean text |
displaymodule | 0:144e2312d558 | 117 | tft.drawString(40, 20, " "); |
displaymodule | 0:144e2312d558 | 118 | tft.drawString(120, 20, " "); |
displaymodule | 0:144e2312d558 | 119 | } |
displaymodule | 0:144e2312d558 | 120 | wait(0.040); |
displaymodule | 0:144e2312d558 | 121 | lastDown = down; |
displaymodule | 0:144e2312d558 | 122 | } |
displaymodule | 0:144e2312d558 | 123 | } |