19#include "driver/rmt_tx.h"
21#include <initializer_list>
35 using size_type = typename ::std::vector<Pixel>::size_type;
98 const Pixel &color)
noexcept;
133 bool reverse_display =
false);
176 void brightness(uint8_t value) { brightnessWeight = value + 1; }
208 static constexpr uint32_t clockResolutionHz = 10000000;
210 static constexpr size_t symbols_per_byte = 8;
212 static constexpr size_t symbols_per_pixel =
213 sizeof(
Pixel) * symbols_per_byte;
216 rmt_channel_handle_t rmtHandle =
nullptr;
218 rmt_encoder_handle_t pixel_encoder_handle =
nullptr;
220 rmt_bytes_encoder_config_t byte_enc_config{};
226 uint16_t brightnessWeight = 128;
228 uint32_t restTimeNs = 280000;
230 bool reversed =
false;
244 static size_t pixels_rmt_encoder(
247 size_t symbols_written,
249 rmt_symbol_word_t *symbols,
277 uint8_t address7bits);
311 void swap() { _state = ~_state; }
346 void *device =
nullptr;
375 void set(
bool state) { _state = state; }
383 bool get() {
return _state; }
390 void swap() { _state = !_state; }
468 result.screen_height = height;
524 ::std::initializer_list<uint8_t> &&try_addresses,
554 bool write(const uint8_t *buffer, ::std::
size_t size) const noexcept;
573 bool write_cmd(uint8_t command, uint8_t arg) const noexcept;
584 bool write_cmd(uint8_t command, uint8_t arg1, uint8_t arg2) const noexcept;
595 const uint8_t *buffer,
596 ::std::
size_t size) const noexcept;
609 void *device =
nullptr;
622 _params.screen_width = 0;
623 _params.screen_height = 0;
645 uint8_t address7bits,
671 return width_b * height_b * 8;
695 void show(
const uint8_t *frame);
Types and constants required for custom firmware setup.
I2CBus
I2C bus controller.
PixelFormat
Byte order of pixel data starting with the least significant byte.
Low-level interface to LED strips.
pixel_vector_type pixelVector(const Pixel &color=0)
Create a vector of pixels suitable for this LED strip.
typename ::std::vector< Pixel > pixel_vector_type
Pixel vector type.
uint8_t getPixelCount()
Retrieve the pixel count in the strip.
void show(const pixel_vector_type &pixels)
Show pixels all at once.
void brightness(uint8_t value)
Set the global brightness.
LEDStrip(OutputGPIO dataPin, uint8_t pixelCount, bool useLevelShift, PixelDriver driver=PixelDriver::WS2812, bool reverse_display=false)
Create an LED strip.
LEDStrip(const LEDStrip &other)=delete
Copy constructor (deleted)
virtual ~LEDStrip()
Destructor.
void clear()
Turn off all LEDs immediately.
LEDStrip & operator=(const LEDStrip &other)=delete
Copy-assignment (deleted)
LEDStrip & operator=(LEDStrip &&other)
Move-assignment.
LEDStrip(LEDStrip &&other)
Move constructor.
8-LED driver based on the PCF8574 GPIO expander
void shiftLeft()
Shift all lights to the left.
uint8_t getState() const
Get the state of each LED.
PCF8574LedDriver(I2CBus bus, uint8_t address7bits)
Construct a LED driver.
void swap()
Invert the state of all LEDs.
void shiftRight()
Shift all lights to the right.
void setLed(uint8_t index, bool state)
Set the state of a single LED.
void setState(uint8_t state)
Set the state of each LED all at once.
void show() const
Show the required LEDs all at once.
A simple LED driver for a single LED.
void swap()
Invert the state of the LED.
SingleLED(OutputGPIO pin)
Create a new single-LED driver.
void set(bool state)
Set the state of the LED.
bool get()
Get the state of the LED.
void show()
Show the state of the LED.
Everything related to pixel control.
void grant() const
Grant this GPIO for non-exclusive use.
Base class for all displays compatible with SSD1306 (I2C interface)
Controller
OLED controllers that can be automatically detected.
@ SSD1306
SSD1306 OLED controller.
@ UNKNOWN
Unknown OLED controller.
@ SH1107
SH1107 OLED controller.
@ SH1106
SH1106 OLED controller.
OLEDBase(::std::initializer_list< uint8_t > &&try_addresses, I2CBus bus) noexcept
Create an OLED base object.
Controller guess_controller() const noexcept
Guess the OLED controller.
bool available() const noexcept
Check if the OLED was found in the I2C bus.
bool write(const uint8_t *buffer, ::std::size_t size) const noexcept
Raw write.
bool write_gdd_ram(const uint8_t *buffer, ::std::size_t size) const noexcept
Write to GDD RAM.
bool read_status(uint8_t &status) const noexcept
Read the status register.
constexpr OLEDBase() noexcept
Create an uninitialized OLED base object.
virtual ~OLEDBase() noexcept
Destructor.
bool write_cmd(uint8_t command) const noexcept
Write a command with no arguments.
Monochrome OLED working parameters.
bool flip_horizontal
True to flip horizontally.
uint8_t oscillator_frequency
Display clock divide ratio/oscillator frequency.
static OLEDParameters for132x64()
Base parameters for 128x64 displays having a 132x64 controller.
uint8_t display_offset
Row offset where the physical display meets the logical display.
uint8_t screen_height
Screen height resolution in pixels.
bool inverted_display
True to swap black and white pixels.
uint8_t screen_width
Screen width resolution in pixels.
uint8_t start_col
Column pixel index where display starts.
bool flip_vertical
True to flip vertically.
uint8_t COMpins
COM pins value as required by the controller, bit[4] = COM pin configuration, bit[5] = COM left/right...
uint8_t contrast
Display contrast (higher value means higher contrast)
uint8_t start_row
Row pixel index where display starts.
static OLEDParameters withResolution(uint8_t width, uint8_t height, const OLEDParameters ¶ms)
Force a specific graphics resolution.
void show(const uint8_t *frame)
Display a frame at once.
void contrast(uint8_t value)
Set the display contrast.
constexpr OLED()
Create an uninitialized OLED.
uint8_t height_b
Screen height in bytes.
void inverse_display(bool yesOrNo)
Switch pixel colors.
OLED(const OLEDParameters ¶ms, I2CBus bus)
Create an OLED using any of the default I2C addresses.
OLEDParameters parameters() const noexcept
Get the OLED parameters passed in the constructor.
OLED(OLED &&other) noexcept=default
Move-constructor (default)
void turn(bool onOrOff)
Turn display on/off.
void clear(bool inverted=false)
Clear the display.
void init()
Initialize the display (called from the constructor)
OLEDParameters _params
OLED parameters given in the constructor.
uint8_t width_b
Screen width in bytes.
uint8_t row2col(uint8_t bit_index, const uint8_t *from, uint8_t row_count)
Utility function to translate a row-major vector graphic to the column-major format used by OLED scre...
OLED & operator=(const OLED &other) noexcept=delete
Copy-Assignment (deleted)
OLED(const OLED &other) noexcept=delete
Copy-constructor (deleted)
::std::size_t frame_size() const noexcept
Get the frame size in bytes.
OLED(const OLEDParameters ¶ms, uint8_t address7bits, I2CBus bus)
Create an OLED using a specific I2C address.
void locate(uint8_t x, uint8_t page)
Set the start page and start column before display.
OLED & operator=(OLED &&other) noexcept=default
Move-Assignment (default)
void enable_display(bool yesOrNo)
Enable/Disable GDD RAM display.
Output-capable GPIO pin number.
Helper class to wrap around pixel vectors.
typename ::std::vector< Pixel > vector_type
Type of the backing variable.
static void shift_right(vector_type &data, size_type count) noexcept
Shift right (or up)
typename ::std::vector< Pixel >::size_type size_type
Size type of this vector.
static void fill(vector_type &data, const Pixel &color) noexcept
Fill the entire vector with a pixel color.
static void shift_left(vector_type &data, size_type count) noexcept
Shift left (or down)
static void fill(vector_type &data, size_type fromIndex, size_type toIndex, const Pixel &color) noexcept
Fill a segment with a pixel color.
static void shift(vector_type &data, size_type from_index, size_type to_index, size_type shift=1)
Shift the contents of a vector up (right) or down (left)
Pixel in 3-byte packed RGB format.