bamlor nuttymaisuay
Dependencies: mbed
Revision 7:61c1f10bf484, committed 2017-12-12
- Comitter:
- jaybehandsome
- Date:
- Tue Dec 12 02:36:58 2017 +0000
- Parent:
- 6:1de63d5df56a
- Commit message:
- full scale
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1de63d5df56a -r 61c1f10bf484 main.cpp --- a/main.cpp Mon Dec 11 23:02:51 2017 +0000 +++ b/main.cpp Tue Dec 12 02:36:58 2017 +0000 @@ -750,7 +750,7 @@ else if(posC > 10+n && posC < 20+n ) { C = 0x49; } else if(posC > 20+n && posC < 30+n ) { C = 0x49; } else if(posC > 30+n && posC < 40+n ) { C = 0x49; } - else if(posC > 40+n && posC < 50+n ) { C = 0x7C; } + else if(posC > 40+n && posC < 50+n ) { C = 0x79; } else if(posC > 50+n && posC < 60+n ) { C = 0x00; } } if (text == '6'){ @@ -842,67 +842,305 @@ else if(posC > 50+n && posC < 60+n ) { C = 0x00; } } } +void Number(char text,float posA,float posB,float posC,int i) +{ + int n = i*50; + if (i ==1 || i ==2) + {n=(i*50)+15;} + if (text == '0'){ + if (posA > 0+n && posA < 9+n) { A = 0x7F; } + else if(posA > 9+n && posA < 18+n ) { A = 0x41; } + else if(posA > 18+n && posA < 27+n ) { A = 0x41; } + else if(posA > 27+n && posA < 36+n ) { A = 0x41; } + else if(posA > 36+n && posA < 45+n ) { A = 0x7F; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x7F; } + else if(posB > 9+n && posB < 18+n ) { B = 0x41; } + else if(posB > 18+n && posB < 27+n ) { B = 0x41; } + else if(posB > 27+n && posB < 36+n ) { B = 0x41; } + else if(posB > 36+n && posB < 45+n ) { B = 0x7F; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x7F; } + else if(posC > 9+n && posC < 18+n ) { C = 0x41; } + else if(posC > 18+n && posC < 27+n ) { C = 0x41; } + else if(posC > 27+n && posC < 36+n ) { C = 0x41; } + else if(posC > 36+n && posC < 45+n ) { C = 0x7F; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '1'){ + if (posA > 0+n && posA < 9+n) { A = 0x01; } + else if(posA > 9+n && posA < 18+n ) { A = 0x01; } + else if(posA > 18+n && posA < 27+n ) { A = 0x7F; } + else if(posA > 27+n && posA < 36+n ) { A = 0x21; } + else if(posA > 36+n && posA < 45+n ) { A = 0x21; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x01; } + else if(posB > 9+n && posB < 18+n ) { B = 0x01; } + else if(posB > 18+n && posB < 27+n ) { B = 0x7F; } + else if(posB > 27+n && posB < 36+n ) { B = 0x21; } + else if(posB > 36+n && posB < 45+n ) { B = 0x21; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x01; } + else if(posC > 9+n && posC < 18+n ) { C = 0x01; } + else if(posC > 18+n && posC < 27+n ) { C = 0x7F; } + else if(posC > 27+n && posC < 36+n ) { C = 0x21; } + else if(posC > 36+n && posC < 45+n ) { C = 0x21; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '2'){ + if (posA > 0+n && posA < 9+n) { A = 0x21; } + else if(posA > 9+n && posA < 18+n ) { A = 0x51; } + else if(posA > 18+n && posA < 27+n ) { A = 0x49; } + else if(posA > 27+n && posA < 36+n ) { A = 0x45; } + else if(posA > 36+n && posA < 45+n ) { A = 0x23; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x21; } + else if(posB > 9+n && posB < 18+n ) { B = 0x51; } + else if(posB > 18+n && posB < 27+n ) { B = 0x49; } + else if(posB > 27+n && posB < 36+n ) { B = 0x45; } + else if(posB > 36+n && posB < 45+n ) { B = 0x23; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x21; } + else if(posC > 9+n && posC < 18+n ) { C = 0x51; } + else if(posC > 18+n && posC < 27+n ) { C = 0x49; } + else if(posC > 27+n && posC < 36+n ) { C = 0x45; } + else if(posC > 36+n && posC < 45+n ) { C = 0x23; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '3'){ + if (posA > 0+n && posA < 9+n) { A = 0x36; } + else if(posA > 9+n && posA < 18+n ) { A = 0x49; } + else if(posA > 18+n && posA < 27+n ) { A = 0x49; } + else if(posA > 27+n && posA < 36+n ) { A = 0x41; } + else if(posA > 36+n && posA < 45+n ) { A = 0x22; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x36; } + else if(posB > 9+n && posB < 18+n ) { B = 0x49; } + else if(posB > 18+n && posB < 27+n ) { B = 0x49; } + else if(posB > 27+n && posB < 36+n ) { B = 0x41; } + else if(posB > 36+n && posB < 45+n ) { B = 0x22; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x36; } + else if(posC > 9+n && posC < 18+n ) { C = 0x49; } + else if(posC > 18+n && posC < 27+n ) { C = 0x49; } + else if(posC > 27+n && posC < 36+n ) { C = 0x41; } + else if(posC > 36+n && posC < 45+n ) { C = 0x22; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '4'){ + if (posA > 0+n && posA < 9+n) { A = 0x04; } + else if(posA > 9+n && posA < 18+n ) { A = 0x1F; } + else if(posA > 18+n && posA < 27+n ) { A = 0x04; } + else if(posA > 27+n && posA < 36+n ) { A = 0x04; } + else if(posA > 36+n && posA < 45+n ) { A = 0x7C; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x04; } + else if(posB > 9+n && posB < 18+n ) { B = 0x1F; } + else if(posB > 18+n && posB < 27+n ) { B = 0x04; } + else if(posB > 27+n && posB < 36+n ) { B = 0x04; } + else if(posB > 36+n && posB < 45+n ) { B = 0x7C; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x04; } + else if(posC > 9+n && posC < 18+n ) { C = 0x1F; } + else if(posC > 18+n && posC < 27+n ) { C = 0x04; } + else if(posC > 27+n && posC < 36+n ) { C = 0x04; } + else if(posC > 36+n && posC < 45+n ) { C = 0x7C; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '5'){ + if (posA > 0+n && posA < 9+n) { A = 0x46; } + else if(posA > 9+n && posA < 18+n ) { A = 0x49; } + else if(posA > 18+n && posA < 27+n ) { A = 0x49; } + else if(posA > 27+n && posA < 36+n ) { A = 0x49; } + else if(posA > 36+n && posA < 45+n ) { A = 0x79; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x46; } + else if(posB > 9+n && posB < 18+n ) { B = 0x49; } + else if(posB > 18+n && posB < 27+n ) { B = 0x49; } + else if(posB > 27+n && posB < 36+n ) { B = 0x49; } + else if(posB > 36+n && posB < 45+n ) { B = 0x79; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x46; } + else if(posC > 9+n && posC < 18+n ) { C = 0x49; } + else if(posC > 18+n && posC < 27+n ) { C = 0x49; } + else if(posC > 27+n && posC < 36+n ) { C = 0x49; } + else if(posC > 36+n && posC < 45+n ) { C = 0x79; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '6'){ + if (posA > 0+n && posA < 9+n) { A = 0x26; } + else if(posA > 9+n && posA < 18+n ) { A = 0x49; } + else if(posA > 18+n && posA < 27+n ) { A = 0x49; } + else if(posA > 27+n && posA < 36+n ) { A = 0x49; } + else if(posA > 36+n && posA < 45+n ) { A = 0x3E; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x26; } + else if(posB > 9+n && posB < 18+n ) { B = 0x49; } + else if(posB > 18+n && posB < 27+n ) { B = 0x49; } + else if(posB > 27+n && posB < 36+n ) { B = 0x49; } + else if(posB > 36+n && posB < 45+n ) { B = 0x3E; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x26; } + else if(posC > 9+n && posC < 18+n ) { C = 0x49; } + else if(posC > 18+n && posC < 27+n ) { C = 0x49; } + else if(posC > 27+n && posC < 36+n ) { C = 0x49; } + else if(posC > 36+n && posC < 45+n ) { C = 0x3E; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '7'){ + if (posA > 0+n && posA < 9+n) { A = 0x60; } + else if(posA > 9+n && posA < 18+n ) { A = 0x50; } + else if(posA > 18+n && posA < 27+n ) { A = 0x47; } + else if(posA > 27+n && posA < 36+n ) { A = 0x40; } + else if(posA > 36+n && posA < 45+n ) { A = 0x40; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x60; } + else if(posB > 9+n && posB < 18+n ) { B = 0x50; } + else if(posB > 18+n && posB < 27+n ) { B = 0x47; } + else if(posB > 27+n && posB < 36+n ) { B = 0x40; } + else if(posB > 36+n && posB < 45+n ) { B = 0x40; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x60; } + else if(posC > 9+n && posC < 18+n ) { C = 0x50; } + else if(posC > 18+n && posC < 27+n ) { C = 0x47; } + else if(posC > 27+n && posC < 36+n ) { C = 0x40; } + else if(posC > 36+n && posC < 45+n ) { C = 0x40; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '8'){ + if (posA > 0+n && posA < 9+n) { A = 0x36; } + else if(posA > 9+n && posA < 18+n ) { A = 0x49; } + else if(posA > 18+n && posA < 27+n ) { A = 0x49; } + else if(posA > 27+n && posA < 36+n ) { A = 0x49; } + else if(posA > 36+n && posA < 45+n ) { A = 0x36; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x36; } + else if(posB > 9+n && posB < 18+n ) { B = 0x49; } + else if(posB > 18+n && posB < 27+n ) { B = 0x49; } + else if(posB > 27+n && posB < 36+n ) { B = 0x49; } + else if(posB > 36+n && posB < 45+n ) { B = 0x36; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x36; } + else if(posC > 9+n && posC < 18+n ) { C = 0x49; } + else if(posC > 18+n && posC < 27+n ) { C = 0x49; } + else if(posC > 27+n && posC < 36+n ) { C = 0x49; } + else if(posC > 36+n && posC < 45+n ) { C = 0x36; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } + if (text == '9'){ + if (posA > 0+n && posA < 9+n) { A = 0x3E; } + else if(posA > 9+n && posA < 18+n ) { A = 0x49; } + else if(posA > 18+n && posA < 27+n ) { A = 0x49; } + else if(posA > 27+n && posA < 36+n ) { A = 0x49; } + else if(posA > 36+n && posA < 45+n ) { A = 0x32; } + else if(posA > 45+n && posA < 50+n ) { A = 0x00; } + + if (posB > 0+n && posB < 9+n) { B = 0x3E; } + else if(posB > 9+n && posB < 18+n ) { B = 0x49; } + else if(posB > 18+n && posB < 27+n ) { B = 0x49; } + else if(posB > 27+n && posB < 36+n ) { B = 0x49; } + else if(posB > 36+n && posB < 45+n ) { B = 0x32; } + else if(posB > 45+n && posB < 50+n ) { B = 0x00; } + + if (posC > 0+n && posC < 9+n) { C = 0x3E; } + else if(posC > 9+n && posC < 18+n ) { C = 0x49; } + else if(posC > 18+n && posC < 27+n ) { C = 0x49; } + else if(posC > 27+n && posC < 36+n ) { C = 0x49; } + else if(posC > 36+n && posC < 45+n ) { C = 0x32; } + else if(posC > 45+n && posC < 50+n ) { C = 0x00; } + } +} -void Velocity(int v ,float posA,float posB,float posC){ +void Velocity(float v ,float posA,float posB,float posC){ char value[3] ; - sprintf(value ,"%.2f",(v*10)); - Text(value[0],posA,posB,posC,0); - Text(value[1],posA,posB,posC,1); - if (posA > 110 && posA < 120) { A = 0x01; } - if (posB > 110 && posB < 120) { B = 0x01; } - if (posC > 110 && posC < 120) { C = 0x01; } - Text(value[2],posA,posB,posC,2); - if (posA > 180 && posA < 190) { A = 0x7F; } - else if(posA > 190 && posA < 200 ) { A = 0x04; } - else if(posA > 210 && posA < 220 ) { A = 0x0A; } - else if(posA > 220 && posA < 230 ) { A = 0x11; } - else if(posA > 230 && posA < 240 ) { A = 0x0F; } - else if(posA > 240 && posA < 250 ) { A = 0x08; } - else if(posA > 250 && posA < 260 ) { A = 0x04; } - else if(posA > 260 && posA < 270 ) { A = 0x08; } - else if(posA > 270 && posA < 280 ) { A = 0x0F; } - else if(posA > 280 && posA < 290 ) { A = 0x03; } - else if(posA > 290 && posA < 300 ) { A = 0x0C; } - else if(posA > 300 && posA < 310 ) { A = 0x30; } - else if(posA > 310 && posA < 320 ) { A = 0x7F; } - else if(posA > 320 && posA < 330 ) { A = 0x08; } - else if(posA > 330 && posA < 340 ) { A = 0x0F; } - else { A = 0x00; } + float w = v*10; + sprintf(value ,"%f",w); + if (v<10){value[2] = value[1];value[1]=value[0];value[0] = 0;} + if (posA > 180 && posA < 190) { A = 0x0F; } + else if(posA > 190 && posA < 200 ) { A = 0x08; } + else if(posA > 200 && posA < 210 ) { A = 0x7F; } + else if(posA > 210 && posA < 220 ) { A = 0x03; } + else if(posA > 220 && posA < 230 ) { A = 0x0C; } + else if(posA > 230 && posA < 240 ) { A = 0x03; } + else if(posA > 240 && posA < 250 ) { A = 0x0F; } + else if(posA > 250 && posA < 260 ) { A = 0x08; } + else if(posA > 260 && posA < 270 ) { A = 0x04; } + else if(posA > 270 && posA < 280 ) { A = 0x08; } + else if(posA > 280 && posA < 290 ) { A = 0x0F; } + else if(posA > 290 && posA < 300 ) { A = 0x11; } + else if(posA > 300 && posA < 310 ) { A = 0x0A; } + else if(posA > 310 && posA < 320 ) { A = 0x04; } + else if(posA > 320 && posA < 330 ) { A = 0x7F; } + else if(posA > 330 && posA < 340 ) { A = 0x00; } + - if (posB > 180 && posB < 190) { B = 0x7F; } - else if(posB > 190 && posB < 200 ) { B = 0x04; } - else if(posB > 210 && posB < 220 ) { B = 0x0A; } - else if(posB > 220 && posB < 230 ) { B = 0x11; } - else if(posB > 230 && posB < 240 ) { B = 0x0F; } - else if(posB > 240 && posB < 250 ) { B = 0x08; } - else if(posB > 250 && posB < 260 ) { B = 0x04; } - else if(posB > 260 && posB < 270 ) { B = 0x08; } - else if(posB > 270 && posB < 280 ) { B = 0x0F; } - else if(posB > 280 && posB < 290 ) { B = 0x03; } - else if(posB > 290 && posB < 300 ) { B = 0x0C; } - else if(posB > 300 && posB < 310 ) { B = 0x30; } - else if(posB > 310 && posB < 320 ) { B = 0x7F; } - else if(posB > 320 && posB < 330 ) { B = 0x08; } - else if(posB > 330 && posB < 340 ) { B = 0x0F; } - else { B = 0x00; } + + if (posB > 180 && posB < 190) { B = 0x0F; } + else if(posB > 190 && posB < 200 ) { B = 0x08; } + else if(posB > 200 && posB < 210 ) { B = 0x7F; } + else if(posB > 210 && posB < 220 ) { B = 0x03; } + else if(posB > 220 && posB < 230 ) { B = 0x0C; } + else if(posB > 230 && posB < 240 ) { B = 0x03; } + else if(posB > 240 && posB < 250 ) { B = 0x0F; } + else if(posB > 250 && posB < 260 ) { B = 0x08; } + else if(posB > 260 && posB < 270 ) { B = 0x04; } + else if(posB > 270 && posB < 280 ) { B = 0x08; } + else if(posB > 280 && posB < 290 ) { B = 0x0F; } + else if(posB > 290 && posB < 300 ) { B = 0x11; } + else if(posB > 300 && posB < 310 ) { B = 0x0A; } + else if(posB > 310 && posB < 320 ) { B = 0x04; } + else if(posB > 320 && posB < 330 ) { B = 0x7F; } + else if(posB > 330 && posB < 340 ) { B = 0x7F; } + else if(posB > 340 && posB < 350 ) { B = 0x00; } - if (posC > 180 && posC < 190) { C = 0x7F; } - else if(posC > 190 && posC < 200 ) { C = 0x04; } - else if(posC > 210 && posC < 220 ) { C = 0x0A; } - else if(posC > 220 && posC < 230 ) { C = 0x11; } - else if(posC > 230 && posC < 240 ) { C = 0x0F; } - else if(posC > 240 && posC < 250 ) { C = 0x08; } - else if(posC > 250 && posC < 260 ) { C = 0x04; } - else if(posC > 260 && posC < 270 ) { C = 0x08; } - else if(posC > 270 && posC < 280 ) { C = 0x0F; } - else if(posC > 280 && posC < 290 ) { C = 0x03; } - else if(posC > 290 && posC < 300 ) { C = 0x0C; } - else if(posC > 300 && posC < 310 ) { C = 0x30; } - else if(posC > 310 && posC < 320 ) { C = 0x7F; } - else if(posC > 320 && posC < 330 ) { C = 0x08; } - else if(posC > 330 && posC < 340 ) { C = 0x0F; } - else { C = 0x00; } - } + if (posC > 180 && posC < 190) { C = 0x0F; } + else if(posC > 190 && posC < 200 ) { C = 0x08; } + else if(posC > 200 && posC < 210 ) { C = 0x7F; } + else if(posC > 210 && posC < 220 ) { C = 0x03; } + else if(posC > 220 && posC < 230 ) { C = 0x0C; } + else if(posC > 230 && posC < 240 ) { C = 0x03; } + else if(posC > 240 && posC < 250 ) { C = 0x0F; } + else if(posC > 250 && posC < 260 ) { C = 0x08; } + else if(posC > 260 && posC < 270 ) { C = 0x04; } + else if(posC > 270 && posC < 280 ) { C = 0x08; } + else if(posC > 280 && posC < 290 ) { C = 0x0F; } + else if(posC > 290 && posC < 300 ) { C = 0x11; } + else if(posC > 300 && posC < 310 ) { C = 0x0A; } + else if(posC > 310 && posC < 320 ) { C = 0x04; } + else if(posC > 320 && posC < 330 ) { C = 0x7F; } + else if(posC > 330 && posC < 340 ) { C = 0x00; } + + if (posA > 50 && posA < 60) { A = 0x01; } + else if (posA > 60 && posA < 65) { A = 0x00; } + if (posB > 50 && posB < 60) { B = 0x01; } + else if (posB > 60 && posB < 65) { B = 0x00; } + if (posC > 50 && posC < 60) { C = 0x01; } + else if (posC > 60 && posC < 65) { C = 0x00; } + Number(value[2],posA,posB,posC,0); + Number(value[1],posA,posB,posC,1); + Number(value[0],posA,posB,posC,2); +} + + + float posA = 0,posB,posC; @@ -1008,21 +1246,16 @@ delt_t = t.read_us() - count; if (delt_t > 1) { // update LCD once per half-second independent of read rate - x = 1.2; + x = 1; posA += (gz*delt_t*x/1000000); posA = fmod(posA,360); posB = fmod(posA + 240,360); posC = fmod(posA + 120,360); count = t.read_us(); - //Text('O',posA,posB,posC,0); -// Text('B',posA,posB,posC,1); -// Text('I',posA,posB,posC,2); -// Text('F',posA,posB,posC,3); -// Text(' ',posA,posB,posC,4); -// Text(' ',posA,posB,posC,5); if (mode == 1) { + Velocity(v,posA,posB,posC); } else if (mode == 2) @@ -1039,7 +1272,7 @@ delt_t2 = t.read_us() - count2; if (delt_t2 >= 1000000) { - v = (gz*x*PI*0.35*3600)/(180*1000*100); + v =(gz*x*PI*0.35*3600)/(180*1000); pc.printf("%0.1f",v); count2 = t.read_us(); }