Skip to content

Commit

Permalink
Merge pull request #25 from oroca/develop
Browse files Browse the repository at this point in the history
TTS 추가, WiFi 셋업 추가,
  • Loading branch information
hancheol-cho authored Apr 17, 2019
2 parents f3ebb40 + b475cff commit f224411
Show file tree
Hide file tree
Showing 22 changed files with 6,875 additions and 182 deletions.
65 changes: 65 additions & 0 deletions examples/Audio/PlayRadio/PlayRadio.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <EduBot.h>



void setup() {
// put your setup code here, to run once:
bool ret;

edubot.begin(115200);

ret = edubot.wifi.begin();

if (ret == true)
{
edubot.lcd.printf(0, 0, "WiFi OK");
edubot.lcd.display();
}
else
{
edubot.lcd.printf(0, 0, "WiFi Fail");
edubot.lcd.display();
}

edubot.audio.setVolume(50);
edubot.audio.playURL("onair.radiogfm.kr:8003");
}

void loop() {
// put your main code here, to run repeatedly
uint32_t pre_time;


pre_time = micros();
edubot.lcd.clearDisplay();
edubot.lcd.printf(0, 0, "Radio");
edubot.lcd.printf(0, 16, "%d", millis());

if (edubot.audio.isBusy())
{
edubot.lcd.printf(0, 32, "Playing");
}
else
{
edubot.lcd.printf(0, 32, "Stop");
}

edubot.lcd.display();
delay(50);

if (edubot.buttonGetPressed())
{
while(edubot.buttonGetPressed());

if (edubot.audio.isBusy())
{
edubot.audio.playStop();
}
else
{
edubot.audio.playURL("onair.radiogfm.kr:8003");
}
}
}


67 changes: 67 additions & 0 deletions examples/Audio/PlayTTS/PlayTTS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <EduBot.h>


void playTTS(void)
{
edubot.audio.playTTS("안녕하세요. 저의 이름은 에듀봇이에요. 나이는 1살이에요. 이것은 구글 TTS를 이용해서 음성을 출력해 본것이에요. 조금은 느리지만 동작은 되네요. ", "ko", false);
}

void setup() {
// put your setup code here, to run once:
bool ret;

edubot.begin(115200);

ret = edubot.wifi.begin();

if (ret == true)
{
edubot.lcd.printf(0, 0, "WiFi OK");
edubot.lcd.display();
}
else
{
edubot.lcd.printf(0, 0, "WiFi Fail");
edubot.lcd.display();
}
edubot.audio.setVolume(50);
playTTS();
}

void loop() {
// put your main code here, to run repeatedly
uint32_t pre_time;


pre_time = micros();
edubot.lcd.clearDisplay();
edubot.lcd.printf(0, 0, "TTS");
edubot.lcd.printf(0, 16, "%d", millis());

if (edubot.audio.isBusy())
{
edubot.lcd.printf(0, 32, "Playing");
}
else
{
edubot.lcd.printf(0, 32, "Stop");
}

edubot.lcd.display();
delay(50);

if (edubot.buttonGetPressed())
{
while(edubot.buttonGetPressed());

if (edubot.audio.isBusy())
{
edubot.audio.playStop();
}
else
{
playTTS();
}
}
}

9 changes: 5 additions & 4 deletions examples/BLE/EduBot_BitBlue/EduBot_BitBlue.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* Authors: byeongkyu, baram */

#define EDUBOT_DRIVER_BLE

#include <EduBot.h>
#include <image/EduBoy.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>




Expand Down
8 changes: 7 additions & 1 deletion examples/EduBot_Main/EduBot_Main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace AppNeoPixel { extern void setup(); extern void loop(); }
namespace AppIrRemote { extern void setup(); extern void loop(); }
namespace AppBattery { extern void setup(); extern void loop(); }
namespace AppBitBlue { extern void setup(); extern void loop(); }
namespace AppPlayTTS { extern void setup(); extern void loop(); }
namespace AppPlayRadio { extern void setup(); extern void loop(); }
namespace AppWifiSetup { extern void setup(); extern void loop(); }


void setup() {
Expand All @@ -30,7 +33,10 @@ void setup() {
edubot.menuAdd("Audio", AppAudio::setup, AppAudio::loop);
edubot.menuAdd("NeoPixel", AppNeoPixel::setup, AppNeoPixel::loop);
edubot.menuAdd("IrRemote", AppIrRemote::setup, AppIrRemote::loop);
edubot.menuAdd("Battery", AppBattery::setup, AppBattery::loop);
edubot.menuAdd("Battery", AppBattery::setup, AppBattery::loop);
edubot.menuAdd("PlayTTS", AppPlayTTS::setup, AppPlayTTS::loop);
edubot.menuAdd("PlayRadio", AppPlayRadio::setup, AppPlayRadio::loop);
edubot.menuAdd("WiFi Setup", AppWifiSetup::setup, AppWifiSetup::loop);
}

void loop() {
Expand Down
67 changes: 67 additions & 0 deletions examples/EduBot_Main/src/PlayRadio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <EduBot.h>


namespace AppPlayRadio
{

void setup() {
// put your setup code here, to run once:
bool ret;

edubot.begin(115200);

ret = edubot.wifi.begin();

if (ret == true)
{
edubot.lcd.printf(0, 0, "WiFi OK");
edubot.lcd.display();
}
else
{
edubot.lcd.printf(0, 0, "WiFi Fail");
edubot.lcd.display();
}

edubot.audio.setVolume(50);
edubot.audio.playURL("onair.radiogfm.kr:8003");
}

void loop() {
// put your main code here, to run repeatedly
uint32_t pre_time;


pre_time = micros();
edubot.lcd.clearDisplay();
edubot.lcd.printf(0, 0, "Radio");
edubot.lcd.printf(0, 16, "%d", millis());

if (edubot.audio.isBusy())
{
edubot.lcd.printf(0, 32, "Playing");
}
else
{
edubot.lcd.printf(0, 32, "Stop");
}

edubot.lcd.display();
delay(50);

if (edubot.buttonGetPressed())
{
while(edubot.buttonGetPressed());

if (edubot.audio.isBusy())
{
edubot.audio.playStop();
}
else
{
edubot.audio.playURL("onair.radiogfm.kr:8003");
}
}
}

}
71 changes: 71 additions & 0 deletions examples/EduBot_Main/src/PlayTTS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <EduBot.h>


namespace AppPlayTTS
{

void playTTS(void)
{
edubot.audio.playTTS("안녕하세요. 저의 이름은 에듀봇이에요. 나이는 1살이에요. 이것은 구글 TTS를 이용해서 음성을 출력해 본것이에요. 조금은 느리지만 동작은 되네요. ", "ko", false);
}

void setup() {
// put your setup code here, to run once:
bool ret;

edubot.begin(115200);

ret = edubot.wifi.begin();

if (ret == true)
{
edubot.lcd.printf(0, 0, "WiFi OK");
edubot.lcd.display();
}
else
{
edubot.lcd.printf(0, 0, "WiFi Fail");
edubot.lcd.display();
}
edubot.audio.setVolume(50);
playTTS();
}

void loop() {
// put your main code here, to run repeatedly
uint32_t pre_time;


pre_time = micros();
edubot.lcd.clearDisplay();
edubot.lcd.printf(0, 0, "TTS");
edubot.lcd.printf(0, 16, "%d", millis());

if (edubot.audio.isBusy())
{
edubot.lcd.printf(0, 32, "Playing");
}
else
{
edubot.lcd.printf(0, 32, "Stop");
}

edubot.lcd.display();
delay(50);

if (edubot.buttonGetPressed())
{
while(edubot.buttonGetPressed());

if (edubot.audio.isBusy())
{
edubot.audio.playStop();
}
else
{
playTTS();
}
}
}

}
24 changes: 15 additions & 9 deletions examples/EduBot_Main/src/Scratch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ int8_t request_display_image = 0;

int8_t request_motor_wait_result = 0;

BLECharacteristic *mCharSensorFloorSensors = NULL;
BLECharacteristic *mCharSensorDistanceSensors = NULL;
BLECharacteristic *mCharSensorImuSensor = NULL;
//BLECharacteristic *mCharSensorFloorSensors = NULL;
//BLECharacteristic *mCharSensorDistanceSensors = NULL;
//BLECharacteristic *mCharSensorImuSensor = NULL;
BLECharacteristic *mCharMiscStatusInfo = NULL;
BLECharacteristic *mCharSensorAllData = NULL;

Expand Down Expand Up @@ -499,6 +499,7 @@ void setup() {
BLEService *mServiceSensor = mServer->createService(BLEUUID(SENSOR_SERVICE_UUID), 20);

// Floor Sensor
/*
mCharSensorFloorSensors = mServiceSensor->createCharacteristic(
SENSOR_CHARACTERISTIC_FLOOR_SENSORS_UUID,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
Expand All @@ -507,7 +508,9 @@ void setup() {
mDescSensorFloorSensors->setValue("Floor Sensors");
mCharSensorFloorSensors->addDescriptor(mDescSensorFloorSensors);
mCharSensorFloorSensors->addDescriptor(new BLE2902());
*/

/*
// Distance Sensor
mCharSensorDistanceSensors = mServiceSensor->createCharacteristic(
SENSOR_CHARACTERISTIC_DISTANCE_SENSOR_UUID,
Expand All @@ -517,8 +520,10 @@ void setup() {
mDescSensorDistanceSensors->setValue("Distance Sensors");
mCharSensorDistanceSensors->addDescriptor(mDescSensorDistanceSensors);
mCharSensorDistanceSensors->addDescriptor(new BLE2902());
*/

// Imu Sensor
/*
mCharSensorImuSensor = mServiceSensor->createCharacteristic(
SENSOR_CHARACTERISTIC_IMU_SENSOR_UUID,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
Expand All @@ -527,6 +532,7 @@ void setup() {
mDescSensorImuSensor->setValue("Imu Sensor");
mCharSensorImuSensor->addDescriptor(mDescSensorImuSensor);
mCharSensorImuSensor->addDescriptor(new BLE2902());
*/

// All Data
mCharSensorAllData = mServiceSensor->createCharacteristic(
Expand Down Expand Up @@ -646,11 +652,11 @@ void loop() {
value_sensor_floor_sensors[1] = edubot.floor_sensor.getRightIn();
value_sensor_floor_sensors[2] = edubot.floor_sensor.getLeftIn();
value_sensor_floor_sensors[3] = edubot.floor_sensor.getLeftOut();
mCharSensorFloorSensors->setValue((uint8_t*)&value_sensor_floor_sensors, 4);
//mCharSensorFloorSensors->setValue((uint8_t*)&value_sensor_floor_sensors, 4);

value_sensor_distance_sensors[0] = edubot.tof_L.distance_mm;
value_sensor_distance_sensors[1] = edubot.tof_R.distance_mm;
mCharSensorDistanceSensors->setValue((uint8_t*)&value_sensor_distance_sensors, 4);
//mCharSensorDistanceSensors->setValue((uint8_t*)&value_sensor_distance_sensors, 4);

value_sensor_imu_sensor[0] = (int16_t)(edubot.imu.getRoll() * 100.0);
value_sensor_imu_sensor[1] = (int16_t)(edubot.imu.getPitch() * 100.0);
Expand All @@ -662,12 +668,12 @@ void loop() {
value_sensor_imu_sensor[7] = (int16_t)(edubot.imu.getGyroY() * 100.0);
value_sensor_imu_sensor[8] = (int16_t)(edubot.imu.getGyroZ() * 100.0);

mCharSensorImuSensor->setValue((uint8_t*)&value_sensor_imu_sensor, 18);
//mCharSensorImuSensor->setValue((uint8_t*)&value_sensor_imu_sensor, 18);

if(device_connected) {
mCharSensorFloorSensors->notify();
mCharSensorDistanceSensors->notify();
mCharSensorImuSensor->notify();
//mCharSensorFloorSensors->notify();
//mCharSensorDistanceSensors->notify();
//mCharSensorImuSensor->notify();
}

status_update_sensors_count = 0;
Expand Down
Loading

0 comments on commit f224411

Please sign in to comment.