Tobias Jansen / Mbed OS Lorawan_Version_0_1

Dependencies:   Lorawan_Version_0_1

Dependents:   Lorawan_Version_0_1

Committer:
jacktractive
Date:
Fri Jan 24 07:32:42 2020 +0000
Revision:
71:ca2425c0a864
Parent:
70:65b2f1cc2859
Child:
72:67c5bce77999
GPS und Lora funktioniert.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jacktractive 69:316fee01f5d9 1 //1Byte Opcode 0x01
jacktractive 69:316fee01f5d9 2 //4Byte Timestemp
jacktractive 69:316fee01f5d9 3 //4Byte Longitude
jacktractive 69:316fee01f5d9 4 //4Byte Latitude
jacktractive 69:316fee01f5d9 5
jacktractive 69:316fee01f5d9 6
jacktractive 69:316fee01f5d9 7 #include <stdio.h>
jacktractive 69:316fee01f5d9 8 #include "GPS.h"
jacktractive 69:316fee01f5d9 9 #include <mbed.h>
jacktractive 69:316fee01f5d9 10 #include "Light.h"
jacktractive 70:65b2f1cc2859 11 static EventQueue *Ref_Events;
jacktractive 69:316fee01f5d9 12
jacktractive 70:65b2f1cc2859 13 Light::Light(EventQueue *q,DigitalOut *la,DigitalOut*lh)
jacktractive 69:316fee01f5d9 14 {
jacktractive 69:316fee01f5d9 15 Ref_Events=q;
jacktractive 70:65b2f1cc2859 16 LichtAus=la;
jacktractive 70:65b2f1cc2859 17 LichtHell=lh;
jacktractive 69:316fee01f5d9 18 }
jacktractive 69:316fee01f5d9 19
jacktractive 69:316fee01f5d9 20 void Light::adjust(bool IsMoving, uint32_t TimeStanding )
jacktractive 69:316fee01f5d9 21 {
jacktractive 70:65b2f1cc2859 22 if (this->BlinkEventID == 0){ // if Blinking is active we shouldnt override the blink outputs
jacktractive 70:65b2f1cc2859 23 if(IsMoving) LichtHell->write(1); else LichtHell->write(0);
jacktractive 70:65b2f1cc2859 24 if(TimeStanding>10000) LichtAus->write(1); else LichtAus->write(0);
jacktractive 70:65b2f1cc2859 25 }
jacktractive 69:316fee01f5d9 26 }
jacktractive 69:316fee01f5d9 27
jacktractive 69:316fee01f5d9 28
jacktractive 70:65b2f1cc2859 29 void Light::Licht_toggle(Light *l)
jacktractive 69:316fee01f5d9 30 {
jacktractive 70:65b2f1cc2859 31 printf("\r\n[Light] TOGGLE\n");
jacktractive 70:65b2f1cc2859 32 if (l->LichtAus->read()){
jacktractive 70:65b2f1cc2859 33 l->LichtHell->write(1);
jacktractive 70:65b2f1cc2859 34 l->LichtAus->write(0);
jacktractive 70:65b2f1cc2859 35 }else{
jacktractive 70:65b2f1cc2859 36 l->LichtHell->write(0);
jacktractive 70:65b2f1cc2859 37 l->LichtAus->write(1);
jacktractive 69:316fee01f5d9 38 }
jacktractive 69:316fee01f5d9 39 }
jacktractive 69:316fee01f5d9 40
jacktractive 69:316fee01f5d9 41
jacktractive 69:316fee01f5d9 42
jacktractive 70:65b2f1cc2859 43 void Light::Blinken_aus(Light *l)
jacktractive 69:316fee01f5d9 44 {
jacktractive 70:65b2f1cc2859 45 printf("\n[Light] BLINK STOP\n");
jacktractive 70:65b2f1cc2859 46 Ref_Events->cancel(l->BlinkEventID);
jacktractive 70:65b2f1cc2859 47 l->BlinkEventID=0;
jacktractive 70:65b2f1cc2859 48 l->LichtHell->write(0);
jacktractive 70:65b2f1cc2859 49 l->LichtAus->write(1);
jacktractive 69:316fee01f5d9 50 }
jacktractive 69:316fee01f5d9 51
jacktractive 69:316fee01f5d9 52
jacktractive 69:316fee01f5d9 53 void Light::Blinken_ein(int time_to_blink)
jacktractive 69:316fee01f5d9 54 {
jacktractive 70:65b2f1cc2859 55 if (this->BlinkEventID == 0){ // we can only track 1 blinkevent so we cant have 2 running at the same time
jacktractive 70:65b2f1cc2859 56 printf("\n [Light] BLINK START\n");
jacktractive 71:ca2425c0a864 57 this->BlinkEventID=Ref_Events->call_every(250,Licht_toggle,this);
jacktractive 70:65b2f1cc2859 58 Ref_Events->call_in(time_to_blink, Blinken_aus,this);
jacktractive 70:65b2f1cc2859 59 }
jacktractive 69:316fee01f5d9 60 }
jacktractive 69:316fee01f5d9 61
jacktractive 69:316fee01f5d9 62
jacktractive 69:316fee01f5d9 63
jacktractive 69:316fee01f5d9 64
jacktractive 69:316fee01f5d9 65
jacktractive 69:316fee01f5d9 66