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.
Fork of DataLogging by
Revision 1:6e25c2b5c20c, committed 2016-04-29
- Comitter:
- ptuytsch
- Date:
- Fri Apr 29 15:51:04 2016 +0000
- Parent:
- 0:ec76b22829d5
- Child:
- 2:f3c2bf5521e5
- Commit message:
- good working base;
Changed in this revision
| Data.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Data.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Data.cpp Sat Apr 16 14:55:37 2016 +0000
+++ b/Data.cpp Fri Apr 29 15:51:04 2016 +0000
@@ -1,10 +1,16 @@
#include "mbed.h"
#include "Data.h"
-#define Period 1 //5000ms
-#define PPR 1
+//#include "eeprom.h"
+
+#define Period 1 //1000ms
+#define PPR 1 // Pulses Per Rotation
#define periphery 2.233168 //periphery of the wheel, in this example a 28" wheel.
+/*#define EEPROM_ADDR 0x0 // I2c EEPROM address is 0x00
+#define SDA PB_9 // I2C SDA pin
+#define SCL PB_8 // I2C SCL pin
+EEPROM mem(SDA,SCL,EEPROM_ADDR,EEPROM::T24C32);*/
int count;
time_t StartTime;
@@ -12,14 +18,15 @@
double lastDistance;
int lastCount;
-void interval(void){
+void Data::interval(void){
lastDistance = count * periphery / PPR;
distance += lastDistance;
lastCount = count;
count = 0;
+ printf("distance: %f \r\nTime Passed: %i:%i\nAverage: %f\nSpeed: %f\n\n",distance, (time(NULL) - StartTime)/60, (time(NULL) - StartTime)%60, (distance/(time(NULL) - StartTime) * 3.6),(lastDistance/Period * 3.6));
}
-void pressed(void){
+void Data::pressed(){
count++;
}
@@ -27,8 +34,8 @@
StartTime = time(NULL);
count = 0;
distance = 0;
- tick.attach(interval,Period);
- button.fall(pressed);
+ tick.attach(this,&Data::interval,Period);
+ button.fall(this,&Data::pressed);
}
double Data::getDistance(void){
--- a/Data.h Sat Apr 16 14:55:37 2016 +0000
+++ b/Data.h Fri Apr 29 15:51:04 2016 +0000
@@ -15,7 +15,8 @@
double getSpeed(void);
double getAverage(void);
int getLastCount(void);
-
+ void pressed(void);
+ void interval(void);
};
#endif
\ No newline at end of file
