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_DISCO_F429ZI mbed BSP_DISCO_F429ZI
ClickClickClouk/codeurRotatifRelatif.cpp@23:1d4562f7b639, 2019-05-10 (annotated)
- Committer:
- ascheriit
- Date:
- Fri May 10 14:06:36 2019 +0000
- Revision:
- 23:1d4562f7b639
- Parent:
- 22:5b2a7d7c73fa
- Parent:
- 20:f3e8319b7899
tentative de fusion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ascheriit | 18:1864979c9b3c | 1 | #include "codeurRotatifRelatif.h" |
ascheriit | 18:1864979c9b3c | 2 | #include <mbed.h> |
ascheriit | 18:1864979c9b3c | 3 | |
ascheriit | 18:1864979c9b3c | 4 | int CdRelatif(void){ |
ascheriit | 18:1864979c9b3c | 5 | DigitalIn pinClick(PG_2); |
ascheriit | 18:1864979c9b3c | 6 | DigitalIn pinRot1(PG_3); |
ascheriit | 18:1864979c9b3c | 7 | DigitalIn pinRot2(PG_9); |
ascheriit | 18:1864979c9b3c | 8 | int actA; //def des variables |
ascheriit | 18:1864979c9b3c | 9 | int actB; |
ascheriit | 19:09ad3ca689f3 | 10 | int actOldA=0; |
ascheriit | 19:09ad3ca689f3 | 11 | int actOldB=0; |
ascheriit | 18:1864979c9b3c | 12 | while(!pinClick.read()){ //on attent un résultat |
ascheriit | 19:09ad3ca689f3 | 13 | actB=!pinRot1.read(); //On lit ce qui se passe aux bornes du codeur |
ascheriit | 19:09ad3ca689f3 | 14 | actA=!pinRot2.read(); |
ascheriit | 19:09ad3ca689f3 | 15 | if(actA && actB){ //un truc se passe |
ascheriit | 19:09ad3ca689f3 | 16 | int r = 1 - 2 * actOldA; //dans un sens on a 1, dans l'autre on a -1 |
ascheriit | 19:09ad3ca689f3 | 17 | return r; |
ascheriit | 18:1864979c9b3c | 18 | } |
ascheriit | 19:09ad3ca689f3 | 19 | actOldA=actA || actOldA; |
ascheriit | 19:09ad3ca689f3 | 20 | actOldB=actB || actOldB; |
ascheriit | 18:1864979c9b3c | 21 | } |
ascheriit | 18:1864979c9b3c | 22 | return 0; |
ascheriit | 18:1864979c9b3c | 23 | } |
ascheriit | 18:1864979c9b3c | 24 | |
ascheriit | 18:1864979c9b3c | 25 | void cRR_test(void){ |
ascheriit | 18:1864979c9b3c | 26 | LCD_DISCO_F429ZI lcdTemp; |
ascheriit | 18:1864979c9b3c | 27 | lcdTemp.Clear(LCD_COLOR_BLUE); |
ascheriit | 20:f3e8319b7899 | 28 | for(ever){ |
ascheriit | 18:1864979c9b3c | 29 | lcdTemp.Clear(LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 30 | int val=CdRelatif(); |
ascheriit | 18:1864979c9b3c | 31 | BS_displayChiffre(50,50,val,4,LCD_COLOR_WHITE); |
ascheriit | 18:1864979c9b3c | 32 | wait(1); |
ascheriit | 20:f3e8319b7899 | 33 | } |
ascheriit | 20:f3e8319b7899 | 34 | /*int a=0; |
ascheriit | 18:1864979c9b3c | 35 | for(ever){ |
ascheriit | 18:1864979c9b3c | 36 | lcdTemp.Clear(LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 37 | int val=CdRelatif(); |
ascheriit | 18:1864979c9b3c | 38 | if(val){ |
ascheriit | 18:1864979c9b3c | 39 | a=a+val; |
ascheriit | 18:1864979c9b3c | 40 | }else{ |
ascheriit | 18:1864979c9b3c | 41 | BS_displayChiffre100Clean(50,50,a,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 42 | BS_displayChiffreClean(150,150,val,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 43 | wait(1); |
ascheriit | 18:1864979c9b3c | 44 | } |
ascheriit | 20:f3e8319b7899 | 45 | }*/ |
ascheriit | 18:1864979c9b3c | 46 | } |