From f5d60d542d1ec0bc18758f93ec41fb6a56c75631 Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Wed, 18 May 2016 00:06:58 -0400 Subject: [PATCH 01/11] Started morse example --- .../FirebaseMorse_ESP8266.ino | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino new file mode 100644 index 00000000..bbf348a1 --- /dev/null +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -0,0 +1,92 @@ +// +// Copyright 2015 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// FirebaseStream_ESP8266 is a sample that stream bitcoin price from a +// public Firebase and optionally display them on a OLED i2c screen. + +#include +#include +#include +#include + +// Set these to run example. +#define WIFI_SSID "SSID" +#define WIFI_PASSWORD "PASSWORD" + +// We define morse . to be binary 0 and - to be binary 1. The longest letter +// is 5 morse elements long so we would have a sparse array of 2^5=32. But +// we need to add a leading 1 to ensure that .- and ..- are not the same value. +// This gives us a size of 2^6=64. +char morseToChar[64]; +morseToChar[B101] = 'a'; +morseToChar[B11000] = 'b'; +morseToChar[B11010] = 'c'; +morseToChar[B1100] = 'd'; +morseToChar[B10] = 'e'; +morseToChar[B10010] = 'f'; +morseToChar[B1110] = 'g'; +morseToChar[B10000] = 'h'; +morseToChar[B100] = 'i'; +morseToChar[B1101] = 'k'; +morseToChar[B10100] = 'l'; +morseToChar[B111] = 'm'; +morseToChar[B1 + +const int oledResetPin = 3; +Adafruit_SSD1306 display(oledResetPin); + +const int morseButtonPin = 2; + +void setup() { + Serial.begin(9600); + + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) + display.display(); + + // connect to wifi. + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("connecting"); + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + Serial.println(); + Serial.print("connected: "); + Serial.println(WiFi.localIP()); + + Firebase.begin("publicdata-cryptocurrency.firebaseio.com"); + Firebase.stream("/bitcoin/last"); +} + +const int longPressThresholdMillis = 1000; + +bool morseButtonDownTime = 0; +String currentMessage; +String currentMorseLetter; +void loop() { + // ButtonDown. + if (morseButtonDownTime == 0 && digitalRead(morseButtonPin) == LOW) { + morseButtonDownTime = millis(); + + // ButtonUp. + } else if (morseButtonDownTime != 0 && digitalRead(morseButtonPin) == HIGH) { + const int millisDown = millis() - moreseButtonDownTime; + morseButtonDownTime = 0; + + const bool longPress = millisDown >= longPressThreshold; + currentMorseLetter += longPress ? "." : "_"; + } +} From 88457595a1cd06063b49d18d561a8d103703d18d Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Wed, 18 May 2016 21:37:22 -0700 Subject: [PATCH 02/11] finished morse mapping --- .../FirebaseMorse_ESP8266.ino | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index bbf348a1..527940c0 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -30,7 +30,7 @@ // is 5 morse elements long so we would have a sparse array of 2^5=32. But // we need to add a leading 1 to ensure that .- and ..- are not the same value. // This gives us a size of 2^6=64. -char morseToChar[64]; +char morseToChar[64] = {}; morseToChar[B101] = 'a'; morseToChar[B11000] = 'b'; morseToChar[B11010] = 'c'; @@ -43,7 +43,29 @@ morseToChar[B100] = 'i'; morseToChar[B1101] = 'k'; morseToChar[B10100] = 'l'; morseToChar[B111] = 'm'; -morseToChar[B1 +morseToChar[B110] = 'n'; +morseToChar[B1111] = 'o'; +morseToChar[B10110] = 'p'; +morseToChar[B11101] = 'q'; +morseToChar[B1010] = 'r'; +morseToChar[B1000] = 's'; +morseToChar[B11] = 't'; +morseToChar[B1001] = 'u'; +morseToChar[B10001] = 'v'; +morseToChar[B1011] = 'w'; +morseToChar[B11001] = 'x'; +morseToChar[B11011] = 'y'; +morseToChar[B11100] = 'z'; +morseToChar[B101111] = '1'; +morseToChar[B100111] = '2'; +morseToChar[B100011] = '3'; +morseToChar[B100001] = '4'; +morseToChar[B100000] = '5'; +morseToChar[B110000] = '6'; +morseToChar[B111000] = '7'; +morseToChar[B111100] = '8'; +morseToChar[B111110] = '9'; +morseToChar[B111111] = '0'; const int oledResetPin = 3; Adafruit_SSD1306 display(oledResetPin); From 660059cbe48862f9fa24cf4eced32e1b13607a93 Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Fri, 20 May 2016 16:32:56 -0700 Subject: [PATCH 03/11] Morse example understanding morse --- .../FirebaseMorse_ESP8266.ino | 141 +++++++++++------- 1 file changed, 89 insertions(+), 52 deletions(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 527940c0..68d29fb1 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -30,42 +30,8 @@ // is 5 morse elements long so we would have a sparse array of 2^5=32. But // we need to add a leading 1 to ensure that .- and ..- are not the same value. // This gives us a size of 2^6=64. -char morseToChar[64] = {}; -morseToChar[B101] = 'a'; -morseToChar[B11000] = 'b'; -morseToChar[B11010] = 'c'; -morseToChar[B1100] = 'd'; -morseToChar[B10] = 'e'; -morseToChar[B10010] = 'f'; -morseToChar[B1110] = 'g'; -morseToChar[B10000] = 'h'; -morseToChar[B100] = 'i'; -morseToChar[B1101] = 'k'; -morseToChar[B10100] = 'l'; -morseToChar[B111] = 'm'; -morseToChar[B110] = 'n'; -morseToChar[B1111] = 'o'; -morseToChar[B10110] = 'p'; -morseToChar[B11101] = 'q'; -morseToChar[B1010] = 'r'; -morseToChar[B1000] = 's'; -morseToChar[B11] = 't'; -morseToChar[B1001] = 'u'; -morseToChar[B10001] = 'v'; -morseToChar[B1011] = 'w'; -morseToChar[B11001] = 'x'; -morseToChar[B11011] = 'y'; -morseToChar[B11100] = 'z'; -morseToChar[B101111] = '1'; -morseToChar[B100111] = '2'; -morseToChar[B100011] = '3'; -morseToChar[B100001] = '4'; -morseToChar[B100000] = '5'; -morseToChar[B110000] = '6'; -morseToChar[B111000] = '7'; -morseToChar[B111100] = '8'; -morseToChar[B111110] = '9'; -morseToChar[B111111] = '0'; +const int morseToCharSize = 64; +char morseToChar[morseToCharSize] = {}; const int oledResetPin = 3; Adafruit_SSD1306 display(oledResetPin); @@ -73,6 +39,8 @@ Adafruit_SSD1306 display(oledResetPin); const int morseButtonPin = 2; void setup() { + initializeMorseToChar(); + Serial.begin(9600); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) @@ -86,29 +54,98 @@ void setup() { delay(500); } Serial.println(); + Serial.print("connected: "); Serial.println(WiFi.localIP()); - - Firebase.begin("publicdata-cryptocurrency.firebaseio.com"); - Firebase.stream("/bitcoin/last"); } -const int longPressThresholdMillis = 1000; +const int shortMillis = 500; -bool morseButtonDownTime = 0; String currentMessage; -String currentMorseLetter; +int currentLetter; void loop() { - // ButtonDown. - if (morseButtonDownTime == 0 && digitalRead(morseButtonPin) == LOW) { - morseButtonDownTime = millis(); - - // ButtonUp. - } else if (morseButtonDownTime != 0 && digitalRead(morseButtonPin) == HIGH) { - const int millisDown = millis() - moreseButtonDownTime; - morseButtonDownTime = 0; + // Wait while button is up. + int upStarted = millis(); + while (digitalRead(morseButtonPin) == HIGH) { + delay(1); + } + int upTime = millis() - upStarted; + if (upTime > shortMillis*3) { + // A letter break is 3 * the length of a short (.). We give a lot of + // lee way for poor morse-coders. + if (currentLetter > morseToCharSize || morseToChar[currentLetter] == '\0') { + Serial.println("Invalid morse char, ignoring"); + } else { + currentMessage += morseToChar[currentLetter]; + } + Serial.println("Listening for new letter."); + currentLetter = B1; - const bool longPress = millisDown >= longPressThreshold; - currentMorseLetter += longPress ? "." : "_"; + if (upTime > shortMillis * 5) { + // A word break is 7 * the length of a short(.). We are being generous and + // accepting anything over 5. + currentMessage += " "; + } + } // else the upTime < shortMillis we attribute to button bounce. + Serial.println(currentMessage); + updateDisplay(currentMessage); + + int pressStarted = millis(); + // Wait while button is down. + while (digitalRead(morseButtonPin) == LOW) { + delay(1); } + int pressTime = millis() - pressStarted; + if (pressTime > shortMillis) { + // Shift the binary representation left once then set last bit to 0 or 1. + // A long is 3 times a short + currentLetter = (currentLetter << 1) | (pressTime > shortMillis*3); + } +} + +void updateDisplay(const String& message) { + display.clearDisplay(); + display.setTextSize(2); + display.setTextColor(WHITE); + display.setCursor(0,0); + display.println(message); + display.display(); +} + +void initializeMorseToChar() { + morseToChar[B101] = 'a'; + morseToChar[B11000] = 'b'; + morseToChar[B11010] = 'c'; + morseToChar[B1100] = 'd'; + morseToChar[B10] = 'e'; + morseToChar[B10010] = 'f'; + morseToChar[B1110] = 'g'; + morseToChar[B10000] = 'h'; + morseToChar[B100] = 'i'; + morseToChar[B1101] = 'k'; + morseToChar[B10100] = 'l'; + morseToChar[B111] = 'm'; + morseToChar[B110] = 'n'; + morseToChar[B1111] = 'o'; + morseToChar[B10110] = 'p'; + morseToChar[B11101] = 'q'; + morseToChar[B1010] = 'r'; + morseToChar[B1000] = 's'; + morseToChar[B11] = 't'; + morseToChar[B1001] = 'u'; + morseToChar[B10001] = 'v'; + morseToChar[B1011] = 'w'; + morseToChar[B11001] = 'x'; + morseToChar[B11011] = 'y'; + morseToChar[B11100] = 'z'; + morseToChar[B101111] = '1'; + morseToChar[B100111] = '2'; + morseToChar[B100011] = '3'; + morseToChar[B100001] = '4'; + morseToChar[B100000] = '5'; + morseToChar[B110000] = '6'; + morseToChar[B111000] = '7'; + morseToChar[B111100] = '8'; + morseToChar[B111110] = '9'; + morseToChar[B111111] = '0'; } From 06f7790cddd6961875a4245c05c90d3da035a77d Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Fri, 20 May 2016 16:36:55 -0700 Subject: [PATCH 04/11] clean up timing --- examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 68d29fb1..6d7d8442 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -71,8 +71,7 @@ void loop() { } int upTime = millis() - upStarted; if (upTime > shortMillis*3) { - // A letter break is 3 * the length of a short (.). We give a lot of - // lee way for poor morse-coders. + // A letter break is 3 * the length of a short (.). if (currentLetter > morseToCharSize || morseToChar[currentLetter] == '\0') { Serial.println("Invalid morse char, ignoring"); } else { @@ -81,9 +80,7 @@ void loop() { Serial.println("Listening for new letter."); currentLetter = B1; - if (upTime > shortMillis * 5) { - // A word break is 7 * the length of a short(.). We are being generous and - // accepting anything over 5. + if (upTime > shortMillis * 7) { currentMessage += " "; } } // else the upTime < shortMillis we attribute to button bounce. From 643301d1a4dfa1e79274438f41f999aa1070c7a9 Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Fri, 20 May 2016 16:43:49 -0700 Subject: [PATCH 05/11] tweaks --- examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 6d7d8442..38d8aec2 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -38,6 +38,9 @@ Adafruit_SSD1306 display(oledResetPin); const int morseButtonPin = 2; +void updateDisplay(const String& message); +void initializeMorseToChar(); + void setup() { initializeMorseToChar(); From 1792de0e15027312c43da407fdbcaf5c4caa0ccf Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Fri, 20 May 2016 17:12:04 -0700 Subject: [PATCH 06/11] Added onscreen indicators --- .../FirebaseMorse_ESP8266.ino | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 38d8aec2..f25cc44c 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -14,9 +14,6 @@ // limitations under the License. // -// FirebaseStream_ESP8266 is a sample that stream bitcoin price from a -// public Firebase and optionally display them on a OLED i2c screen. - #include #include #include @@ -38,7 +35,7 @@ Adafruit_SSD1306 display(oledResetPin); const int morseButtonPin = 2; -void updateDisplay(const String& message); +void updateDisplay(const String& message, const char& indicator); void initializeMorseToChar(); void setup() { @@ -63,6 +60,7 @@ void setup() { } const int shortMillis = 500; +const int longMillis = shortMillis * 3; String currentMessage; int currentLetter; @@ -70,6 +68,13 @@ void loop() { // Wait while button is up. int upStarted = millis(); while (digitalRead(morseButtonPin) == HIGH) { + if (millis() - upStarted > longMillis) { + updateDisplay(currentMessage, 'w'); + } else if (millis() - upStarted > shortMillis) { + updateDisplay(currentMessage, 'l'); + } else { + updateDisplay(currentMessage, ' '); + } delay(1); } int upTime = millis() - upStarted; @@ -83,35 +88,46 @@ void loop() { Serial.println("Listening for new letter."); currentLetter = B1; + // 7 * short timing is a new word. if (upTime > shortMillis * 7) { currentMessage += " "; } } // else the upTime < shortMillis we attribute to button bounce. Serial.println(currentMessage); - updateDisplay(currentMessage); int pressStarted = millis(); // Wait while button is down. while (digitalRead(morseButtonPin) == LOW) { + if (millis() - pressStarted > longMillis) { + updateDisplay(currentMessage, '-'); + } else if (millis() - pressStarted > shortMillis) { + updateDisplay(currentMessage, '.'); + } else { + updateDisplay(currentMessage, ' '); + } delay(1); } int pressTime = millis() - pressStarted; if (pressTime > shortMillis) { // Shift the binary representation left once then set last bit to 0 or 1. - // A long is 3 times a short - currentLetter = (currentLetter << 1) | (pressTime > shortMillis*3); + currentLetter = (currentLetter << 1) | (pressTime > longMillis); } } -void updateDisplay(const String& message) { +void updateDisplay(const String& message, const char& indicator) { display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(0,0); display.println(message); + + display.setTextSize(1); + display.setCursor(display.width() - 10, display.height() - 10); + display.print(indicator); display.display(); } + void initializeMorseToChar() { morseToChar[B101] = 'a'; morseToChar[B11000] = 'b'; From e3d77e3750534fcf6eb94074efa537fd10989cdc Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Mon, 23 May 2016 09:38:32 -0700 Subject: [PATCH 07/11] added partial morse display --- .../FirebaseMorse_ESP8266.ino | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index f25cc44c..87313af7 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -23,6 +23,9 @@ #define WIFI_SSID "SSID" #define WIFI_PASSWORD "PASSWORD" +const int shortMillis = 500; +const int longMillis = shortMillis * 3; + // We define morse . to be binary 0 and - to be binary 1. The longest letter // is 5 morse elements long so we would have a sparse array of 2^5=32. But // we need to add a leading 1 to ensure that .- and ..- are not the same value. @@ -35,7 +38,7 @@ Adafruit_SSD1306 display(oledResetPin); const int morseButtonPin = 2; -void updateDisplay(const String& message, const char& indicator); +void updateDisplay(const String& message, const char& indicator, int code); void initializeMorseToChar(); void setup() { @@ -59,9 +62,6 @@ void setup() { Serial.println(WiFi.localIP()); } -const int shortMillis = 500; -const int longMillis = shortMillis * 3; - String currentMessage; int currentLetter; void loop() { @@ -69,11 +69,11 @@ void loop() { int upStarted = millis(); while (digitalRead(morseButtonPin) == HIGH) { if (millis() - upStarted > longMillis) { - updateDisplay(currentMessage, 'w'); + updateDisplay(currentMessage, 'w', currentLetter); } else if (millis() - upStarted > shortMillis) { - updateDisplay(currentMessage, 'l'); + updateDisplay(currentMessage, 'l', currentLetter); } else { - updateDisplay(currentMessage, ' '); + updateDisplay(currentMessage, ' ', currentLetter); } delay(1); } @@ -99,11 +99,11 @@ void loop() { // Wait while button is down. while (digitalRead(morseButtonPin) == LOW) { if (millis() - pressStarted > longMillis) { - updateDisplay(currentMessage, '-'); + updateDisplay(currentMessage, '-', currentLetter); } else if (millis() - pressStarted > shortMillis) { - updateDisplay(currentMessage, '.'); + updateDisplay(currentMessage, '.', currentLetter); } else { - updateDisplay(currentMessage, ' '); + updateDisplay(currentMessage, ' ', currentLetter); } delay(1); } @@ -114,7 +114,7 @@ void loop() { } } -void updateDisplay(const String& message, const char& indicator) { +void updateDisplay(const String& message, const char& indicator, int code) { display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); @@ -122,12 +122,17 @@ void updateDisplay(const String& message, const char& indicator) { display.println(message); display.setTextSize(1); + display.setCursor(0, display.height() - 10); + const int mask = 1; + while (code > 1) { + display.print((code&mask) ? '-' : '.'); + code = code >> 1; + } display.setCursor(display.width() - 10, display.height() - 10); display.print(indicator); display.display(); } - void initializeMorseToChar() { morseToChar[B101] = 'a'; morseToChar[B11000] = 'b'; From 58c7ca2eb3697053c93e61c0e0b965b263cd3512 Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Mon, 23 May 2016 09:57:10 -0700 Subject: [PATCH 08/11] trigger github update --- examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 87313af7..e263e65b 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -23,6 +23,7 @@ #define WIFI_SSID "SSID" #define WIFI_PASSWORD "PASSWORD" + const int shortMillis = 500; const int longMillis = shortMillis * 3; From 42809b73e3e80acd4a8e320f80a21458f73cdeaa Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Mon, 23 May 2016 14:29:16 -0700 Subject: [PATCH 09/11] Fix letter break timing --- examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index e263e65b..6f48c499 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -71,7 +71,7 @@ void loop() { while (digitalRead(morseButtonPin) == HIGH) { if (millis() - upStarted > longMillis) { updateDisplay(currentMessage, 'w', currentLetter); - } else if (millis() - upStarted > shortMillis) { + } else if (millis() - upStarted > shortMillis*3) { updateDisplay(currentMessage, 'l', currentLetter); } else { updateDisplay(currentMessage, ' ', currentLetter); From 5b7bedc5cf3f5a94a8989522360cc4f229105a6f Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Mon, 23 May 2016 14:32:35 -0700 Subject: [PATCH 10/11] Fix letter/word break timing --- examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 6f48c499..6366eecd 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -69,9 +69,9 @@ void loop() { // Wait while button is up. int upStarted = millis(); while (digitalRead(morseButtonPin) == HIGH) { - if (millis() - upStarted > longMillis) { + if (millis() - upStarted > shortMillis*7) { updateDisplay(currentMessage, 'w', currentLetter); - } else if (millis() - upStarted > shortMillis*3) { + } else if (millis() - upStarted > longMillis) { updateDisplay(currentMessage, 'l', currentLetter); } else { updateDisplay(currentMessage, ' ', currentLetter); @@ -79,7 +79,7 @@ void loop() { delay(1); } int upTime = millis() - upStarted; - if (upTime > shortMillis*3) { + if (upTime > longMillis) { // A letter break is 3 * the length of a short (.). if (currentLetter > morseToCharSize || morseToChar[currentLetter] == '\0') { Serial.println("Invalid morse char, ignoring"); From 4de027f01657ed11e118c431518c8b412b716b51 Mon Sep 17 00:00:00 2001 From: Ed Coyne Date: Mon, 23 May 2016 20:29:32 -0700 Subject: [PATCH 11/11] Disable wifi, we don't use it yet. --- examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino index 6366eecd..4863e211 100644 --- a/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino +++ b/examples/FirebaseMorse_ESP8266/FirebaseMorse_ESP8266.ino @@ -49,7 +49,7 @@ void setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) display.display(); - +/* // connect to wifi. WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("connecting"); @@ -61,6 +61,7 @@ void setup() { Serial.print("connected: "); Serial.println(WiFi.localIP()); +*/ } String currentMessage;