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: mbed PowerControl
Fork of Projet_S5 by
Revision 7:89be89aeed5a, committed 2014-04-05
- Comitter:
- joGenie
- Date:
- Sat Apr 05 18:07:45 2014 +0000
- Parent:
- 6:ef8bfca9e69b
- Child:
- 8:9bf215a760f5
- Commit message:
- Analyzer initial
Changed in this revision
--- a/analyzer.cpp Thu Apr 03 15:04:49 2014 +0000
+++ b/analyzer.cpp Sat Apr 05 18:07:45 2014 +0000
@@ -15,7 +15,18 @@
void Analyzer::checkMouvement()
{
+ Serial pc(USBTX, USBRX);
+ pc.printf("Init: %i, min: %i, max: %i\n", x.initial, x.min, x.max);
+ pc.printf("Init: %i, min: %i, max: %i\n", y.initial, y.min, y.max);
+ pc.printf("Init: %i, min: %i, max: %i\n", z.initial, z.min, z.max);
+}
+
+void Analyzer::setInitial(signed char* init)
+{
+ x.setInitial(init[0]);
+ y.setInitial(init[1]);
+ z.setInitial(init[2]);
}
extern "C" void *Analyzer_C_new()
@@ -35,6 +46,12 @@
an->setMinMax(values);
}
+extern "C" void Analyzer_C_setInitial(signed char* init, void *analyzer)
+{
+ Analyzer *an = (Analyzer*)analyzer;
+ an->setInitial(init);
+}
+
extern "C" void Analyzer_C_checkMouvement(void *analyzer)
{
Analyzer *an = (Analyzer*)analyzer;
--- a/analyzer.h Thu Apr 03 15:04:49 2014 +0000
+++ b/analyzer.h Sat Apr 05 18:07:45 2014 +0000
@@ -11,6 +11,7 @@
~Analyzer();
void setMinMax(signed char* values);
+ void setInitial(signed char* value);
void checkMouvement();
private:
@@ -18,8 +19,9 @@
{
signed char min;
signed char max;
+ signed char initial;
- Data(): min(CHAR_MAX/2), max(0){}
+ Data(): min(SCHAR_MAX), max(SCHAR_MIN){}
void setMinMax(signed char value)
{
@@ -28,7 +30,14 @@
if (value > max)
max = value;
- }
+ }
+
+ void setInitial(signed char init)
+ {
+ initial = init;
+ min = initial;
+ max = initial;
+ }
};
Data x, y, z;
@@ -42,6 +51,7 @@
extern void *Analyzer_C_new();
extern void Analyzer_C_delete(void *analyzer);
extern void Analyzer_C_setMinMax(signed char* values, void *analyzer);
+extern void Analyzer_C_setInitial(signed char* value, void *analyzer);
extern void Analyzer_C_checkMouvement(void *analyzer);
#ifdef __cplusplus
--- a/main.cpp Thu Apr 03 15:04:49 2014 +0000
+++ b/main.cpp Sat Apr 05 18:07:45 2014 +0000
@@ -38,11 +38,16 @@
appuyer = true;
NVIC_EnableIRQ(TIMER3_IRQn); // Enable timer3 interrupt
+
+ signed char* values = Accelerometer_C_getAccelValue(accelerometer);
+
+ // Analyze data
+ Analyzer_C_setInitial(values, analyzer);
}
else
{
led1 = 0;
- LPC_TIM2->CCR = (0x05 << 0); //rising edge
+ LPC_TIM2->CCR = (5 << 0); //rising edge
LPC_TIM3->TC = 0; // clear timer counter
LPC_TIM3->PC = 0; // clear prescale counter
@@ -53,6 +58,8 @@
appuyer = false;
rebound = true;
NVIC_DisableIRQ(TIMER3_IRQn); // Disable timer3 interrupt
+
+ Analyzer_C_checkMouvement(analyzer);
}
@@ -120,8 +127,6 @@
int main()
{
-
- Analyzer analyzer;
initialize();
while(true)
