Skip to content

Commit

Permalink
Merge pull request #12 from kd8bxp/bbt
Browse files Browse the repository at this point in the history
Updated timings, fixed sayMinutes.
  • Loading branch information
kd8bxp authored May 28, 2018
2 parents 9480de0 + e2f27ad commit a885d31
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 90 deletions.
3 changes: 3 additions & 0 deletions Information_README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ _HERTZ is abrivated to _HZ
IMPORTANT OTHER THINGS TO BE AWARE OF:
all words (underscored or otherwise) are defined and not variables. As such they should be avoided as variable names.

* Big Buddy Talker special consideration had to be taken for the Alphabets
see the BBT_example_three_Alphabets example for more information.


Big Buddy Talker default timing has changed to 850 milliseconds to account for a couple of the long words on the 3rd chip. However most words work good with the original 700 milliseconds timings. Example BBT_example_two_compound_words has more information about how to change timings on the fly

3 changes: 3 additions & 0 deletions New_Features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ https://www.instructables.com/id/A-Talking-Sensor-Si7021-and-Little-Buddy-Talker

V5.0.0 - May 2018 Updated to work with the Big Buddy Talker. (Works a bit different then previous models)

v5.0.7 - May 28, 2018 changed default timing for BBT to 850, corrected/fixxed sayMinute for BBT


89 changes: 14 additions & 75 deletions examples/BBT_d1_mini_talking_clock/BBT_d1_mini_talking_clock.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ This program is free software: you can redistribute it and/or modify
* hold the button until it speaks, it will announce the hours and minutes.
* The sketch connects to a NTP (Time Server) to grab the time. The NTPClient library is required, see below.
* The WiFiManager library is also required, see below.
* Possiable Improvement - Display Time on the 0.66" OLED.
* Possiable Improvement - Display Time on the 0.66" OLED.
*
* May 28, 2018 - Updated and simplified sketch to work with BBT Library (better)
*
*/

#include <NTPClient.h> //https://github.com/arduino-libraries/NTPClient
Expand All @@ -57,20 +60,12 @@ This program is free software: you can redistribute it and/or modify

#define BUTTON_PIN D3
#define arr_len( x ) ( sizeof ( x ) / sizeof (*x) )
#define HUNDRED 100
#define TEN 10

#define TIMEOFFSET -14400 //Find your Time Zone off set Here https://www.epochconverter.com/timezones OFF Set in Seconds
#define AMPM 1 //1 = AM PM time, 0 = MILITARY/24 HR Time

int BBTdigits[11][2] = {{_ZERO},{_ONE},{_TWO},{_THREE},{_FOUR},{_FIVE},{_SIX},{_SEVEN},{_EIGHT},{_NINE}};
int BBTdecades[7][2] = {{0x00,0},{0x00,0},{_TWENTY},{_THIRTY},{_FORTY},{_FIFTY}};
int BBTtens[11][2] = {{_TEN},{_ELEVEN},{_TWELVE},{_THIRTEEN},{_FOURTEEN},{_FIFTEEN},{_SIXTEEN},{_SEVENTEEN},{_EIGHTEEN},{_NINETEEN}};
int hundreds;
int tens;

//The Big Buddy Talker uses 4 CS select pins.
#define CS1_PIN D1
#define CS1_PIN D1
#define CS2_PIN D2
#define CS3_PIN D4
#define CS4_PIN D0
Expand All @@ -87,11 +82,13 @@ NTPClient timeClient(ntpUDP, "pool.ntp.org");
void setup(){
Serial.begin(9600);
Word100.begin();

delay(600); //wait for BBT to come online
WiFiManager wifiManager;
wifiManager.autoConnect("TalkingClock");
Serial.println("connected...yeey :)");

Word100.setDelay(500); //changed default word timings
Word100.say(_ON);
Word100.say(_LINE);
timeClient.begin();
timeClient.setTimeOffset(TIMEOFFSET);
pinMode(BUTTON_PIN, INPUT_PULLUP);
Expand All @@ -103,10 +100,8 @@ void loop() {
timeClient.update();
if (digitalRead(BUTTON_PIN) == LOW) {sayTime();}
Serial.println(timeClient.getFormattedTime());
delay(1000);
yield();

}
yield();
}

void sayTime() {
for (int i = 0; i < arr_len(sentence); i++) {
Expand All @@ -115,69 +110,13 @@ void sayTime() {
}
Word100.sayHours(timeClient.getHours());
delay(50);
sayMinute(timeClient.getMinutes());

if (AMPM) {
if (timeClient.getHours() < 12) {
Word100.say(_AM_); } else {
Word100.say(_PM_); }
}
Word100.sayMinutes(timeClient.getMinutes());
//May 28, 2018 - new issue found - minutes ending in zero (10,20,30,40,50) will not say AM or PM (?)

}

/* The code in sayMinute and sayHours is based on saynumber code
* example by Matt Ganis (matt.ganis@gmail.com) or @mattganis on Twitter
* Copyright (c) 2018 Matt Ganis
*/


int sayMinute(long number) {

if (number == 0) {

Word100.say(_ZERO); //special case for zero
return 0;
}
int period;
period = number;
tens = period / TEN;
if (tens == 1) {
Word100.say(BBTtens[period-10][0],BBTtens[period-10][1]);
period = 0; }

if (tens > 1) {
Word100.say(BBTdecades[tens][0],BBTdecades[tens][1]);
period = period - tens*TEN; } else {
Word100.say(_ZERO);
}

if (period == 0) { return 0; } else {
Word100.say(BBTdigits[period][0],BBTdigits[period][1]); }
}

/*
int sayHours(long number) {
if (number == 0) {
Word100.say(_ZERO); //special case for zero
return 0;
}
int period;
period = number;
if (AMPM) {
if (period >= 13) { period = period -12;}
}
tens = period / TEN;
if (tens == 1) {
Word100.say(BBTtens[period-10]);
period = 0; }
if (tens > 1) {
Word100.say(BBTdecades[tens]);
period = period - tens*TEN; }
if (period == 0) { return 0; } else {
Word100.say(BBTdigits[period]); }
}*/
20 changes: 20 additions & 0 deletions examples/BBT_d1_mini_talking_clock/license.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (c) 2018 LeRoy Miller
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses>
Change Log:
*/
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This program is free software: you can redistribute it and/or modify
* Word timings can be set on the fly, see the code below.
* This does take some trial and error, but produces some nice effects.
* Copyright (c) 2018 LeRoy Miller
* Updated May 28, 2018 - LeRoy Miller
*/

/* Big Buddy Talker Arduino UNO Hookup
Expand Down Expand Up @@ -87,17 +88,22 @@ Word100.say(_BUDDY);
*
* Timings are tricky and take some trial and error
* to get right.
*
* Big Buddy Talker has a default timing of 850, which is too
* long for most words, but needed for the few really long words/sentences
* Under most conditions a timing of 700 works pretty well, but does
* sound a little robotic.
*/

Word100.setDelay(475);
Word100.say(_COUNTER);
Word100.setDelay(700); //default timing for most words
Word100.setDelay(700); //timing that works for most words
Word100.say(_CLOCKWISE);

//lighting
Word100.setDelay(450);
Word100.say(_LIGHT);
Word100.setDelay(700); //default timing for most words
Word100.setDelay(700); //timing that works for most words
Word100.say(_ING);

//micrometers
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Word100 Library
version=5.0.6
version=5.0.7
author=LeRoy Miller
maintainer=LeRoy Miller <kd8bxp@aol.com>
sentence=Library for 100+ Word Shield and LBT
Expand Down
18 changes: 6 additions & 12 deletions src/Word100BBT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ This program is free software: you can redistribute it and/or modify
May 4, 2018 Updated for the Big Buddy Talker, LeRoy Miller (2018 (c))
May 12, 2018 sayNumber functions (minutes,hours) all working again.
Made small change to how setAMPM work, but nothing that effects the sketches
May 28, 2018 Updated timing to 850, and fixed sayMinute issues
*/

// Connect pin#13 (SCLK) To S2 on AP23
// Connect pin#11 (DATOUT) To S3 on AP23
// Connect pin#13 (SCLK) To S2 on AP23
// Connect pin#10 (CS) To S1 on AP23
// GPIO 9 = STOP
// DO from Ap23 optional S4 - Not used here
// ** Add stop bit so that MCU knows then the chip has stopped talking. OUT1 is what you'll want to use


#define _PLAY_ 0x98
#define _RAMPUP 0xA8 //COUT ramp up - this value never changes
Expand All @@ -53,7 +47,7 @@ _cs[1] = cs2;
_cs[2] = cs3;
_cs[3] = cs4;
Word100bbt::setAMPM(1);
Word100bbt:setDelay(700); //default delay is about 700 milliseconds
Word100bbt:setDelay(850); //default delay is about 850 milliseconds
}

void Word100bbt::begin() {
Expand Down Expand Up @@ -94,7 +88,7 @@ void Word100bbt::say(int value, int pin) // Calling this function reads words
int Word100bbt::sayMinutes(long number) {
if (number == 0) {

Word100bbt::say(_ZERO); //special case for zero
//Word100bbt::say(_ZERO); //special case for zero
return 0;
}

Expand All @@ -108,9 +102,9 @@ if (number == 0) {
if (_tens > 1) {
Word100bbt::say(_sayDecades[_tens][0],_sayDecades[_tens][1]);
_period = _period - _tens*TEN; } else {
Word100bbt::say(_ZERO);
//Word100bbt::say(_ZERO);
}

if (number < 10) { Word100bbt::say(_ZERO); }
if (_period == 0) { return 0; } else {
Word100bbt::say(_sayDigits[_period][0],_sayDigits[_period][1]);
}
Expand Down

0 comments on commit a885d31

Please sign in to comment.