Skip to content

Instantly share code, notes, and snippets.

@kd8bxp
Created May 2, 2018 23:13
Show Gist options
  • Save kd8bxp/3b7bdba11cefb79627e9402076514609 to your computer and use it in GitHub Desktop.
Save kd8bxp/3b7bdba11cefb79627e9402076514609 to your computer and use it in GitHub Desktop.
Little Buddy Talker CPP code for Raspberry PI - based on the original Arduino code for the LBT. This just says all the words in the device.
/*
* Based on example code found at:
* https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial
* and the original Arduino code for the Little Buddy Talker
* http://www.engineeringshock.com/the-little-buddy-talker-project-page.html
* April 2018 by LeRoy Miller (C) 2018
* This example says all of the 254 words in the LBT.
*/
#include <iostream>
#include <errno.h>
#include <wiringPiSPI.h>
#include <unistd.h>
#include <wiringPi.h>
using namespace std;
static const int CHANNEL = 1;
int value1 = 0x98; // play command - This value never changes
int value2 = 0; // voice address - when you place a hex value in this integer and call the "readout()" function, that specific word will play
int value3 = 0xA8; // COUT ramp up - This value never changes
int value4 = 0xB8; // COUT ramp down - This value never changes
// ALL OF THE ABOVE CODE IS REQUIRED FOR THE OPERATION OF THE LBT
// value2 and value4 are not used in this example.
unsigned char buffer[20]; //probably a lot more than we need.
int main() {
wiringPiSPISetup(CHANNEL, 500000);
delay(1000); // One second delay
// ramp up Little Buddy Talker
buffer[0] = value3;
wiringPiSPIDataRW(CHANNEL,buffer,2);
buffer[0] = 0x00;
wiringPiSPIDataRW(CHANNEL,buffer,2);
for (int i = 0; i <= 254; i++) {
delay(7);
// Transmit Data
buffer[0] = value1;
buffer[1] = i;
wiringPiSPIDataRW(CHANNEL,buffer,2); // Send word address and play
delay(700); // As soon as the word starts to play, this delay starts. You need to give the word enough time to play. Once the delay is done,
// Another word can be played. Play around with this delay if you wish.
delay(50);
}
}
@kd8bxp
Copy link
Author

kd8bxp commented May 2, 2018

compile with gcc.
Used on the April 2018 release of Raspbian (Full install)
Does not use the Word100 Library, the library should work on the Raspberry PI but I've not verified that.

@kd8bxp
Copy link
Author

kd8bxp commented May 2, 2018

I take that back, the library will need to be re-written for the raspberry pi - it's on my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment