48 lines
904 B
C++
48 lines
904 B
C++
/*
|
|
* max7219.h
|
|
*
|
|
* Created: 17-10-17 21:26:30
|
|
* Author: Adrien
|
|
*/
|
|
|
|
|
|
#ifndef __MAX7219_H__
|
|
#define __MAX7219_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
class max7219
|
|
{
|
|
//variables
|
|
public:
|
|
typedef enum{NOP=0x00,D1=0x01,D2=0x02,D3,D4,D5,D6,D7,D8,DECODEMODE,INTENSITY=0x0A,SCANLIMIT,SHUTDOWN,TEST=0x0F} address;
|
|
protected:
|
|
private:
|
|
uint8_t nOfDigit;
|
|
uint8_t din,load,clk;
|
|
uint8_t decodeMode;
|
|
volatile uint8_t *pinDin, *portDin, *ddrDin;
|
|
volatile uint8_t *pinLoad, *portLoad, *ddrLoad;
|
|
volatile uint8_t *pinClk, *portClk, *ddrClk;
|
|
|
|
|
|
|
|
//functions
|
|
public:
|
|
max7219(uint8_t din, uint8_t load, uint8_t clk, uint8_t nOfDigit);
|
|
void sendRAWdata(uint8_t data, address ad);
|
|
void on();
|
|
void off();
|
|
void sendDigitFromArray(uint8_t *array, uint8_t s);
|
|
void setIntensity(uint8_t i);
|
|
protected:
|
|
private:
|
|
void setClkTo(uint8_t v);
|
|
void setLoadTo(uint8_t v);
|
|
void setDataTo(uint8_t v);
|
|
|
|
|
|
}; //max7219
|
|
|
|
#endif //__MAX7219_H__
|