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
Diff: main.cpp
- Revision:
- 5:46a732673cc5
- Parent:
- 4:610e1572bd1b
- Child:
- 6:5a2c3d7d4623
diff -r 610e1572bd1b -r 46a732673cc5 main.cpp
--- a/main.cpp Thu Mar 24 17:13:45 2022 +0000
+++ b/main.cpp Sat Mar 26 09:26:26 2022 +0000
@@ -11,6 +11,7 @@
// Déclarations des ressources
#include "mbed.h"
#include "fonctions.h" // Appel des fonctions du fichier : fonctions.h
+#include "soft_uart.h"
//==============================================================================
// Déclaration des broches
@@ -23,6 +24,9 @@
char c; // variable de type caractère
float temp; // variable de type réel
int16_t vitesse; // variable de type 16 bits signée
+char tab[10]; // tableau de variable de type caractère
+char buf[10];
+uint8_t ptr, k;
//==============================================================================
// Début du Programme
@@ -30,17 +34,49 @@
{
Init_Fonctions(); // Exécute cette fonction
pc.printf("\r\nFabLab Bluetooth\r\n\n");
+
+ init_uart(); // Initialise la liaison série soft
+ printStr("FabLab Bluetooth\r\n");
+ ptr = 0;
+ k = 0;
//==============================================================================
// Boucle Infinie
while(1)
{
- vitesse = Anemometre();
-
- if(vitesse != -1) // Lecture disponible
+ if (kbhit()) // Un caractère est reçu sur le BT
{
- pc.printf("Vit Vent : %d\n",vitesse); // Affichage sur Putty
+ buf[k] = _getchar(); // Mémorise le carcatère dans un tableau
+
+ if((buf[k] == 0x0A) || (buf[k] == 0x0D)) // Test touche entrée en mode ASCII
+ {
+ buf[k] = 0; // Transforme le tableau en chaine de caractères
+ k = 0; // Met le pointeur à 0
+ pc.printf("%s\n\r",buf); // Envoi le texte vers le PC
+ }
+ else
+ {
+ k++; // incrémente pour lire le prochain caractère
+ }
+
}
+ if(pc.readable()) // Si appui caractère au clavier
+ {
+ tab[ptr] = pc.getc(); // Mémorise le caractère et vide le registre de réception
+
+ if((tab[ptr] == 0x0A) || (tab[ptr] == 0x0D)) // Test touche entrée en mode ASCII
+ {
+ tab[ptr] = 0; // Transforme le tableau en chaine de caractères
+ ptr = 0;
+ printStr(tab); // Envoi le texte vers le BT
+ printStr("\r\n");
+ }
+ else
+ {
+ ptr++;
+ }
+ }
+
} // Fin du while(1)
//==============================================================================
} // Fin du Programme