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.
main.cpp
00001 #include "mbed.h" 00002 DigitalOut myled(LED1); 00003 AnalogIn CameraIn(PTD5); 00004 DigitalOut SI(PTD7); 00005 DigitalOut CLK(PTE1); 00006 00007 Serial pc(USBTX,USBRX); 00008 DigitalIn butt(PTC13); 00009 00010 int i; 00011 float camera[128]; 00012 float convolutions[142]; 00013 float camera_con[156]; 00014 float soucet[156][15]; 00015 float jadro[] = {0,0.222520749166399,0.433883397574414,0.623489357288624,0.78183100975747, 00016 0.900968456705778,0.974927659118645,1,0.974928249597434,0.900969608054333, 00017 0.781832664242464,0.623491431947411,0.433885788375115,0.222523336224485,2.65358979335278E-06}; 00018 00019 int convolution() 00020 { 00021 float temp; 00022 for(int a = 0; a<=13; a++) 00023 { 00024 camera_con[a] = 1; 00025 } 00026 00027 for(int a = 14; a<=142; a++) 00028 { 00029 camera_con[a] = camera[a-14]; 00030 } 00031 00032 for(int a = 143; a<=155; a++) 00033 { 00034 camera_con[a] = 1; 00035 } 00036 00037 for(int a = 0; a<=142; a++) 00038 { 00039 00040 for(int b = 0; b < 15; b++) 00041 { 00042 00043 soucet[a][b]= camera_con[a]*jadro[b]; 00044 } 00045 00046 00047 } 00048 for(int a = 0; a<=128; a++) 00049 { 00050 convolutions[a] = soucet[a][15]+soucet[a+1][14]+soucet[a+2][13]+soucet[a+3][12]+soucet[a+4][11]+soucet[a+5][10]+soucet[a+6][9]+ 00051 soucet[a+7][8]+soucet[a+8][7]+soucet[a+9][6]+soucet[a+10][5]+soucet[a+11][4]+soucet[a+12][3]+soucet[a+13][2]+soucet[a+14][1]+soucet[a+15][0]; 00052 } 00053 00054 00055 return(1); 00056 } 00057 00058 int scan() 00059 { 00060 CLK = 0; 00061 SI = 1; 00062 wait_us(65); 00063 CLK = 1; 00064 SI = 0; 00065 wait_us(65); 00066 for(i=0; i<128; i++) 00067 { 00068 camera[i]= CameraIn; 00069 wait_us(65); 00070 CLK=0; 00071 wait_us(65); 00072 CLK = 1; 00073 } 00074 return(1); 00075 } 00076 00077 00078 00079 int main() { 00080 while(1) { 00081 scan(); 00082 convolution(); 00083 if(butt == 1) 00084 { 00085 00086 for(i=0; i<128; i++) 00087 { 00088 pc.printf(" %f;",convolutions[i]); 00089 wait_us(20); 00090 } 00091 pc.printf("\n"); 00092 } 00093 00094 00095 } 00096 }
Generated on Sun Jul 31 2022 12:38:56 by
1.7.2