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
Diff: ClickClickClouk/codeurRotatifRelatif.cpp
- Revision:
- 18:1864979c9b3c
- Child:
- 19:09ad3ca689f3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ClickClickClouk/codeurRotatifRelatif.cpp Sun Apr 28 11:25:43 2019 +0000 @@ -0,0 +1,66 @@ +#include "codeurRotatifRelatif.h" +#include <mbed.h> + +/*int CdRelatif(void){ + DigitalIn pinClick(PG_2); + DigitalIn pinRot1(PG_3); + DigitalIn pinRot2(PG_9); + int actA; //def des variables + int actB; + int actOldA=0; + //int actOldB=0; + while(!pinClick.read()){ //on attent un résultat + actA=!pinRot1.read(); //On lit ce qui se passe aux bornes du codeur + actB=!pinRot2.read(); + if(actA && actB){ //un truc se passe + int r = 1 - 2 * actOldA; //dans un sens on a 1, dans l'autre on a -1 + return r; + } + actOldA=actA; + //actOldB=actB; + } + return 0; +}*/ + +int CdRelatif(void){ + DigitalIn pinClick(PG_2); + DigitalIn pinRot1(PG_3); + DigitalIn pinRot2(PG_9); + int actA; //def des variables + int actB; + while(!pinClick.read()){ //on attent un résultat + //On lit ce qui se passe aux bornes du codeur + actB=!pinRot2.read(); + actA=!pinRot1.read(); + if(actA || actB){ //un truc se passe + int r = 1 - 2 * actA; //dans un sens on a 1, dans l'autre on a -1 + return r; + + + } + } + return 0; +} + +void cRR_test(void){ + LCD_DISCO_F429ZI lcdTemp; + lcdTemp.Clear(LCD_COLOR_BLUE); + for(ever){ + lcdTemp.Clear(LCD_COLOR_BLUE); + int val=CdRelatif(); + BS_displayChiffre(50,50,val,4,LCD_COLOR_WHITE); + wait(1); + } + /*int a=0; + for(ever){ + lcdTemp.Clear(LCD_COLOR_BLUE); + int val=CdRelatif(); + if(val){ + a=a+val; + }else{ + BS_displayChiffre100Clean(50,50,a,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); + BS_displayChiffreClean(150,150,val,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); + wait(1); + } + }*/ +}