Initialise arrays on the stack in esp32 servo
This commit is contained in:
@@ -33,27 +33,25 @@ void setupServos(uint8_t size, uint8_t *calibrationValues)
|
|||||||
|
|
||||||
void modifyServo(uint8_t channel, uint8_t newAngle)
|
void modifyServo(uint8_t channel, uint8_t newAngle)
|
||||||
{
|
{
|
||||||
if(servos.count(channel) > 0){
|
if (servos.count(channel) > 0)
|
||||||
|
{
|
||||||
servos[channel]->write(newAngle);
|
servos[channel]->write(newAngle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
uint8_t *header = new uint8_t[2];
|
uint8_t header[2];
|
||||||
Serial.readBytes(header, 2);
|
Serial.readBytes(header, 2);
|
||||||
|
|
||||||
if (header[0] == 0)
|
if (header[0] == 0)
|
||||||
{
|
{
|
||||||
uint8_t *calibration = new uint8_t[2 * header[1]];
|
uint8_t calibration[2 * header[1]];
|
||||||
Serial.readBytes(calibration, header[1]);
|
Serial.readBytes(calibration, header[1]);
|
||||||
setupServos(header[1], calibration);
|
setupServos(header[1], calibration);
|
||||||
delete [] calibration;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
modifyServo(header[0], header[1]);
|
modifyServo(header[0], header[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] header;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user