A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TaskLight.cpp Source File

TaskLight.cpp

00001 /*
00002  * TaskLight.cpp
00003  *
00004  *  Created on: May 27, 2016
00005  *      Author: Adrian
00006  */
00007 
00008 #include "TaskLight.h "
00009 
00010 TaskLight::TaskLight(MAX44009* max44009,Mutex* mutexI2C, Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>* queue){
00011     this->max44009 = max44009;
00012     setMutex(mutexI2C);
00013     setQueue(queue);
00014 }
00015 
00016 TaskLight::TaskLight(MAX44009* max44009,rtos::Mutex* mutexI2C,
00017         rtos::Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>* queue,
00018         osPriority priority, uint32_t stackSize, unsigned char *stackPointer){
00019     this->max44009 = max44009;
00020     setMutex(mutexI2C);
00021     setQueue(queue);
00022     setPriority(priority);
00023     setStackSize(stackSize);
00024     setStackPointer(stackPointer);
00025     setState(SLEEPING);
00026 }
00027 
00028 TaskLight::~TaskLight() {
00029     // TODO Auto-generated destructor stub
00030 }
00031 
00032 void TaskLight::measure(){
00033     MAX44009Message* max44009Message = new MAX44009Message();
00034 
00035     while(true){
00036         mutexInterface->lock(osWaitForever);
00037         max44009Message->setLux(max44009->getLux());
00038         mutexInterface->unlock();
00039 
00040         queue->put(max44009Message,osWaitForever);
00041         osDelay(LIGHT_TASK_DELAY_MS);
00042     }
00043 
00044 }
00045 
00046 void TaskLight::setQueue(Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>* queue){
00047     this->queue = queue;
00048 }
00049