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.
Dependencies: Lorawan_Version_0_1
Dependents: Lorawan_Version_0_1
Light/Light.cpp
- Committer:
- jacktractive
- Date:
- 2020-01-24
- Revision:
- 71:ca2425c0a864
- Parent:
- 70:65b2f1cc2859
- Child:
- 72:67c5bce77999
File content as of revision 71:ca2425c0a864:
//1Byte Opcode 0x01 //4Byte Timestemp //4Byte Longitude //4Byte Latitude #include <stdio.h> #include "GPS.h" #include <mbed.h> #include "Light.h" static EventQueue *Ref_Events; Light::Light(EventQueue *q,DigitalOut *la,DigitalOut*lh) { Ref_Events=q; LichtAus=la; LichtHell=lh; } void Light::adjust(bool IsMoving, uint32_t TimeStanding ) { if (this->BlinkEventID == 0){ // if Blinking is active we shouldnt override the blink outputs if(IsMoving) LichtHell->write(1); else LichtHell->write(0); if(TimeStanding>10000) LichtAus->write(1); else LichtAus->write(0); } } void Light::Licht_toggle(Light *l) { printf("\r\n[Light] TOGGLE\n"); if (l->LichtAus->read()){ l->LichtHell->write(1); l->LichtAus->write(0); }else{ l->LichtHell->write(0); l->LichtAus->write(1); } } void Light::Blinken_aus(Light *l) { printf("\n[Light] BLINK STOP\n"); Ref_Events->cancel(l->BlinkEventID); l->BlinkEventID=0; l->LichtHell->write(0); l->LichtAus->write(1); } void Light::Blinken_ein(int time_to_blink) { if (this->BlinkEventID == 0){ // we can only track 1 blinkevent so we cant have 2 running at the same time printf("\n [Light] BLINK START\n"); this->BlinkEventID=Ref_Events->call_every(250,Licht_toggle,this); Ref_Events->call_in(time_to_blink, Blinken_aus,this); } }