flipdot/flipcontrol_esp32/include/flipdot.h

79 lines
1.8 KiB
C
Raw Normal View History

2023-02-07 16:51:02 +00:00
#ifndef FLIPDOT_H
#define FLIPDOT_H
#include <Arduino.h>
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
/*
D7 - Ser (data)
D5 - clock
D1 - _OE
D2 - latch
D3 - _clear
*/
//Pins connected to Shift registers on own controller board
#define PIN_DATA 13
#define PIN_CLK 14
#define PIN_OE 27 //active low
#define PIN_LATCH 26
//Pins connected to stuff on annax driver board
#define PIN_DATA_DRVBRD 33
#define PIN_CLK_DRVBRD 32
//#define PIN_CLEAR 25 //active low
#define PIN_DRIVE 25 //enables 12v to panels via transistor
#define PIN_CLEAR 12 //connects CLEAR Pin from Annax board to GND (clears column)
#define NUMPANELS 1
#define COLUMNBYTES 7 //4 columns per byte. one panel has 25 columns
//### Timings ###
#define MICROS_DRIVEDOTSET 1500 //time dot will be powered for flipping to bright side. in microseconds. 700 sometimes flips too late
#define MICROS_DRIVEDOTCLEAR 20000 //time dot will be powered for flipping to black. in microseconds. always flips at least a whole column. 10000 is too short
#define MICROS_SHIFTDELAY 50/2 //shift register clock (100/2 = 1/(100/1000000) Hz) .at 25/2 nothing is flipping!
#define MICROS_SHIFT_LATCH 100 //latch high time for 595 (row drivers)
class Flipdot
{
private:
int blafoo;
public:
Flipdot();
void init();
void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
bool clearSelectedColumn();
bool setSelectedDot();
void selectColumnClear(uint8_t selcolumn);
void selectColumnSet(uint8_t selcolumn);
void selectColumn(uint8_t selcolumn, bool clear);
bool HBridgeOK();
void shiftData();
void resetColumns();
uint16_t row; //controls shift registers on own controller pcb
uint8_t col[COLUMNBYTES]; //column drivers and shift registers on annax pcb
};
#endif