Created
November 23, 2021 05:14
-
-
Save ak1211/433ae0968cd04d2d59574efe83972ebd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* i2c_lcd.h | |
* | |
* Created on: 2021/11/22 | |
* Author: Akihiro Yamamoto | |
* | |
* Copyright 2021 Akihiro Yamamoto | |
* Licensed under the Apache License, Version 2.0 | |
* | |
*/ | |
#ifndef INC_I2C_LCD_H_ | |
extern void i2c_lcd_init(I2C_HandleTypeDef *i2c); | |
extern void i2c_lcd_send_commands(I2C_HandleTypeDef *hi2c, size_t size, | |
uint8_t cmds[size]); | |
inline static void i2c_lcd_send_command(I2C_HandleTypeDef *hi2c, uint8_t cmd) { | |
i2c_lcd_send_commands(hi2c, 1, &cmd); | |
} | |
extern void i2c_lcd_send_data(I2C_HandleTypeDef *hi2c, size_t size, | |
uint8_t data[size]); | |
inline static void i2c_lcd_send_datum(I2C_HandleTypeDef *hi2c, uint8_t datum) { | |
i2c_lcd_send_data(hi2c, 1, &datum); | |
} | |
extern void i2c_lcd_puts(I2C_HandleTypeDef *hi2c, char *s); | |
inline static void i2c_lcd_clear_display(I2C_HandleTypeDef *hi2c) { | |
i2c_lcd_send_command(hi2c, 0b00000001); | |
HAL_Delay(1); | |
} | |
inline static void i2c_lcd_return_home(I2C_HandleTypeDef *hi2c) { | |
i2c_lcd_send_command(hi2c, 0b00000010); | |
HAL_Delay(1); | |
} | |
inline static void i2c_lcd_set_ddram_address(I2C_HandleTypeDef *hi2c, | |
uint8_t addr) { | |
i2c_lcd_send_command(hi2c, 0x80 | (addr & 0x7f)); | |
} | |
typedef uint16_t icon_code_t; | |
#define I2C_LCD_ICON_a ((icon_code_t)(1<<12)) | |
#define I2C_LCD_ICON_b ((icon_code_t)(1<<11)) | |
#define I2C_LCD_ICON_c ((icon_code_t)(1<<10)) | |
#define I2C_LCD_ICON_d ((icon_code_t)(1<<9)) | |
#define I2C_LCD_ICON_e ((icon_code_t)(1<<8)) | |
#define I2C_LCD_ICON_f ((icon_code_t)(1<<7)) | |
#define I2C_LCD_ICON_g ((icon_code_t)(1<<6)) | |
#define I2C_LCD_ICON_h ((icon_code_t)(1<<5)) | |
#define I2C_LCD_ICON_i ((icon_code_t)(1<<4)) | |
#define I2C_LCD_ICON_j ((icon_code_t)(1<<3)) | |
#define I2C_LCD_ICON_k ((icon_code_t)(1<<2)) | |
#define I2C_LCD_ICON_l ((icon_code_t)(1<<1)) | |
#define I2C_LCD_ICON_m ((icon_code_t)(1<<0)) | |
extern void i2c_lcd_show_icon(I2C_HandleTypeDef *hi2c, icon_code_t bitflag); | |
#endif /* INC_I2C_LCD_H_ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment