This is a part of the Kinetiszer project.

Dependents:   SoundEngine

Committer:
Clemo
Date:
Tue Oct 28 12:19:22 2014 +0000
Revision:
0:5a419ba2726d
Error & warning free (I believe as I don't know how to clean).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clemo 0:5a419ba2726d 1 /**
Clemo 0:5a419ba2726d 2 * @file
Clemo 0:5a419ba2726d 3 * Definitions for an I2C LCD driver based on the ST7032i chip from Sitronix.
Clemo 0:5a419ba2726d 4 *
Clemo 0:5a419ba2726d 5 * Author: Clemens Valens
Clemo 0:5a419ba2726d 6 * License: GNU General Public License
Clemo 0:5a419ba2726d 7 *
Clemo 0:5a419ba2726d 8 * History
Clemo 0:5a419ba2726d 9 * 2014.09.08 ver 1.00 Preliminary version, first release
Clemo 0:5a419ba2726d 10 */
Clemo 0:5a419ba2726d 11
Clemo 0:5a419ba2726d 12 #ifndef __LCD_H__
Clemo 0:5a419ba2726d 13 #define __LCD_H__
Clemo 0:5a419ba2726d 14
Clemo 0:5a419ba2726d 15
Clemo 0:5a419ba2726d 16 #include "board.h"
Clemo 0:5a419ba2726d 17
Clemo 0:5a419ba2726d 18
Clemo 0:5a419ba2726d 19 #define LCD_I2C_ADDRESS (0x3e)
Clemo 0:5a419ba2726d 20
Clemo 0:5a419ba2726d 21 // The speed of the display depends on the frequency of its internal oscillator.
Clemo 0:5a419ba2726d 22 #define ST7032_FOSC (192000) /* [Hz], can be tweaked if extended mode is available. */
Clemo 0:5a419ba2726d 23 #define ST7032_RESPONSE_TIME_SLOW (410*1000000/ST7032_FOSC) /* [us] */
Clemo 0:5a419ba2726d 24 #define ST7032_RESPONSE_TIME_NORMAL (10*1000000/ST7032_FOSC) /* [us] */
Clemo 0:5a419ba2726d 25
Clemo 0:5a419ba2726d 26 #define ST7032_RESET_RECOVERY_TIME (40) /* [ms] */
Clemo 0:5a419ba2726d 27
Clemo 0:5a419ba2726d 28 // ST7032 commands
Clemo 0:5a419ba2726d 29 // Clear Display
Clemo 0:5a419ba2726d 30 #define ST7032_CMD_CLEAR (0x01)
Clemo 0:5a419ba2726d 31
Clemo 0:5a419ba2726d 32 // Return Home
Clemo 0:5a419ba2726d 33 #define ST7032_CMD_HOME (0x02)
Clemo 0:5a419ba2726d 34
Clemo 0:5a419ba2726d 35 // Entry Mode Set
Clemo 0:5a419ba2726d 36 #define ST7032_CMD_ENTRY_MODE (0x04)
Clemo 0:5a419ba2726d 37 #define ST7032_SHIFT_CURSOR (0x00) /* default */
Clemo 0:5a419ba2726d 38 #define ST7032_SHIFT_DISPLAY (0x01)
Clemo 0:5a419ba2726d 39 #define ST7032_DECREMENT (0x00)
Clemo 0:5a419ba2726d 40 #define ST7032_INCREMENT (0x02) /* default */
Clemo 0:5a419ba2726d 41
Clemo 0:5a419ba2726d 42 // Display ON/OFF
Clemo 0:5a419ba2726d 43 #define ST7032_CMD_ON_OFF (0x08)
Clemo 0:5a419ba2726d 44 #define ST7032_BLINK_OFF (0x00) /* default */
Clemo 0:5a419ba2726d 45 #define ST7032_BLINK_ON (0x01)
Clemo 0:5a419ba2726d 46 #define ST7032_CURSOR_OFF (0x00) /* default */
Clemo 0:5a419ba2726d 47 #define ST7032_CURSOR_ON (0x02)
Clemo 0:5a419ba2726d 48 #define ST7032_DISPLAY_OFF (0x00) /* default */
Clemo 0:5a419ba2726d 49 #define ST7032_DISPLAY_ON (0x04)
Clemo 0:5a419ba2726d 50
Clemo 0:5a419ba2726d 51 // Cursor or Display Shift
Clemo 0:5a419ba2726d 52 #define ST7032_CMD_SHIFT (0x10)
Clemo 0:5a419ba2726d 53 #define ST7032_SHIFT_LEFT (0x00)
Clemo 0:5a419ba2726d 54 #define ST7032_SHIFT_RIGHT (0x04)
Clemo 0:5a419ba2726d 55 #define ST7032_SHIFT_CURSOR (0x00)
Clemo 0:5a419ba2726d 56 #define ST7032_SHIFT_SCREEN (0x08)
Clemo 0:5a419ba2726d 57
Clemo 0:5a419ba2726d 58 // Function Set
Clemo 0:5a419ba2726d 59 #define ST7032_CMD_FUNCTION (0x20)
Clemo 0:5a419ba2726d 60 #define ST7032_FUNC_NORMAL (0x00) /* default */
Clemo 0:5a419ba2726d 61 #define ST7032_FUNC_EXTENDED (0x01)
Clemo 0:5a419ba2726d 62 #define ST7032_FUNC_HEIGHT_NORMAL (0x00) /* default */
Clemo 0:5a419ba2726d 63 #define ST7032_FUNC_HEIGHT_DOUBLE (0x04)
Clemo 0:5a419ba2726d 64 #define ST7032_FUNC_1_LINE (0x00) /* default */
Clemo 0:5a419ba2726d 65 #define ST7032_FUNC_2_LINES (0x08)
Clemo 0:5a419ba2726d 66 #define ST7032_FUNC_4_BIT (0x00)
Clemo 0:5a419ba2726d 67 #define ST7032_FUNC_8_BIT (0x10) /* default */
Clemo 0:5a419ba2726d 68
Clemo 0:5a419ba2726d 69 #define ST7032_FUNC_CONFIG_NORMAL (ST7032_FUNC_NORMAL | ST7032_FUNC_HEIGHT_NORMAL | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT)
Clemo 0:5a419ba2726d 70 #define ST7032_FUNC_CONFIG_EXTENDED (ST7032_FUNC_EXTENDED | ST7032_FUNC_HEIGHT_NORMAL | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT)
Clemo 0:5a419ba2726d 71 #define ST7032_FUNC_CONFIG_EXTENDED_DOUBLE (ST7032_FUNC_EXTENDED | ST7032_FUNC_HEIGHT_DOUBLE | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT)
Clemo 0:5a419ba2726d 72
Clemo 0:5a419ba2726d 73 // Set CGRAM Address (normal function, ST7032_FUNC_NORMAL)
Clemo 0:5a419ba2726d 74 #define ST7032_CMD_CGRAM_ADDRESS (0x40)
Clemo 0:5a419ba2726d 75 #define ST7032_CGRAM_ADDRESS_MASK (0x3f)
Clemo 0:5a419ba2726d 76
Clemo 0:5a419ba2726d 77 // Set DDRAM Address
Clemo 0:5a419ba2726d 78 #define ST7032_CMD_DDRAM_ADDRESS (0x80)
Clemo 0:5a419ba2726d 79 #define ST7032_DDRAM_ADDRESS_MASK (0x7f)
Clemo 0:5a419ba2726d 80
Clemo 0:5a419ba2726d 81 // Bias selection/Internal OSC frequency adjust (extended function)
Clemo 0:5a419ba2726d 82 #define ST7032_CMD_BIAS_OSC (0x10)
Clemo 0:5a419ba2726d 83 #define ST7032_BIAS_020 (0x00) /* default */
Clemo 0:5a419ba2726d 84 #define ST7032_BIAS_025 (0x08)
Clemo 0:5a419ba2726d 85 #define ST7032_OSC_MASK (0x07) /* defaults to 0x04 */
Clemo 0:5a419ba2726d 86
Clemo 0:5a419ba2726d 87 // Set Icon RAM Address (extended function)
Clemo 0:5a419ba2726d 88 #define ST7032_CMD_ICON_RAM_ADDRESS (0x40)
Clemo 0:5a419ba2726d 89 #define ST7032_ICON_ADDRESS_MASK (0x0f)
Clemo 0:5a419ba2726d 90
Clemo 0:5a419ba2726d 91 // Power/ICON control/Contrast set (high byte) (extended function)
Clemo 0:5a419ba2726d 92 #define ST7032_CMD_POWER_ICON_CONTRAST (0x50)
Clemo 0:5a419ba2726d 93 #define ST7032_BOOSTER_OFF (0x00) /* default */
Clemo 0:5a419ba2726d 94 #define ST7032_BOOSTER_ON (0x04)
Clemo 0:5a419ba2726d 95 #define ST7032_ICON_OFF (0x00) /* default */
Clemo 0:5a419ba2726d 96 #define ST7032_ICON_ON (0x08)
Clemo 0:5a419ba2726d 97 #define ST7032_CONTRAST_HI_MASK (0x03) /* defaults to 0x02 */
Clemo 0:5a419ba2726d 98
Clemo 0:5a419ba2726d 99 // Follower control (extended function)
Clemo 0:5a419ba2726d 100 #define ST7032_CMD_FOLLOWER (0x60)
Clemo 0:5a419ba2726d 101 #define ST7032_FOLLOWER_OFF (0x00) /* default */
Clemo 0:5a419ba2726d 102 #define ST7032_FOLLOWER_ON (0x08)
Clemo 0:5a419ba2726d 103 #define ST7032_AMPLIFIER_RATIO_MASK (0x07) /* defaults to 0x02 */
Clemo 0:5a419ba2726d 104
Clemo 0:5a419ba2726d 105 // Contrast set (low byte) (extended function)
Clemo 0:5a419ba2726d 106 #define ST7032_CMD_CONTRAST_LO (0x70)
Clemo 0:5a419ba2726d 107 #define ST7032_CONTRAST_LO_MASK (0x0f) /* defaults to 0x00 */
Clemo 0:5a419ba2726d 108
Clemo 0:5a419ba2726d 109
Clemo 0:5a419ba2726d 110 uint8_t lcd_putc(char ch);
Clemo 0:5a419ba2726d 111 uint8_t lcd_puts(char *p_str);
Clemo 0:5a419ba2726d 112 void lcd_clear(void);
Clemo 0:5a419ba2726d 113 void lcd_cursor(uint8_t line, uint8_t column);
Clemo 0:5a419ba2726d 114 void lcd_display_cursor_blink(uint8_t display, uint8_t cursor, uint8_t blink);
Clemo 0:5a419ba2726d 115 void lcd_clear_to_eol(int line, int column);
Clemo 0:5a419ba2726d 116 void lcd_contrast(uint8_t contrast);
Clemo 0:5a419ba2726d 117 void lcd_font(uint8_t font);
Clemo 0:5a419ba2726d 118 void lcd_set_custom_character(uint8_t index, const uint8_t *p_data);
Clemo 0:5a419ba2726d 119 void lcd_bar_graph(uint8_t position, uint8_t value, uint8_t value_max);
Clemo 0:5a419ba2726d 120 void lcd_init(void);
Clemo 0:5a419ba2726d 121
Clemo 0:5a419ba2726d 122
Clemo 0:5a419ba2726d 123 #endif // __LCD_H__