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 12:04b0ccb40acc, committed 2019-06-02
- Comitter:
- AndersonIctus
- Date:
- Sun Jun 02 16:51:50 2019 -0300
- Parent:
- 11:766cc101f664
- Child:
- 14:85442510347c
- Commit message:
- - Incluindo as logicas para uso do Giroscopio !!
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| sgam-lib.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jun 01 16:41:08 2019 +0000
+++ b/main.cpp Sun Jun 02 16:51:50 2019 -0300
@@ -1,6 +1,54 @@
#include "mbed.h"
-// #include "Grove_temperature.h"
-// #include "MPU6050.h"
+#include "Event.h"
+
+#include "Temperature.h"
+#include "Gyroscope.h"
+
+Serial pc(USBTX, USBRX); // SAIDA SERIAL PADRÃO
+
+// LEDs para serem acesas
+DigitalOut led1 (LED1); // LED 1 de 3 DO BOARD
+DigitalOut led_dig(D6); // LED 1 da porta Digital 6 (A placa tem D6 e D8)
+
+Temperature temp (A1); // Instancia de Temperatura
+
+I2C i2c(I2C_SDA, I2C_SCL); // PORTA I2C
+Gyroscope giro(i2c); // Instancia do Giroscopio
+
+// FILAS PARA EVENTOS
+EventQueue eventQueue1;
+EventQueue eventQueue2;
+
+// --------------------------------------------------------------------------------- //
+void fazLeituraTemperatura() {
+ printf("** Temperatura => %02.02f", *(temp.getValue()) );
+}
+
+void fazLeituraGyroscopio() {
+ GyroscopeData* data = giro.getValue();
+ printf("*** (g_x = %03d; g_y = %03d; g_z = %03d) ***\r\n", data->gx, data->gy, data->gz);
+}
+
+// --------------------------------------------------------------------------------- //
+int main() {
+ printf("!!!INICIO!!!\r\n");
+
+ //////////////////
+ // 1 -> Fazer um temporizador que fica lendo a temperatura a cada 5 segundos !!
+ Thread eventThread(osPriorityNormal);
+ eventThread.start( callback(&eventQueue1, &EventQueue::dispatch_forever) );
+
+ Ticker ledTicker;
+ ledTicker.attach(eventQueue1.event(&fazLeituraTemperatura), 5.0f);
+
+ // 2 - Verificar se houve alguma mudança no Giroscópio
+ // Thread eventThread_2(osPriorityNormal);
+ // eventThread_2.start( callback(&eventQueue2, &EventQueue::dispatch_forever) );
+
+
+ printf("!!!FIM DE INICIALIZACAO!!!\r\n");
+ wait(osWaitForever);
+}
/*
DigitalOut led1 (LED1); // LED 1 de 3 DO BOARD
@@ -89,8 +137,6 @@
printf("!!!FIM DE LEITURA!!!\r\n");
return 1;
}
-*/
+// */
-int main(){
- return 1;
-}
+
--- a/sgam-lib.lib Sat Jun 01 16:41:08 2019 +0000 +++ b/sgam-lib.lib Sun Jun 02 16:51:50 2019 -0300 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/AndersonIctus/code/sgam-lib/#b028b978980a +https://os.mbed.com/users/AndersonIctus/code/sgam-lib/#f998244e9f80