Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ConfigFile HCSR04 PID PPM2 mbed-rtos mbed
Revision 11:002927b2675d, committed 2017-10-27
- Comitter:
- edy05
- Date:
- Fri Oct 27 10:30:06 2017 +0000
- Parent:
- 10:bb9c778f8e3e
- Child:
- 12:18b31682dfe9
- Child:
- 13:33024b5880b3
- Commit message:
- Updated mbed, added function for writint errorLogs - not tested
Changed in this revision
--- a/ESP8266/Server.h Fri Oct 27 09:29:29 2017 +0000
+++ b/ESP8266/Server.h Fri Oct 27 10:30:06 2017 +0000
@@ -74,9 +74,9 @@
while(1){
if(DataRX==1) {
ReadWebData();
+ // Save data to configFile
+ writeSettingsToConfig();
if (servreq == 1 && weberror == 0) {
- // Save data to configFile
- writeServerSettingsToConfig();
// send HTTP Response
sendpage();
}
--- a/hardware.h Fri Oct 27 09:29:29 2017 +0000
+++ b/hardware.h Fri Oct 27 10:30:06 2017 +0000
@@ -1,5 +1,5 @@
-#ifndef HARDWARE
-#define HARDWARE
+#ifndef HARDWARE_H
+#define HARDWARE_H
#include "mbed.h"
#include "PpmRegen.h"
@@ -7,7 +7,19 @@
#include "hcsr04.h"
#include "ConfigFile.h"
+
+void loadConfigFile(void);
+void writeSettingsToConfig(void);
+void writeErrorLog(char *message);
+void ConvertToCharArray(float number);
+
Serial pc(USBTX, USBRX); // tx, rx
+PID* _groundDistance;
+HCSR04* _sonic;
+PpmRegen* _ppmRegen;
+
+ConfigFile _configFile;
+LocalFileSystem local("local");
Thread serverThread;
Thread distanceThread;
@@ -19,23 +31,16 @@
PwmOut* _yaw = new PwmOut(p24);
PwmOut* _aux1 = new PwmOut(p25);
PwmOut* _aux2 = new PwmOut(p26);
-PpmRegen* _ppmRegen;
-PID* _groundDistance;
-HCSR04* _sonic;
-
-ConfigFile _configFile;
-LocalFileSystem local("local");
char* _str = new char[1024];
-
float _P = 0;
float _I = 0;
float _D = 0;
-void loadConfigFile(void);
-void writeServerSettingsToConfig(void);
-void ConvertToCharArray(float number);
+
+
+
void loadConfigFile(void){
//reading configFile
@@ -50,7 +55,7 @@
}
-void writeServerSettingsToConfig(void){
+void writeSettingsToConfig(void){
ConvertToCharArray(_P);
_configFile.setValue("P", _str);
ConvertToCharArray(_I);
@@ -62,6 +67,15 @@
}
+
+void writeErrorLog(char *message){
+ FILE *fp = fopen("/local/errorlog.txt", "w");
+ fprintf(fp, message);
+ fclose(fp);
+
+}
+
+
//Converts float to char array
void ConvertToCharArray(float number)
{
--- a/main.cpp Fri Oct 27 09:29:29 2017 +0000
+++ b/main.cpp Fri Oct 27 10:30:06 2017 +0000
@@ -9,10 +9,7 @@
#include "ConfigFile.h"
//TEMP
-/*
-ConfigFile _configFile;
-LocalFileSystem local("local");
-*/
+
//VARIABLES
uint16_t ppmInChannelsValue[CHANNELS];
@@ -35,22 +32,6 @@
wait(1);
while(1){
-
- /*
- // writing to configFile
- _configFile.setValue("ahoj", "edo");
- _configFile.write("/local/config.cfg");
-
-
- //reading configFile
- _configFile.read("/local/config.cfg");
- char* key = "ahoj";
- char value[BUFSIZ];
- if (_configFile.getValue(key, &value[0], sizeof(value)))
- pc.printf("'%s'='%s'\n", key, value);
- */
-
- wait(2);
Thread::wait(osWaitForever);
}
--- a/mbed.bld Fri Oct 27 09:29:29 2017 +0000 +++ b/mbed.bld Fri Oct 27 10:30:06 2017 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/b484a57bc302 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file