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: mbed-rtos mbed mlcd_32pt
Revision 4:cb1507dc9dd9, committed 2013-12-15
- Comitter:
- annicksenecal
- Date:
- Sun Dec 15 16:07:44 2013 +0000
- Parent:
- 3:e3681694d955
- Commit message:
- laboratoire 6 final
Changed in this revision
| mlcd_32pt.lib | Show annotated file Show diff for this revision Revisions of this file |
| testLab6.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/mlcd_32pt.lib Mon Dec 09 20:46:01 2013 +0000 +++ b/mlcd_32pt.lib Sun Dec 15 16:07:44 2013 +0000 @@ -1,1 +1,1 @@ -mlcd_32pt#6f6391e78959 +http://mbed.org/users/annicksenecal/code/mlcd_32pt/#20cb03f394d5
--- a/testLab6.cpp Mon Dec 09 20:46:01 2013 +0000
+++ b/testLab6.cpp Sun Dec 15 16:07:44 2013 +0000
@@ -1,6 +1,6 @@
// Print messages when the AnalogIn is greater than 50%
-#include "mbed.h"
+#include "mbed.h"
#include "mlcd_32pt.h" //Librairie pour l'écran LCD
#include "Serial.h" //Librairie pour la communication série
#include "rtos.h"
@@ -10,7 +10,7 @@
#define ON 1
#define OFF 0
#define DEBUT_LIGNE 0
-#define NOIR 0xFFFF
+#define BLANC 0xFFFF
#define WIDTH 1
#define HEIGHT 1
#define LIGNE_SUIV 15
@@ -27,12 +27,17 @@
Mutex flag;
unsigned char message[50];
-void lectureCapteur (void const *args)
+typedef struct {
+ float gris;
+
+} mail_t;
+
+Mail<mail_t, 16> mail_box;
+
+void lectureCapteur (void const *args) //Lecture du capteur infra-rouge
{
- while(true)
- {
- if(ir < .6)
- {
+ while(true) {
+ if(ir < .6) {
couleur = false;
sprintf((char*)message,"c'est noir! (%f)\n \r", ir.read());
printf((char*)message);
@@ -40,45 +45,39 @@
Thread::wait(500);
myled = 0;
Thread::wait(500);
- }
- else
- {
- couleur = true;
+ } else {
+ couleur = true;
sprintf((char*)message,"c'est blanc! (%f)\n \r", ir.read());
printf((char*)message);
myled2 = 1;
Thread::wait(500);
myled2 = 0;
- Thread::wait(500);
+ Thread::wait(500);
}
-
- }
+
+ }
}
-void envoiMessage (void const *args)
+void envoiMessage (void const *args) //Envoi du message sur l'écran avec le Mailbox
{
- while(1)
- {
- if (couleur == false)
- {
- drawString(DEBUT_LIGNE, lignes, FONT_8_12, NOIR, WIDTH, HEIGHT, message);
- lignes += LIGNE_SUIV;
- Thread::wait(1000);
- }
- else
- {
- drawString(DEBUT_LIGNE, lignes, FONT_8_12, NOIR, WIDTH, HEIGHT, message);
- lignes += LIGNE_SUIV;
- Thread::wait(1000);
- }
-
- if (lignes >= 225)
- {
+ uint32_t i = 0;
+
+ while(1) {
+
+ i++; // fake data update
+ mail_t *mail = mail_box.alloc();
+ mail->gris = i;
+ mail_box.put(mail);
+
+ drawString(DEBUT_LIGNE, lignes, FONT_8_12, BLANC, WIDTH, HEIGHT, message);
+ lignes += LIGNE_SUIV;
+
+ if (lignes >= 225) {
copier_coller();
-
+
lignes -= LIGNE_SUIV;
}
- }
+ } ;
}
/*void resetEcran (void const *args)
@@ -93,35 +92,42 @@
}
*/
-int main()
+int main()
{
- int retour = 0;
- int bckground = 0;
-
+ int retour = 0;
+ int bckground = 0;
+
+ // Initialisation de l'écran
+
init_lcd();
- //bckground = rgb(0,255,0);//213,44,180
- //retour = setbgColor(bckground);
-
- if (retour == NAK)
- {
+ bckground = rgb(213,44,180);
+ retour = setbgColor(bckground);
+
+ if (retour == NAK) {
myled3 = ON;
- }
- else
- {
+ } else {
sprintf((char*)message,"Lecture du capteur\n\r");
printf("%s", (char*)message);
- drawString(DEBUT_LIGNE, lignes, FONT_8_12, NOIR, WIDTH, HEIGHT, message);
+ drawString(DEBUT_LIGNE, lignes, FONT_8_12, BLANC, WIDTH, HEIGHT, message);
lignes += LIGNE_SUIV;
}
+ //boucle avec les threads
Thread thread(lectureCapteur);
Thread thread1(envoiMessage);
- //Thread thread2(resetEcran);
- while(true);
-
-
-
+ //Thread thread2(resetEcran);
+ while(true) {
+ osEvent evt = mail_box.get();
+ if (evt.status == osEventMail) {
+ mail_t *mail = (mail_t*)evt.value.p;
+ printf("Valeur du gris", mail->gris);
+
+ mail_box.free(mail);
+ };
+
+
+
+ }
}
-