Skip to content

Commit f739c8f

Browse files
committed
Support for user access to SSD1306 commands longer than one byte
1 parent 2da2f65 commit f739c8f

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

Adafruit_SSD1306.cpp

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,58 @@ void Adafruit_SSD1306::Transaction::data(uint8_t byte) { send(false, byte); }
496496
/*!
497497
@brief Issue a single low-level command directly to the SSD1306
498498
display, bypassing the library.
499-
@param c
499+
@param cmd
500+
Command to issue (0x00 to 0xFF, see datasheet).
501+
@return None (void).
502+
*/
503+
void Adafruit_SSD1306::ssd1306_command(uint8_t cmd) {
504+
Transaction trans(*this);
505+
trans.command(cmd);
506+
}
507+
508+
/*!
509+
@brief Issue a two byte low-level command directly to the SSD1306
510+
display, bypassing the library.
511+
@param cmd
512+
Command to issue (0x00 to 0xFF, see datasheet).
513+
@param a
514+
The second byte of the command.
515+
@return None (void).
516+
*/
517+
void Adafruit_SSD1306::ssd1306_command(uint8_t cmd, uint8_t a) {
518+
Transaction trans(*this);
519+
trans.command(cmd, a);
520+
}
521+
522+
/*!
523+
@brief Issue a three byte low-level command directly to the SSD1306
524+
display, bypassing the library.
525+
@param cmd
500526
Command to issue (0x00 to 0xFF, see datasheet).
527+
@param a
528+
The second byte of the command.
529+
@param b
530+
The third byte of the command.
531+
@return None (void).
532+
*/
533+
void Adafruit_SSD1306::ssd1306_command(uint8_t cmd, uint8_t a, uint8_t b) {
534+
Transaction trans(*this);
535+
trans.command(cmd, a, b);
536+
}
537+
538+
/*!
539+
@brief Issue a multi byte low-level command directly to the SSD1306
540+
display, bypassing the library.
541+
@param cmd
542+
Pointer to command bytes to issue.
543+
@param n
544+
Number of bytes in the command.
501545
@return None (void).
502546
*/
503-
void Adafruit_SSD1306::ssd1306_command(uint8_t c) {
547+
void Adafruit_SSD1306::ssd1306_command(const uint8_t *cmd, uint8_t n) {
504548
Transaction trans(*this);
505-
trans.command(c);
549+
while (n--)
550+
trans.command(pgm_read_byte(cmd++));
506551
}
507552

508553
// ALLOCATE & INIT DISPLAY -------------------------------------------------

Adafruit_SSD1306.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,15 @@ class Adafruit_SSD1306 : public Adafruit_GFX {
156156
void startscrolldiagright(uint8_t start, uint8_t stop);
157157
void startscrolldiagleft(uint8_t start, uint8_t stop);
158158
void stopscroll(void);
159-
void ssd1306_command(uint8_t c);
160159
bool getPixel(int16_t x, int16_t y);
161160
uint8_t *getBuffer(void);
162161

162+
// low level access to SSD1306 commands
163+
void ssd1306_command(uint8_t cmd);
164+
void ssd1306_command(uint8_t cmd, uint8_t a);
165+
void ssd1306_command(uint8_t cmd, uint8_t a, uint8_t b);
166+
void ssd1306_command(const uint8_t *cmd, uint8_t n);
167+
163168
private:
164169
inline void SPIwrite(uint8_t d) __attribute__((always_inline));
165170
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color);

0 commit comments

Comments
 (0)