Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
lcd.h
00001 /** 00002 * @file 00003 * Definitions for an I2C LCD driver based on the ST7032i chip from Sitronix. 00004 * 00005 * Author: Clemens Valens 00006 * License: GNU General Public License 00007 * 00008 * History 00009 * 2014.09.08 ver 1.00 Preliminary version, first release 00010 */ 00011 00012 #ifndef __LCD_H__ 00013 #define __LCD_H__ 00014 00015 00016 #include "board.h" 00017 00018 00019 #define LCD_I2C_ADDRESS (0x3e) 00020 00021 // The speed of the display depends on the frequency of its internal oscillator. 00022 #define ST7032_FOSC (192000) /* [Hz], can be tweaked if extended mode is available. */ 00023 #define ST7032_RESPONSE_TIME_SLOW (410*1000000/ST7032_FOSC) /* [us] */ 00024 #define ST7032_RESPONSE_TIME_NORMAL (10*1000000/ST7032_FOSC) /* [us] */ 00025 00026 #define ST7032_RESET_RECOVERY_TIME (40) /* [ms] */ 00027 00028 // ST7032 commands 00029 // Clear Display 00030 #define ST7032_CMD_CLEAR (0x01) 00031 00032 // Return Home 00033 #define ST7032_CMD_HOME (0x02) 00034 00035 // Entry Mode Set 00036 #define ST7032_CMD_ENTRY_MODE (0x04) 00037 #define ST7032_SHIFT_CURSOR (0x00) /* default */ 00038 #define ST7032_SHIFT_DISPLAY (0x01) 00039 #define ST7032_DECREMENT (0x00) 00040 #define ST7032_INCREMENT (0x02) /* default */ 00041 00042 // Display ON/OFF 00043 #define ST7032_CMD_ON_OFF (0x08) 00044 #define ST7032_BLINK_OFF (0x00) /* default */ 00045 #define ST7032_BLINK_ON (0x01) 00046 #define ST7032_CURSOR_OFF (0x00) /* default */ 00047 #define ST7032_CURSOR_ON (0x02) 00048 #define ST7032_DISPLAY_OFF (0x00) /* default */ 00049 #define ST7032_DISPLAY_ON (0x04) 00050 00051 // Cursor or Display Shift 00052 #define ST7032_CMD_SHIFT (0x10) 00053 #define ST7032_SHIFT_LEFT (0x00) 00054 #define ST7032_SHIFT_RIGHT (0x04) 00055 #define ST7032_SHIFT_CURSOR (0x00) 00056 #define ST7032_SHIFT_SCREEN (0x08) 00057 00058 // Function Set 00059 #define ST7032_CMD_FUNCTION (0x20) 00060 #define ST7032_FUNC_NORMAL (0x00) /* default */ 00061 #define ST7032_FUNC_EXTENDED (0x01) 00062 #define ST7032_FUNC_HEIGHT_NORMAL (0x00) /* default */ 00063 #define ST7032_FUNC_HEIGHT_DOUBLE (0x04) 00064 #define ST7032_FUNC_1_LINE (0x00) /* default */ 00065 #define ST7032_FUNC_2_LINES (0x08) 00066 #define ST7032_FUNC_4_BIT (0x00) 00067 #define ST7032_FUNC_8_BIT (0x10) /* default */ 00068 00069 #define ST7032_FUNC_CONFIG_NORMAL (ST7032_FUNC_NORMAL | ST7032_FUNC_HEIGHT_NORMAL | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT) 00070 #define ST7032_FUNC_CONFIG_EXTENDED (ST7032_FUNC_EXTENDED | ST7032_FUNC_HEIGHT_NORMAL | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT) 00071 #define ST7032_FUNC_CONFIG_EXTENDED_DOUBLE (ST7032_FUNC_EXTENDED | ST7032_FUNC_HEIGHT_DOUBLE | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT) 00072 00073 // Set CGRAM Address (normal function, ST7032_FUNC_NORMAL) 00074 #define ST7032_CMD_CGRAM_ADDRESS (0x40) 00075 #define ST7032_CGRAM_ADDRESS_MASK (0x3f) 00076 00077 // Set DDRAM Address 00078 #define ST7032_CMD_DDRAM_ADDRESS (0x80) 00079 #define ST7032_DDRAM_ADDRESS_MASK (0x7f) 00080 00081 // Bias selection/Internal OSC frequency adjust (extended function) 00082 #define ST7032_CMD_BIAS_OSC (0x10) 00083 #define ST7032_BIAS_020 (0x00) /* default */ 00084 #define ST7032_BIAS_025 (0x08) 00085 #define ST7032_OSC_MASK (0x07) /* defaults to 0x04 */ 00086 00087 // Set Icon RAM Address (extended function) 00088 #define ST7032_CMD_ICON_RAM_ADDRESS (0x40) 00089 #define ST7032_ICON_ADDRESS_MASK (0x0f) 00090 00091 // Power/ICON control/Contrast set (high byte) (extended function) 00092 #define ST7032_CMD_POWER_ICON_CONTRAST (0x50) 00093 #define ST7032_BOOSTER_OFF (0x00) /* default */ 00094 #define ST7032_BOOSTER_ON (0x04) 00095 #define ST7032_ICON_OFF (0x00) /* default */ 00096 #define ST7032_ICON_ON (0x08) 00097 #define ST7032_CONTRAST_HI_MASK (0x03) /* defaults to 0x02 */ 00098 00099 // Follower control (extended function) 00100 #define ST7032_CMD_FOLLOWER (0x60) 00101 #define ST7032_FOLLOWER_OFF (0x00) /* default */ 00102 #define ST7032_FOLLOWER_ON (0x08) 00103 #define ST7032_AMPLIFIER_RATIO_MASK (0x07) /* defaults to 0x02 */ 00104 00105 // Contrast set (low byte) (extended function) 00106 #define ST7032_CMD_CONTRAST_LO (0x70) 00107 #define ST7032_CONTRAST_LO_MASK (0x0f) /* defaults to 0x00 */ 00108 00109 00110 uint8_t lcd_putc(char ch); 00111 uint8_t lcd_puts(char *p_str); 00112 void lcd_clear(void); 00113 void lcd_cursor(uint8_t line, uint8_t column); 00114 void lcd_display_cursor_blink(uint8_t display, uint8_t cursor, uint8_t blink); 00115 void lcd_clear_to_eol(int line, int column); 00116 void lcd_contrast(uint8_t contrast); 00117 void lcd_font(uint8_t font); 00118 void lcd_set_custom_character(uint8_t index, const uint8_t *p_data); 00119 void lcd_bar_graph(uint8_t position, uint8_t value, uint8_t value_max); 00120 void lcd_init(void); 00121 00122 00123 #endif // __LCD_H__
Generated on Mon Jul 18 2022 18:20:47 by
1.7.2