• Stars
    star
    187
  • Rank 199,896 (Top 5 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

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

OneBitDisplay (1-bpp OLED/LCD library)

Project started 3/23/2020
Copyright (c) 2020 BitBank Software, Inc.
Written by Larry Bank
[email protected]

OneBitDisplay
The purpose of this code is to easily control monochrome (1-bit per pixel) OLED and LCD displays. The displays can be connected to the traditional I2C or SPI bus, or you can use GPIO pins to bit bang the signals.

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 I2C 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:
---------

  • C API and C++ wrapper class which mimics the Adafruit_GFX API
  • 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, 64x128 (SH1107), 128x128 (SH1107) and 132x64 (SH1106) OLED display sizes
  • Supports 96x68 HX1230, 84x48 Nokia 5110 and 128x64 ST7567/UC1701 mono LCDs
  • Supports 144x168 and 400x240 Sharp Memory LCDs
  • Supports the ST7302 low power LCD (250x122, 2.13")
  • NEW supports a few popular epd (e-ink) panels
  • Virtual displays of any size which can be drawn across multiple physical displays
  • Flexible copy function can convert the internal pixel format to any output format and orientation
  • Drive displays from I2C, SPI or any GPIO pins (virtual I2C/SPI)
  • Includes 5 sizes of fixed fonts (6x8, 8x8, 12x16, 16x16, 16x32)
  • Text drawing at any fractional scale (e.g. 1.25x), and any of 4 directions/rotations
  • Can use Adafruit_GFX format bitmap fonts (proportional and fixed)
  • 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
  • Optimized Bresenham line drawing
  • Optimized Bresenham outline and filled ellipse drawing
  • Optimized outline and filled rectangle drawing
  • Optional backing RAM (needed for some text and drawing functions)
  • 16x16 Tile/Sprite drawing at any angle.
  • Run full frame animations at high frame rates with a simple API

This code depends on the BitBang_I2C library. You can download it here:
https://github.com/bitbank2/BitBang_I2C
See the Wiki for help getting started
https://github.com/bitbank2/OneBitDisplay/wiki

Fonts A few words about fonts
-----------------------

The library includes 3 fixed fonts (6x8, 8x8 and 16x32). The 16x32 font is disabled when compiling for AVR targets (e.g. Arduino Uno) to save FLASH program space. The other 2 fonts offer 2x stretched versions (12x16 from 6x8 and 16x16 from 8x8). A simple smoothing algorithm is applied to the stretched 6x8 font to make it look better. In the photo above are the first 4 font sizes shown on a 128x64 yellow OLED display. Only 96 ASCII characters are defined per font to save space. To use more elaborate fonts with more extensive character support, use Adafruit_GFX format bitmap fonts with the obdWriteStringCustom() function.

Sharp Memory LCD Sharp Memory LCD Support
------------------------
New - support for the Sharp 144x168 and 400x240 memory LCDs. These are a different type of LCD that have a high refresh rate and low power usage. They cost quite a bit more than normal LCDs. They require a memory back buffer to use the drawing functions due to the way data is written to them one line at a time. I've also added a specific function if you would like to skip the back buffer - obdWriteLCDLine(). It allows you to write a single line of pixels without needing any additional memory. Please see the Wiki for more details.

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) or you can specify it. 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 obdSetBackBuffer() 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 obdDumpBuffer(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_8x8), 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 or becomming a Github sponsor.

paypal

More Repositories

1

JPEGDEC

An optimized JPEG decoder for Arduino
C
345
star
2

AnimatedGIF

An optimized GIF decoder suitable for microcontrollers and PCs
C
333
star
3

Thermal_Printer

Arduino library to draw text and graphics on BLE thermal printers
C
326
star
4

BitBang_I2C

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

ss_oled

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

image_to_c

Convert image files into C arrays of uint8_t for compiling into your project
C
164
star
7

PNGdec

Arduino PNG image decoder library
C
152
star
8

SPI_LCD

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

SmartResponseXE

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

oled_96

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

ArmbianIO

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

Multi_OLED

Control multiple OLED displays on one or more I2C buses simultaneously
C++
75
star
13

SLIC

Simple lossless imaging codec
C++
74
star
14

Print2BLE

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

JPEGENC

Arduino JPEG encoder
C++
52
star
16

VL53L0X

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

bb_spi_lcd

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

unzipLIB

An embedded-friendly library for decompressing files from zip archives
C
49
star
19

oled_turbo

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

PNGenc

An embedded-friendly PNG encoder
C
37
star
21

Multi_BitBang

A software I2C implementation to create multiple I2C buses using GPIO lines
C++
36
star
22

SMART_bootloader

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

giflib-turbo

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

BB-CP

A faster replacement for FBTFT + FBCP
C
30
star
25

ssd1327

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

oled_animator

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

LCD1602

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

BLE_Keyboard

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

Pocket_CO2

A CH32V003 low cost pocket CO2 sensor
C
21
star
30

I2C_Detector

Scan I2C buses and identify devices which respond.
C++
21
star
31

uc1701

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

MAX7219

A C library for controlling any number of Maxim LED matrix controllers
C
19
star
33

sg_free

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

TIFF_G4

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

Pi_Pico_C_Projects

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

bbgfx

BitBank Graphics Library - optimized primitives for RGB565 surfaces on ARMv5
C
16
star
37

epd_image

Prepare image data for writing directly to e-paper displays
C++
15
star
38

sense_hat_unchained

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

Nano_33_Gamepad

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

BLE_2_EPaper

A collection of projects to send images over BLE to e-paper displays
C
13
star
41

gcc_perf

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

tm1637

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

esp32_gamepad

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

bb_captouch

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

Animated_Sand

Arduino demo for SSD1306 I2C display + MPU-6050 accelerometer.
C++
10
star
46

gif_play

Play animated GIF images directly on a Linux framebuffer or SPI LCD
C
10
star
47

KiCad_Projects

A place to share all of my PCB projects
10
star
48

bin_to_c

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

FastIO

A fast substitute for Arduino digital pin functions on AVR MCUs
C++
9
star
50

NeoPixel

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

G4Enc

Optimized CCITT G4 encoder for embedded and larger systems
C++
8
star
52

CCS811

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

TwoBitDisplay

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

RemoteDisplay

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

CH32V_Experiments

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

ESLImageTransfer

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

gnu_asm

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

hx1230

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

ESP_NOW_Weather

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

bme280

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

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
62

SmartGear_ESP32

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

CH32V_Color_LCD

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

bb_uc1701

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

zeemouse

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

ir_receiver

C code to receive NEC codes from a GPIO connected to a IR demodulator
C
4
star
67

W600FastIO

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

oled_sprites

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

imageinfo

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

LED_Clock

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

Nano_33_BeetleC

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

nokia5110

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

bb_scd41

Sensiron SCD4x Arduino library
C++
3
star
74

max44009

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

bb_hx1230

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

FT6236G

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

ISBIC

Incredibly Simple Bitonal Image Compression
C
3
star
78

rtc_eeprom

C code to talk to the DS3231 and AT24C32 (usually sold together)
C++
3
star
79

Fusion_360_Projects

A place to share 3D projects
3
star
80

bb_rtc

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

accelerometers

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

nrf24_test_rig

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

framebuffer

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

min_search_arm

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

galactic_unicorn_test

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

rtc_setter

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

armbian_oled

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

CO2_USB_033

A portable CO2 monitor based on the CH32X033 MCU
C
2
star
89

pi_car

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

oled_example

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

weather_mon

A sample weather monitoring program which records the output to a CSV file
C
1
star
92

bb-hole

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

bitbank2

1
star
94

bb_ltr390

visible/UV light sensor Arduino library
C++
1
star
95

NXP_Test

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

bme680

An Arduino library to read data from the Bosch BME680 environmental sensor
C++
1
star