Skip to content

Commit 5d3962b

Browse files
committed
Support for user access to SSD1306 commands longer than one byte
1 parent 8d4fddb commit 5d3962b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Adafruit_SSD1306.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,32 @@ void Adafruit_SSD1306::Transaction::data(uint8_t byte) {
453453
Command to issue (0x00 to 0xFF, see datasheet).
454454
@return None (void).
455455
*/
456-
void Adafruit_SSD1306::ssd1306_command(uint8_t c) {
456+
void Adafruit_SSD1306::ssd1306_command(uint8_t cmd) {
457457
Transaction trans(*this);
458-
trans.command(c);
458+
trans.command(cmd);
459459
}
460460

461+
void Adafruit_SSD1306::ssd1306_command(uint8_t cmd, uint8_t a) {
462+
Transaction trans(*this);
463+
trans.command(cmd, a);
464+
}
465+
466+
void Adafruit_SSD1306::ssd1306_command(uint8_t cmd, uint8_t a, uint8_t b) {
467+
Transaction trans(*this);
468+
trans.command(cmd, a, b);
469+
}
470+
471+
void Adafruit_SSD1306::ssd1306_command(const uint8_t *cmd, uint8_t n) {
472+
Transaction trans(*this);
473+
while (n--)
474+
trans.command(pgm_read_byte(cmd++));
475+
}
476+
477+
478+
479+
480+
481+
461482
// ALLOCATE & INIT DISPLAY -------------------------------------------------
462483

463484
/*!

Adafruit_SSD1306.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,15 @@ class Adafruit_SSD1306 : public Adafruit_GFX {
154154
void startscrolldiagright(uint8_t start, uint8_t stop);
155155
void startscrolldiagleft(uint8_t start, uint8_t stop);
156156
void stopscroll(void);
157-
void ssd1306_command(uint8_t c);
158157
boolean getPixel(int16_t x, int16_t y);
159158
uint8_t *getBuffer(void);
160159

160+
// low level access to SSD1306 commands
161+
void ssd1306_command(uint8_t cmd);
162+
void ssd1306_command(uint8_t cmd, uint8_t a);
163+
void ssd1306_command(uint8_t cmd, uint8_t a, uint8_t b);
164+
void ssd1306_command(const uint8_t* cmd, uint8_t n);
165+
161166
private:
162167
inline void SPIwrite(uint8_t d) __attribute__((always_inline));
163168
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w,

0 commit comments

Comments
 (0)