
test export
Dependencies: DmTftLibrary mbed
Fork of dm_touch by
main.cpp@6:d28b8be6e90a, 2015-09-18 (annotated)
- Committer:
- displaymodule
- Date:
- Fri Sep 18 14:59:45 2015 +0000
- Revision:
- 6:d28b8be6e90a
- Parent:
- 5:cf0097e3a18c
- Child:
- 7:5cc7d70faa97
add DM-TFT28-116: DmTpFt6x06.cpp / h
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 | 5:cf0097e3a18c | 24 | #include "DmTftRa8875.h" |
displaymodule | 0:144e2312d558 | 25 | #include "DmTouch.h" |
displaymodule | 6:d28b8be6e90a | 26 | #include "DmTpFt6x06.h" |
displaymodule | 0:144e2312d558 | 27 | |
displaymodule | 0:144e2312d558 | 28 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 29 | * Typedefs and defines |
displaymodule | 0:144e2312d558 | 30 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 31 | |
displaymodule | 1:63e25ac12708 | 32 | /* Note that there are restrictions on which platforms that can use printf |
displaymodule | 1:63e25ac12708 | 33 | in combinations with the DmTftLibrary. Some platforms (e.g. LPC1549 LPCXpresso) |
displaymodule | 1:63e25ac12708 | 34 | use the same pins for USBRX/USBTX and display control. Printing will |
displaymodule | 1:63e25ac12708 | 35 | cause the display to not work. Read more about this on the display's notebook |
displaymodule | 1:63e25ac12708 | 36 | page. */ |
displaymodule | 0:144e2312d558 | 37 | //#define log(...) printf(__VA_ARGS__) |
displaymodule | 0:144e2312d558 | 38 | #define log(...) |
displaymodule | 0:144e2312d558 | 39 | |
displaymodule | 1:63e25ac12708 | 40 | #if 1 |
displaymodule | 1:63e25ac12708 | 41 | /* Displays without adapter */ |
displaymodule | 1:63e25ac12708 | 42 | #define DM_PIN_SPI_MOSI D11 |
displaymodule | 1:63e25ac12708 | 43 | #define DM_PIN_SPI_MISO D12 |
displaymodule | 1:63e25ac12708 | 44 | #define DM_PIN_SPI_SCLK D13 |
displaymodule | 1:63e25ac12708 | 45 | #define DM_PIN_CS_TOUCH D4 |
displaymodule | 1:63e25ac12708 | 46 | #define DM_PIN_CS_TFT D10 |
displaymodule | 1:63e25ac12708 | 47 | #define DM_PIN_CS_SDCARD D8 |
displaymodule | 1:63e25ac12708 | 48 | #define DM_PIN_CS_FLASH D6 |
displaymodule | 1:63e25ac12708 | 49 | #else |
displaymodule | 1:63e25ac12708 | 50 | /* Displays with adapter */ |
displaymodule | 1:63e25ac12708 | 51 | #define DM_PIN_SPI_MOSI A0 |
displaymodule | 1:63e25ac12708 | 52 | #define DM_PIN_SPI_MISO D9 |
displaymodule | 1:63e25ac12708 | 53 | #define DM_PIN_SPI_SCLK A1 |
displaymodule | 1:63e25ac12708 | 54 | #define DM_PIN_CS_TOUCH D8 |
displaymodule | 1:63e25ac12708 | 55 | #define DM_PIN_CS_TFT A3 |
displaymodule | 1:63e25ac12708 | 56 | #define DM_PIN_CS_SDCARD D10 |
displaymodule | 0:144e2312d558 | 57 | #endif |
displaymodule | 0:144e2312d558 | 58 | |
displaymodule | 0:144e2312d558 | 59 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 60 | * Local variables |
displaymodule | 0:144e2312d558 | 61 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 62 | |
displaymodule | 1:63e25ac12708 | 63 | //DmTftIli9325 tft; /* DM_TFT28_103 and DM_TFT24_104 */ |
displaymodule | 6:d28b8be6e90a | 64 | DmTftIli9341 tft; /* DM_TFT28_105 */ |
displaymodule | 5:cf0097e3a18c | 65 | //DmTftSsd2119 tft; /* DM_TFT35_107 */ |
displaymodule | 6:d28b8be6e90a | 66 | //DmTftRa8875 tft; /* DM_TFT43_108 and DM_TFT50_111 */ |
displaymodule | 0:144e2312d558 | 67 | |
displaymodule | 1:63e25ac12708 | 68 | //DmTouch touch(DmTouch::DM_TFT28_103, DmTouch::Software); /* For LPC4088 QuickStart Board */ |
displaymodule | 0:144e2312d558 | 69 | //DmTouch touch(DmTouch::DM_TFT28_103); |
displaymodule | 1:63e25ac12708 | 70 | //DmTouch touch(DmTouch::DM_TFT24_104, DmTouch::Software); /* For LPC4088 QuickStart Board */ |
displaymodule | 1:63e25ac12708 | 71 | //DmTouch touch(DmTouch::DM_TFT24_104); |
displaymodule | 0:144e2312d558 | 72 | //DmTouch touch(DmTouch::DM_TFT28_105); |
displaymodule | 5:cf0097e3a18c | 73 | //DmTouch touch(DmTouch::DM_TFT35_107); |
displaymodule | 5:cf0097e3a18c | 74 | //DmTouch touch(DmTouch::DM_TFT43_108); // For DmTftRa8875 driver, The panel resolution should be config in DmTftRa8875::init() function on the DmTftRa8875.cpp file. |
displaymodule | 6:d28b8be6e90a | 75 | //DmTouch touch(DmTouch::DM_TFT50_111); |
displaymodule | 6:d28b8be6e90a | 76 | |
displaymodule | 6:d28b8be6e90a | 77 | // DM-TFT28-116; |
displaymodule | 6:d28b8be6e90a | 78 | I2C i2c(D14, D15); |
displaymodule | 6:d28b8be6e90a | 79 | DmTpFt6x06 touch(DmTpFt6x06::DM_TFT28_116, i2c); |
displaymodule | 0:144e2312d558 | 80 | |
displaymodule | 0:144e2312d558 | 81 | DigitalInOut csTouch(DM_PIN_CS_TOUCH, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 82 | DigitalInOut csDisplay(DM_PIN_CS_TFT, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 83 | DigitalInOut csSDCard(DM_PIN_CS_SDCARD, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 84 | #ifdef DM_PIN_CS_FLASH |
displaymodule | 0:144e2312d558 | 85 | DigitalInOut csFlash(DM_PIN_CS_FLASH, PIN_OUTPUT, PullUp, 1); |
displaymodule | 0:144e2312d558 | 86 | #endif |
displaymodule | 0:144e2312d558 | 87 | |
displaymodule | 0:144e2312d558 | 88 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 89 | * Global variables |
displaymodule | 0:144e2312d558 | 90 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 91 | |
displaymodule | 0:144e2312d558 | 92 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 93 | * Local functions |
displaymodule | 0:144e2312d558 | 94 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 95 | |
displaymodule | 0:144e2312d558 | 96 | |
displaymodule | 0:144e2312d558 | 97 | /****************************************************************************** |
displaymodule | 0:144e2312d558 | 98 | * Main |
displaymodule | 0:144e2312d558 | 99 | *****************************************************************************/ |
displaymodule | 0:144e2312d558 | 100 | |
displaymodule | 0:144e2312d558 | 101 | int main() { |
displaymodule | 0:144e2312d558 | 102 | log("init tft \r\n"); |
displaymodule | 0:144e2312d558 | 103 | tft.init(); |
displaymodule | 5:cf0097e3a18c | 104 | |
displaymodule | 0:144e2312d558 | 105 | uint16_t x = 0; |
displaymodule | 0:144e2312d558 | 106 | uint16_t y = 0; |
displaymodule | 0:144e2312d558 | 107 | uint16_t w = tft.width(); |
displaymodule | 0:144e2312d558 | 108 | uint16_t h = tft.height(); |
displaymodule | 0:144e2312d558 | 109 | |
displaymodule | 0:144e2312d558 | 110 | bool down = false; |
displaymodule | 0:144e2312d558 | 111 | bool lastDown = false; |
displaymodule | 0:144e2312d558 | 112 | |
displaymodule | 0:144e2312d558 | 113 | tft.drawString(20, 20, "x:"); |
displaymodule | 0:144e2312d558 | 114 | tft.drawString(100, 20, "y:"); |
displaymodule | 0:144e2312d558 | 115 | |
displaymodule | 0:144e2312d558 | 116 | touch.init(); |
displaymodule | 0:144e2312d558 | 117 | while (1) { |
displaymodule | 0:144e2312d558 | 118 | touch.readTouchData(x, y, down); |
displaymodule | 0:144e2312d558 | 119 | if (down) { |
displaymodule | 0:144e2312d558 | 120 | tft.drawNumber(40, 20, x, 5, false); |
displaymodule | 0:144e2312d558 | 121 | tft.drawNumber(120, 20, y, 5, false); |
displaymodule | 0:144e2312d558 | 122 | } else if (lastDown) { |
displaymodule | 0:144e2312d558 | 123 | // no longer pressed, clean text |
displaymodule | 0:144e2312d558 | 124 | tft.drawString(40, 20, " "); |
displaymodule | 0:144e2312d558 | 125 | tft.drawString(120, 20, " "); |
displaymodule | 0:144e2312d558 | 126 | } |
displaymodule | 0:144e2312d558 | 127 | wait(0.040); |
displaymodule | 0:144e2312d558 | 128 | lastDown = down; |
displaymodule | 0:144e2312d558 | 129 | } |
displaymodule | 0:144e2312d558 | 130 | } |