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@18:1864979c9b3c, 2019-04-28 (annotated)
- Committer:
- ascheriit
- Date:
- Sun Apr 28 11:25:43 2019 +0000
- Revision:
- 18:1864979c9b3c
- Child:
- 19:09ad3ca689f3
Debut des betises avec les interuptions.
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 | 18:1864979c9b3c | 10 | int actOldA=0; |
ascheriit | 18:1864979c9b3c | 11 | //int actOldB=0; |
ascheriit | 18:1864979c9b3c | 12 | while(!pinClick.read()){ //on attent un résultat |
ascheriit | 18:1864979c9b3c | 13 | actA=!pinRot1.read(); //On lit ce qui se passe aux bornes du codeur |
ascheriit | 18:1864979c9b3c | 14 | actB=!pinRot2.read(); |
ascheriit | 18:1864979c9b3c | 15 | if(actA && actB){ //un truc se passe |
ascheriit | 18:1864979c9b3c | 16 | int r = 1 - 2 * actOldA; //dans un sens on a 1, dans l'autre on a -1 |
ascheriit | 18:1864979c9b3c | 17 | return r; |
ascheriit | 18:1864979c9b3c | 18 | } |
ascheriit | 18:1864979c9b3c | 19 | actOldA=actA; |
ascheriit | 18:1864979c9b3c | 20 | //actOldB=actB; |
ascheriit | 18:1864979c9b3c | 21 | } |
ascheriit | 18:1864979c9b3c | 22 | return 0; |
ascheriit | 18:1864979c9b3c | 23 | }*/ |
ascheriit | 18:1864979c9b3c | 24 | |
ascheriit | 18:1864979c9b3c | 25 | int CdRelatif(void){ |
ascheriit | 18:1864979c9b3c | 26 | DigitalIn pinClick(PG_2); |
ascheriit | 18:1864979c9b3c | 27 | DigitalIn pinRot1(PG_3); |
ascheriit | 18:1864979c9b3c | 28 | DigitalIn pinRot2(PG_9); |
ascheriit | 18:1864979c9b3c | 29 | int actA; //def des variables |
ascheriit | 18:1864979c9b3c | 30 | int actB; |
ascheriit | 18:1864979c9b3c | 31 | while(!pinClick.read()){ //on attent un résultat |
ascheriit | 18:1864979c9b3c | 32 | //On lit ce qui se passe aux bornes du codeur |
ascheriit | 18:1864979c9b3c | 33 | actB=!pinRot2.read(); |
ascheriit | 18:1864979c9b3c | 34 | actA=!pinRot1.read(); |
ascheriit | 18:1864979c9b3c | 35 | if(actA || actB){ //un truc se passe |
ascheriit | 18:1864979c9b3c | 36 | int r = 1 - 2 * actA; //dans un sens on a 1, dans l'autre on a -1 |
ascheriit | 18:1864979c9b3c | 37 | return r; |
ascheriit | 18:1864979c9b3c | 38 | |
ascheriit | 18:1864979c9b3c | 39 | |
ascheriit | 18:1864979c9b3c | 40 | } |
ascheriit | 18:1864979c9b3c | 41 | } |
ascheriit | 18:1864979c9b3c | 42 | return 0; |
ascheriit | 18:1864979c9b3c | 43 | } |
ascheriit | 18:1864979c9b3c | 44 | |
ascheriit | 18:1864979c9b3c | 45 | void cRR_test(void){ |
ascheriit | 18:1864979c9b3c | 46 | LCD_DISCO_F429ZI lcdTemp; |
ascheriit | 18:1864979c9b3c | 47 | lcdTemp.Clear(LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 48 | for(ever){ |
ascheriit | 18:1864979c9b3c | 49 | lcdTemp.Clear(LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 50 | int val=CdRelatif(); |
ascheriit | 18:1864979c9b3c | 51 | BS_displayChiffre(50,50,val,4,LCD_COLOR_WHITE); |
ascheriit | 18:1864979c9b3c | 52 | wait(1); |
ascheriit | 18:1864979c9b3c | 53 | } |
ascheriit | 18:1864979c9b3c | 54 | /*int a=0; |
ascheriit | 18:1864979c9b3c | 55 | for(ever){ |
ascheriit | 18:1864979c9b3c | 56 | lcdTemp.Clear(LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 57 | int val=CdRelatif(); |
ascheriit | 18:1864979c9b3c | 58 | if(val){ |
ascheriit | 18:1864979c9b3c | 59 | a=a+val; |
ascheriit | 18:1864979c9b3c | 60 | }else{ |
ascheriit | 18:1864979c9b3c | 61 | BS_displayChiffre100Clean(50,50,a,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 62 | BS_displayChiffreClean(150,150,val,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); |
ascheriit | 18:1864979c9b3c | 63 | wait(1); |
ascheriit | 18:1864979c9b3c | 64 | } |
ascheriit | 18:1864979c9b3c | 65 | }*/ |
ascheriit | 18:1864979c9b3c | 66 | } |