31 lines
736 B
C++
31 lines
736 B
C++
/***************************************************
|
|
7-segment display driver.
|
|
***************************************************/
|
|
|
|
#ifndef DISPLAY_H
|
|
#define DISPLAY_H
|
|
|
|
#include <stdint.h> // For uint8_t
|
|
|
|
class Display {
|
|
public:
|
|
// Constructor with the inverse flag (default false)
|
|
Display(bool inverse = false);
|
|
|
|
// Write a digit (0-9) to the display
|
|
void write(uint8_t digit);
|
|
|
|
// Multiplexed display update
|
|
void update(uint8_t displayNum, uint8_t digit);
|
|
|
|
private:
|
|
bool _inverse;
|
|
|
|
// Helper method to map digit to segment pattern
|
|
uint8_t _digitToPattern(uint8_t digit);
|
|
|
|
// Latch the display (make only selected display active)
|
|
void _latch(uint8_t displayNum);
|
|
};
|
|
|
|
#endif // DISPLAY_H
|