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:
Rhyme
Date:
2017-10-18
Revision:
23:e4d2316383a1
Parent:
21:d03c7bbb9f37

File content as of revision 23:e4d2316383a1:

#include "ToDoQ.h"

#include "SensorsMain.hpp"

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);
}

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

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

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