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:
2016-12-20
Revision:
0:20bce0dcc921
Child:
1:b2a9a6f2c30e

File content as of revision 0:20bce0dcc921:

#include "ToDoQ.h"
#if defined (TARGET_KL25Z)
    #include "TempHandler.h"
    #include "PowerHandler.h"
    #include "ColorHandler.h"
#elif defined (TARGET_TEENSY3_1)
    #include "TapHandler.h"
#endif

namespace MaruSolSensorManager
{
    static uint32_t read_tilt_delay = 0;
    static ToDoQ* self = NULL;
    ToDoQ*
    ToDoQ::create(onGetTodo callback)
    {
        return self == NULL ? self = new ToDoQ(callback) : self;
    }
    ToDoQ::ToDoQ(onGetTodo callback)
    {
        for (int i = 0; i < TODO_QUEUE_SIZE; i++) {
            q[i] = NULL;
        }
        _onGetTodo = callback;
#if defined (TARGET_KL25Z)
        TempHandler::getInstance();
        PowerHandler::getInstance();
        ColorHandler::getInstance();
        TempHandler::getInstance();
#elif defined (TARGET_TEENSY3_1)
        TapHandler::getInstance();
#endif
    }
    void
    ToDoQ::loop()
    {
        if(read_tilt_delay > 200)
        {
            read_tilt_delay = 0;
            TapHandler::getInstance()->read_tilt();
        }
        else
        {
            ++read_tilt_delay;
        }
        
        for (int i = 0; i < TODO_QUEUE_SIZE; i++)
        {
            if (q[i] != NULL)
            {
                _onGetTodo(q[i]);
                q[i]=NULL;
                break;
            }
        }
    }
    void
    ToDoQ::_queuePut(ToDo *todo)
    {
        SERIAL_PRINT_DBG("ToDoQ::_queuePut entered\n");
        for (int i = 0; i < TODO_QUEUE_SIZE; i++)
        {
            if(q[i] == NULL)
            {
                SERIAL_PRINT_DBG("ToDoQ::_queuePut found empty slot\n");
                q[i] = todo;
                break;
            }
        }
    }
    void
    ToDoQ::queuePut(ToDo *todo)
    {
        self->_queuePut(todo);
    }
};