final lab 6, écran lcd
Dependencies: mbed-rtos mbed mlcd_32pt
Revision 3:e3681694d955, committed 2013-12-09
- Comitter:
- annicksenecal
- Date:
- Mon Dec 09 20:46:01 2013 +0000
- Parent:
- 2:dfd0d133d964
- Child:
- 4:cb1507dc9dd9
- Commit message:
- reste a terminer copier coller et double clic
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 Fri Dec 06 20:06:30 2013 +0000 +++ b/mlcd_32pt.lib Mon Dec 09 20:46:01 2013 +0000 @@ -1,1 +1,1 @@ -mlcd_32pt#d5e6226759e6 +mlcd_32pt#6f6391e78959
--- a/testLab6.cpp Fri Dec 06 20:06:30 2013 +0000
+++ b/testLab6.cpp Mon Dec 09 20:46:01 2013 +0000
@@ -5,13 +5,27 @@
#include "Serial.h" //Librairie pour la communication série
#include "rtos.h"
+#define ACK 0x06
+#define NAK 0x15
+#define ON 1
+#define OFF 0
+#define DEBUT_LIGNE 0
+#define NOIR 0xFFFF
+#define WIDTH 1
+#define HEIGHT 1
+#define LIGNE_SUIV 15
+
AnalogIn ir(p19); //Initialisation de la pin qui reçoit la valeur du capteur infra-rouge
DigitalOut myled(LED4); //Sert surtout au dépannage
DigitalOut myled2(LED2); //Sert surtout au dépannage
+DigitalOut myled3(LED3);
Serial terminal (USBTX,USBRX); //pour envoyer au port de communication
+int lignes = 0;
bool couleur;
+Mutex flag;
+unsigned char message[50];
void lectureCapteur (void const *args)
{
@@ -20,25 +34,8 @@
if(ir < .6)
{
couleur = false;
-
- }
- else
- {
- couleur = true;
-
- }
- Thread::wait(1000);
- }
-}
-
-void envoiMessage (void const *args)
-{
-
- while(1)
- {
- if (couleur == false)
- {
- printf("c'est noir! (%f)\n \r", ir.read());
+ sprintf((char*)message,"c'est noir! (%f)\n \r", ir.read());
+ printf((char*)message);
myled = 1;
Thread::wait(500);
myled = 0;
@@ -46,23 +43,82 @@
}
else
{
- printf("c'est blanc! (%f)\n \r", ir.read());
+ 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)
+{
+ 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)
+ {
+ copier_coller();
+
+ lignes -= LIGNE_SUIV;
+ }
+ }
+}
+
+/*void resetEcran (void const *args)
+{
+ if (double_clic()) {
+ flag.lock();
+ sprintf((char*)message,"Reset de l'ecran");
+ drawString(DEBUT_LIGNE, lignes, FONT_8_12, NOIR, WIDTH, HEIGHT, message);
+ lignes = 0;
+ }
+
+}
+*/
+
int main()
{
+ int retour = 0;
+ int bckground = 0;
+
+ init_lcd();
+ //bckground = rgb(0,255,0);//213,44,180
+ //retour = setbgColor(bckground);
- init_com(BAUD9600);
-
+ if (retour == NAK)
+ {
+ myled3 = ON;
+ }
+ else
+ {
+ sprintf((char*)message,"Lecture du capteur\n\r");
+ printf("%s", (char*)message);
+ drawString(DEBUT_LIGNE, lignes, FONT_8_12, NOIR, WIDTH, HEIGHT, message);
+ lignes += LIGNE_SUIV;
+ }
+
+
Thread thread(lectureCapteur);
- Thread thread1(envoiMessage);
+ Thread thread1(envoiMessage);
+ //Thread thread2(resetEcran);
while(true);