Tobias Jansen / Mbed OS Lorawan_Version_0_1

Dependencies:   Lorawan_Version_0_1

Dependents:   Lorawan_Version_0_1

Light/Light.cpp

Committer:
jacktractive
Date:
2020-01-19
Revision:
69:316fee01f5d9
Child:
70:65b2f1cc2859

File content as of revision 69:316fee01f5d9:

//1Byte Opcode 0x01
//4Byte Timestemp
//4Byte Longitude
//4Byte Latitude 
  
  
#include <stdio.h>
#include "GPS.h"
#include <mbed.h>
#include "Light.h"



DigitalOut LichtAus(PC_12);
DigitalOut LichtHell(PC_9);
DigitalOut led1(LED1);

static EventQueue *Ref_Events;
int BlinkEventID;


    int blink_counter,max_blink_count;
int GPSEvent;

Light::Light(EventQueue *q)
{
    Ref_Events=q;
}

void Light::adjust(bool IsMoving, uint32_t TimeStanding )
{       
     LichtHell=IsMoving;
     LichtAus=TimeStanding>10000;
}

void Light::Licht_aus()
{
     printf("\r\n LICHT AUS \r\n");
     LichtHell=0;
     LichtAus=1;
}

void Light::Licht_an(int time)
{     
    printf("\r\n LICHT AN\r\n"); 
    LichtHell=1;    
    LichtAus=0;
    if (time>0) {Ref_Events->call_in(time, Licht_aus);}    
}


void Light::Licht_hell()
{
     LichtHell=1;
}

void Light::Licht_dunkel()
{
     LichtHell=0;
}


void Light::Licht_toggle()
{      
    printf("\r\n LICHT TOGGLE \r\n"); 
    if (LichtAus)
    {
    LichtHell=1;
    LichtAus=0;           
    }else
    {
    LichtHell=0;
    LichtAus=1;       
    }
}



void Light::Blinken_aus()
{  
    printf("\r\n BLINKEN AUS \r\n");  
    Ref_Events->cancel(BlinkEventID);     
    LichtHell=0;
    LichtAus=1;    
}


void Light::Blinken_ein(int time_to_blink)
{
    printf("\r\n BLINKEN EIN\r\n");   
    BlinkEventID=Ref_Events->call_every(500,Licht_toggle);
    Ref_Events->call_in(time_to_blink, Blinken_aus);
}