Commit 9ac3f2a2 authored by Wouter Klop's avatar Wouter Klop

Wireless related tasks now run on core 0, closing #7

parent 2f8c0abc
......@@ -22,6 +22,12 @@ Hit the upload button. Currently, the auto reset functionality of the ESP32 modu
## OTA upload
When the ESP32 boots, it's IP address is printed. In platformio.ini, fill in this IP address under upload_port. Or, even better, use the hostname balancingRobot.local. This means you don't have to mess around with IP addresses. Make sure to be connected to the same WiFi network as the ESP32, and hit upload.
## File system
Initially, or when changing the web page files, you need to upload the file system. To do so, open a terminal within the PlatformIO environment, and run:
platformio run --target uploadfs
This will upload all content of the data folder to the ESP32 flash memory (either via the serial port or OTA).
# WiFi connection
After flashing, the ESP32 will start an access point (AP), named balancingRobot. The default key is "turboturbo". Once connected, open the balancingRobot web configuration page. Here, among others, you can change the WiFi options. Under "WiFi configuration", enter the SSID and key of your home network, change the selector from "AP" to "SSID", and click the "set" button, followed by the "reboot" button. If all goes well, the ESP32 will now connect to your home network.
......
......@@ -29,10 +29,6 @@ void FlySkyIBus::begin(Stream& stream)
void FlySkyIBus::loop(void)
{
// static uint32_t tStart = 0;
// if (state!=DISCARD && (millis()-tStart>2)) state = DISCARD;
while (stream->available() > 0)
{
uint32_t now = millis();
......
......@@ -868,6 +868,3 @@ void WebSocketsServer::handleHeader(WSclient_t * client, String * headerLine) {
}
}
}
......@@ -15,4 +15,5 @@ framework = arduino
monitor_port = COM3
monitor_speed = 115200
; upload_port = COM3
upload_port = balancingrobot.local
; upload_port = balancingrobot.local
upload_port = 192.168.178.35
......@@ -89,7 +89,7 @@ fastStepper motLeft(5, 4, 0, motLeftTimerFunction);
fastStepper motRight(2, 15, 1, motRightTimerFunction);
uint8_t microStep = 32;
uint8_t motorCurrent = 100;
uint8_t motorCurrent = 150;
float maxStepSpeed = 3000;
// -- PID control
......@@ -145,6 +145,18 @@ void setMotorCurrent() {
dacWrite(motorCurrentPin, motorCurrent);
}
uint8_t x = 0;
void wirelessTask(void * parameters) {
while (1) {
IBus.loop();
wsServer.loop(); // Shouldn't this run on core 0?
// x++;
// Serial.println(x);
delay(1);
}
}
// ----- Main code
void setup() {
......@@ -302,6 +314,15 @@ void setup() {
pidSpeed.setParameters(6,5,0,20);
pidSpeed.setpoint = 0;
xTaskCreatePinnedToCore(
wirelessTask, /* Function to implement the task */
"wirelessTask", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
Serial.println("Ready");
}
......@@ -481,9 +502,7 @@ void loop() {
// Run other tasks
ArduinoOTA.handle();
IBus.loop();
wsServer.loop(); // Shouldn't this run on core 0?
// delay(1);
}
void parseSerial() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment