daily_automated
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
[{000214A0-0000-0000-C000-000000000046}]
|
||||
Prop4=31,Arduino - Keypad 4x4 aanraakgevoelig (TTP229)
|
||||
Prop3=19,2
|
||||
[{A7AF692E-098D-4C08-A225-D433CA835ED0}]
|
||||
Prop5=3,0
|
||||
Prop9=19,0
|
||||
[InternetShortcut]
|
||||
URL=http://domoticx.com/arduino-keypad-4x4-aanraakgevoelig-ttp229/
|
||||
IDList=
|
||||
IconFile=http://domoticx.com/favicon.ico
|
||||
IconIndex=1
|
||||
[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}]
|
||||
Prop5=8,Microsoft.Website.1A8DF974.67A34795
|
||||
65
trunk/Arduino/sketch_pro_Touch-Keyboard/Example.ino.txt
Normal file
65
trunk/Arduino/sketch_pro_Touch-Keyboard/Example.ino.txt
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* touchpad16_interrupt.ino
|
||||
*
|
||||
* Created: 5/27/2015 9:02:08 PM
|
||||
* Author: Steve Stover
|
||||
*
|
||||
* 16 Key Capacitive Touchpad using TTP229B IC
|
||||
* http://www.ebay.com/itm/371304274498
|
||||
*
|
||||
* The Touchpad has a jumper on TP1/SAHL for active high serial out
|
||||
* and a jumper on TP2/KYSEL for 16-keys operation
|
||||
*
|
||||
* Processing the input via external interrupt INT1
|
||||
* on an Arduino Nano v3.0
|
||||
*/
|
||||
|
||||
#include <util/atomic.h>
|
||||
|
||||
#define CLR(x,y) (x&=(~(1<<y)))
|
||||
#define SET(x,y) (x|=(1<<y))
|
||||
|
||||
#define clock_Pin 2
|
||||
#define sdo_Pin 3
|
||||
|
||||
// Touchpad value
|
||||
volatile uint16_t touchVal; // var for ISR access
|
||||
uint16_t touchValc; // copy var for main loop
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(clock_Pin, OUTPUT);
|
||||
pinMode(sdo_Pin, INPUT);
|
||||
// set up INT1 on digital pin 3
|
||||
EICRA = (1 << ISC11) | (1 << ISC10); // external INT1 on rising edge
|
||||
EIMSK = (1 << INT1); // External Interrupt Request 1 Enable
|
||||
sei();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
ATOMIC_BLOCK(ATOMIC_FORCEON) {
|
||||
touchValc = touchVal;
|
||||
}
|
||||
if (touchValc) {
|
||||
Serial.print(touchValc, DEC);
|
||||
for (byte b=0; b<=15; b++) {
|
||||
if ((touchValc >> b) & 1) {
|
||||
Serial.print('\t'); Serial.print("bit "); Serial.print(b);
|
||||
Serial.print('\t'); Serial.print("pad "); Serial.print(b+1);
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
ISR(INT1_vect) {
|
||||
touchVal = 0;
|
||||
delayMicroseconds(100);
|
||||
for (byte i=0; i<=15; i++) {
|
||||
SET(PORTD, clock_Pin);
|
||||
delayMicroseconds(50);
|
||||
touchVal |= (digitalRead(sdo_Pin) << i);
|
||||
CLR(PORTD, clock_Pin);
|
||||
delayMicroseconds(50);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,43 @@
|
||||
|
||||
/*
|
||||
Reading a TTP229 based capacitive touch Keyboard
|
||||
to enable 16-Key Mode short TP2 with a 820kOhms (up to 1MOhms)
|
||||
Resistor to GROUND or close Jumper 3 on TP229 Module
|
||||
|
||||
hardware required TTP229 Module with
|
||||
* SCL connected to PIN8
|
||||
* SDD connected to PIN9
|
||||
|
||||
created 1 Mar 2015
|
||||
by Thomas Schmitz (thomas.schmitz@tschmitz.com)
|
||||
|
||||
This example code is part of the public domain
|
||||
*/
|
||||
|
||||
#define CLOCK_PIN 8
|
||||
#define DATA_PIN 9
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
pinMode(CLOCK_PIN, OUTPUT);
|
||||
pinMode(DATA_PIN, INPUT);
|
||||
digitalWrite(CLOCK_PIN, HIGH);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
for (int button = 1; button < 17; button++)
|
||||
{
|
||||
//set clock
|
||||
digitalWrite(CLOCK_PIN, LOW);
|
||||
|
||||
//read bit
|
||||
int databit = digitalRead(DATA_PIN);
|
||||
Serial.print(databit);
|
||||
|
||||
//reset clock
|
||||
digitalWrite(CLOCK_PIN, HIGH);
|
||||
};
|
||||
Serial.println();
|
||||
}
|
||||
BIN
trunk/Arduino/sketch_pro_Touch-Keyboard/TTP229 datasheet.pdf
Normal file
BIN
trunk/Arduino/sketch_pro_Touch-Keyboard/TTP229 datasheet.pdf
Normal file
Binary file not shown.
450
trunk/Arduino/sketch_pro_Touch-Keyboard/Touch-Keyboard.ino.txt
Normal file
450
trunk/Arduino/sketch_pro_Touch-Keyboard/Touch-Keyboard.ino.txt
Normal file
@@ -0,0 +1,450 @@
|
||||
#include <SPI.h>
|
||||
|
||||
#if 0
|
||||
#define DEBUG_BUTTON16(a) (a)
|
||||
#else
|
||||
#define DEBUG_BUTTON16(a)
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#define DEBUG_STATUS(a) (a)
|
||||
#else
|
||||
#define DEBUG_STATUS(a)
|
||||
#endif
|
||||
|
||||
|
||||
#pragma pack(push, 0)
|
||||
|
||||
// TBD: Replace with proper interrupt pin macros. It does not seem to be defined for atmega328p or I am incapable of finding it
|
||||
#ifndef INT0_PIN
|
||||
#ifdef __AVR_ATmega328P__
|
||||
#define INT0_PIN 2
|
||||
#else
|
||||
#warning Define INT0_PIN for this microcontroller to use interrupt
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INT1_PIN
|
||||
#ifdef __AVR_ATmega328P__
|
||||
#define INT1_PIN 3
|
||||
#else
|
||||
#warning Define INT1_PIN for this microcontroller to use interrupt
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint32_t g_intCount = 0;
|
||||
|
||||
struct CTtp229ButtonEvent
|
||||
{
|
||||
uint8_t ButtonNumber : 5; // ButtonNumber != 0 : Event is present. if equals 0, no event is received
|
||||
uint8_t IsButtonReleased : 1; // True = Button is pressed. False = Button is released
|
||||
};
|
||||
|
||||
class CTtP229TouchButton
|
||||
{
|
||||
struct CTtp229Prop
|
||||
{
|
||||
uint16_t SclPin : 6;
|
||||
uint16_t SdoPin : 6;
|
||||
uint16_t Is16Button : 1;
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
uint16_t HasPendingInterrupt : 1;
|
||||
uint16_t IgnoreNextEvent : 1; // When reading 16th key and if it is pressed, SDO stays low for 2ms.
|
||||
// If we enable interrupt before that, then it will trigger after 2ms, only to find the same condition.
|
||||
// To make things worse, at the end of reading the pin will stay low and generate another interrupt.
|
||||
// TBD: One possible fix is to send more pulses to make it roll over to HIGH. Have to find out if all 16 keys can be pressed in multi-key scenario (NOT supported yet).
|
||||
uint16_t UnhandledButtonPresses;
|
||||
#endif
|
||||
uint16_t PreviousButtonValue;
|
||||
};
|
||||
|
||||
static CTtp229Prop g_prop;
|
||||
|
||||
//
|
||||
// Internal function that captures the data from TTP229 on which key is pressed.
|
||||
// Currently, this function only supports one key being pressed. Multi-key press needs to be added later.
|
||||
//
|
||||
// Return Value : Bit field of buttons pressed
|
||||
//
|
||||
static uint16_t GetPressedButton()
|
||||
{
|
||||
DEBUG_BUTTON16(Serial.println("GetPressedButton : Enter "));
|
||||
uint16_t buttonsPressed = 0;
|
||||
// Need to generate the LOW and then HIGH on the clock and read the value from data when clock is back high.
|
||||
// As per the specification, the TTP229 chip can support 512Khz. This translates to approximately 2us for a cycle. So introducing clock with fall and raise each of 1us.
|
||||
uint8_t maxCnt = g_prop.Is16Button ? 16 : 8;
|
||||
for(uint8_t ndx = 0; ndx < maxCnt; ndx++ )
|
||||
{
|
||||
digitalWrite(g_prop.SclPin, LOW);
|
||||
delayMicroseconds(1);
|
||||
digitalWrite(g_prop.SclPin, HIGH);
|
||||
|
||||
int val = digitalRead(g_prop.SdoPin);
|
||||
|
||||
delayMicroseconds(1); // Technically this can be moved after the if for most atmel microcontrollers. But if there is a really fast one (now/future) and the next call to GetPressedButton made immediately, we might overclock TTP229. Being safe here
|
||||
|
||||
if( LOW == val )
|
||||
{
|
||||
buttonsPressed |= (1 << ndx);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_BUTTON16(Serial.print("GetPressedButton : Exit. Return Value : ")); DEBUG_BUTTON16(Serial.println(buttonsPressed));
|
||||
|
||||
return buttonsPressed;
|
||||
}
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
// Detaching the interrupt after receiving the data can cause problem in sleeping. If the interrupt is not properly dispatched, it can lead to permanent sleep and can't wake up from button
|
||||
static void HandleButtonEvent()
|
||||
{
|
||||
if( g_prop.IgnoreNextEvent )
|
||||
{
|
||||
// We ignored an event. Now we will accept the event
|
||||
g_prop.IgnoreNextEvent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_prop.HasPendingInterrupt = true;
|
||||
g_intCount++;
|
||||
}
|
||||
}
|
||||
|
||||
static void SetInterruptHandler()
|
||||
{
|
||||
#ifdef INT0_PIN
|
||||
if( INT0_PIN == g_prop.SdoPin )
|
||||
{
|
||||
DEBUG_BUTTON16(Serial.println("Configure : With interrupt 0"));
|
||||
EIFR = 0x01; // Clear INTF0 flag
|
||||
attachInterrupt(0, HandleButtonEvent, RISING); // The pin goes down for 93us and then raises that is when the device is ready (technically after 10us)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef INT1_PIN
|
||||
if( INT1_PIN == g_prop.SdoPin )
|
||||
{
|
||||
DEBUG_BUTTON16(Serial.println("Configure : With interrupt 1"));
|
||||
EIFR = 0x02; // Clear INTF1 flag
|
||||
attachInterrupt(1, HandleButtonEvent, RISING); // The pin goes down for 93us and then raises that is when the device is ready (technically after 10us)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void RemoveInterruptHandler()
|
||||
{
|
||||
#ifdef INT0_PIN
|
||||
if( INT0_PIN == g_prop.SdoPin )
|
||||
{
|
||||
detachInterrupt(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef INT1_PIN
|
||||
if( INT1_PIN == g_prop.SdoPin )
|
||||
{
|
||||
detachInterrupt(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Returns button number being pressed. High bit indicates more changes present
|
||||
//
|
||||
static uint8_t GetButtonNumberFromFlag(uint16_t buttonsChanged)
|
||||
{
|
||||
uint16_t flag = 1;
|
||||
for(uint8_t ndx = 1; ndx <=16; ndx++, flag <<= 1)
|
||||
{
|
||||
if( (buttonsChanged & flag) != 0 )
|
||||
{
|
||||
if( (buttonsChanged & ~flag) != 0 )
|
||||
{
|
||||
// Some other bit is present
|
||||
ndx |= 0x80;
|
||||
}
|
||||
|
||||
return ndx;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
//
|
||||
// Setup the TTP229 Touch button on this input.
|
||||
//
|
||||
// Inputs:
|
||||
// sclPin - Clock Pin of the button (3rd from left on button, connected to arduino's digital pin number)
|
||||
// sdoPin - Data pin to read from the button (4th pin from left on button, connected to arduino's digital pin number)
|
||||
// is16Button - true = 16 buttons board. false = 8 button board
|
||||
//
|
||||
static void Configure(int sclPin, int sdoPin, bool is16Button = true)
|
||||
{
|
||||
DEBUG_BUTTON16(Serial.println("Configure : Enter"));
|
||||
|
||||
g_prop.SclPin = sclPin;
|
||||
g_prop.SdoPin = sdoPin;
|
||||
g_prop.Is16Button = is16Button;
|
||||
|
||||
g_prop.PreviousButtonValue = 0;
|
||||
|
||||
// Configure clock as output and hold it high
|
||||
pinMode( sclPin, OUTPUT );
|
||||
digitalWrite(sclPin, HIGH);
|
||||
|
||||
// Configure data pin as input
|
||||
pinMode( sdoPin, INPUT);
|
||||
|
||||
DEBUG_BUTTON16(Serial.print("Button Configuration\n\rSCL Pin : "));
|
||||
DEBUG_BUTTON16(Serial.println(sclPin));
|
||||
DEBUG_BUTTON16(Serial.print("SDO Pin : "));
|
||||
DEBUG_BUTTON16(Serial.println(sdoPin));
|
||||
DEBUG_BUTTON16(Serial.print("Number of Keys : "));
|
||||
DEBUG_BUTTON16(Serial.println(is16Button ? 16 : 8));
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
g_prop.UnhandledButtonPresses = 0;
|
||||
g_prop.HasPendingInterrupt = false;
|
||||
g_prop.IgnoreNextEvent = false;
|
||||
SetInterruptHandler();
|
||||
#endif
|
||||
|
||||
DEBUG_BUTTON16(Serial.println("Configure : Exit"));
|
||||
}
|
||||
|
||||
//
|
||||
// Get the current status from the 16 button touch device
|
||||
//
|
||||
// Return Value : Returns the bitflag of the keys pressed. returns 0, if no key is pressed.
|
||||
//
|
||||
static uint16_t GetButtonStatus()
|
||||
{
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
g_prop.HasPendingInterrupt = 0;
|
||||
#endif
|
||||
|
||||
uint16_t returnValue = GetPressedButton();
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
returnValue |= g_prop.UnhandledButtonPresses; // and also include any data that was received that we have not sent yet.
|
||||
g_prop.UnhandledButtonPresses = 0;
|
||||
#endif
|
||||
|
||||
g_prop.PreviousButtonValue = returnValue;
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
//
|
||||
// Gets the event from the button. This is useful for monitoring press and release only.
|
||||
// Each button press will generate max 2 events, one for press and another for release. When the button is press and held, this method will return no event.
|
||||
// If the calls were not made often enough, the events could be missed. For instance, you might get 2 pressed, followed by 4 pressed, which automatically means 2 released in single key mode.
|
||||
//
|
||||
// Return Value : if ButtonNumber is 0, then no event
|
||||
//
|
||||
static CTtp229ButtonEvent GetButtonEvent()
|
||||
{
|
||||
CTtp229ButtonEvent returnValue = {0, 0};
|
||||
uint8_t buttonNumber;
|
||||
|
||||
DEBUG_BUTTON16(Serial.print("Old Value : "));
|
||||
DEBUG_BUTTON16(Serial.println(g_prop.PreviousButtonValue));
|
||||
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
if(
|
||||
#if defined(INT0_PIN)
|
||||
INT0_PIN == g_prop.SdoPin
|
||||
#endif
|
||||
#if defined(INT0_PIN) && defined(INT1_PIN)
|
||||
||
|
||||
#endif
|
||||
#if defined(INT1_PIN)
|
||||
INT1_PIN == g_prop.SdoPin
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// Interrupts are used. Check if we have interrupt
|
||||
if( g_prop.HasPendingInterrupt )
|
||||
{
|
||||
RemoveInterruptHandler(); // From this point upto SetInterruptHandler is called, ensure there is no return path that will leave without SetInterruptHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_BUTTON16(Serial.println("GetButtonEvent: No interrupt pending"));
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t currValue = GetPressedButton();
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
currValue |= g_prop.UnhandledButtonPresses; // Get any previously returned but not returned now values also into the mix
|
||||
#endif
|
||||
|
||||
uint16_t changes = g_prop.PreviousButtonValue ^ currValue;
|
||||
uint16_t pressed = (changes & currValue);
|
||||
uint16_t released = (changes & g_prop.PreviousButtonValue);
|
||||
|
||||
// First check if any key is that is pressed and generate press event
|
||||
if( 0 != pressed )
|
||||
{
|
||||
buttonNumber = GetButtonNumberFromFlag(pressed);
|
||||
returnValue.ButtonNumber = (buttonNumber & 0x7F);
|
||||
|
||||
uint16_t mask = (1 << (returnValue.ButtonNumber -1));
|
||||
// set the new notified button into prev
|
||||
g_prop.PreviousButtonValue |= mask;
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
g_prop.UnhandledButtonPresses = currValue;
|
||||
g_prop.UnhandledButtonPresses = currValue & ~g_prop.PreviousButtonValue; // clear unhandled for this bit, just in case
|
||||
#endif
|
||||
}
|
||||
else if(0 != released)
|
||||
{
|
||||
buttonNumber = GetButtonNumberFromFlag(released);
|
||||
returnValue.ButtonNumber = (buttonNumber & 0x7F);
|
||||
|
||||
// The unmatching bit whose previous value of 1 means, it is released
|
||||
returnValue.IsButtonReleased = true;
|
||||
|
||||
// clear the notified release button
|
||||
g_prop.PreviousButtonValue &= ~(1 << (returnValue.ButtonNumber -1));
|
||||
}
|
||||
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
|
||||
if(((!returnValue.IsButtonReleased || (0 == pressed)) // We handle release but no pending press
|
||||
&& ((buttonNumber & 0x80) == 0 )) // or more button changes are detected
|
||||
|| (returnValue.ButtonNumber == 0) ) // safety in case interrupt and data mismatch or code bug
|
||||
{
|
||||
// No more button notification pending
|
||||
g_prop.HasPendingInterrupt = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_BUTTON16(Serial.println("not Clearing interrupt"));
|
||||
}
|
||||
|
||||
g_prop.IgnoreNextEvent = digitalRead(g_prop.SdoPin) == LOW; // If the pin is still low at the end of reading, ignore next event which is for data finished raise
|
||||
DEBUG_BUTTON16(Serial.print(g_prop.IgnoreNextEvent ? "Ignoring next event\n\r" : "Not ignoring\n\r"));
|
||||
|
||||
// All the data has been read. Now reactivate the interrupt
|
||||
SetInterruptHandler();
|
||||
#endif
|
||||
|
||||
DEBUG_BUTTON16(Serial.print("currValue : "));
|
||||
DEBUG_BUTTON16(Serial.println(currValue));
|
||||
DEBUG_BUTTON16(Serial.print("Changes : "));
|
||||
DEBUG_BUTTON16(Serial.println(changes));
|
||||
DEBUG_BUTTON16(Serial.print("Button N : "));
|
||||
DEBUG_BUTTON16(Serial.println(buttonNumber));
|
||||
DEBUG_BUTTON16(Serial.print("Unhandled : "));
|
||||
DEBUG_BUTTON16(Serial.println(g_prop.UnhandledButtonPresses));
|
||||
DEBUG_BUTTON16(Serial.print("ButtonRelease : "));
|
||||
DEBUG_BUTTON16(Serial.println(returnValue.IsButtonReleased));
|
||||
DEBUG_BUTTON16(Serial.print("buttonNumber : "));
|
||||
DEBUG_BUTTON16(Serial.println(buttonNumber));
|
||||
DEBUG_BUTTON16(Serial.print("Pending interrupts :"));
|
||||
DEBUG_BUTTON16(Serial.println(g_prop.HasPendingInterrupt));
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
static bool HasEvent()
|
||||
{
|
||||
#if defined(INT0_PIN)
|
||||
if( INT0_PIN == g_prop.SdoPin )
|
||||
{
|
||||
return g_prop.HasPendingInterrupt;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(INT1_PIN)
|
||||
if( INT1_PIN == g_prop.SdoPin )
|
||||
{
|
||||
return g_prop.HasPendingInterrupt;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
CTtP229TouchButton::CTtp229Prop CTtP229TouchButton::g_prop;
|
||||
CTtP229TouchButton g_ttp229Button;
|
||||
|
||||
#define TTP16Button g_ttp229Button
|
||||
#pragma pack(pop)
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
DEBUG_STATUS(Serial.println("===================================================================="));
|
||||
DEBUG_STATUS(Serial.println("Button Input tester started"));
|
||||
DEBUG_STATUS(Serial.println("===================================================================="));
|
||||
|
||||
TTP16Button.Configure(7, 2);
|
||||
}
|
||||
|
||||
void TestStatus()
|
||||
{
|
||||
uint8_t buttonNumber = TTP16Button.GetButtonStatus();
|
||||
|
||||
if( 0 != buttonNumber )
|
||||
{
|
||||
DEBUG_STATUS(Serial.print("Button Pressed : "));
|
||||
DEBUG_STATUS(Serial.println(buttonNumber));
|
||||
}
|
||||
|
||||
delayMicroseconds(2500); // TTP229 document says it will reset the output if 2ms idle + little bit safety
|
||||
}
|
||||
|
||||
void TestEvent()
|
||||
{
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
if( TTP16Button.HasEvent())
|
||||
#endif
|
||||
{
|
||||
CTtp229ButtonEvent buttonEvent = TTP16Button.GetButtonEvent();
|
||||
|
||||
if( 0 != buttonEvent.ButtonNumber )
|
||||
{
|
||||
if( buttonEvent.IsButtonReleased )
|
||||
{
|
||||
DEBUG_STATUS(Serial.print("Button Released: "));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_STATUS(Serial.print("Button Pressed : "));
|
||||
}
|
||||
DEBUG_STATUS(Serial.println(buttonEvent.ButtonNumber));
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(INT0_PIN) || defined(INT1_PIN)
|
||||
DEBUG_STATUS(Serial.println("Are you not using interrupt? Should never come here for interrupt based system."));
|
||||
#endif
|
||||
}
|
||||
|
||||
//Serial.print("CurrentTime : "); Serial.println(millis());
|
||||
delayMicroseconds(2500); // TTP229 document says it will reset the output if 2ms idle + little bit safety. Not required if using interrupts
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//TestStatus();
|
||||
TestEvent();
|
||||
}
|
||||
131
trunk/Arduino/sketch_pro_Touch-Keyboard/makefile
Normal file
131
trunk/Arduino/sketch_pro_Touch-Keyboard/makefile
Normal file
@@ -0,0 +1,131 @@
|
||||
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
|
||||
#
|
||||
|
||||
BOARD_TAG = pro
|
||||
BOARD_SUB = 16MHzatmega328
|
||||
include ../paths.mk
|
||||
include ../Arduino.mk
|
||||
|
||||
# --- leonardo (or pro micro w/leo bootloader)
|
||||
#BOARD_TAG = leonardo
|
||||
#MONITOR_PORT = /dev/ttyACM0
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- mega2560 ide 1.0
|
||||
#BOARD_TAG = mega2560
|
||||
#ARDUINO_PORT = /dev/ttyACM0
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- mega2560 ide 1.6
|
||||
#BOARD_TAG = mega
|
||||
#BOARD_SUB = atmega2560
|
||||
#MONITOR_PORT = /dev/ttyACM0
|
||||
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- nano ide 1.0
|
||||
#BOARD_TAG = nano328
|
||||
#MONITOR_PORT = /dev/ttyUSB0
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- nano ide 1.6
|
||||
#BOARD_TAG = nano
|
||||
#BOARD_SUB = atmega328
|
||||
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- pro mini
|
||||
#BOARD_TAG = pro5v328
|
||||
#MONITOR_PORT = /dev/ttyUSB0
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- sparkfun pro micro
|
||||
#BOARD_TAG = promicro16
|
||||
#ALTERNATE_CORE = promicro
|
||||
#BOARDS_TXT = $(HOME)/arduino/hardware/promicro/boards.txt
|
||||
#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/promicro/bootloaders
|
||||
#BOOTLOADER_PATH = caterina
|
||||
#BOOTLOADER_FILE = Caterina-promicro16.hex
|
||||
#ISP_PROG = usbasp
|
||||
#AVRDUDE_OPTS = -v
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- chipkit
|
||||
#BOARD_TAG = mega_pic32
|
||||
#MPIDE_DIR = /where/you/installed/mpide-0023-linux64-20130817-test
|
||||
#include /usr/share/arduino/chipKIT.mk
|
||||
|
||||
# --- pinoccio
|
||||
#BOARD_TAG = pinoccio256
|
||||
#ALTERNATE_CORE = pinoccio
|
||||
#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/pinoccio/bootloaders
|
||||
#BOOTLOADER_PATH = STK500RFR2/release_0.51
|
||||
#BOOTLOADER_FILE = boot_pinoccio.hex
|
||||
#CFLAGS_STD = -std=gnu99
|
||||
#CXXFLAGS_STD = -std=gnu++11
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- fio
|
||||
#BOARD_TAG = fio
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- atmega-ng ide 1.6
|
||||
#BOARD_TAG = atmegang
|
||||
#BOARD_SUB = atmega168
|
||||
#MONITOR_PORT = /dev/ttyACM0
|
||||
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- arduino-tiny ide 1.0
|
||||
#ISP_PROG = usbasp
|
||||
#BOARD_TAG = attiny85at8
|
||||
#ALTERNATE_CORE = tiny
|
||||
#ARDUINO_VAR_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny
|
||||
#ARDUINO_CORE_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny
|
||||
#AVRDUDE_OPTS = -v
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- arduino-tiny ide 1.6
|
||||
#ISP_PROG = usbasp
|
||||
#BOARD_TAG = attiny85at8
|
||||
#ALTERNATE_CORE = tiny
|
||||
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- damellis attiny ide 1.0
|
||||
#ISP_PROG = usbasp
|
||||
#BOARD_TAG = attiny85
|
||||
#ALTERNATE_CORE = attiny-master
|
||||
#AVRDUDE_OPTS = -v
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- damellis attiny ide 1.6
|
||||
#ISP_PROG = usbasp
|
||||
#BOARD_TAG = attiny
|
||||
#BOARD_SUB = attiny85
|
||||
#ALTERNATE_CORE = attiny
|
||||
#F_CPU = 16000000L
|
||||
#ARDUINO_DIR = /where/you/installed/arduino-1.6.5
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- teensy3
|
||||
#BOARD_TAG = teensy31
|
||||
#ARDUINO_DIR = /where/you/installed/the/patched/teensy/arduino-1.0.6
|
||||
#include /usr/share/arduino/Teensy.mk
|
||||
|
||||
# --- mighty 1284p
|
||||
#BOARD_TAG = mighty_opt
|
||||
#BOARDS_TXT = $(HOME)/arduino/hardware/mighty-1284p/boards.txt
|
||||
#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/mighty-1284p/bootloaders
|
||||
#BOOTLOADER_PATH = optiboot
|
||||
#BOOTLOADER_FILE = optiboot_atmega1284p.hex
|
||||
#ISP_PROG = usbasp
|
||||
#AVRDUDE_OPTS = -v
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
|
||||
# --- atmega328p on breadboard
|
||||
#BOARD_TAG = atmega328bb
|
||||
#ISP_PROG = usbasp
|
||||
#AVRDUDE_OPTS = -v
|
||||
#BOARDS_TXT = $(HOME)/arduino/hardware/breadboard/boards.txt
|
||||
#include /usr/share/arduino/Arduino.mk
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
/*
|
||||
Reading a TTP229 based capacitive touch Keyboard
|
||||
to enable 16-Key Mode short TP2 with a 820kOhms (up to 1MOhms)
|
||||
Resistor to GROUND or close Jumper 3 on TP229 Module
|
||||
|
||||
hardware required TTP229 Module with
|
||||
* SCL connected to PIN8
|
||||
* SDD connected to PIN9
|
||||
|
||||
created 1 Mar 2015
|
||||
by Thomas Schmitz (thomas.schmitz@tschmitz.com)
|
||||
|
||||
This example code is part of the public domain
|
||||
*/
|
||||
|
||||
#define CLOCK_PIN 8
|
||||
#define DATA_PIN 9
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
pinMode(CLOCK_PIN, OUTPUT);
|
||||
pinMode(DATA_PIN, INPUT);
|
||||
digitalWrite(CLOCK_PIN, HIGH);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
for (int button = 1; button < 17; button++)
|
||||
{
|
||||
//set clock
|
||||
digitalWrite(CLOCK_PIN, LOW);
|
||||
|
||||
//read bit
|
||||
int databit = digitalRead(DATA_PIN);
|
||||
Serial.print(databit);
|
||||
|
||||
//reset clock
|
||||
digitalWrite(CLOCK_PIN, HIGH);
|
||||
};
|
||||
Serial.println();
|
||||
}
|
||||
BIN
trunk/Arduino/sketch_pro_Touch-Keyboard/tp16.png
Normal file
BIN
trunk/Arduino/sketch_pro_Touch-Keyboard/tp16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 304 KiB |
Reference in New Issue
Block a user