sentry_chassis_hzz/modules/oled/oled.h

146 lines
3.5 KiB
C
Raw Normal View History

/**
* @file oled.h
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2023-02-14
* @todo show string/init/clean/update buffer等的实现
*
* @copyright Copyright (c) 2023
*
*/
#ifndef OLED_H
#define OLED_H
#include <stdint.h>
// the I2C address of oled
#define OLED_I2C_ADDRESS 0x78
// the resolution of oled 128*64
#define MAX_COLUMN 128
#define MAX_ROW 64
#define X_WIDTH MAX_COLUMN
#define Y_WIDTH MAX_ROW
#define OLED_CMD 0x00
#define OLED_DATA 0x01
#define CHAR_SIZE_WIDTH 6
#define CHAR_SIZE_HIGHT 12
typedef enum
{
PEN_CLEAR = 0x00,
PEN_WRITE = 0x01,
PEN_INVERSION = 0x02,
} pen_typedef;
/**
* @brief OLED模块
* @param[in] none
* @retval none
*/
extern void OLED_init(void);
/**
* @brief OLED显示
* @param[in] none
* @retval none
*/
extern void OLED_display_on(void);
/**
* @brief OLED显示
* @param[in] none
* @retval none
*/
extern void OLED_display_off(void);
/**
* @brief GRAM内存(128*8char数组)
* @param[in] pen: .
PEN_CLEAR: 0x00
PEN_WRITE: 0xff
PEN_INVERSION:
* @retval none
*/
extern void OLED_operate_gram(pen_typedef pen);
/**
* @brief (x,y)
* @param[in] x:x轴, 0 127
* @param[in] y:y轴, 0 7
* @retval none
*/
extern void OLED_set_pos(uint8_t x, uint8_t y);
/**
* @brief GRAM中的一个位
* @param[in] x:x轴, [0,X_WIDTH-1]
* @param[in] y:y轴, [0,Y_WIDTH-1]
* @param[in] pen: ,
PEN_CLEAR: (x,y) 0
PEN_WRITE: (x,y) 1
PEN_INVERSION: (x,y)
* @retval none
*/
extern void OLED_draw_point(int8_t x, int8_t y, pen_typedef pen);
/**
* @brief 线(x1,y1)(x2,y2)
* @param[in] x1:
* @param[in] y1:
* @param[in] x2:
* @param[in] y2:
* @param[in] pen: ,PEN_CLEAR,PEN_WRITE,PEN_INVERSION.
* @retval none
*/
extern void OLED_draw_line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, pen_typedef pen);
/**
* @brief
* @param[in] row:
* @param[in] col:
* @param[in] chr:
* @retval none
*/
extern void OLED_show_char(uint8_t row, uint8_t col, uint8_t chr);
/**
* @brief
* @param[in] row:
* @param[in] col:
* @param[in] chr:
* @retval none
*/
extern void OLED_show_string(uint8_t row, uint8_t col, uint8_t *chr);
/**
* @brief
* @param[in] row: 0 <= row <= 4;
* @param[in] col: 0 <= col <= 20;
* @param[in] *fmt:
* @note
* @retval none
*/
extern void OLED_printf(uint8_t row, uint8_t col, const char *fmt, ...);
/**
* @brief OLED的GRAM
* @param[in] none
* @retval none
*/
extern void OLED_refresh_gram(void);
/**
* @brief RM的LOGO
* @param[in] none
* @retval none
*/
extern void OLED_LOGO(void);
#endif