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.
Revision 1:cae174481a60, committed 2015-01-28
- Comitter:
- havri
- Date:
- Wed Jan 28 11:15:59 2015 +0000
- Parent:
- 0:7d02a614f4e7
- Child:
- 2:5506657d79a8
- Commit message:
- ahoj
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 27 08:19:13 2015 +0000
+++ b/main.cpp Wed Jan 28 11:15:59 2015 +0000
@@ -1,39 +1,81 @@
#include "mbed.h"
-#include "LIS302.h"
DigitalOut myled(LED1);
AnalogIn CameraIn(PTD5);
DigitalOut SI(PTD7);
DigitalOut CLK(PTE1);
-float camera[128];
+
Serial pc(USBTX,USBRX);
DigitalIn butt(PTC13);
-Timer t;
+int i;
+float camera[128];
+float convolutions[142];
+float camera_con[156];
+float jadro[] = {0,0.222520749166399,0.433883397574414,0.623489357288624,0.78183100975747,
+ 0.900968456705778,0.974927659118645,1,0.974928249597434,0.900969608054333,
+ 0.781832664242464,0.623491431947411,0.433885788375115,0.222523336224485,2.65358979335278E-06};
+
+int convolution()
+ {
+ float temp;
+ for(int a = 0; a<15; a++)
+ {
+ camera_con[a] = 1;
+ }
+
+ for(int a = 15; a<143; a++)
+ {
+ camera_con[a] = camera[a-15];
+ }
+
+ for(int a = 143; a<157; a++)
+ {
+ camera_con[a] = 1;
+ }
+
+ for(int a = 0; a<143; a++)
+ {
+ for(int b = 0; b < 15; b++)
+ {
+ temp += camera_con[a + b]*jadro[b];
+ }
+ convolutions[a] = temp;
+ }
+
+ return(1);
+ }
+
+int scan()
+ {
+ CLK = 0;
+ SI = 1;
+ wait_us(65);
+ CLK = 1;
+ SI = 0;
+ wait_us(65);
+ for(i=0; i<128; i++)
+ {
+ camera[i]= CameraIn;
+ wait_us(65);
+ CLK=0;
+ wait_us(65);
+ CLK = 1;
+ }
+ return(1);
+ }
+
+
+
int main() {
- while(1) {
- CLK = 0;
- SI = 1;
- wait_us(65);
- CLK = 1;
- SI = 0;
- wait_us(65);
- int i;
- for(i=0; i<128; i++)
+ while(1) {
+ scan();
+ convolution();
+ if(butt == 1)
+ {
+
+ for(i=0; i<142; i++)
{
- camera[i]= CameraIn;
- wait_us(65);
- CLK=0;
- wait_us(65);
- CLK = 1;
- }
-
-
- if(butt == 1)
- {
-
- for(i=0; i<128; i++)
- {
- pc.printf(" %f;",camera[i]);
+ pc.printf(" %f;",convolutions[i]);
wait_us(20);
}
pc.printf("\n");