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

util/DebugIO.hpp

Committer:
wataloh
Date:
2017-01-24
Revision:
2:dfe671e31221
Child:
5:9d5c7ee80f3b

File content as of revision 2:dfe671e31221:

#ifndef _MARUSOL_DEBUG_IO_HPP_
#define _MARUSOL_DEBUG_IO_HPP_
#if 0
#elif defined (TARGET_TEENSY3_1)
        #include "USBSerial.h"
#endif

namespace MaruSolSensorManager
{
    template<type A> class debug_io_singleton
    {
    protected:
        static A *self;
    public:
        static A* getInstance()
        {
            return self!=NULL ? self : new A();
        }
        static void destroy()
        {
            if(self!=NULL)
            {
                delete self;
                self = NULL;
            }
        }
    };
    
    template<> A debug_io_singleton<A>::self = NULL;
    
    class DebugIO : public debug_io_singleton<DebugIO>
    {
#if defined (TARGET_KL25Z)
        Serial *debugIO;
#elif defined (TARGET_TEENSY3_1)
        USBSerial *debugIO;
#endif
    public:
        friend class debug_io_singleton;
        DebugIO::DebugIO()
        {
            if(PREFERENCES::DBG_ENABLED == true || PREFERENCES::DBG_ASR_ENABLED == true)
            {
#if defined (TARGET_KL25Z)
                debugIO = new Serial();
                debugIO->baud(PINS::UART::BAUD_RATE);
                pPrintf = &DebugIO::printf;
#elif defined (TARGET_TEENSY3_1)
                debugIO = new USBSerial();
#endif
            }
            else
            {
                pPrintf = &DebugIO::printfNOP;
            }
        }
        enum MSG_TYPE
        {
            DBG = 0,
            DBG_ASR_1,
            INFO
        };
        template <typename... Args> void (DebugIO::*pPrintf)(MSG_TYPE type, char *fmt, ...);
        template <typename... Args> void printfNOP(MSG_TYPE type, char *fmt, Args... args)
        {
            
        }
        
        template <class... Args> void f(Args... args);
        
        template <typename... Args> printf(MSG_TYPE type, char *fmt, Args... args)
        {
            
            debugIO->printf(type,fmt,args...);
            
            if(type == MSG_TYPE::DBG || PREFERENCES::DBG_ENABLED == true)
            {
                
            }
        }
        template <typename... Args> print_dbg(char* fmt, Args... args)
        {
            this->printf(DBG, fmt,args...);
        }
        template <typename... Args> print_dbg_asr(char* fmt, Args... args)
        {
            this->printf(DBG_ASR, fmt,args...);
        }
    };
};
#endif
#endif //_MARUSOL_DEBUG_IO_HPP_