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: MAG3110 SLCD aqm1248a_lcd mbed
Revision 1:ad135c286d4d, committed 2015-05-04
- Comitter:
- TareObjects
- Date:
- Mon May 04 08:53:50 2015 +0000
- Parent:
- 0:47be4d9de4b9
- Commit message:
- Faster; ; - Less Sampling datas (256->128); - Wait for status, and fetch data; // I tried to use INT1, but I could not get interrupt....
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri May 01 19:26:11 2015 +0000
+++ b/main.cpp Mon May 04 08:53:50 2015 +0000
@@ -4,12 +4,15 @@
#include "fft4g.h"
#include "aqm1248a_lcd.h"
-#define NMAX 256
+#define NMAX 64
#define NMAXSQRT 32
#define MAX(x,y) ((x) > (y) ? (x) : (y))
MAG3110 mag(PTE25, PTE24);
+InterruptIn magInt(PTD1);
+PwmOut Red(PTE29);
+
SLCD slcd;
aqm1248a_lcd lcd;
@@ -20,6 +23,9 @@
double magBuffer[NMAX+1];
void readerFunction() {
+ if ((mag.dataReady() & 1) == 0) return; // XDR:X-axis new Data Available.
+
+ Red = (float)nFilled / (float)NMAX;
if (modeFilling) {
float x;
mag.getX(&x);
@@ -55,24 +61,31 @@
int cnt = 0;
+ Red.period_ms(1);
+
+ Red = 1;
+
lcd.setmode(NORMAL);
lcd.set_contrast(25);
+ reader.attach(&readerFunction, 0.001);
+// magInt.mode(PullUp);
+// magInt.rise(readerFunction);
+
mag.enable();
- wait(0.1);
+ wait(0.1);
- reader.attach(&readerFunction, 0.0333333);
-
+ int n2 = n/2;
+ int height = lcd.height();
+ int width = lcd.width();
+ int barWidth = lcd.width() / n2;
+
while (1) {
- while(modeFilling == true) wait(0.1);
+ while(modeFilling == true) wait(0.01);
rdft(n, 1, magBuffer, ip, w);
- int n2 = n/2;
- int height = lcd.height();
- int width = lcd.width();
-
double max = 0;
for (int i = 0; i < n2; i++) {
int i2 = i*2;
@@ -88,7 +101,7 @@
max = height / max;
for (int i = 1; i < n2; i++) {
- lcd.line(i, height-1, i, height-1-max*magBuffer[i], 1);
+ lcd.fillrect((i-1)*barWidth, height-1, i*barWidth-1, height-1-max*magBuffer[i], 1);
}
sprintf(buf, "%4d", cnt++);