TTP229 16key touch keypad
This library support only 16key mode and active low mode
jamper set TP1=1(default) and TP2=0(jamper close).
pin connection
mbed TTP229 GPIO(InterruptIn) --------------- SDO GPIO(DigitalOut) --------------- SCL 3.3V --------------- VCC GND --------------- GND
sample program is here.
アマゾンで購入したTTP229 を使った16キーのタッチキーパッドを使うためのライブラリです。
このボードは8keyモードにも設定できますが、このライブラリは16キーモード専用です
16キーモードに設定するには TP2を高抵抗でGNDに繋ぎます。私が入手したボードではジャンパ設定の3番をクローズにすればこの状態になります。
TP1で active low と active highの切替が出来ますが、このライブラリは active lowを想定していますので、TP1はデフォルトのまま(GNDには繋がない)にしてください。その他のジャンパは使用目的に応じて自由に設定して構いません。
詳しくはこちらをご覧ください。
TTP229.cpp
- Committer:
- jk1lot
- Date:
- 2016-07-16
- Revision:
- 2:550c26cd6734
- Parent:
- 0:50226acdb872
File content as of revision 2:550c26cd6734:
#include "TTP229.h" TTP229::TTP229(PinName sdopin, PinName sclpin) : sdo(sdopin), sdoInt(sdopin), scl(sclpin) { scl=1; sdoInt.fall(this, &TTP229::interrupt); } void TTP229::interrupt() { sdoInt.disable_irq(); swnum=0; while(!sdo) {} wait_us(10); for(int i=0; i<16; i++) { scl=0; wait_us(2); if((sw[i]=!sdo)==true) swnum=i+1; scl=1; wait_us(2); } callback(); sdoInt.enable_irq(); }