Control Surface  1.1.1
MIDI Control Surface library for Arduino
MAX7219.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
6 AH_DIAGNOSTIC_WERROR() // Enable errors on warnings
7 
8 #include "StaticSizeExtendedIOElement.hpp"
11 
13 
21 class MAX7219 : public MAX7219_Base, public StaticSizeExtendedIOElement<8 * 8> {
22  public:
29  MAX7219(pin_t loadPin) : MAX7219_Base(loadPin) {}
30 
33  void begin() override { init(); }
34 
39  void pinMode(pin_t pin, uint8_t mode) override __attribute__((deprecated)) {
40  (void)pin;
41  (void)mode;
42  }
43 
53  void digitalWrite(pin_t pin, uint8_t val) override {
54  buffer.set(pin, val);
55  update();
56  }
57 
68  int digitalRead(pin_t pin) override { return buffer.get(pin); }
69 
80  analog_t analogRead(pin_t pin) override __attribute__((deprecated)) {
81  return 1023 * digitalRead(pin);
82  }
83 
97  void analogWrite(pin_t pin, analog_t val) override
98  __attribute__((deprecated)) {
99  digitalWrite(pin, val >= 0x80);
100  }
101 
107  void update() override {
108  for (uint8_t i = 0; i < buffer.getBufferLength(); i++)
109  sendRaw(i + 1, buffer.getByte(i));
110  }
111 
112  private:
114 };
115 
117 
AH::MAX7219_Base
A base class for classes that control MAX7219 LED drivers.
Definition: MAX7219_Base.hpp:23
Warnings.hpp
AH::MAX7219::begin
void begin() override
Initialize.
Definition: MAX7219.hpp:33
AH::ExtIO::digitalRead
int digitalRead(pin_t pin)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:60
AH::pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Hardware-Types.hpp:17
BitArray.hpp
AH_DIAGNOSTIC_POP
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:17
AH::MAX7219::pinMode
void pinMode(pin_t pin, uint8_t mode) override __attribute__((deprecated))
The pinMode function is not implemented because the mode is OUTPUT by definition.
Definition: MAX7219.hpp:39
AH::MAX7219::buffer
BitArray< 8 *8 > buffer
Definition: MAX7219.hpp:113
AH::MAX7219::MAX7219
MAX7219(pin_t loadPin)
Create a MAX7219 ExtendedIOElement.
Definition: MAX7219.hpp:29
AH::MAX7219::digitalWrite
void digitalWrite(pin_t pin, uint8_t val) override
Set the state of a given output pin.
Definition: MAX7219.hpp:53
AH::analog_t
uint16_t analog_t
The type returned from analogRead and similar functions.
Definition: Hardware-Types.hpp:15
AH::MAX7219
A class for LED outputs using the MAX7219 LED display driver.
Definition: MAX7219.hpp:21
AH::StaticSizeExtendedIOElement
A class for ExtendedIOElements with a fixed size.
Definition: StaticSizeExtendedIOElement.hpp:19
AH::MAX7219::update
void update() override
Write the buffer to the display.
Definition: MAX7219.hpp:107
AH::MAX7219::analogRead
analog_t analogRead(pin_t pin) override __attribute__((deprecated))
The analogRead function is deprecated because a MAX7219 is always digital.
Definition: MAX7219.hpp:80
AH_DIAGNOSTIC_WERROR
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:16
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:9
AH::MAX7219::analogWrite
void analogWrite(pin_t pin, analog_t val) override __attribute__((deprecated))
The analogWrite function is deprecated because a MAX7219 is always digital.
Definition: MAX7219.hpp:97
AH::MAX7219::digitalRead
int digitalRead(pin_t pin) override
Get the current state of a given output.
Definition: MAX7219.hpp:68
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:10
AH::ExtIO::digitalWrite
void digitalWrite(pin_t pin, uint8_t val)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:48
AH::BitArray< 8 *8 >
MAX7219_Base.hpp