• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple and small library to control 1-bpp OLED displays (Linux + Arduino)

ss_oled (Small Simple OLED library)

Project started 1/15/2017
Copyright (c) 2017 BitBank Software, Inc.
Written by Larry Bank
[email protected]

ss_oled
The purpose of this code is to easily control SH1106/SSD1306 OLED displays using a minimum of FLASH and RAM. The displays can be connected to the traditional I2C bus or you can use any 2 GPIO pins to define a virtual I2C bus. On AVR microcontrollers, there is an optimized option to speed up access to the GPIO pins to allow speeds which match or exceed normal I2C speeds. The pins are numbered with the Port letter as the first digit followed by the bit number. For example, To use bit 0 of Port B, you would reference pin number 0xb0. Includes the unique feature that the init function can optionally detect the display address (0x3C or 0x3D) and the controller type (SSD1306, SH1106 or SH1107).
I try to support as many OLEDs as I can. I was able to justify buying a bunch of different sized SSD1306 displays because they're around $2 each. A generous patron donated money so that I could purchase Pimoroni's 128x128 OLED and add support for it. It uses the SH1107 controller and behaves very similarly to the SH1106.

Features:
---------

  • Supports any number of simultaneous displays of any type (mix and match)
  • Optionally detect the display address and type (I2C only)
  • Supports 72x40, 96x16, 64x32, 128x32, 128x64, 128x128 (SH1107) and 132x64 (SH1106) display sizes
  • Drive displays from I2C, SPI or any 2 GPIO pins (virtual I2C)
  • 5 sizes of fixed fonts (6x8, 8x8, 12x16, 16x16, 16x32)
  • Deferred rendering allows preparing a back buffer, then displaying it (usually faster)
  • Text scrolling features (vertical and horizontal)
  • Text cursor position with optional line wrap
  • a function to load a Windows BMP file
  • Pixel drawing on SH1106/7 without needing backing RAM
  • Draw text into the back buffer at any scale and rotation (in 90 deg increments)
  • Optimized Bresenham line drawing
  • Optimized Bresenham outline and filled ellipse drawing
  • Optimized outline and filled rectangle drawing
  • Optional backing RAM for drawing pixels for systems with enough RAM
  • 16x16 Tile/Sprite drawing at any angle.
  • Run full frame animations at high frame rates with a simple API
  • Light enough to run on an ATtiny85

This code depends on the BitBang_I2C library. You can download it here:

https://github.com/bitbank2/BitBang_I2C

Instructions for use:
---------------------
Start by initializing the library. Either using hardware I2C, bit-banged I2C or SPI to talk to the display. For I2C, the address of the display will be detected automatically (either 0x3c or 0x3d). The typical MCU only allows setting the I2C speed up to 400Khz, but the SSD1306 displays can handle a much faster signal. With the bit-bang code, you can usually specify a stable 800Khz clock and with Cortex-M0 targets, the hardware I2C can be told to be almost any speed, but the displays I've tested tend to stop working beyond 1.6Mhz. After initializing the display you can begin drawing text or graphics on it. The final parameter of all of the drawing functions is a render flag. When true, the graphics will be sent to the internal backing buffer (when available) and sent to the display. You optionally pass the library a backing buffer (if your MCU has enough RAM) with the oledSetBackBuffer() function. When the render flag is false, the graphics will only be drawn into the internal buffer. Once you're ready to send the pixels to the display, call oledDumpBuffer(NULL) and it will copy the internal buffer in its entirety to the display. The text drawing function now has a scroll offset parameter. This tells it how many pixels of the text to skip before drawing the text at the given destination coordinates. For example, if you pass a value of 20 for the scroll offset and are using an 8-pixel wide font (FONT_NORMAL), the first two and a half characters will not be drawn; the second half of the third and subsequent characters will be drawn starting at the x/y you specified. This allows you to create a scrolling text effect by repeatedly calling the oledWriteString() function with progressively larger scroll offset values to make the text scroll from right to left.

If you find this code useful, please consider sending a donation.

paypal

More Repositories

1

JPEGDEC

An optimized JPEG decoder suitable for microcontrollers and PCs.
C
399
star
2

Thermal_Printer

Arduino library to draw text and graphics on BLE thermal printers
C
373
star
3

AnimatedGIF

An optimized GIF decoder suitable for microcontrollers and PCs
C
363
star
4

BitBang_I2C

A software I2C implementation to run on any GPIO pins on any system
C++
240
star
5

image_to_c

Convert image files into C arrays of uint8_t for compiling into your project
C
198
star
6

OneBitDisplay

A full featured Arduino display library for 1-bit per pixel OLED, LCD and e-paper displays
C
195
star
7

PNGdec

An optimized PNG decoder suitable for microcontrollers and PCs
C
180
star
8

SPI_LCD

A simple C library for directly communicating with SPI-connected LCD displays
C
112
star
9

bb_spi_lcd

SPI LCD/OLED library which can be built for Arduino and Linux
C++
91
star
10

SmartResponseXE

Arduino library with LCD, Keyboard and SPI Flash support for the SMART Response XE classroom communicator
C++
89
star
11

SLIC

Simple lossless imaging codec
C++
80
star
12

oled_96

A simple C library (Linux + Arduino) for drawing text and graphics on SSD1306/SH1106 OLED displays
C
79
star
13

ArmbianIO

A C (+ Python and Java) library for simplifying access to I2C, SPI and GPIO on boards supported by Armbian
C
78
star
14

Multi_OLED

Control multiple OLED displays on one or more I2C buses simultaneously
C++
76
star
15

Print2BLE

MacOS app which allows drag and drop of images to BLE thermal printers
Objective-C
72
star
16

CYD_Projects

A collection of Arduino sketches for the "Cheap Yellow Display" board(s)
C
58
star
17

JPEGENC

Arduino JPEG encoder
C++
55
star
18

VL53L0X

A simple C library to read the distance values from the VL53L0X time of flight sensor
C
54
star
19

unzipLIB

An embedded-friendly library for decompressing files from zip archives
C
51
star
20

oled_turbo

An experiment to push the limits of the SSD1306 through bit banging on Arduinos
C++
45
star
21

PNGenc

An embedded-friendly PNG encoder
C
39
star
22

Multi_BitBang

A software I2C implementation to create multiple I2C buses using GPIO lines
C++
38
star
23

giflib-turbo

A faster drop-in replacement for giflib. It uses more RAM, but you get more speed.
C
37
star
24

SMART_bootloader

Send sketches wirelessly from the Arduino IDE to your SMART Response XE
C
35
star
25

BB-CP

A faster replacement for FBTFT + FBCP
C
31
star
26

LCD1602

A C library (Linux + Arduino) to control 2 line x 16 character I2C LCD displays
C
28
star
27

ssd1327

SSD1327 and SSD1322 OLED display library for Arduino+Linux
C++
26
star
28

oled_animator

C code for converting animated GIF images into a form to run on MCUs and SSD1306 OLED displays
C
26
star
29

Pocket_CO2

A CH32V003 low cost pocket CO2 sensor
C
24
star
30

BLE_Keyboard

An HID keyboard sketch for the Arduino Nano 33 BLE
C++
23
star
31

TIFF_G4

A set of highly optimized functions for decoding and displaying 1-bpp CCITT G4 images
C
22
star
32

I2C_Detector

Scan I2C buses and identify devices which respond.
C++
22
star
33

MAX7219

A C library for controlling any number of Maxim LED matrix controllers
C
21
star
34

bb_captouch

An ESP32/Arduino library to talk to CST820, FT6x36 and GT911 capacitive touch sensors (auto-detects)
C++
21
star
35

Pi_Pico_C_Projects

A collection of C code for the Raspberry Pi Pico
C
20
star
36

uc1701

A C library (Linux + Arduino) to control the UC1701/ST7565/ST7920 128x64 monochrome LCD
C
20
star
37

sg_free

The open source version of SmartGear - a multi-system game emulator
C
19
star
38

epd_image

Prepare image data for writing directly to e-paper displays
C++
18
star
39

bbgfx

BitBank Graphics Library - optimized primitives for RGB565 surfaces on ARMv5
C
17
star
40

Nano_33_Gamepad

A sketch to connect BLE HID gamepads to the Arduino Nano 33 BLE
C++
15
star
41

sense_hat_unchained

A C library to work with the Sense Hat on non-RPI hardware
C
15
star
42

tm1637

A C library for controlling Titan Micro Electronic's 7-segment LED controller
C
13
star
43

esp32_gamepad

Arduino library to connect a SteelSeries:Free gamepad to your ESP32 microcontroller
C++
13
star
44

BLE_2_EPaper

A collection of projects to send images over BLE to e-paper displays
C
12
star
45

KiCad_Projects

A place to share all of my PCB projects
12
star
46

gcc_perf

Test ARM/X86 C/SIMD/ASM perf on 32-bit and 64-bit Linux to see machine/compiler differences
C
12
star
47

bb_truetype

An incomplete, but fast + useful truetype font renderer for embedded devices
C++
11
star
48

Animated_Sand

Arduino demo for SSD1306 I2C display + MPU-6050 accelerometer.
C++
11
star
49

G4Enc

Optimized CCITT G4 encoder for embedded and larger systems
C++
10
star
50

FastIO

A fast substitute for Arduino digital pin functions on AVR MCUs
C++
10
star
51

bin_to_c

A simple Linux command line tool for turning binary files into C source code (array of unsigned chars)
C
9
star
52

gif_play

Play animated GIF images directly on a Linux framebuffer or SPI LCD
C
9
star
53

ESP_NOW_Weather

An e-paper weather project which uses a client/server approach to save battery life
C
9
star
54

bb_epaper

A frustration-free library for working with all 24-pin eink panels
C
8
star
55

NeoPixel

A simple NeoPixel (WS2812B) sketch for generating long light patterns with low RAM usage
C++
8
star
56

TwoBitDisplay

An Arduino library to control 2-bit (4 gray level) LCD displays
C++
8
star
57

RemoteDisplay

An Arduino library to control local or remote (BLE/I2C/UART/WiFi) displays with optional button input
C++
8
star
58

CH32V_Experiments

A place to share code and projects related to the WCH CH32V RISC-V processors
C
8
star
59

CCS811

A simple C library for working with the CCS811 air quality sensor
C
8
star
60

ESLImageTransfer

An Android native app to transfer images to the hacked ESLs
Java
7
star
61

gnu_asm

A C command line tool to convert Microsoft ASM files to GAS (GNU assembler) format
C
7
star
62

hx1230

A C library (Linux + Arduino) to control hx1230 monochrome LCDs
C++
7
star
63

bme280

A simple C library (Linux + Arduino) to read the calibrated temperature/pressure/humidity values from a Bosch BME280 I2C sensor
C
6
star
64

CH32V003_Sensor_Platform

Firmware for a small PCB with LCD which allows easy plug-n-play field-testing of some I2C sensors
C
6
star
65

zlib_turbo

Optimized zlib inflate (+gzip) library for embedded
C++
6
star
66

SmartGear_ESP32

multi-game emulator for the ESP32
C++
5
star
67

ir_receiver

C code to receive NEC codes from a GPIO connected to a IR demodulator
C
5
star
68

LED_Clock

A low cost PCB project (w/firmware) for a dark-room-friendly digital clock
C
5
star
69

CH32V_Color_LCD

A set of functions to control Sitronix color LCDs on CH32V RISC-V MCUs
C
5
star
70

rtc_eeprom

C code to talk to the DS3231 and AT24C32 (usually sold together)
C++
5
star
71

zeemouse

Use 'undocumented' bluetooth game controllers to control your mouse and/or generate keypresses from buttons and stick movements
C
5
star
72

bb_uc1701

Arduino ST7565/UC1701 128x64 LCD display library
C++
5
star
73

CO2_USB_033

A portable CO2 monitor based on the CH32X033 MCU
C
5
star
74

W600FastIO

Optimized GPIO pin functions for the WinnerMicro W600 SoC
C++
4
star
75

arduinoVNC

A VNC client for Arduino
C++
4
star
76

max44009

A simple C library to initialize and read the ambient light value
C
3
star
77

bb_rtc

An Arduino RealTime Clock library which auto-detects DS3231, RV-3032 and PCF8563
C++
3
star
78

oled_sprites

A sprite and tile system for the ATtiny85 & SSD1306 (or more powerful MCU)
C++
3
star
79

imageinfo

A lightweight (aka fast) tool for identifying and displaying the relevant info for image files.
C
3
star
80

accelerometers

A C library to read the accelerometer and gyroscope values from a collection of popular sensors
C
3
star
81

nokia5110

A simple C library (Linux + Arduino) to talk to Nokia 5110 LCD displays
C
3
star
82

nrf24_test_rig

An Arduino sketch for nRF24 range testing using a Pro Mini, 64x32 OLED and 2 buttons
C++
3
star
83

Nano_33_BeetleC

Control the M5Stack Beetle-C car over BLE with an Arduino Nano 33 BLE
C++
3
star
84

weather_mon

A sample weather monitoring program which records the output to a CSV file
C
3
star
85

galactic_unicorn_test

A simple Arduino project to display time + temp + humidity + CO2
C++
3
star
86

rtc_setter

An Arduino sketch to set the local time (corrected for DST) to your DS3231 RTC
C++
3
star
87

bb_hx1230

Arduino library to control HX1230 / STE2007 96x68 LCD displays
C++
3
star
88

FT6236G

An Arduino library for FocalTech FT6x36 capacitive touch controllers
C++
3
star
89

ISBIC

Incredibly Simple Bitonal Image Compression
C
3
star
90

Fusion_360_Projects

A place to share 3D projects
3
star
91

bb_temperature

A multi-device temperature/humidity/pressure sensor library with auto-detection.
C++
3
star
92

bb_scd41

Sensiron SCD4x Arduino library
C++
2
star
93

framebuffer

Experiments with using the Linux framebuffer directly (mostly on Raspberry Pi)
C
2
star
94

min_search_arm

Arm NEON demo to search an unsorted list of integers for the minimum value
C
2
star
95

NXP_Test

Experimental code for the OKDO E1 (NXP LPC55S69)
C
2
star
96

bb_ltr390

visible/UV light sensor Arduino library
C++
2
star
97

armbian_oled

A C library for SSD1306 displays (I2C+SPI) which uses my ArmbianIO library
C
2
star
98

pi_car

A bluetooth gamepad controlled 4wd car with a Rasberry Pi Zero as its brain
C
1
star
99

oled_example

Sample code to talk to a SSD1306 OLED display utilizing my oled_96 library
C
1
star
100

bb-hole

A DNS black hole for filtering out ads/dangerous sites
C
1
star