diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 81 |
1 files changed, 49 insertions, 32 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2298f4d..2e9aa7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,7 @@ enum RobotEmotion { volatile RobotEmotion currentState = E_NEUTRAL;
volatile char manualMotors = '0';
+volatile char manualRGB = '0';
String ipRobot = "Connection error";
WiFiUDP udp;
@@ -95,6 +96,7 @@ void wifiTask(void * pvParameters) { if (millis() - emotionStartTime >= EMOTION_DURATION_MS) {
currentState = MANUAL;
manualMotors = '0';
+ manualRGB = '0';
}
}
@@ -109,15 +111,15 @@ void oledSetup(){ display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
roboEyes.begin(OLED_WIDTH, OLED_HEIGHT, 50);
- display.clearDisplay();
- display.setTextSize(1);
- display.setTextColor(SSD1306_WHITE);
- display.setCursor(0, 10);
- display.println("Connected:");
- display.print("IP: ");
- display.println(ipRobot);
- display.display();
- delay(5000);
+ // display.clearDisplay();
+ // display.setTextSize(1);
+ // display.setTextColor(SSD1306_WHITE);
+ // display.setCursor(0, 10);
+ // display.println("Connected:");
+ // display.print("IP: ");
+ // display.println(ipRobot);
+ // display.display();
+ // delay(5000);
roboEyes.setAutoblinker(ON, 3, 2);
roboEyes.setIdleMode(ON, 2, 2);
@@ -154,37 +156,52 @@ void oledTask(void * pvParameters) { /*================================= RGB =================================*/
void rgbTask(void * pvParameters) {
- RobotEmotion lastEmotion = E_NEUTRAL;
+ RobotEmotion lastAction = E_NEUTRAL;
rgb.setColorRGB(0, 0, 0, true);
for(;;) {
- if (currentState != lastEmotion) {
+ if (currentState != lastAction) {
switch(currentState) {
case E_HAPPY: rgb.fadeColor(255, 250, 0, 500); break;
case E_SAD: rgb.fadeColor(118, 116, 237, 500); break;
case E_ANGRY: rgb.fadeColor(255, 0, 0, 500); break;
- case E_NEUTRAL:
default: rgb.fadeColor(0, 0, 0, 500); break;
}
- lastEmotion = currentState;
+ lastAction = currentState;
}
- switch(currentState) {
- case E_HAPPY:
- rgb.setBrightness(40);
- rgb.rainbowCycle(1000, 2);
- break;
- case E_SAD:
- rgb.setBrightness(40);
- break;
- case E_ANGRY:
- rgb.setBrightness(100);
- rgb.blink(1, 300);
- break;
- case E_NEUTRAL:
- default:
- break;
+ if (currentState == MANUAL) {
+ switch(manualMotors) {
+ case 'F':
+ break;
+ case 'B':
+ rgb.setBrightness(50);
+ rgb.setColorRGB(255, 100, 0);
+ rgb.blink(1, 300);
+ rgb.setColorRGB(0, 0, 0, 0);
+ break;
+ case 'L': ; break;
+ case 'R': ; break;
+ default:; break;
+ }
+ } else {
+ switch(currentState) {
+ case E_HAPPY:
+ rgb.setBrightness(40);
+ rgb.rainbowCycle(1000, 2);
+ break;
+ case E_SAD:
+ rgb.setBrightness(40);
+ break;
+ case E_ANGRY:
+ rgb.setBrightness(100);
+ rgb.blink(1, 300);
+ break;
+ case E_NEUTRAL:
+ default:
+ break;
+ }
}
vTaskDelay(20 / portTICK_PERIOD_MS);
}
@@ -206,12 +223,12 @@ void motorsTask(void * pvParameters) { } else {
switch(currentState) {
case E_HAPPY:
- motors.leftTurn(100, 1000);
- motors.rightTurn(100, 1000);
+ motors.leftTurn(100, 130);
+ motors.rightTurn(100, 130);
break;
case E_ANGRY:
- motors.forward(100, 1000);
- motors.backward(100, 1000);
+ motors.forward(100, 130);
+ motors.backward(100, 130);
break;
default:
motors.stop();
|