pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT

Dependencies:   mbed MMA8451Q USBDevice WakeUp vt100

Fork of afero_node_suntory_2017_06_15 by Orefatoi

sensors/ToDoQ.cpp

Committer:
wataloh
Date:
2017-05-16
Revision:
14:b205267fa5f6
Parent:
1:b2a9a6f2c30e
Child:
19:b45b077c88bc

File content as of revision 14:b205267fa5f6:

#include "ToDoQ.h"

#include "SensorsMain.hpp"

NAMESPACE_MARUSOLSENSORMANAGER_START

DEF_SELF(ToDoQ);
    
ToDoQ*
ToDoQ::create(onGetTodo callback)
{
    if(self == NULL)
    {
        self = new ToDoQ();
    }
    self->setOnToDo(callback);
    return self;
}

ToDoQ::ToDoQ()
{
    todoQ = new USQueue<ToDo*>(NULL,USQueue<ToDo*>::QSIZE_16);
    for (int i = 0; i < TODO_QUEUE_SIZE; i++)
    {
        q[i] = NULL;
    }
}

void 
ToDoQ::setOnToDo(onGetTodo callback)
{
    _onGetTodo = callback;    
}
    
void
ToDoQ::loop()
{
    SensorsMain::getInstance()->loop();
    
    ToDo* todoP = todoQ->deq();
    
    if(todoP != NULL)
    {
        if(_onGetTodo(todoP)!=true)
        {
//            SERIAL_PRINT_DBG("ToDoQ::_onGetTodo returned false\n");
            ++(todoP->retry_count);
            todoQ->enq(todoP);
        }
        else
        {
            SERIAL_PRINT_DBG("ToDoQ retry count : %d\n", todoP->retry_count);
            todoP->retry_count = 0;
        }
    }
}

void
ToDoQ::_queuePut(ToDo *todo)
{
    SERIAL_PRINT_DBG("ToDoQ::_queuePut entered\n");
    todoQ->enq(todo);
}

void
ToDoQ::queuePut(ToDo *todo)
{
    getInstance<ToDoQ>()->_queuePut(todo);
}

NAMESPACE_MARUSOLSENSORMANAGER_END