Skip to content

Commit 73f4a09

Browse files
committed
2.0.0
1 parent b6fde90 commit 73f4a09

File tree

19 files changed

+163
-245
lines changed

19 files changed

+163
-245
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
# Flicker 1.1.4
1+
# Flicker 2.0.0
22
### A library for making capacitive touch easy to use.
33
###### by Josh Nishikawa <github.com/joshnishikawa/Flicker>
44
###### The "TouchSwitch" class was adapted from the Bounce library by: Thomas O Fredericks, Eric Lowry, Jim Schimpf and Tom Harkaway
55
Includes all the functions found in the Bounce library, smoothes eratic values to make variable input more useful and includes functions for measuring velocity.
66
___
77
### VERSION LOG:
8+
2.0.0
9+
- Thresholds for TouchSwitch are now set more dynamically and updated when
10+
highest/lowest readings are updated. This better accommodates more setups
11+
regardless of quiescent readings or ranges between highest/lowest readings.
12+
13+
- setThresholds() MUST be called during setup and requires two arguments: the lowest possible reading that detects your finger and the reading at which a the value should be returned (contact). Use rangeFinder.ino to find these values.
14+
- responsiveRead() is deprecated. Use read() instead.
15+
- Setting outLo and outHi in the constructor is deprecated. Just map the return
16+
value of read() in the sketch.
17+
818

919
1.1.4
1020
- Added previousDuration() function that can be used on rising/falling edge to return the length of the input's previous state.

examples/multitask_example/multitask_example.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Also, a variable reading is taken from the same input,
66
// mapped to a range of 0~1023 and printed to serial.
77

8-
const uint8_t touchPin = 15; // CHOOSE A TOUCH PIN
8+
const uint8_t touchPin = 0; // CHOOSE A TOUCH PIN
99
const uint8_t ledPin = 13;
1010
bool ledState = false;
1111
int preVal = 0;

examples/on-off_stable/on-off_stable.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// If you hold your finger on the input,
44
// something will happen.
55

6-
const uint8_t touchPin = 15; // CHOOSE A TOUCH PIN
6+
const uint8_t touchPin = 0; // CHOOSE A TOUCH PIN
77
const uint8_t ledPin = 13;
88
TouchSwitch myInput(touchPin);
99

@@ -14,7 +14,11 @@ void setup() {
1414
// WARNING! if you setThreshold with no argument,
1515
// the threshold is calculated based on a call to
1616
// touchRead() so DON'T touch the input during setup()
17-
myInput.setThreshold();
17+
myInput.setThreshold();
18+
19+
// Use rangeFinder.ino to find a specific threshold
20+
// Then replace '1200' and use the following line instead.
21+
// myInput.setThreshold(1200);
1822
}
1923

2024
void loop() {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
This is not an example for how to use this library.
3+
Rather, it's a utility to find a usable range and/or
4+
thresholds for your particular needs. Get the values
5+
printed in the serial monitor to use in other sketches.
6+
*/
7+
8+
#include "Bounce2.h"
9+
10+
int touchPin = 0; // Change to the TOUCH pin you want to use.
11+
int resetPin = 19; // you can set a pin to reset hi/lo
12+
Bounce reset = Bounce(resetPin, 50);
13+
int hi;
14+
15+
void setReset(){
16+
hi = touchRead(touchPin);
17+
Serial.print("High Touch: "); Serial.println(hi);
18+
}
19+
20+
void setup(){
21+
pinMode(resetPin, INPUT_PULLUP);
22+
setReset();
23+
}
24+
25+
void loop(){
26+
reset.update();
27+
if(reset.rose()){
28+
setReset();
29+
}
30+
31+
int newVal = touchRead(touchPin);
32+
if (newVal > hi){
33+
hi = newVal;
34+
Serial.print("High Touch: "); Serial.println(hi);
35+
}
36+
}

examples/switch_duration/switch_duration.ino

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// If you hold your finger on the input
44
// for long enough, something will happen.
55

6-
const uint8_t touchPin = 15; // CHOOSE A TOUCH PIN
6+
const uint8_t touchPin = 0; // CHOOSE A TOUCH PIN
77
const uint8_t ledPin = 13;
88
TouchSwitch myInput(touchPin);
99

@@ -14,7 +14,12 @@ void setup() {
1414
// the threshold is calculated based on a call to
1515
// touchRead() so DON'T touch the input during setup()
1616
myInput.setThreshold();
17-
myInput.interval(300); // How long to hold?
17+
18+
// Use rangeFinder.ino to find a specific threshold
19+
// Then replace '1200' and use the following line instead.
20+
// myInput.setThreshold(1200);
21+
22+
myInput.interval(300); // How long to hold before response?
1823
}
1924

2025
void loop() {

examples/switch_latch/switch_latch.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// The input goes on when touched
44
// and off when touched again.
55

6-
byte touchPin = 15; // CHOOSE A TOUCH PIN
6+
byte touchPin = 0; // CHOOSE A TOUCH PIN
77
byte ledPin = 13;
88

99
// MOMENTARY (the default) or LATCH can be specified

examples/switch_previousDuration/switch_previousDuration.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This will tell you how long the input stayed in its PREVIOUS state.
44
// It may be useful to call this within rose() or fell().
55

6-
const uint8_t touchPin = 15; // CHOOSE A TOUCH PIN
6+
const uint8_t touchPin = 0; // CHOOSE A TOUCH PIN
77
const uint8_t ledPin = 13;
88
TouchSwitch myInput(touchPin);
99

examples/switch_retrigger/switch_retrigger.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// As long as the input is held,
44
// it will be triggered repeatedly.
55

6-
const uint8_t touchPin = 15; // CHOOSE A TOUCH PIN
6+
const uint8_t touchPin = 0; // CHOOSE A TOUCH PIN
77
const uint8_t ledPin = 13;
88
bool ledState = false;
99
TouchSwitch myInput(touchPin);

examples/variable_setOutputRange/variable_setOutputRange.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Map the variable touuch input to a specific range.
44
// Examples: 0~1023 to emulate analog; or 0~127 for MIDI.
55

6-
byte touchPin = 15; // CHOOSE A TOUCH PIN
6+
byte touchPin = 0; // CHOOSE A TOUCH PIN
77
int preVal;
88
TouchVariable myInput(touchPin);
99

@@ -14,7 +14,7 @@ void setup() {
1414
// the input range is calculated based on a call to
1515
// touchRead() so DON'T touch the input during setup()
1616
myInput.setInputRange();
17-
myInput.setOutputRange(0, 1023); // 7-bit MIDI
17+
myInput.setOutputRange(0, 1023); // 10-bit analog
1818
}
1919

2020
void loop(){

examples/variable_stable/variable_stable.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// value only when the signal is biased enough.
55
// The larger the change, the more immediate the response.
66

7-
byte touchPin = 15; // CHOOSE A TOUCH PIN
7+
byte touchPin = 0; // CHOOSE A TOUCH PIN
88
byte ledPin = 13;
99
int preVal;
1010
TouchVariable myInput(touchPin);

0 commit comments

Comments
 (0)