Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

XPT2046 - Code example
[XPT2046 - Library for touch screen controller]

 #include <otSerial.h>
 #include <otPrintfLite.h>
 #include <otTimer.h>
 #include <otXPT2046.h>
 
 otXPT2046 ts;
 
 void setup()
 {
        // Setup the UART0 used by printf
        UartEnableSignals(UART0);
        UartSetBaud(UART0, 115200);
        // Init printf
        setStdout(UART0); // printf output is now directed on UART0
        ts.init(240, 320);
 }
 
 void loop()
 {
        U16     x, y, z;
        if(ts.rawData(x, y, z))
                printf("x = %4d, y = %4d, z = %4d\n", x, y, z);
        DelayMs(10);
        if(ts.position(x, y))
                printf("x = %4d, y = %4d\n", x, y);
        DelayMs(100);
 }
footer
otStudio - Library Reference - (C) 2020-23 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0