-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVFD_MN12832L.h
More file actions
116 lines (94 loc) · 2.48 KB
/
VFD_MN12832L.h
File metadata and controls
116 lines (94 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
Mario Becker, 2018, License:MIT.
Code is for TeensyLC, others not tested! Critical things used:
- IntervalTimer
*/
#pragma once
#include <Adafruit_GFX.h>
#include <SPI.h>
template <size_t BitDepth> class MN12832Lgeneric : public Adafruit_GFX
{
public:
MN12832Lgeneric(
byte pinBLK = 4,
byte pinLAT = 6,
byte pinGCP = 3,
byte MOSI_PIN = 11,
byte SCK_PIN = 13);
~MN12832Lgeneric(void);
void begin();
uint32_t getDisplayTime(); // 24us
uint32_t getDisplayFps1(); // 24us
virtual void drawPixel(int16_t x, int16_t y, uint16_t color);
virtual void fillScreen(uint8_t color);
void swapBuffers();
/** must be called from timer or otherwise very regularly ! Go for min 4000 times per sec */
static void refresh();
static const int16_t targetFps = 75 * 44; // this is per gate //
protected:
static void nextGate();
static const int16_t bufferSize = 136 / 8 * 32; // black'n'white, + margin
// bufferlayout
/// front | back
/// 0 | 1 | 0 | 1 //bitplanes
uint8_t buffer[bufferSize*2*BitDepth];
uint16_t bufferOffset = 0;
uint8_t tempBuffer[30];
union u32u4
{
uint64_t u32;
uint8_t u4[4];
};
union u64u8
{
uint64_t u64;
uint8_t u8[8];
};
uint8_t gate;
u64u8 gateBuf;
uint32_t displayTime;
uint32_t displayLast;
uint32_t displayFps1;
uint32_t loadLast;
uint32_t loadFps1;
const byte pinBLK;
const byte pinLAT;
const byte pinGCP;
const byte MOSI_PIN;
const byte SCK_PIN;
SPISettings spiSettings;
static MN12832Lgeneric *_the;
};
/**
* MN12832L in "black'n'white or mono or 1 bit depth.
* In this case the two serial inputs must be wired in parallel.
* * The refresh function is faster -> less CPU load.
* * Needs less memory.
*/
class MN12832Lmono : public MN12832Lgeneric<1>
{
public:
MN12832Lmono(
byte pinBLK = 4,
byte pinLAT = 6,
byte pinGCP = 3,
byte MOSI_PIN = 11,
byte SCK_PIN = 13);
};
/**
* MN12832L with 4 grey levels, colors 0-3.
* In this case the SOUT1 must be connected to SIN2 so the two shift registers are chained S1->S2.
* * 2x CPU load then the mono version
* * Uses 1k more RAM
*/
class MN12832Lgrey : public MN12832Lgeneric<2>
{
public:
MN12832Lgrey(
byte pinBLK = 4,
byte pinLAT = 6,
byte pinGCP = 3,
byte MOSI_PIN = 11,
byte SCK_PIN = 13);
};
#include "VFD_MN12832L.inl"