Delete st7567-i2c.h
This commit is contained in:
129
st7567-i2c.h
129
st7567-i2c.h
@@ -1,129 +0,0 @@
|
||||
#ifndef ST7567_H
|
||||
#define ST7567_H
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "driver/i2c_master.h"
|
||||
|
||||
// Display dimensions
|
||||
#define ST7567_WIDTH 128
|
||||
#define ST7567_HEIGHT 64
|
||||
#define ST7567_PAGES (ST7567_HEIGHT / 8)
|
||||
|
||||
// Default I2C 7-bit address for most ST7567 breakout boards (some use 0x3F)
|
||||
#define ST7567_I2C_ADDR_DEFAULT 0x3F
|
||||
|
||||
// ST7567 command set
|
||||
#define ST7567_CMD_DISPLAY_OFF 0xAE
|
||||
#define ST7567_CMD_DISPLAY_ON 0xAF
|
||||
#define ST7567_CMD_START_LINE 0x40 // OR with 0-63
|
||||
#define ST7567_CMD_PAGE_ADDR 0xB0 // OR with 0-8
|
||||
#define ST7567_CMD_COL_ADDR_HIGH 0x10 // OR with high nibble
|
||||
#define ST7567_CMD_COL_ADDR_LOW 0x00 // OR with low nibble
|
||||
#define ST7567_CMD_ADC_NORMAL 0xA0 // column addr 0 = SEG0
|
||||
#define ST7567_CMD_ADC_REVERSE 0xA1 // column addr 131 = SEG0
|
||||
#define ST7567_CMD_ALL_PIXEL_NORMAL 0xA4
|
||||
#define ST7567_CMD_ALL_PIXEL_ON 0xA5
|
||||
#define ST7567_CMD_DISPLAY_NORMAL 0xA6
|
||||
#define ST7567_CMD_DISPLAY_INVERSE 0xA7
|
||||
#define ST7567_CMD_BIAS_1_9 0xA2
|
||||
#define ST7567_CMD_BIAS_1_7 0xA3
|
||||
#define ST7567_CMD_RESET 0xE2
|
||||
#define ST7567_CMD_COM_NORMAL 0xC0
|
||||
#define ST7567_CMD_COM_REVERSE 0xC8
|
||||
#define ST7567_CMD_POWER_CTRL 0x28 // OR with 0-7 (booster/regulator/follower bits)
|
||||
#define ST7567_CMD_RESISTOR_RATIO 0x20 // OR with 0-7
|
||||
#define ST7567_CMD_CONTRAST_MODE 0x81 // followed by a second byte, 0-63
|
||||
#define ST7567_CMD_STATIC_INDICATOR_OFF 0xAC
|
||||
#define ST7567_CMD_NOP 0xE3
|
||||
|
||||
// Configuration structure
|
||||
typedef struct {
|
||||
i2c_master_bus_handle_t i2c_bus; // already-initialized I2C bus
|
||||
uint16_t i2c_addr; // 7-bit device address, 0 = use ST7567_I2C_ADDR_DEFAULT
|
||||
uint32_t i2c_clock_speed_hz; // 0 = use 400kHz default
|
||||
uint8_t contrast; // 0-63, 0 = use a sane default (0x20)
|
||||
} st7567_config_t;
|
||||
|
||||
// Handle for ST7567 device
|
||||
typedef struct {
|
||||
i2c_master_dev_handle_t i2c_dev;
|
||||
uint8_t framebuffer[ST7567_WIDTH * ST7567_PAGES];
|
||||
} st7567_device_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize ST7567 display
|
||||
*
|
||||
* @param config Configuration structure
|
||||
* @param device Pointer to store device state (framebuffer etc, caller-owned)
|
||||
* @return esp_err_t ESP_OK on success
|
||||
*/
|
||||
esp_err_t st7567_init(const st7567_config_t *config, st7567_device_t *device);
|
||||
|
||||
/**
|
||||
* @brief Send a single command byte to the ST7567
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @param cmd Command byte
|
||||
* @return esp_err_t ESP_OK on success
|
||||
*/
|
||||
esp_err_t st7567_send_cmd(const st7567_device_t *dev, uint8_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Send a data buffer to the ST7567
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @param data Pointer to data buffer
|
||||
* @param len Length of data buffer
|
||||
* @return esp_err_t ESP_OK on success
|
||||
*/
|
||||
esp_err_t st7567_send_data(const st7567_device_t *dev, const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Clear the display (just wipe framebuffer, don't send any commands)
|
||||
*
|
||||
* @param dev Device handle
|
||||
*/
|
||||
void st7567_clear_buffer(st7567_device_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Clear the display (both GDRAM and local framebuffer)
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @return esp_err_t ESP_OK on success
|
||||
*/
|
||||
esp_err_t st7567_clear(st7567_device_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Set contrast (electronic volume)
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @param contrast 0-63
|
||||
* @return esp_err_t ESP_OK on success
|
||||
*/
|
||||
esp_err_t st7567_set_contrast(const st7567_device_t *dev, uint8_t contrast);
|
||||
|
||||
/**
|
||||
* @brief Push the local framebuffer contents to the display
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @return esp_err_t ESP_OK on success
|
||||
*/
|
||||
esp_err_t st7567_update_screen(const st7567_device_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Turn a pixel ON at given coordinates
|
||||
* @param dev Device handle
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
*/
|
||||
void st7567_draw_pixel(void *dev, uint8_t x, uint8_t y);
|
||||
|
||||
/**
|
||||
* @brief Turn a pixel OFF at given coordinates
|
||||
* @param dev Device handle
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
*/
|
||||
void st7567_clear_pixel(void *dev, uint8_t x, uint8_t y);
|
||||
|
||||
#endif // ST7567_H
|
||||
Reference in New Issue
Block a user