113 lines
3.7 KiB
C
113 lines
3.7 KiB
C
/*
|
|
* Stairs lighting
|
|
* Copyright 2017 (c) Mark van Renswoude
|
|
*
|
|
* https://git.x2software.net/pub/Stairs
|
|
*
|
|
* Port of Stephen Denne's Tiny4kOLED to C,
|
|
* without the Arduino framework dependency but with
|
|
* a hardcoded dependency on VeryTinyI2C.
|
|
*
|
|
* Original:
|
|
* https://github.com/technoblogy/tiny-i2c
|
|
*/
|
|
#ifndef __VeryTinySSD1306
|
|
#define __VeryTinySSD1306
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
|
|
typedef struct {
|
|
uint8_t *bitmap; // character bitmaps data
|
|
uint8_t width; // character width in pixels
|
|
uint8_t height; // character height in pages (8 pixels)
|
|
uint8_t first, last; // ASCII extents
|
|
} DCfont;
|
|
|
|
|
|
#define SSD1306_DisplayWidth 128
|
|
#define SSD1306_DisplayHeight 32
|
|
|
|
#ifndef SSD1306
|
|
#define SSD1306 0x3C // Slave address
|
|
#endif
|
|
|
|
|
|
void ssd1306_begin_default(void);
|
|
void ssd1306_begin(uint8_t init_sequence_length, const uint8_t init_sequence []);
|
|
void ssd1306_switchRenderFrame(void);
|
|
void ssd1306_switchDisplayFrame(void);
|
|
void ssd1306_switchFrame(void);
|
|
uint8_t ssd1306_currentRenderFrame(void);
|
|
uint8_t ssd1306_currentDisplayFrame(void);
|
|
void ssd1306_setFont(const DCfont *font);
|
|
void ssd1306_setCursor(uint8_t x, uint8_t y);
|
|
void ssd1306_newLine();
|
|
void ssd1306_fill(uint8_t fill);
|
|
void ssd1306_fillToEOL(uint8_t fill);
|
|
void ssd1306_fillLength(uint8_t fill, uint8_t length);
|
|
void ssd1306_clear(void);
|
|
void ssd1306_clearToEOL(void);
|
|
void ssd1306_bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t bitmap[]);
|
|
void ssd1306_startData(void);
|
|
void ssd1306_sendData(const uint8_t data);
|
|
void ssd1306_endData(void);
|
|
|
|
// 1. Fundamental Command Table
|
|
|
|
void ssd1306_setContrast(uint8_t contrast);
|
|
void ssd1306_setEntireDisplayOn(bool enable);
|
|
void ssd1306_setInverse(bool enable);
|
|
void ssd1306_off(void);
|
|
void ssd1306_on(void);
|
|
|
|
// 2. Scrolling Command Table
|
|
|
|
void ssd1306_scrollRight(uint8_t startPage, uint8_t interval, uint8_t endPage);
|
|
void ssd1306_scrollLeft(uint8_t startPage, uint8_t interval, uint8_t endPage);
|
|
void ssd1306_scrollRightOffset(uint8_t startPage, uint8_t interval, uint8_t endPage, uint8_t offset);
|
|
void ssd1306_scrollLeftOffset(uint8_t startPage, uint8_t interval, uint8_t endPage, uint8_t offset);
|
|
void ssd1306_deactivateScroll(void);
|
|
void ssd1306_activateScroll(void);
|
|
void ssd1306_setVerticalScrollArea(uint8_t top, uint8_t rows);
|
|
|
|
// 3. Addressing Setting Command Table
|
|
void ssd1306_setColumnStartAddress(uint8_t startAddress);
|
|
void ssd1306_setMemoryAddressingMode(uint8_t mode);
|
|
void ssd1306_setColumnAddress(uint8_t startAddress, uint8_t endAddress);
|
|
void ssd1306_setPageAddress(uint8_t startPage, uint8_t endPage);
|
|
void ssd1306_setPageStartAddress(uint8_t startPage);
|
|
|
|
// 4. Hardware Configuration (Panel resolution and layout related) Command Table
|
|
|
|
void ssd1306_setDisplayStartLine(uint8_t startLine);
|
|
void ssd1306_setSegmentRemap(uint8_t remap);
|
|
void ssd1306_setMultiplexRatio(uint8_t mux);
|
|
void ssd1306_setComOutputDirection(uint8_t direction);
|
|
void ssd1306_setDisplayOffset(uint8_t offset);
|
|
void ssd1306_setComPinsHardwareConfiguration(uint8_t alternative, uint8_t enableLeftRightRemap);
|
|
|
|
// 5. Timing and Driving Scheme Setting Command table
|
|
|
|
void ssd1306_setDisplayClock(uint8_t divideRatio, uint8_t oscillatorFrequency);
|
|
void ssd1306_setPrechargePeriod(uint8_t phaseOnePeriod, uint8_t phaseTwoPeriod);
|
|
void ssd1306_setVcomhDeselectLevel(uint8_t level);
|
|
void ssd1306_nop(void);
|
|
|
|
// 6. Advance Graphic Command table
|
|
|
|
void ssd1306_fadeOut(uint8_t interval);
|
|
void ssd1306_blink(uint8_t interval);
|
|
void ssd1306_disableFadeOutAndBlinking(void);
|
|
void ssd1306_enableZoomIn(void);
|
|
void ssd1306_disableZoomIn(void);
|
|
|
|
// Charge Pump Settings
|
|
|
|
void ssd1306_enableChargePump(void);
|
|
void ssd1306_disableChargePump(void);
|
|
|
|
uint8_t ssd1306_write(uint8_t c);
|
|
|
|
#endif |