Regenerating PPM signal based on distances from ultrasonic sensors, ESP8266 for connectin via wifi. Autonomous quadcopter behaviour, autonomou height holding. Flying direction based on front and back ultrasonic sensors.
Dependencies: ConfigFile HCSR04 PID PPM2 mbed-rtos mbed
Diff: hardware.h
- Branch:
- DistanceRegulation
- Revision:
- 14:076ef843e1ba
- Parent:
- 13:33024b5880b3
- Child:
- 15:9cdf757269fb
diff -r 33024b5880b3 -r 076ef843e1ba hardware.h --- a/hardware.h Fri Oct 27 10:47:12 2017 +0000 +++ b/hardware.h Fri Oct 27 14:59:21 2017 +0000 @@ -12,6 +12,7 @@ void writeSettingsToConfig(void); void writeErrorLog(char *message); void ConvertToCharArray(float number); +void ConvertToCharArray(int number); Serial pc(USBTX, USBRX); // tx, rx PID* _groundDistance; @@ -38,6 +39,7 @@ float _P = 0; float _I = 0; float _D = 0; +int _groundSetPoint = 0; @@ -53,6 +55,8 @@ _I = atof(value); if (_configFile.getValue("D", &value[0], sizeof(value))) _D = atof(value); + if (_configFile.getValue("groundSetPoint", &value[0], sizeof(value))) + _groundSetPoint = atof(value); } @@ -63,6 +67,8 @@ _configFile.setValue("I", _str); ConvertToCharArray(_D); _configFile.setValue("D", _str); + ConvertToCharArray(_groundSetPoint); + _configFile.setValue("groundSetPoint", _str); _configFile.write("/local/config.cfg"); @@ -85,5 +91,11 @@ sprintf(_str, "%4.2f", number ); } +//Converts integer to char array +void ConvertToCharArray(int number) +{ + sprintf(_str, "%d", number ); +} + #endif \ No newline at end of file