EasyManua.ls Logo

Freenove ESP32 - Page 148

Default Icon
159 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Need support? support@freenove.com
146
Chapter 15 Dog
www.freenove.com
115
116
117
118
119
120
121
122
123
124
125
126
case ACTION_BODY_HEIGHT:
case ACTION_MOVE_ANY:
case ACTION_TWIST:
case ACTION_DANCING:
mqMotion.enterForced(msg);
controlTask(TASK_MOTION_SERVICE, TASK_RESUME);
break;
default:
mqInfo.enterForced(msg);
break;
}
}
Message queue. Each time instructions are received, they will be stored in a queue and waiting for the
main thread to parse and execute it one by one.
3
4
DataQueue<String> mqMotion(2); // Motion message queue, When there are too many messages, some
messages can be ignored to reduce latency.
DataQueue<String> mqInfo(100); // Info message queue, Important, can not ignore.
Initialize the robot dog's drivers.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Serial.begin(115200);
Serial.println("\n\nProgram begin ... ");
bleSetup();
prefs.begin(NMSPC_STORAGE);
pca.begin();
pca.releaseAllServo();
getServoOffsetFromStorage();
getLedConfigFromStorage();
cs.begin();
setupAdc();
setupBuzzer();
setupSonar();
setupRGBLED();
setupBuiltInLed();
setupTouchPad();
Serial.println("setup finished!\n\n");
Receive commands by Serial.
60
61
62
63
64
65
66
67
68
void serialEventRun() {
static String serialInputString = "";
while (Serial.available()) {
char inChar = (char)Serial.read();
serialInputString += inChar;
if (inChar == '\n') {
enterMessageQueue(serialInputString);
serialInputString = "";
}

Related product manuals