nothing

Dependencies:   mbed tsi_sensor

Files at this revision

API Documentation at this revision

Comitter:
benbrou06
Date:
Tue Dec 03 11:04:13 2019 +0000
Commit message:
V1

Changed in this revision

lib.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
tsi_sensor.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib.h	Tue Dec 03 11:04:13 2019 +0000
@@ -0,0 +1,16 @@
+/* This defines will be replaced by PinNames soon */
+#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
+#define ELEC0 9
+#define ELEC1 10
+#elif defined (TARGET_KL05Z)
+#define ELEC0 9
+#define ELEC1 8
+#else
+#error TARGET NOT DEFINED
+#endif
+
+TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
+float lire_slider()
+{
+    return (1-tsi.readPercentage());
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 03 11:04:13 2019 +0000
@@ -0,0 +1,107 @@
+#define DM5_ER
+#ifdef DM5_ER
+
+#include "mbed.h"
+#include "tsi_sensor.h"
+#include "lib.h"
+
+DigitalOut led1(LED_RED);
+DigitalOut led2(LED_GREEN);
+DigitalOut led3(LED_BLUE);
+
+int main(void)
+{
+    float val;
+    int etat=0;
+    led1.write(1);
+    led2.write(1);
+    led3.write(1);
+    while (1) {
+
+        val = lire_slider();
+        printf("val = %f",val);
+        switch ( etat ) { // gestion de l’etat
+            case 0 :
+                if ((val > 0.8)&(val < 1)) {
+                    etat =1;
+                } else if ((val > 0.4)&(val < 0.6)) {
+                    etat =3;
+                } else if (val < 0.2) {
+                    etat =2;
+                }
+                break ;
+            case 1 :
+                if (val ==1) {
+                    etat =4;
+                }
+                break ;
+            case 2 :
+                if (val ==1) {
+                    etat =4;
+                }
+                break ;
+            case 3 :
+                if (val ==1) {
+                    etat =4;
+                }
+                break ;
+            case 4 :
+                if ((val > 0.5)&(val < 1)) {
+                    etat =5;
+                } else if (val < 0.5) {
+                    etat =6;
+                }
+                break ;
+            case 5 :
+                if (val==1) {
+                    etat =0;
+                }
+                break ;
+            case 6 :
+                if (val==1) {
+                    etat =0;
+                }
+                break ;
+        }
+
+        switch ( etat ) { // gestion des sorties
+            case 0 :
+                led1.write(1);
+                led2.write(1);
+                led3.write(1);
+                break ;
+            case 1 :
+                led1.write(0);
+                led2.write(1);
+                led3.write(1);
+                break ;
+            case 2 :
+                led1.write(1);
+                led2.write(0);
+                led3.write(1);
+                break ;
+            case 3 :
+                led1.write(1);
+                led2.write(1);
+                led3.write(0);
+                break ;
+            case 4 :
+                led1.write(1);
+                led2.write(1);
+                led3.write(1);
+                break ;
+            case 5 :
+                led1.write(0);
+                led2.write(0);
+                led3.write(1);
+                break ;
+            case 6 :
+                led1.write(0);
+                led2.write(0);
+                led3.write(0);
+                break ;
+        }
+        wait(0.1);
+    }
+}
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 03 11:04:13 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsi_sensor.lib	Tue Dec 03 11:04:13 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Kojto/code/tsi_sensor/#976904559b5c