Alexandre Lemay
/
APP1_s5_A17
PARTYYYY
main.cpp@11:09317efe9bb5, 2017-09-06 (annotated)
- Committer:
- ThierryLeonard
- Date:
- Wed Sep 06 03:46:20 2017 +0000
- Revision:
- 11:09317efe9bb5
- Parent:
- MainEvr.cpp@9:b9ac1d914762
Beautify LOL still ugly
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThierryLeonard | 9:b9ac1d914762 | 1 | #include "Accelerometre.h" |
ThierryLeonard | 9:b9ac1d914762 | 2 | #include "Afficheur.h" |
ThierryLeonard | 9:b9ac1d914762 | 3 | |
ThierryLeonard | 9:b9ac1d914762 | 4 | Serial pc(USBTX, USBRX); |
ThierryLeonard | 9:b9ac1d914762 | 5 | int main() { |
ThierryLeonard | 9:b9ac1d914762 | 6 | |
ThierryLeonard | 9:b9ac1d914762 | 7 | |
ThierryLeonard | 9:b9ac1d914762 | 8 | |
ThierryLeonard | 9:b9ac1d914762 | 9 | Afficheur afficheur; |
ThierryLeonard | 9:b9ac1d914762 | 10 | Accelerometre acc; |
ThierryLeonard | 9:b9ac1d914762 | 11 | |
ThierryLeonard | 9:b9ac1d914762 | 12 | double angle = 0; |
ThierryLeonard | 9:b9ac1d914762 | 13 | |
ThierryLeonard | 9:b9ac1d914762 | 14 | while(true){ |
ThierryLeonard | 9:b9ac1d914762 | 15 | |
ThierryLeonard | 9:b9ac1d914762 | 16 | acc.readxyzAngle(&angle); |
ThierryLeonard | 9:b9ac1d914762 | 17 | pc.printf("angle is : %lf\r\n",angle); |
ThierryLeonard | 9:b9ac1d914762 | 18 | |
ThierryLeonard | 9:b9ac1d914762 | 19 | |
ThierryLeonard | 9:b9ac1d914762 | 20 | |
ThierryLeonard | 9:b9ac1d914762 | 21 | char c1[10]; |
ThierryLeonard | 9:b9ac1d914762 | 22 | char c2[4]; |
ThierryLeonard | 9:b9ac1d914762 | 23 | |
ThierryLeonard | 9:b9ac1d914762 | 24 | sprintf(c1 , "%4f" , angle); |
ThierryLeonard | 9:b9ac1d914762 | 25 | int virgule; |
ThierryLeonard | 9:b9ac1d914762 | 26 | int j =0; |
ThierryLeonard | 9:b9ac1d914762 | 27 | for(int i =0;i<4;i++){ |
ThierryLeonard | 9:b9ac1d914762 | 28 | if(c1[j] == '.'){ |
ThierryLeonard | 9:b9ac1d914762 | 29 | virgule = 1 <<j-1; |
ThierryLeonard | 9:b9ac1d914762 | 30 | i--; |
ThierryLeonard | 9:b9ac1d914762 | 31 | j++; |
ThierryLeonard | 9:b9ac1d914762 | 32 | continue; |
ThierryLeonard | 9:b9ac1d914762 | 33 | } |
ThierryLeonard | 9:b9ac1d914762 | 34 | c2[i] = c1[j]; |
ThierryLeonard | 9:b9ac1d914762 | 35 | j++; |
ThierryLeonard | 9:b9ac1d914762 | 36 | |
ThierryLeonard | 9:b9ac1d914762 | 37 | } |
ThierryLeonard | 9:b9ac1d914762 | 38 | |
ThierryLeonard | 9:b9ac1d914762 | 39 | pc.printf("virg= %d",virgule); |
ThierryLeonard | 9:b9ac1d914762 | 40 | afficheur.write(c2,4, virgule); |
ThierryLeonard | 9:b9ac1d914762 | 41 | |
ThierryLeonard | 9:b9ac1d914762 | 42 | pc.printf("test"); |
ThierryLeonard | 9:b9ac1d914762 | 43 | wait(0.45); |
ThierryLeonard | 9:b9ac1d914762 | 44 | } |
ThierryLeonard | 9:b9ac1d914762 | 45 | } |