Programa para establecer la comunicación con un módem Siemens A56 y un modulo FRDMKL25Z opera como rastreador satelital para Geolocalizacion. Por la UART (1) se conecta el MODEM y por la uart (2) el GPS (se lee en modo NEMEA) Este sistema genera una cadena de geolocalizacion para GoogleMaps con las coordenadas locales Si previamente se envia el mensaje (Coordenadas o coordenadas) El sistema ademas recibe ordenes de tipo mensaje GSM PDU para accionar cargas

Dependencies:   mbed GPS_G

Conexion propuesta de celular siemens A56i y La FRDMKL25Z /media/uploads/tony63/imgb.jpg Se puede emular un GPS usando una aplicación de Proteus /media/uploads/tony63/imgc.jpg

DebouncedIn.cpp

Committer:
tony63
Date:
2019-04-12
Revision:
3:8aef67673965
Parent:
0:b2a6aa7c0c8c

File content as of revision 3:8aef67673965:

#include "DebouncedIn.h"
#include "mbed.h"

/*
 * Constructor
 */
DebouncedIn::DebouncedIn(PinName in) 
    : _in(in) {    
        
    // reset all the flags and counters    
    _samples = 0;
    _output = 0;
    _output_last = 0;
    _rising_flag = 0;
    _falling_flag = 0;
    _state_counter = 0;
    
    // Attach ticker
    _ticker.attach(this, &DebouncedIn::_sample, 0.005);     
}
  
void DebouncedIn::_sample() {

    // take a sample
    _samples = _samples >> 1; // shift left
      
    if (_in) {
        _samples |= 0x80;
    }  
      
    // examine the sample window, look for steady state
    if (_samples == 0x00) {
        _output = 0;
    } 
    else if (_samples == 0xFF) {
        _output = 1;
    }


    // Rising edge detection
    if ((_output == 1) && (_output_last == 0)) {
        _rising_flag++;
        _state_counter = 0;
    }

    // Falling edge detection
    else if ((_output == 0) && (_output_last == 1)) {
        _falling_flag++;
        _state_counter = 0;
    }
    
    // steady state
    else {
        _state_counter++;
    }
    
   // update the output
    _output_last = _output;
    
}



// return number of rising edges
int DebouncedIn::rising(void) {
    int return_value = _rising_flag; 
    _rising_flag = 0;
    return(return_value);
}

// return number of falling edges
int DebouncedIn::falling(void) {
    int return_value = _falling_flag; 
    _falling_flag = 0;
    return(return_value);
}

// return number of ticsk we've bene steady for
int DebouncedIn::steady(void) {
return(_state_counter);
}

// return the debounced status
int DebouncedIn::read(void) {
    return(_output);
}

// shorthand for read()
DebouncedIn::operator int() {
    return read();
}