2

There is a function in the Adafruit SSD1306 Library that prints a scrolling text. For example: display.startscrollright(0x00,0x0F); will print a text scrolling towards the right. What are the arguments "0x00" and "0x0F" for and what kind of arguments are they?

ocrdu
  • 8,705
  • 21
  • 30
  • 42
Souradeep Das
  • 101
  • 1
  • 6

1 Answers1

5

display.startscrollright(0x00,0x0F); will print a text scrolling towards the right. What are the arguments "0x00" and "0x0F for and what kind of arguments are they?

The short answer is that those parameters define which parts of the display to scroll. Using display.startscrollright(0x00,0x0F) will scroll the whole display, as I explain below.


You can learn about this yourself in these steps:

  1. Go to the Adafruit SSD1306 Library source code.

  2. Find the specific code for display.startscrollright() in Adafruit_SSD1306.cpp:

// To scroll the whole display, run: display.startscrollright(0x00, 0x0F) <-- SEE THIS!!
void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop) {
  TRANSACTION_START
  static const uint8_t PROGMEM scrollList1a[] = {
    SSD1306_RIGHT_HORIZONTAL_SCROLL,
    0X00 };
  ssd1306_commandList(scrollList1a, sizeof(scrollList1a));
  ssd1306_command1(start);
  ssd1306_command1(0X00);
  ssd1306_command1(stop);
  static const uint8_t PROGMEM scrollList1b[] = {
    0X00,
    0XFF,
    SSD1306_ACTIVATE_SCROLL };
  ssd1306_commandList(scrollList1b, sizeof(scrollList1b));
  TRANSACTION_END
}

Notice that startscrollright(0x00,0x0F) is specifically described in the code above as scrolling the whole display, so that might be all you were asking. But in case you wanted more explanation, read on.

From Adafruit_SSD1306.h see that:

#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 ///< Init rt scroll
and
#define SSD1306_ACTIVATE_SCROLL 0x2F ///< Start scroll

As you see, the parameters start and stop are passed to the SSD1306 controller, as part of a 0x26 command sequence. Therefore...

  1. Go to the SSD1306 datasheet, and look at the commands (0x26 and 0x2F) being sent to that controller, by the Adafruit library code.

  2. For example, in the datasheet, command 26h (i.e. 0x26) and its parameters are explained e.g.:


Brief overview of horizontal scrolling setup command parameters from SSD1306 datasheet


That part of the datasheet explains that command 26h (i.e. 0x26) sets up the horizontal scroll parameters and describes them.

Then command 2Fh is also explained - this command actually starts the scrolling, after the setup has been done using command 26h (or one of the other scrolling setup commands 27h, 29h, 2Ah):


Brief overview of activate scrolling command from SSD1306 datasheet


Then look at this table for more details about command 26h:


Explanation of SSD1306 command 0x26 from its datasheet


You can see that the two parameters start and stop from that routine in the Adafruit library are actually B[2:0] and D[2:0] in that description i.e. they select which pages of the GDDRAM (i.e. which parts of the display) are scrolled. See:


Explanation of SSD1306 GDDRAM layout from its datasheet


The datasheet includes this example of scrolling only part of the display to the right - in the example it is only PAGE5 to PAGE7 towards the bottom of the screen, which are scrolled:


Example of horizontal scrolling command from SSD1306 datasheet


So that is the whole story - the library routine passes those parameters to the SSD1306 horizontal scrolling setup command, to define which part of the display to scroll.

SamGibson
  • 17,231
  • 5
  • 37
  • 58