Repository navigation
Expand file tree
/
Copy pathAutoPlex14.h
More file actions
70 lines (64 loc) · 2.73 KB
/
Copy pathAutoPlex14.h
File metadata and controls
70 lines (64 loc) · 2.73 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
#ifndef AUTOPLEX14_H
#define AUTOPLEX14_H
#include <Arduino.h>
#define COMMON_ANODE 0
#define COMMON_CATHODE 1
#define CAWDDT 2 // Common Anode With Digit Drive Transistors
#define CCWDDT 3 // Common Cathode With Digit Drive Transistors
#define MAX_DIGITS 6 // Defines the maximum number of digits the library can support per display. You may increase this if you plan to use larger displays, at the cost of more memory usage
#define MAX_DISPLAYS 4 // Defines the maximum number of total individual displays the library can control simultaneously. May be increased at the price of more memory usage
#define AUTOPLEX 1 // Automatic interrupt-based multiplexing
#define MANUALPLEX 0 // Manual multiplexing flag
struct glyph {
char32_t identifier;
uint16_t bitmap;
};
using font = const glyph;
#define END { 0, 0 }
extern font systemFont[];
extern font defaultFont[];
extern uint8_t _displayIndex;
class AutoPlex14 {
private:
uint8_t digitsClass, digitPinsClass[MAX_DIGITS], segmentPinsClass[15];
bool segmentOn, segmentOff, digitOn, digitOff;
volatile uint8_t bufferPos = 0; // The character within the buffer which the multiplexing logic is currently reviewing
volatile uint8_t displayPos = 0; // The physical position of the current character on the display
static bool timerConfigured;
char32_t buffer[(MAX_DIGITS * 2) + 1] = U""; // Buffer to hold the contents of the display. Enough space for MAX_DIGITS characters, decimal points, and a null termination
font* currentFont = defaultFont;
bool manualplexing = false;
inline __attribute__ ((always_inline)) void fastWrite(uint8_t pin, bool val) {
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *out = portOutputRegister(port);
if (val) {
*out |= bit;
}else{
*out &= ~bit;
}
}
void wipeDisplay();
size_t filterDecimals(const char32_t* string);
size_t filterDecimals(const char* string);
char32_t* strcpy8to32(char32_t* dest, const char* src);
char32_t* strcpy32(char32_t* dest, const char32_t* src);
size_t strlen32(const char32_t* string);
public:
static AutoPlex14* displays[MAX_DISPLAYS];
bool begin(uint8_t displayType, uint8_t digits, uint8_t digitPins[], uint8_t segmentPins[], bool multiplexing = AUTOPLEX);
void testDisplay(unsigned long ms);
void multiplex();
void append(const char* text);
void append(const char32_t* text);
void append(int num);
void append(double num, uint8_t decimalPlaces);
void setFont(font* newFont);
void clear();
void print(const char* text);
void print(const char32_t* text);
void print(int num);
void print(double num, uint8_t decimalPlaces);
void print(double num);
};
#endif