touch screen handler for the microchip AR1020
ar1020.h
- Committer:
- hlipka
- Date:
- 2011-02-21
- Revision:
- 0:cf4dd04052e3
- Child:
- 1:264ad2a00fd9
File content as of revision 0:cf4dd04052e3:
/* * mbed AR1020 library * Copyright (c) 2010 Hendrik Lipka * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef __AR1020_H_ #define __AR1020_H_ #include "mbed.h" #include "touchpanel.h" #include "touchevent.h" class AR1020: public TouchPanel { public: /** requires SPI mode=1 (POL=0, PHA=1 [falling edge]) SPI frequency lower than 900 kHz (something about 100kHz preferred) @param spi the SPI object where the AR1020 is connected @params enable the pin name where /CS is connected */ AR1020(SPI *spi, PinName enable, PinName sqi, bool swapX=false, bool swapY=false, bool swapXY=false); AR1020(PinName mosi, PinName miso, PinName clk, PinName enable, PinName sqi, bool swapX=false, bool swapY=false, bool swapXY=false); ~AR1020(); virtual void init(); virtual int x(); virtual int y(); virtual int pen(); virtual void read(); void calibrate(); private: int cmd(char cmd,char* data, int len); int readCalibResponse(); int readByte(); void writeByte(char byte); SPI *_spi; DigitalOut *_enable; InterruptIn *_irq; DigitalIn *_sqi; int _x, _y, _pen; DigitalOut *_led; DigitalOut *_mosi; DigitalIn *_miso; DigitalOut *_clk; bool _oldPen; TouchEvent _event; }; #endif