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.
Revision 1:ea27eae94ab2, committed 2021-04-15
- Comitter:
- softris
- Date:
- Thu Apr 15 17:10:47 2021 +0000
- Parent:
- 0:6e688c52e0cc
- Commit message:
- Version de base
Changed in this revision
--- a/Classe_1.cpp Mon Apr 04 08:19:48 2016 +0000
+++ b/Classe_1.cpp Thu Apr 15 17:10:47 2021 +0000
@@ -1,30 +1,26 @@
-
#include "Classe_1.h"
Classe_1::Classe_1 (void)
{
- variable_1 = 0 ;
- };
+ point.x = 0.0f ;
+ point.y = 0.0f ;
+ }
void Classe_1::fonction_1(void)
{
- variable_1++;
- //*pOutput = 0 ;
- //*(pAdresses->pOut) = 0 ;
- pOutput->write(0) ;
+ point.x = 0.0f ;
+ point.y = 0.0f ;
}
-int Classe_1::fonction_2(void)
+
+float Classe_1::fonction_2(void)
{
- //*pOutput = 1 ;
- //*(pAdresses->pOut) = 1 ;
- pOutput->write(1) ;
- return (variable_1);
+ float ret = sqrt( pow ( point.x , 2 ) + pow ( point.y , 2 ) ) ;
+ return (ret);
}
- void Classe_1::Set_Out ()
+int Classe_1::fonction_3(Point *pP)
{
- //pOutput = pOut ;
- pOutput = pAdresses->pOut ;
+ point.x += pP->x ;
+ point.y += pP->y ;
+ return (1);
}
- //int variable_1 ;
-
--- a/Classe_1.h Mon Apr 04 08:19:48 2016 +0000
+++ b/Classe_1.h Thu Apr 15 17:10:47 2021 +0000
@@ -1,31 +1,27 @@
#include "mbed.h"
#ifndef _Classe_1_
+#define _Classe_1_
typedef struct
{
- int Index ;
- DigitalOut *pOut ;
-} Adresses ;
+ float x ;
+ float y ;
+} Point ;
class Classe_1
{
public:
Classe_1(void) ;
- void fonction_1(void) ;
- int fonction_2(void) ;
- void Set_Out (void) ;
- DigitalOut *pOutput ;
-
- Adresses *pAdresses ;
-
- private:
- int variable_1 ;
-
+ void fonction_1(void) ;
+ float fonction_2(void) ;
+ int fonction_3(Point *pPoint) ;
+
+ Point point ;
};
-#define _Classe_1_
+
#endif
--- a/main.cpp Mon Apr 04 08:19:48 2016 +0000
+++ b/main.cpp Thu Apr 15 17:10:47 2021 +0000
@@ -1,38 +1,50 @@
#include "mbed.h"
#include "Classe_1.h"
-DigitalOut myled(LED1);
-DigitalOut led2(LED2);
-DigitalOut led3(LED3);
-Classe_1 Test_Classe ;
+// Objet liaison serie sur USB pour mode debug
+Serial pc(USBTX, USBRX) ;
-
+Classe_1 P1 ;
-signed short Memoire[100] ;
-
-int main() {
- int valeur ;
- Adresses* pTable_Adresses ;
+int main(void) {
+
+ Point P2 ;
+
+ P2.x = 3.0f ;
+ P2.y = 4.0f ;
+
+ P1.fonction_1() ;
- myled = 0 ;
+ pc.printf( "\n\r sortie 1 : x = %6f \t y = %6f " , P1.point.x , P1.point.y ) ;
+ // sortie 1 : x = y =
+
+ P1.fonction_3(&P2) ;
- pTable_Adresses = (Adresses*) &Memoire[10] ;
+ pc.printf( "\n\r sortie 2 : x = %6f \t y = %6f " , P1.point.x , P1.point.y ) ;
+ // sortie 2 : x = y =
+
+ float ret = P1.fonction_2() ;
- pTable_Adresses->pOut = &led3 ;
+ pc.printf( "\n\r sortie 3 : f2 = %6f" , ret ) ;
+ // sortie 3 : f2 =
+
+ Classe_1 *P3 = new ( Classe_1 ) ;
- Test_Classe.pAdresses = pTable_Adresses ;
- Test_Classe.Set_Out () ;
+ P3->fonction_1() ;
+
+ pc.printf( "\n\r sortie 4 : x = %6f \t y = %6f " , P3->point.x , P3->point.y ) ;
+ // sortie 4 : x = y =
+
+ P3->fonction_3(&P2) ;
- while(1) {
-
-
- Test_Classe.fonction_1 ();
-
- myled = 1;
- wait(0.2);
-
- valeur = Test_Classe.fonction_2 ();
- myled = 0;
- wait(0.2);
- }
+ pc.printf( "\n\r sortie 5 : x = %6f \t y = %6f " , P3->point.x , P3->point.y ) ;
+ // sortie 5 : x = y =
+
+ ret = P3->fonction_2() ;
+
+ pc.printf( "\n\r sortie 6 : f2 = %6f" , ret ) ;
+ // sortie 6 : f2 =
+
+ while(1){} ;
+
}
--- a/mbed.bld Mon Apr 04 08:19:48 2016 +0000 +++ b/mbed.bld Thu Apr 15 17:10:47 2021 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file