2#ifndef SA_OLED_SSD130X_H
3#define SA_OLED_SSD130X_H
39 i2c_address_ =
config.i2c_address;
50 for(
size_t i = 0;
i <
size;
i++)
173 clk_delay =
config.pin_config.sclk_delay;
189 SoftSpiTransmit(
cmd);
195 for(
size_t i = 0;
i <
size;
i++)
196 SoftSpiTransmit(
buff[
i]);
203 val = ((
val & 0x01) << 7) | ((
val & 0x02) << 5) | ((
val & 0x04) << 3)
204 | ((
val & 0x08) << 1) | ((
val & 0x10) >> 1) | ((
val & 0x20) >> 3)
205 | ((
val & 0x40) >> 5) | ((
val & 0x80) >> 7);
207 for(
uint8_t bit = 0
u; bit < 8u; bit++)
209 pin_mosi_.
Write((
val & (1 << bit)) ? 1 : 0);
232template <
size_t w
idth,
size_t height,
typename Transport>
337 size_t Width()
const {
return width; };
342 if(x >= width || y >=
height)
345 buffer_[x + (y / 8) * width] |= (1 << (y % 8));
347 buffer_[x + (y / 8) * width] &= ~(1 << (y % 8));
452template <
size_t w
idth,
size_t height,
typename Transport>
488 transport_.SendCommand(0xaE);
491 transport_.SendCommand(0x20);
494 transport_.SendCommand(0xA6);
497 transport_.SendCommand(0xA8);
501 transport_.SendCommand(0xA4);
504 transport_.SendCommand(0xD3);
508 transport_.SendCommand(0xD5);
509 transport_.SendCommand(0x80);
512 transport_.SendCommand(0xD9);
513 transport_.SendCommand(0x22);
516 transport_.SendCommand(0xDA);
517 transport_.SendCommand(0x12);
520 transport_.SendCommand(0xDB);
521 transport_.SendCommand(0x35);
524 transport_.SendCommand(0x81);
525 transport_.SendCommand(0x80);
528 transport_.SendCommand(0xAF);
531 size_t Width()
const {
return width; };
536 if(x >= width || y >=
height)
539 buffer_[x + (y / 8) * width] |= (1 << (y % 8));
541 buffer_[x + (y / 8) * width] &= ~(1 << (y % 8));
546 for(
size_t i = 0;
i <
sizeof(buffer_);
i++)
548 buffer_[
i] =
on ? 0xff : 0x00;
567 transport_.SendCommand(0xB0 +
i);
568 transport_.SendCommand(0x00);
570 transport_.SendData(&buffer_[width *
i], width);
General Purpose I/O control.
Definition gpio.h:22
void Write(bool state)
Changes the state of the GPIO hardware when configured as an OUTPUT.
void Init()
Initialize the GPIO using the internal Config struct.
void Toggle()
flips the current state of the GPIO. If it was HIGH, it will go LOW, and vice versa.
Result Init(const Config &config)
Result TransmitBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Definition leddriver.h:33
void Init(I2CHandle i2c, const uint8_t(&addresses)[numDrivers], DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, Pin oe_pin=Pin(PORTX, 0))
Definition leddriver.h:65
Definition oled_ssd130x.h:454
void Init(Config config)
Definition oled_ssd130x.h:461
size_t Width() const
Definition oled_ssd130x.h:531
void DrawPixel(uint_fast8_t x, uint_fast8_t y, bool on)
Definition oled_ssd130x.h:534
void Update()
Definition oled_ssd130x.h:555
void Fill(bool on)
Definition oled_ssd130x.h:544
size_t Height() const
Definition oled_ssd130x.h:532
Definition oled_ssd130x.h:140
void SendData(uint8_t *buff, size_t size)
Definition oled_ssd130x.h:192
void SendCommand(uint8_t cmd)
Definition oled_ssd130x.h:186
void Init(const Config &config)
Definition oled_ssd130x.h:168
Definition oled_ssd130x.h:66
void SendCommand(uint8_t cmd)
Definition oled_ssd130x.h:118
void SendData(uint8_t *buff, size_t size)
Definition oled_ssd130x.h:124
void Init(const Config &config)
Definition oled_ssd130x.h:103
Definition oled_ssd130x.h:234
void Update()
Definition oled_ssd130x.h:361
size_t Height() const
Definition oled_ssd130x.h:338
void Fill(bool on)
Definition oled_ssd130x.h:350
size_t Width() const
Definition oled_ssd130x.h:337
void Init(Config config)
Definition oled_ssd130x.h:241
Transport transport_
Definition oled_ssd130x.h:381
void DrawPixel(uint_fast8_t x, uint_fast8_t y, bool on)
Definition oled_ssd130x.h:340
uint8_t buffer_[width *height/8]
Definition oled_ssd130x.h:382
Definition oled_ssd130x.h:16
void Init(const Config &config)
Definition oled_ssd130x.h:37
void SendData(uint8_t *buff, size_t size)
Definition oled_ssd130x.h:48
void SendCommand(uint8_t cmd)
Definition oled_ssd130x.h:42
Result BlockingTransmit(uint8_t *buff, size_t size, uint32_t timeout=100)
Result Init(const Config &config)
static void Delay(uint32_t delay_ms)
static void DelayTicks(uint32_t delay_ticks)
Hardware defines and helpers for daisy field platform.
Definition index.h:2
@ PORTX
Definition daisy_core.h:188
@ PORTB
Definition daisy_core.h:178
@ PORTC
Definition daisy_core.h:179
@ PORTD
Definition daisy_core.h:180
@ PORTG
Definition daisy_core.h:183
struct daisy::I2CHandle::Config::@15 pin_config
Mode mode
Definition i2c.h:65
Speed speed
Definition i2c.h:64
Peripheral periph
Definition i2c.h:57
representation of hardware port/pin combination
Definition daisy_core.h:193
Definition oled_ssd130x.h:457
Transport::Config transport_config
Definition oled_ssd130x.h:458
Definition oled_ssd130x.h:143
void Defaults()
Definition oled_ssd130x.h:157
Config()
Definition oled_ssd130x.h:144
uint32_t sclk_delay
Definition oled_ssd130x.h:151
Pin reset
Definition oled_ssd130x.h:155
Pin mosi
Definition oled_ssd130x.h:153
struct daisy::SSD130x4WireSoftSpiTransport::Config::@10 pin_config
Pin dc
Definition oled_ssd130x.h:154
Pin sclk
Definition oled_ssd130x.h:152
Definition oled_ssd130x.h:69
Pin reset
Definition oled_ssd130x.h:79
Pin dc
Definition oled_ssd130x.h:78
SpiHandle::Config spi_config
Definition oled_ssd130x.h:75
void Defaults()
Definition oled_ssd130x.h:81
struct daisy::SSD130x4WireSpiTransport::Config::@9 pin_config
Config()
Definition oled_ssd130x.h:70
Definition oled_ssd130x.h:237
Transport::Config transport_config
Definition oled_ssd130x.h:238
Definition oled_ssd130x.h:19
uint8_t i2c_address
Definition oled_ssd130x.h:26
void Defaults()
Definition oled_ssd130x.h:27
I2CHandle::Config i2c_config
Definition oled_ssd130x.h:25
Config()
Definition oled_ssd130x.h:20
ClockPolarity clock_polarity
Definition spi.h:104
Peripheral periph
Definition spi.h:100
Pin nss
Definition spi.h:88
struct daisy::SpiHandle::Config::@18 pin_config
Mode mode
Definition spi.h:101
ClockPhase clock_phase
Definition spi.h:105
BaudPrescaler baud_prescaler
Definition spi.h:107
Direction direction
Definition spi.h:102
unsigned long datasize
Definition spi.h:103