Skip to content

Commit

Permalink
Merge pull request #12 from oroca/develop
Browse files Browse the repository at this point in the history
merge from develop
  • Loading branch information
hancheol-cho authored Mar 22, 2019
2 parents 5911de0 + 37d4ba5 commit b657a51
Show file tree
Hide file tree
Showing 34 changed files with 3,747 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"vector": "cpp",
"xhash": "cpp",
"xstring": "cpp",
"xutility": "cpp"
"xutility": "cpp",
"iosfwd": "cpp"
}
}
2 changes: 0 additions & 2 deletions examples/Audio/PlayFile/PlayFile.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://blog.naver.com/chcbaram/221416603068
*/

EduBot edubot;



void setup() {
Expand Down
17 changes: 0 additions & 17 deletions examples/BLE/BLE_Driver/BLE_Driver.ino

This file was deleted.

1 change: 0 additions & 1 deletion examples/EduBot_App/EduBot_App.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <image/EduBoy.h>


EduBot edubot;

#define MOTOR_SERVICE_UUID "e005"
#define MOTOR_CHARACTERISTIC_SET_STEP_UUID "34443c33-3356-11e9-b210-d663bd873d93"
Expand Down
44 changes: 44 additions & 0 deletions examples/EduBot_Main/EduBot_Main.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <EduBot.h>


extern void scratch_setup();
extern void scratch_loop();
extern void linetrace_setup();
extern void linetrace_loop();
extern void stepmotor_setup();
extern void stepmotor_loop();
extern void getacc_setup();
extern void getacc_loop();
extern void getgyro_setup();
extern void getgyro_loop();
extern void getrpy_setup();
extern void getrpy_loop();
extern void tof_setup();
extern void tof_loop();
extern void audio_setup();
extern void audio_loop();
extern void neopixel_setup();
extern void neopixel_loop();


void setup() {
// put your setup code here, to run once:
edubot.begin(115200);

edubot.menuAdd("스크래치 3.0", scratch_setup, scratch_loop);
edubot.menuAdd("LineTrace", linetrace_setup, linetrace_loop);
edubot.menuAdd("StepMotor", stepmotor_setup, stepmotor_loop);
edubot.menuAdd("GetAcc", getacc_setup, getacc_loop);
edubot.menuAdd("GetGyro", getgyro_setup, getgyro_loop);
edubot.menuAdd("GetRPY", getrpy_setup, getrpy_loop);
edubot.menuAdd("ToF", tof_setup, tof_loop);
edubot.menuAdd("Audio", audio_setup, audio_loop);
edubot.menuAdd("NeoPixel", neopixel_setup, neopixel_loop);
}

void loop() {
// put your main code here, to run repeatedly:
edubot.menuUpdate();
}


2,439 changes: 2,439 additions & 0 deletions examples/EduBot_Main/src/Audio.cpp

Large diffs are not rendered by default.

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




void getacc_setup() {
// put your setup code here, to run once:
edubot.begin(115200);
}

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


if (millis()-pre_time >= 50)
{
pre_time = millis();

edubot.lcd.clearDisplay();
edubot.lcd.printf(16*0, 16*0, "aX : %f",edubot.imu.getAccX());
edubot.lcd.printf(16*0, 16*1, "aY : %f",edubot.imu.getAccY());
edubot.lcd.printf(16*0, 16*2, "aZ : %f",edubot.imu.getAccZ());
edubot.lcd.display();

Serial.print("aX : ");
Serial.print(edubot.imu.getAccX());
Serial.print("\taY : ");
Serial.print(edubot.imu.getAccY());

Serial.print("\taZ : ");
Serial.print(edubot.imu.getAccZ());
Serial.println();
}
}
34 changes: 34 additions & 0 deletions examples/EduBot_Main/src/GetGyro.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <EduBot.h>



void getgyro_setup() {
// put your setup code here, to run once:
edubot.begin(115200);
}

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


if (millis()-pre_time >= 50)
{
pre_time = millis();

edubot.lcd.clearDisplay();
edubot.lcd.printf(16*0, 16*0, "gX : %f",edubot.imu.getGyroX());
edubot.lcd.printf(16*0, 16*1, "gY : %f",edubot.imu.getGyroY());
edubot.lcd.printf(16*0, 16*2, "gZ : %f",edubot.imu.getGyroZ());
edubot.lcd.display();

Serial.print("gX : ");
Serial.print(edubot.imu.getGyroX());
Serial.print("\tgY : ");
Serial.print(edubot.imu.getGyroY());

Serial.print("\tgZ : ");
Serial.print(edubot.imu.getGyroZ());
Serial.println();
}
}
34 changes: 34 additions & 0 deletions examples/EduBot_Main/src/GetRPY.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <EduBot.h>




void getrpy_setup() {
// put your setup code here, to run once:
edubot.begin(115200);
}

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

if (millis()-pre_time >= 50)
{
pre_time = millis();

edubot.lcd.clearDisplay();
edubot.lcd.printf(16*0, 16*0, "R : %f",edubot.imu.getRoll());
edubot.lcd.printf(16*0, 16*1, "P : %f",edubot.imu.getPitch());
edubot.lcd.printf(16*0, 16*2, "Y : %f",edubot.imu.getYaw());
edubot.lcd.display();

Serial.print("R : ");
Serial.print(edubot.imu.getRoll());
Serial.print("\tP : ");
Serial.print(edubot.imu.getPitch());

Serial.print("\tY : ");
Serial.print(edubot.imu.getYaw());
Serial.println();
}
}
92 changes: 92 additions & 0 deletions examples/EduBot_Main/src/LineTrace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include <EduBot.h>




static int step_speed = 90;

void linetrace_setup() {
// put your setup code here, to run once:

edubot.begin(115200);
}

void linetrace_loop() {
// put your main code here, to run repeatedly
int x = 0;
int y = 0;
int sen[4];
static uint8_t mode = 0;
static int line_pos = 0;


edubot.lcd.clearDisplay();


sen[0] = edubot.floor_sensor.getRightOut();
sen[1] = edubot.floor_sensor.getRightIn();
sen[2] = edubot.floor_sensor.getLeftIn();
sen[3] = edubot.floor_sensor.getLeftOut();


if (mode == 0)
{
edubot.lcd.printf(0, 16*0, "%d", sen[0]);
edubot.lcd.printf(0, 16*1, "%d", sen[1]);
edubot.lcd.printf(0, 16*2, "%d", sen[2]);
edubot.lcd.printf(0, 16*3, "%d", sen[3]);
}
else if (mode == 1)
{
for (int i=0; i<4; i++)
{
sen[i] = map(sen[i], 0, 255, 1, 60);
edubot.lcd.fillRect(11 + 32*i, 64-sen[i], 10, sen[i], WHITE);
}

line_pos = (sen[1]-sen[2])/1;

edubot.lcd.fillRect(64- 5 + line_pos, 4, 10, 4, WHITE);


int left_speed;
int right_speed;

left_speed = step_speed - line_pos*2;
right_speed = step_speed + line_pos*2;

if ( sen[1] < 2 && sen[2] < 2)
{
left_speed = 0;
right_speed = 0;
}

edubot.led.leftBright(0, sen[2], 0);
edubot.led.rightBright(0, sen[1], 0);

if (edubot.tof_L.distance_mm < 60 || edubot.tof_R.distance_mm < 80)
{
left_speed = 0;
right_speed = 0;
}
edubot.motor.setSpeed(left_speed, right_speed);

}
else
{
edubot.motor.setSpeed(0, 0);
edubot.lcd.printf(0, 0 , "L %d mm", edubot.tof_L.distance_mm);
edubot.lcd.printf(0, 16, "R %d mm", edubot.tof_R.distance_mm);
}
edubot.lcd.display();

delay(1);

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

mode++;
mode %= 3;
}
}
57 changes: 57 additions & 0 deletions examples/EduBot_Main/src/NeoPixel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <EduBot.h>





void neopixel_setup() {
// put your setup code here, to run once:

edubot.begin(115200);

}

void neopixel_loop() {
// put your main code here, to run repeatedly
static uint8_t led_bright = 0;
static int led_dir = 1;
static int led_index = 0;


edubot.lcd.clearDisplay();

if (led_index == 0)
{
edubot.led.leftBright(led_bright, 0, 0);
edubot.led.rightBright(led_bright, 0, 0);

edubot.lcd.printf(16*0, 16*0, "빨간색 : %d", led_bright);
}
else if(led_index == 1)
{
edubot.led.leftBright(0, led_bright, 0);
edubot.led.rightBright(0, led_bright, 0);
edubot.lcd.printf(16*0, 16*0, "그린색 : %d", led_bright);
}
else
{
edubot.led.leftBright(0, 0, led_bright);
edubot.led.rightBright(0, 0, led_bright);
edubot.lcd.printf(16*0, 16*0, "파란색 : %d", led_bright);
}
edubot.lcd.display();

led_bright += led_dir;

if (led_bright == 255)
{
led_dir = -1;
}
if (led_bright == 0)
{
led_dir = 1;
led_index++;
led_index %= 3;
}
delay(2);
}
Loading

0 comments on commit b657a51

Please sign in to comment.