Anderson Cunha
/
monitoramento_ativos
Programa Teste para monitoramento de ativos eletricos
Diff: main.cpp
- Revision:
- 5:1b0cd3a1f3c7
- Parent:
- 4:bdc930225ade
diff -r bdc930225ade -r 1b0cd3a1f3c7 main.cpp --- a/main.cpp Wed May 08 21:36:20 2019 -0300 +++ b/main.cpp Tue May 14 22:34:36 2019 -0300 @@ -7,9 +7,9 @@ #define ONE_SECOND 1000 -#define MBED_CONF_EVENTS_PRESENT -#define MBED_CONF_RTOS_PRESENT -#define DEVICE_INTERRUPTIN +// #define MBED_CONF_EVENTS_PRESENT +// #define MBED_CONF_RTOS_PRESENT +// #define DEVICE_INTERRUPTIN DigitalOut led1 (LED1); @@ -34,50 +34,27 @@ led1 = 0; } -void contaFinalFuncao() { - int count = 0; - while(count++ < 10) { - sprintf(l.buffer, "Contando ... %d", count); - l.log(l.buffer); - wait(1.0f); - } - - // eventQueue3.break_dispatch(); -} - -// IRQ CONTEXT !! (n pode haver LOG NA SERIAL NESSE CONTEXTO) -void button_pressed() { - eventQueue2.call(&contaFinalFuncao); -} - int main() { // Sistema.inicializar(/*Confs iniciais do sistema*/); temp.setLog(&l); giro.setLog(&l); gps.setLog(&l); + // 1 - Fazer um time out para verificar a temperatura a cada 5 Segundos Thread eventThread(osPriorityNormal); eventThread.start(callback(&eventQueue1, &EventQueue::dispatch_forever)); - // call blink_led2 every second, automatically defering to the eventThread Ticker ledTicker; ledTicker.attach(eventQueue1.event(&lancaMetodo), 5.0f); - // 1 - Fazer um time out para verificar a temperatura a cada 15 Minutos - // Ticker tempTimeOut; - // tempTimeOut.attach( - // eventQueue.event(&lancaMetodo), - // 3.0f); + // 2 - Verificar se houve alguma mudança no Giroscópio + Giroscopio::setListener(&giro); + Thread eventThread_giroscopio(osPriorityNormal); + eventThread_giroscopio.start(callback(giro.listMovimentacoes(), &EventQueue::dispatch_forever)); - // 2 - Verificar se houve alguma mudança no Giroscópio - // OBSERVA O EVENTO DE HAVER MUDANÇA - giro.ouvirMovimentacao( &interrupcaoMovimentacao ); - - Thread eventThread_count(osPriorityNormal); - eventThread_count.start(callback(&eventQueue2, &EventQueue::dispatch_forever)); - - btn.fall(&button_pressed); - + giro.setCallBackMovimentos(&interrupcaoMovimentacao); + btn.fall( &Giroscopio::ouvirMovimentacao ); // Usa o evento de botao para SIMULAR uma movimentação em estado de IRQ ! + led1 = 0; l.log("FINAL do main ... !"); wait(osWaitForever);