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: LCD_fonts SPI_TFT_ILI9341 CMSIS_DSP_401_without_cm4 mbed-src SDFileSystem wavfile
main.cpp@1:f1f3dfff9107, 2015-11-17 (annotated)
- Committer:
- linx0576
- Date:
- Tue Nov 17 23:51:55 2015 +0000
- Revision:
- 1:f1f3dfff9107
- Parent:
- 0:52568bab75f8
- Child:
- 2:afdb1aaa7608
fix 1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| linx0576 | 0:52568bab75f8 | 1 | #include <math.h> |
| linx0576 | 0:52568bab75f8 | 2 | #include "stdio.h" |
| linx0576 | 0:52568bab75f8 | 3 | #include "mbed.h" |
| linx0576 | 0:52568bab75f8 | 4 | #include "SPI_TFT_ILI9341.h" |
| linx0576 | 0:52568bab75f8 | 5 | #include "string" |
| linx0576 | 0:52568bab75f8 | 6 | #include "Arial12x12.h" |
| linx0576 | 0:52568bab75f8 | 7 | #include "Arial24x23.h" |
| linx0576 | 0:52568bab75f8 | 8 | #include "arm_math.h" |
| linx0576 | 0:52568bab75f8 | 9 | #define num 128 |
| linx0576 | 1:f1f3dfff9107 | 10 | //AnalogIn analogValue(A2); |
| linx0576 | 1:f1f3dfff9107 | 11 | DigitalIn bt(PC_8); |
| linx0576 | 0:52568bab75f8 | 12 | |
| linx0576 | 0:52568bab75f8 | 13 | /** External Input and Output buffer Declarations for FFT Bin Example **/ |
| linx0576 | 1:f1f3dfff9107 | 14 | //static float32_t testInput_f32_10khz[num]; |
| linx0576 | 1:f1f3dfff9107 | 15 | |
| linx0576 | 0:52568bab75f8 | 16 | /** Global variables for FFT Bin Example **/ |
| linx0576 | 1:f1f3dfff9107 | 17 | |
| linx0576 | 0:52568bab75f8 | 18 | uint32_t ifftFlag = 0; |
| linx0576 | 0:52568bab75f8 | 19 | uint32_t doBitReverse = 1; |
| linx0576 | 0:52568bab75f8 | 20 | |
| linx0576 | 0:52568bab75f8 | 21 | /* Reference index at which max energy of bin ocuurs */ |
| linx0576 | 0:52568bab75f8 | 22 | uint32_t refIndex = 213, testIndex = 0; |
| linx0576 | 0:52568bab75f8 | 23 | |
| linx0576 | 0:52568bab75f8 | 24 | extern unsigned char p1[]; // the mbed logo |
| linx0576 | 0:52568bab75f8 | 25 | const float32_t a[num] = { -0.865129623056441, -2.655020678073846, 0.600664612949661, 0.080378093886515, -2.899160484012034, 2.563004262857762, 3.078328403304206, 0.105906778385130, |
| linx0576 | 0:52568bab75f8 | 26 | 0.048366940168201, -0.145696461188734, -0.023417155362879, 2.127729174988954, -1.176633086028377, 3.690223557991855, -0.622791766173194, 0.722837373872203, |
| linx0576 | 0:52568bab75f8 | 27 | 2.739754205367484, -0.062610410524552, -0.891296810967338, -1.845872258871811, 1.195039415434387, -2.177388969045026, 1.078649103637905, 2.570976050490193, |
| linx0576 | 0:52568bab75f8 | 28 | -1.383551403404574, 2.392141424058873, 2.858002843205065, -3.682433899725536, -3.488146646451150, 1.323468578888120, -0.099771155430726, 1.561168082500454, |
| linx0576 | 0:52568bab75f8 | 29 | 1.025026795103179, 0.928841900171200, 2.930499509864950, 2.013349089766430, 2.381676148486737, -3.081062307950236, -0.389579115537544, 0.181540149166620, |
| linx0576 | 0:52568bab75f8 | 30 | -2.601953341353208, 0.333435137783218, -2.812945856162965, 2.649109640172910, -1.003963025744654, 1.552460768755035, 0.088641345335247, -2.519951327113426, |
| linx0576 | 0:52568bab75f8 | 31 | -4.341348988610527, 0.557772429359965, -1.671267412948494, 0.733951350960387, 0.409263788034864, 3.566033071952806, 1.882565173848352, -1.106017073793287, |
| linx0576 | 0:52568bab75f8 | 32 | 0.154456720778718, -2.513205795512153, 0.310978660939421, 0.579706500111723, 0.000086383683251, -1.311866980897721, 1.840007477574986, -3.253005768451345, |
| linx0576 | 0:52568bab75f8 | 33 | 1.462584328739432, 1.610103610851738, 0.761914676858907, 0.974541361089834, 0.686845845885983, 1.849153122025191, 0.787800410401453, -1.187438909666279, |
| linx0576 | 0:52568bab75f8 | 34 | -0.754937911044720, 0.084373858395232, -2.600269011710521, -0.962982842142644, -0.369328108540868, 0.810791418361879, 3.587016488699641, -0.520776145083723, |
| linx0576 | 0:52568bab75f8 | 35 | 0.640249919627884, 1.103122489464969, 2.231779881455556, -1.308035392685241, 0.424070304330106, -0.200383932651189, -2.365526783356541, -0.989114757436628, |
| linx0576 | 0:52568bab75f8 | 36 | 2.770807688959777, -0.444172737462307, 0.079760979374078, -0.005199118412183, -0.664712668309527, -0.624171857561896, 0.537306979007338, -2.575955675497642, |
| linx0576 | 0:52568bab75f8 | 37 | 1.562363235756780, 1.814069369848895, -1.293428583392509, -1.026188449495686, -2.981771815588717, -4.223468103075124, 2.672674782004045, -0.856096801117735, |
| linx0576 | 0:52568bab75f8 | 38 | 0.048517345512563, -0.026860721136222, 0.392932277758187, -1.331740855093099, -1.894292129477081, -1.425006468460681, -2.721772427617057, -1.616831100216806, |
| linx0576 | 0:52568bab75f8 | 39 | 3.551177651488947, -0.069685667896087, -3.134634907409102, -0.263627598944639, -1.650469945991350, -2.203580339374399, -0.872203246123242, 1.230782812607287, |
| linx0576 | 0:52568bab75f8 | 40 | 0.257288860093291, 1.989083106173137, -1.985638729453261, -1.416185105842892, -1.131097688325772, -2.245130805416057, -1.938873996219074, 2.043608361562645, |
| linx0576 | 0:52568bab75f8 | 41 | }; |
| linx0576 | 0:52568bab75f8 | 42 | const float32_t b[num] = { -0.865129623056441, -2.655020678073846, 0.600664612949661, 0.080378093886515, -2.899160484012034, 2.563004262857762, 3.078328403304206, 0.105906778385130, |
| linx0576 | 0:52568bab75f8 | 43 | 0.048366940168201, -0.145696461188734, -0.023417155362879, 2.127729174988954, -1.176633086028377, 3.690223557991855, -0.622791766173194, 0.722837373872203, |
| linx0576 | 0:52568bab75f8 | 44 | 2.739754205367484, -0.062610410524552, -0.891296810967338, -1.845872258871811, 1.195039415434387, -2.177388969045026, 1.078649103637905, 2.570976050490193, |
| linx0576 | 0:52568bab75f8 | 45 | -1.383551403404574, 2.392141424058873, 2.858002843205065, -3.682433899725536, -0.369328108540868, 0.810791418361879, 3.587016488699641, -0.520776145083723, |
| linx0576 | 0:52568bab75f8 | 46 | 0.640249919627884, 1.103122489464969, 2.231779881455556, -1.308035392685241, 0.424070304330106, -0.200383932651189, -2.365526783356541, -0.989114757436628, |
| linx0576 | 0:52568bab75f8 | 47 | 2.770807688959777, -0.444172737462307, 0.079760979374078, -0.005199118412183, -0.664712668309527, -0.624171857561896, 0.537306979007338, -2.575955675497642, |
| linx0576 | 0:52568bab75f8 | 48 | 1.562363235756780, 1.814069369848895, -1.293428583392509, -1.026188449495686, -2.981771815588717, -4.223468103075124, 2.672674782004045, -0.856096801117735, |
| linx0576 | 0:52568bab75f8 | 49 | 0.048517345512563, -0.026860721136222, 0.392932277758187, -1.331740855093099, -1.894292129477081, -1.425006468460681, -2.721772427617057, -1.616831100216806, |
| linx0576 | 0:52568bab75f8 | 50 | 3.551177651488947, -0.069685667896087, -3.134634907409102, -0.263627598944639, -1.650469945991350, -2.203580339374399, -0.872203246123242, 1.230782812607287, |
| linx0576 | 0:52568bab75f8 | 51 | 0.257288860093291, 1.989083106173137, -1.985638729453261, -1.416185105842892, -1.131097688325772, -2.245130805416057, -1.938873996219074, 2.043608361562645, |
| linx0576 | 0:52568bab75f8 | 52 | -3.488146646451150, 1.323468578888120, -0.099771155430726, 1.561168082500454, 1.025026795103179, 0.928841900171200, 2.930499509864950, 2.013349089766430, |
| linx0576 | 0:52568bab75f8 | 53 | 2.381676148486737, -3.081062307950236, -0.389579115537544, 0.181540149166620, -2.601953341353208, 0.333435137783218, -2.812945856162965, 2.649109640172910, |
| linx0576 | 0:52568bab75f8 | 54 | -1.003963025744654, 1.552460768755035, 0.088641345335247, -2.519951327113426, -4.341348988610527, 0.557772429359965, -1.671267412948494, 0.733951350960387, |
| linx0576 | 0:52568bab75f8 | 55 | 0.409263788034864, 3.566033071952806, 1.882565173848352, -1.106017073793287, 0.154456720778718, -2.513205795512153, 0.310978660939421, 0.579706500111723, |
| linx0576 | 0:52568bab75f8 | 56 | 0.000086383683251, -1.311866980897721, 1.840007477574986, -3.253005768451345, 1.462584328739432, 1.610103610851738, 0.761914676858907, 0.974541361089834, |
| linx0576 | 0:52568bab75f8 | 57 | 0.686845845885983, 1.849153122025191, 0.787800410401453, -1.187438909666279, -0.754937911044720, 0.084373858395232, -2.600269011710521, -0.962982842142644, |
| linx0576 | 0:52568bab75f8 | 58 | }; |
| linx0576 | 0:52568bab75f8 | 59 | float32_t a1, b1; |
| linx0576 | 0:52568bab75f8 | 60 | float32_t subOutput, SquareOutput; |
| linx0576 | 0:52568bab75f8 | 61 | |
| linx0576 | 0:52568bab75f8 | 62 | SPI_TFT_ILI9341 TFT(D11, D12, D13, D10, D8, D9, "TFT"); // mosi, miso, sclk, cs, reset, dc |
| linx0576 | 1:f1f3dfff9107 | 63 | |
| linx0576 | 0:52568bab75f8 | 64 | int main() |
| linx0576 | 1:f1f3dfff9107 | 65 | { |
| linx0576 | 1:f1f3dfff9107 | 66 | // arm_cfft_radix2_instance_f32 S; |
| linx0576 | 1:f1f3dfff9107 | 67 | int stage=0; |
| linx0576 | 1:f1f3dfff9107 | 68 | int pu, pd, pl, pr, ps; |
| linx0576 | 0:52568bab75f8 | 69 | TFT.claim(stdout); // send stdout to the TFT display |
| linx0576 | 0:52568bab75f8 | 70 | TFT.claim(stderr); // send stderr to the TFT display |
| linx0576 | 0:52568bab75f8 | 71 | //TFT.set_orientation(1); // comment out = "||" include = "=" |
| linx0576 | 0:52568bab75f8 | 72 | TFT.background(Black); // set background to black |
| linx0576 | 0:52568bab75f8 | 73 | TFT.foreground(White); // set chars to white |
| linx0576 | 0:52568bab75f8 | 74 | TFT.cls(); // clear the screen |
| linx0576 | 0:52568bab75f8 | 75 | |
| linx0576 | 1:f1f3dfff9107 | 76 | while(1) |
| linx0576 | 1:f1f3dfff9107 | 77 | { TFT.cls(); |
| linx0576 | 1:f1f3dfff9107 | 78 | TFT.background(Black); |
| linx0576 | 1:f1f3dfff9107 | 79 | |
| linx0576 | 1:f1f3dfff9107 | 80 | if (stage==0) //menu |
| linx0576 | 1:f1f3dfff9107 | 81 | { int menu=0; |
| linx0576 | 1:f1f3dfff9107 | 82 | TFT.cls(); |
| linx0576 | 1:f1f3dfff9107 | 83 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 84 | TFT.locate(20,60); |
| linx0576 | 1:f1f3dfff9107 | 85 | printf("Configuration"); |
| linx0576 | 1:f1f3dfff9107 | 86 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 87 | TFT.locate(20,110); |
| linx0576 | 1:f1f3dfff9107 | 88 | TFT.printf(" Waveform"); |
| linx0576 | 1:f1f3dfff9107 | 89 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 90 | TFT.locate(20,160); |
| linx0576 | 1:f1f3dfff9107 | 91 | TFT.printf(" Log"); |
| linx0576 | 1:f1f3dfff9107 | 92 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 93 | TFT.locate(20,260); |
| linx0576 | 1:f1f3dfff9107 | 94 | printf(" Return"); |
| linx0576 | 0:52568bab75f8 | 95 | |
| linx0576 | 1:f1f3dfff9107 | 96 | if (menu==0) //Configuration |
| linx0576 | 1:f1f3dfff9107 | 97 | { pu=0; pd=0; pl=0; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 98 | TFT.rect(15,55,220,85,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 99 | TFT.rect(15,105,220,135,Black); |
| linx0576 | 1:f1f3dfff9107 | 100 | ps=1; |
| linx0576 | 1:f1f3dfff9107 | 101 | if (pd==1) {wait(1); menu=1;} |
| linx0576 | 1:f1f3dfff9107 | 102 | if (ps==1) {wait(1); stage=1;} |
| linx0576 | 1:f1f3dfff9107 | 103 | } |
| linx0576 | 1:f1f3dfff9107 | 104 | |
| linx0576 | 1:f1f3dfff9107 | 105 | if (menu==1) //waveform |
| linx0576 | 1:f1f3dfff9107 | 106 | { pu=0; pd=0; pl=0; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 107 | TFT.rect(15,55,220,85,Black); |
| linx0576 | 1:f1f3dfff9107 | 108 | TFT.rect(15,105,220,135,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 109 | TFT.rect(15,155,220,185,Black); |
| linx0576 | 1:f1f3dfff9107 | 110 | pd=1; |
| linx0576 | 1:f1f3dfff9107 | 111 | if (pu==1) {wait(1); menu=0;} |
| linx0576 | 1:f1f3dfff9107 | 112 | if (pd==1) {wait(1); menu=2;} |
| linx0576 | 1:f1f3dfff9107 | 113 | if (ps==1) {wait(1); stage=2;} |
| linx0576 | 1:f1f3dfff9107 | 114 | } |
| linx0576 | 0:52568bab75f8 | 115 | |
| linx0576 | 1:f1f3dfff9107 | 116 | if (menu==2) //log |
| linx0576 | 1:f1f3dfff9107 | 117 | { pu=0; pd=0; pl=0; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 118 | TFT.rect(15,105,220,135,Black); |
| linx0576 | 1:f1f3dfff9107 | 119 | TFT.rect(15,155,220,185,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 120 | TFT.rect(15,255,220,285,Black); |
| linx0576 | 1:f1f3dfff9107 | 121 | ps=1; |
| linx0576 | 1:f1f3dfff9107 | 122 | if (pu==1) {wait(1); menu=1;} |
| linx0576 | 1:f1f3dfff9107 | 123 | if (pd==1) {wait(1); menu=3;} |
| linx0576 | 1:f1f3dfff9107 | 124 | if (ps==1) {wait(1); stage=3;} |
| linx0576 | 1:f1f3dfff9107 | 125 | } |
| linx0576 | 1:f1f3dfff9107 | 126 | |
| linx0576 | 1:f1f3dfff9107 | 127 | if (menu==3) //return |
| linx0576 | 1:f1f3dfff9107 | 128 | { pu=0; pd=0; pl=0; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 129 | TFT.rect(15,155,220,185,Black); |
| linx0576 | 1:f1f3dfff9107 | 130 | TFT.rect(15,255,220,285,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 131 | if (pu==1) {wait(1); menu=0;} |
| linx0576 | 1:f1f3dfff9107 | 132 | if (ps==1) {wait(1); stage=3;} |
| linx0576 | 1:f1f3dfff9107 | 133 | } |
| linx0576 | 1:f1f3dfff9107 | 134 | } |
| linx0576 | 1:f1f3dfff9107 | 135 | |
| linx0576 | 1:f1f3dfff9107 | 136 | if (stage==1) //Configuration |
| linx0576 | 1:f1f3dfff9107 | 137 | { TFT.cls(); |
| linx0576 | 1:f1f3dfff9107 | 138 | int i, j; |
| linx0576 | 1:f1f3dfff9107 | 139 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 140 | TFT.locate(20,60); |
| linx0576 | 1:f1f3dfff9107 | 141 | printf("SET PERIOD"); |
| linx0576 | 1:f1f3dfff9107 | 142 | TFT.rect(15,55, 220,85,Red); |
| linx0576 | 1:f1f3dfff9107 | 143 | TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 144 | TFT.locate(40,270); |
| linx0576 | 1:f1f3dfff9107 | 145 | printf("Set"); |
| linx0576 | 1:f1f3dfff9107 | 146 | TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 147 | TFT.locate(165,270); |
| linx0576 | 1:f1f3dfff9107 | 148 | printf("Return"); |
| linx0576 | 1:f1f3dfff9107 | 149 | |
| linx0576 | 1:f1f3dfff9107 | 150 | pu=0; pd=0; pl=1; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 151 | i=3; j=38; |
| linx0576 | 1:f1f3dfff9107 | 152 | while (ps==0) |
| linx0576 | 1:f1f3dfff9107 | 153 | { TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 154 | TFT.locate(20,130); |
| linx0576 | 1:f1f3dfff9107 | 155 | TFT.printf(" %i %i", i-1, j-1); |
| linx0576 | 1:f1f3dfff9107 | 156 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 157 | TFT.locate(20,150); |
| linx0576 | 1:f1f3dfff9107 | 158 | TFT.printf(" %i Hr %i Min", i, j); |
| linx0576 | 1:f1f3dfff9107 | 159 | TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 160 | TFT.locate(20,180); |
| linx0576 | 1:f1f3dfff9107 | 161 | TFT.printf(" %i %i", i+1, j+1); |
| linx0576 | 1:f1f3dfff9107 | 162 | pu=0; pd=0; pl=1; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 163 | if (pl==1) |
| linx0576 | 1:f1f3dfff9107 | 164 | { TFT.rect(20,145, 58,175,Yellow); |
| linx0576 | 1:f1f3dfff9107 | 165 | TFT.rect(120,145,158,175,Blue); |
| linx0576 | 1:f1f3dfff9107 | 166 | pu=1; |
| linx0576 | 1:f1f3dfff9107 | 167 | if (i>05) i=0; |
| linx0576 | 1:f1f3dfff9107 | 168 | if (pu==1) {wait(1); i=i+1; } |
| linx0576 | 1:f1f3dfff9107 | 169 | if (pd==1) {wait(1); i=i-1; } |
| linx0576 | 1:f1f3dfff9107 | 170 | } |
| linx0576 | 1:f1f3dfff9107 | 171 | pu=0; pd=0; pl=0; pr=1; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 172 | if (pr==1) |
| linx0576 | 1:f1f3dfff9107 | 173 | { TFT.rect(20,145, 58,175,Blue); |
| linx0576 | 1:f1f3dfff9107 | 174 | TFT.rect(120,145,158,175,Yellow); |
| linx0576 | 1:f1f3dfff9107 | 175 | pu=1; |
| linx0576 | 1:f1f3dfff9107 | 176 | if (j>60) j=0; |
| linx0576 | 1:f1f3dfff9107 | 177 | if (pu==1) {wait(1); j=j+1; } |
| linx0576 | 1:f1f3dfff9107 | 178 | if (pd==1) {wait(1); j=j-1; } |
| linx0576 | 1:f1f3dfff9107 | 179 | } |
| linx0576 | 1:f1f3dfff9107 | 180 | // ps=1; |
| linx0576 | 1:f1f3dfff9107 | 181 | } |
| linx0576 | 0:52568bab75f8 | 182 | |
| linx0576 | 1:f1f3dfff9107 | 183 | pu=0; pd=0; pl=1; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 184 | while (ps==0) |
| linx0576 | 1:f1f3dfff9107 | 185 | { if (pl==1) |
| linx0576 | 1:f1f3dfff9107 | 186 | { TFT.rect(15,265,85,285,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 187 | TFT.rect(150,265,220,285,Black); |
| linx0576 | 1:f1f3dfff9107 | 188 | wait(1); |
| linx0576 | 1:f1f3dfff9107 | 189 | } |
| linx0576 | 1:f1f3dfff9107 | 190 | pr=1; |
| linx0576 | 1:f1f3dfff9107 | 191 | if (pr==1) |
| linx0576 | 1:f1f3dfff9107 | 192 | { TFT.rect(15,265,85,285,Black); |
| linx0576 | 1:f1f3dfff9107 | 193 | TFT.rect(150,265,220,285,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 194 | wait(1); |
| linx0576 | 1:f1f3dfff9107 | 195 | } |
| linx0576 | 1:f1f3dfff9107 | 196 | ps=1; |
| linx0576 | 1:f1f3dfff9107 | 197 | if (ps==1) {wait(1); stage=0;} |
| linx0576 | 1:f1f3dfff9107 | 198 | } |
| linx0576 | 1:f1f3dfff9107 | 199 | } |
| linx0576 | 1:f1f3dfff9107 | 200 | |
| linx0576 | 1:f1f3dfff9107 | 201 | if (stage==2) //waveform |
| linx0576 | 1:f1f3dfff9107 | 202 | { TFT.cls(); |
| linx0576 | 1:f1f3dfff9107 | 203 | pu=0; pd=0; pl=0; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 204 | int abc, x2, y2; |
| linx0576 | 1:f1f3dfff9107 | 205 | int x1 = 0; |
| linx0576 | 1:f1f3dfff9107 | 206 | int y1 = 100; |
| linx0576 | 1:f1f3dfff9107 | 207 | float32_t sum=0; |
| linx0576 | 1:f1f3dfff9107 | 208 | float32_t k=0; |
| linx0576 | 1:f1f3dfff9107 | 209 | |
| linx0576 | 1:f1f3dfff9107 | 210 | for(abc=0; abc<num; abc++) |
| linx0576 | 1:f1f3dfff9107 | 211 | { a1 = a[abc]; |
| linx0576 | 1:f1f3dfff9107 | 212 | b1 = b[abc]; |
| linx0576 | 1:f1f3dfff9107 | 213 | arm_sub_f32(&a1, &b1, &subOutput, 1); |
| linx0576 | 1:f1f3dfff9107 | 214 | arm_mult_f32(&subOutput, &subOutput, &SquareOutput, 1); |
| linx0576 | 1:f1f3dfff9107 | 215 | sum = sum+SquareOutput; |
| linx0576 | 0:52568bab75f8 | 216 | |
| linx0576 | 1:f1f3dfff9107 | 217 | x2 = abc*2; |
| linx0576 | 1:f1f3dfff9107 | 218 | y2 = 80+a1*10; |
| linx0576 | 1:f1f3dfff9107 | 219 | TFT.line(x1,y1,x2,y2,Green); |
| linx0576 | 1:f1f3dfff9107 | 220 | x1 = x2; |
| linx0576 | 1:f1f3dfff9107 | 221 | y1 = y2; |
| linx0576 | 1:f1f3dfff9107 | 222 | } |
| linx0576 | 1:f1f3dfff9107 | 223 | k = sum / num; |
| linx0576 | 0:52568bab75f8 | 224 | |
| linx0576 | 1:f1f3dfff9107 | 225 | TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 226 | TFT.locate(10,180); |
| linx0576 | 1:f1f3dfff9107 | 227 | TFT.printf("sum: %f", sum); |
| linx0576 | 1:f1f3dfff9107 | 228 | TFT.locate(10,190); |
| linx0576 | 1:f1f3dfff9107 | 229 | TFT.printf("num: %i", num); |
| linx0576 | 1:f1f3dfff9107 | 230 | TFT.locate(10,210); |
| linx0576 | 1:f1f3dfff9107 | 231 | TFT.printf("Mean Square Error: "); |
| linx0576 | 1:f1f3dfff9107 | 232 | TFT.locate(10,220); |
| linx0576 | 1:f1f3dfff9107 | 233 | TFT.printf(" %f", k); |
| linx0576 | 1:f1f3dfff9107 | 234 | TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 235 | TFT.locate(165,270); |
| linx0576 | 1:f1f3dfff9107 | 236 | printf("Return"); |
| linx0576 | 1:f1f3dfff9107 | 237 | TFT.rect(150,265,220,285,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 238 | ps=1; |
| linx0576 | 1:f1f3dfff9107 | 239 | if (ps==1) {wait(1); stage=0;} |
| linx0576 | 1:f1f3dfff9107 | 240 | } |
| linx0576 | 1:f1f3dfff9107 | 241 | |
| linx0576 | 1:f1f3dfff9107 | 242 | if (stage==3) //log |
| linx0576 | 1:f1f3dfff9107 | 243 | { TFT.cls(); |
| linx0576 | 1:f1f3dfff9107 | 244 | pu=0; pd=0; pl=0; pr=0; ps=0; |
| linx0576 | 1:f1f3dfff9107 | 245 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 246 | TFT.locate(20,60); |
| linx0576 | 1:f1f3dfff9107 | 247 | printf("Team Riedel"); |
| linx0576 | 1:f1f3dfff9107 | 248 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 249 | TFT.locate(30,110); |
| linx0576 | 1:f1f3dfff9107 | 250 | TFT.printf("We are"); |
| linx0576 | 1:f1f3dfff9107 | 251 | TFT.set_font((unsigned char*) Arial24x23); |
| linx0576 | 1:f1f3dfff9107 | 252 | TFT.locate(40,160); |
| linx0576 | 1:f1f3dfff9107 | 253 | TFT.printf("awesome!"); |
| linx0576 | 1:f1f3dfff9107 | 254 | TFT.set_font((unsigned char*) Arial12x12); |
| linx0576 | 1:f1f3dfff9107 | 255 | TFT.locate(165,270); |
| linx0576 | 1:f1f3dfff9107 | 256 | printf("Return"); |
| linx0576 | 1:f1f3dfff9107 | 257 | TFT.rect(150,265,220,285,GreenYellow); |
| linx0576 | 1:f1f3dfff9107 | 258 | ps=1; |
| linx0576 | 1:f1f3dfff9107 | 259 | if (ps==1) {wait(1); stage=0;} |
| linx0576 | 1:f1f3dfff9107 | 260 | } |
| linx0576 | 1:f1f3dfff9107 | 261 | } |
| linx0576 | 1:f1f3dfff9107 | 262 | } |