Skip to content

Commit

Permalink
Merge pull request #49 from andysheen/master
Browse files Browse the repository at this point in the history
added pin switches to update long fading times
  • Loading branch information
mikevanis authored Oct 8, 2020
2 parents 04d50a3 + 9884ed2 commit cd9a2a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
9 changes: 6 additions & 3 deletions ESP32-SOCKETIO.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//#define DEV
//#define STAGING

#define FADE_3 22
#define FADE_1 21

#define EXTERNAL_BUTTON 23
#define CAPTOUCH T0

Expand Down Expand Up @@ -69,7 +72,7 @@ using namespace ace_button;
#define REMOTELED 1
#define RGBLEDPWMSTART 120
#define FASTLONGFADE 120
#define LONGFADEMINUTESMAX 360
int LONGFADEMINUTESMAX = 360;
#define LONGFADECHECKMILLIS 60000
unsigned long prevLongFadeVal = 0;
uint8_t hue[NUMPIXELS];
Expand Down Expand Up @@ -171,10 +174,10 @@ int port = 80; // Socket.IO Port Address
char path[] = "/socket.io/?transport=websocket"; // Socket.IO Base Path

void setup() {

setupPixels();
Serial.begin(115200);
setupPins();
LONGFADEMINUTESMAX = checkFadingLength();
setupCapacitiveTouch();

//create 10 digit ID
Expand Down Expand Up @@ -239,7 +242,7 @@ void setPairedStatus() {

String getCurrentPairedStatusAsString() {
String currentPairedStatusAsString = "";

switch (currentPairedStatus) {
case remoteSetup: currentPairedStatusAsString = "remoteSetup"; break;
case localSetup: currentPairedStatusAsString = "localSetup"; break;
Expand Down
23 changes: 21 additions & 2 deletions utility.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ void setupPins() {
pinMode(BUTTON_BUILTIN, INPUT);
pinMode(EXTERNAL_BUTTON, INPUT_PULLUP);

pinMode(FADE_3, INPUT_PULLUP);
pinMode(FADE_1, INPUT_PULLUP);

ButtonConfig* buttonConfigBuiltIn = buttonBuiltIn.getButtonConfig();
buttonConfigBuiltIn->setEventHandler(handleButtonEvent);
buttonConfigBuiltIn->setFeature(ButtonConfig::kFeatureClick);
Expand Down Expand Up @@ -171,12 +174,28 @@ String generateID() {
void setupCapacitiveTouch() {
int touchAverage = 0;
for (byte i = 0; i < 10; i++) {
touchAverage = touchAverage+touchRead(CAPTOUCH);
touchAverage = touchAverage + touchRead(CAPTOUCH);
delay(100);
}
touchAverage = touchAverage/10;
touchAverage = touchAverage / 10;
TOUCH_THRESHOLD = touchAverage - TOUCH_HYSTERESIS;
Serial.print("Touch threshold is:");
Serial.println(TOUCH_THRESHOLD);
touchConfig.setThreshold(TOUCH_THRESHOLD);
}

int checkFadingLength() {
if (digitalRead(FADE_3) == 0 && digitalRead(FADE_1) == 1) {
Serial.println("Your fade time is 3 hours");
return 180;
} else if (digitalRead(FADE_1) == 0 && digitalRead(FADE_3) == 1) {
Serial.println("Your fade time is 1 hour");
return 60;
} else if (digitalRead(FADE_3) == 0 && digitalRead(FADE_1) == 0) {
Serial.println("Your fade time is 9 hours");
return 540;
} else {
Serial.println("Your fade time is 6 hours");
return 360;
}
}

0 comments on commit cd9a2a5

Please sign in to comment.