Sample Code of http://ohurochan.jp/blog/?p=446 Added SerialController to control BitPattern from PC via Serial. Based on https://developer.mbed.org/users/tandk1124/code/LED_BitPattern/

Dependencies:   mbed

Fork of LED_BitPattern by Takuma Arai

Added Control class for SeirialPC. You can change LED Lighting Bit Pattern from PC Serial. Type "1" to set countup. Type "0" to set countdown.

/media/uploads/tandk1124/bitpattern2log.jpeg

CtrlBase.hpp

Committer:
tandk1124
Date:
2017-03-07
Revision:
6:3e4a21461691
Parent:
5:683d6fff1ebc

File content as of revision 6:3e4a21461691:

#include <mbed.h>

Serial pc(USBTX, USBRX);
Serial uart(p28, p27);

class CtrlBase{
public:
    CtrlBase(Serial& tgt) : _refTarget(tgt){};
    bool isReadable(){
        return _refTarget.readable();
    };
    char getc(){ return _refTarget.getc(); };
    void putc(char c){ _refTarget.putc(c); };
private:
    Serial& _refTarget;
};

class CtrlPCSerial : public CtrlBase {
public:
    CtrlPCSerial(): CtrlBase(pc){};
};

class CtrlUART : public CtrlBase{
public:
    CtrlUART(): CtrlBase(uart){};
};