// Built with BFTC Rev. 1.0.0, gio 28 agosto 2014 11:53:51 /* Copyright 2014 Digital Technology Art SRL This file is part of Blackfin Toolchain (BFTC) project. BFTC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. BFTC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Name-Program. If not, see <http://www.gnu.org/licenses/>. */ // Example that show how to use touch screen library // #include "main.h" int main(void) { bool ok; char buf[32]; int sx, sy, ox = -1, oy; Set_PLL(16, 4); // CORE: 25MHz * 16 = 400MHz, SCLK: 400MHz / 4 = 100MHz Set_Port(); // Set the port according to project set Set_Uart0(115200); // printf is redirected to UART0 // Init display Set_SPI(SPI_PP); Set_ExpansionPort(0xF0);// Init control bit on expansion port for LCD controls Set_TFTlightPower(true);// Turn on backligth Set_TFTlight(15); // Set maximum brightness Set_SPI(SPI_TFT); // Switch to graphics SPI channel Set_TFTinit(); // Init LCD controller gxClear(TFT_BLACK); // Clear the screen gxFontColorSize(TFT_YELLOW, TFT_BLACK, 1, 1); gxPutString(10, 220, "TOUCH SCREEN TEST"); // Init Touch Screen TS_Open(); TS_Enable(true); // Enable read of the pen while(1) // Main loop { if(TS_Check()) // Check if Touch Screen is active { // Read cursor position ok = TS_ReadCursor(&sx, &sy); if(ok) { // Disable TS TS_Enable(false); // Dump on LCD coordinates and cursor Set_SPI(SPI_TFT); // Switch to graphics SPI channel if(ox >= 0) // Remove previous cross { gxLine(ox - 10, oy, ox + 10, oy, TFT_BLACK); gxLine(ox, oy - 10, ox, oy + 10, TFT_BLACK); } // Draw a cross in the cursor position gxLine(sx - 10, sy, sx + 10, sy, TFT_WHITE); gxLine(sx, sy - 10, sx, sy + 10, TFT_WHITE); // Display coordinates sprintf(buf, "X = %3d, Y = %3d", sx, sy); gxPutString(10, 10, buf); // Set SPI on TSC channel Set_SPI(SPI_TSC); // Switch to touch screen the SPI channel ox = sx; oy = sy; // Enable touch screen read TS_Enable(true); } } } return 0; }