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:
- 22:5b2a7d7c73fa
- Child:
- 23:1d4562f7b639
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ClickClickClouk/codeurRotatifRelatif.cpp Thu May 09 10:32:58 2019 +0000 @@ -0,0 +1,46 @@ +#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 + actB=!pinRot1.read(); //On lit ce qui se passe aux bornes du codeur + actA=!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 || actOldA; + actOldB=actB || actOldB; + } + 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); + } + }*/ +}