### Example Usage Source: https://github.com/datacute/tiny4koled/blob/master/README.md Demonstrates how to initialize and use the Tiny4kOLED library, including I2C implementation choices, display rotation, current reference settings, font selection, clearing the display, and updating content. ```c // Choose your I2C implementation before including Tiny4kOLED.h // The default is selected is Wire.h // To use the Wire library: //#include // To use the Adafruit's TinyWireM library: //#include // To use the TinyI2C library from https://github.com/technoblogy/tiny-i2c //#include // The blue OLED screen requires a long initialization on power on. // The code to wait for it to be ready uses 20 bytes of program storage space // If you are using a white OLED, this can be reclaimed by uncommenting // the following line (before including Tiny4kOLED.h): //#define TINY4KOLED_QUICK_BEGIN #include void setup() { // Send the initialization sequence to the oled. This leaves the display turned off oled.begin(); // Two rotations are supported, // The begin() method sets the rotation to 1. //oled.setRotation(0); // Some newer devices do not contain an external current reference. // Older devices may also support using the internal curret reference, // which provides more consistent brightness across devices. // The internal current reference can be configured as either low current, or high current. // Using true as the parameter value choses the high current internal current reference, // resulting in a brighter display, and a more effective contrast setting. //oled.setInternalIref(true); // Two fonts are supplied with this library, FONT8X16 and FONT6X8 // Other fonts are available from the TinyOLED-Fonts library oled.setFont(FONT8X16); // Clear the memory before turning on the display oled.clear(); // Turn on the display oled.on(); // Switch the half of RAM that we are writing to, to be the half that is non currently displayed oled.switchRenderFrame(); } void loop() { updateDisplay(); delay(50); } void updateDisplay() { // Clear the half of memory not currently being displayed. oled.clear(); // Position the text cursor // In order to keep the library size small, text can only be positioned // with the top of the font aligned with one of the four 8 bit high RAM pages. // The Y value therefore can only have the value 0, 1, 2, or 3. // usage: oled.setCursor(X IN PIXELS, Y IN ROWS OF 8 PIXELS STARTING WITH 0); oled.setCursor(0, 1); // Write text to oled RAM (which is not currently being displayed). oled.print(F("ms: ")); // Write the number of milliseconds since power on. oled.print(millis()); // Swap which half of RAM is being written to, and which half is being displayed. // This is equivalent to calling both switchRenderFrame and switchDisplayFrame. oled.switchFrame(); } ``` -------------------------------- ### SSD1306 Display Initialization Parameters Source: https://github.com/datacute/tiny4koled/blob/master/README.md This code snippet demonstrates how to initialize the SSD1306 display for various resolutions and orientations (b=bright, r=rotated) using the `oled.begin()` function with specific initialization data. ```c++ // this is equivalent to tiny4koled_init_128x32r oled.begin(); oled.begin(128, 64, sizeof(tiny4koled_init_128x64), tiny4koled_init_128x64); oled.begin(128, 64, sizeof(tiny4koled_init_128x64b), tiny4koled_init_128x64b); oled.begin(128, 64, sizeof(tiny4koled_init_128x64r), tiny4koled_init_128x64r); oled.begin(128, 64, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br); oled.begin(128, 32, sizeof(tiny4koled_init_128x32), tiny4koled_init_128x32); oled.begin(128, 32, sizeof(tiny4koled_init_128x32b), tiny4koled_init_128x32b); oled.begin(128, 32, sizeof(tiny4koled_init_128x32r), tiny4koled_init_128x32r); oled.begin(128, 32, sizeof(tiny4koled_init_128x32br), tiny4koled_init_128x32br); oled.begin(72, 40, sizeof(tiny4koled_init_72x40), tiny4koled_init_72x40); oled.begin(72, 40, sizeof(tiny4koled_init_72x40b), tiny4koled_init_72x40b); oled.begin(72, 40, sizeof(tiny4koled_init_72x40r), tiny4koled_init_72x40r); oled.begin(72, 40, sizeof(tiny4koled_init_72x40br), tiny4koled_init_72x40br); oled.begin(64, 48, sizeof(tiny4koled_init_64x48), tiny4koled_init_64x48); oled.begin(64, 48, sizeof(tiny4koled_init_64x48b), tiny4koled_init_64x48b); oled.begin(64, 48, sizeof(tiny4koled_init_64x48r), tiny4koled_init_64x48r); oled.begin(64, 48, sizeof(tiny4koled_init_64x48br), tiny4koled_init_64x48br); oled.begin(64, 32, sizeof(tiny4koled_init_64x32), tiny4koled_init_64x32); oled.begin(64, 32, sizeof(tiny4koled_init_64x32b), tiny4koled_init_64x32b); oled.begin(64, 32, sizeof(tiny4koled_init_64x32r), tiny4koled_init_64x32r); oled.begin(64, 32, sizeof(tiny4koled_init_64x32br), tiny4koled_init_64x32br); ``` -------------------------------- ### Resetting SSD1306 to Default Settings Source: https://github.com/datacute/tiny4koled/blob/master/README.md This code snippet shows how to reset an SSD1306 display to its default configuration, including enabling the charge pump and setting a common orientation. ```c++ oled.begin(128, 64, sizeof(tiny4koled_init_defaults), tiny4koled_init_defaults); oled.enableChargePump(); // The default is off, but most boards need this. oled.setRotation(1); // The default orientation is not the most commonly used. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.