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.
main.cpp
00001 /**********************************************************************/ 00002 /* */ 00003 /* Programme de test de l'extension codeur */ 00004 /* pour la carte F446RE */ 00005 /* */ 00006 /* Sylvain CASTANET - Octobre 2019 */ 00007 /* */ 00008 /* ------ */ 00009 /* */ 00010 /* Test des différentes fonctions de la carte : */ 00011 /* - codeur incrémental */ 00012 /* - poussoir du codeur */ 00013 /* - Led */ 00014 /* */ 00015 /**********************************************************************/ 00016 00017 #include "mbed.h" 00018 #include "C12832.h" 00019 00020 // Using Arduino pin notation 00021 C12832 lcd(D11, D13, D12, D7, D10); 00022 00023 // Entrées numériques 00024 //InterruptIn CodeurA(PA_15,PullUp); // Mode PullUp 00025 //DigitalIn CodeurB(PA_14,PullUp); // Mode PullUp 00026 InterruptIn BP(PC_12); // Mode PullUp 00027 InterruptIn CodeurA(PA_15); //PB_7 00028 InterruptIn CodeurB(PB_7); //PA_15 00029 //InterruptIn BP(PC_12); 00030 Serial pc(SERIAL_TX, SERIAL_RX); 00031 00032 00033 // Leds 00034 DigitalOut Led(PC_10); 00035 00036 int counter=0; 00037 00038 00039 // Sortie de test 00040 00041 00042 void ca(){ 00043 if(CodeurB==0)counter++; 00044 } 00045 void cb(){ 00046 if(CodeurA==0)counter--; 00047 } 00048 00049 void clignot(){ 00050 Led = !Led; 00051 counter=0; 00052 } 00053 00054 int main() 00055 { 00056 lcd.cls(); // Clear screen 00057 lcd.locate(0,3); // 1ere ligne 00058 lcd.printf("Essai du module codeur"); 00059 BP.mode(PullUp); 00060 CodeurA.mode(PullUp); 00061 CodeurB.mode(PullUp); 00062 pc.printf("Hello world \n"); 00063 Led = 1; 00064 CodeurA.fall(&ca); 00065 CodeurB.fall(&cb); 00066 BP.fall(&clignot); 00067 00068 while(1) { 00069 00070 pc.printf("Compteur : %d \r\n",counter); 00071 lcd.locate(0,15); 00072 lcd.printf("Compteur : %d ",counter); 00073 wait_ms(100); 00074 00075 00076 00077 wait(0.1); 00078 } 00079 }
Generated on Tue Nov 8 2022 10:54:14 by
1.7.2