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();
    }
}
Committer:
jirrick
Date:
Sun Mar 01 10:20:26 2020 +0000
Revision:
0:b21b3517a1d6
Child:
1:db1e69c22bc6
initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jirrick 0:b21b3517a1d6 1 #ifndef JIRRICK_M5451_H
jirrick 0:b21b3517a1d6 2 #define JIRRICK_M5451_H
jirrick 0:b21b3517a1d6 3
jirrick 0:b21b3517a1d6 4 #include "mbed.h"
jirrick 0:b21b3517a1d6 5
jirrick 0:b21b3517a1d6 6 #define JIRRICK_M5451_WAIT 1
jirrick 0:b21b3517a1d6 7 #define JIRRICK_M5451_OUTPUTS 35
jirrick 0:b21b3517a1d6 8
jirrick 0:b21b3517a1d6 9 class M5451 {
jirrick 0:b21b3517a1d6 10 public:
jirrick 0:b21b3517a1d6 11 M5451(PinName dataPin, PinName clockPin);
jirrick 0:b21b3517a1d6 12 int outputs();
jirrick 0:b21b3517a1d6 13 void setState(uint64_t state);
jirrick 0:b21b3517a1d6 14 void setBit(char position, char value);
jirrick 0:b21b3517a1d6 15 void setAllBits(char value);
jirrick 0:b21b3517a1d6 16 void update();
jirrick 0:b21b3517a1d6 17 uint64_t getState();
jirrick 0:b21b3517a1d6 18
jirrick 0:b21b3517a1d6 19 private:
jirrick 0:b21b3517a1d6 20 DigitalOut _dataPin;
jirrick 0:b21b3517a1d6 21 DigitalOut _clockPin;
jirrick 0:b21b3517a1d6 22 uint64_t _state;
jirrick 0:b21b3517a1d6 23 void _send(char bit);
jirrick 0:b21b3517a1d6 24 };
jirrick 0:b21b3517a1d6 25
jirrick 0:b21b3517a1d6 26 #endif