Simple control for ST M5451 LED driver.
Sample usage
#include "mbed.h" #include "M5451.h" M5451 m5451(D8, D7); void toggleOneByOne(){ for(char i = 0; i < m5451.outputs(); i++){ m5451.toggleBit(i); m5451.update(); wait_ms(250); m5451.toggleBit(i); } } int main() { while(1) { m5451.setAllBits(0); toggleOneByOne(); m5451.setAllBits(1); toggleOneByOne(); } }
Diff: M5451.h
- Revision:
- 0:b21b3517a1d6
- Child:
- 1:db1e69c22bc6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/M5451.h Sun Mar 01 10:20:26 2020 +0000 @@ -0,0 +1,26 @@ +#ifndef JIRRICK_M5451_H +#define JIRRICK_M5451_H + +#include "mbed.h" + +#define JIRRICK_M5451_WAIT 1 +#define JIRRICK_M5451_OUTPUTS 35 + +class M5451 { +public: + M5451(PinName dataPin, PinName clockPin); + int outputs(); + void setState(uint64_t state); + void setBit(char position, char value); + void setAllBits(char value); + void update(); + uint64_t getState(); + +private: + DigitalOut _dataPin; + DigitalOut _clockPin; + uint64_t _state; + void _send(char bit); +}; + +#endif \ No newline at end of file