LCD module Switch Science SKU#1405, which driver IC is ST7032i.

Committer:
coisme
Date:
Sat Jul 01 16:01:37 2017 +0000
Revision:
0:92bfc61fb13b
First commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
coisme 0:92bfc61fb13b 1 #ifndef __ST7072I_H__
coisme 0:92bfc61fb13b 2 #define __ST7072I_H__
coisme 0:92bfc61fb13b 3
coisme 0:92bfc61fb13b 4 #include "mbed.h"
coisme 0:92bfc61fb13b 5
coisme 0:92bfc61fb13b 6 /**
coisme 0:92bfc61fb13b 7 * Device driver for LCD SSCI-014052 (Switch Science SKU#1405),
coisme 0:92bfc61fb13b 8 * which display controller is ST7032i.
coisme 0:92bfc61fb13b 9 * https://www.switch-science.com/catalog/1405/
coisme 0:92bfc61fb13b 10 *
coisme 0:92bfc61fb13b 11 * Tested with BLENano.
coisme 0:92bfc61fb13b 12 *
coisme 0:92bfc61fb13b 13 * Example:
coisme 0:92bfc61fb13b 14 * @code
coisme 0:92bfc61fb13b 15 * #include "mbed.h"
coisme 0:92bfc61fb13b 16 * #include "st7032i.h"
coisme 0:92bfc61fb13b 17 *
coisme 0:92bfc61fb13b 18 * int main(void){
coisme 0:92bfc61fb13b 19 * // Creates an I2C object
coisme 0:92bfc61fb13b 20 * I2C i2c(I2C_SDA0, I2C_SCL0);
coisme 0:92bfc61fb13b 21 *
coisme 0:92bfc61fb13b 22 * // Creates an display object
coisme 0:92bfc61fb13b 23 * St7032i st7032i(&i2c);
coisme 0:92bfc61fb13b 24 *
coisme 0:92bfc61fb13b 25 * // Waits for settling the system.
coisme 0:92bfc61fb13b 26 * wait_ms(1000);
coisme 0:92bfc61fb13b 27 *
coisme 0:92bfc61fb13b 28 * // Initialize the display module.
coisme 0:92bfc61fb13b 29 * st7032i.init();
coisme 0:92bfc61fb13b 30 *
coisme 0:92bfc61fb13b 31 * while(1){
coisme 0:92bfc61fb13b 32 * st7032i.puts("Hello, World!!");
coisme 0:92bfc61fb13b 33 * // Waits 1 second.
coisme 0:92bfc61fb13b 34 * wait(1.0);
coisme 0:92bfc61fb13b 35 * // Clears the display
coisme 0:92bfc61fb13b 36 * st7032i.clear();
coisme 0:92bfc61fb13b 37 * // Waits 0.5 second.
coisme 0:92bfc61fb13b 38 * wait(0.5);
coisme 0:92bfc61fb13b 39 * }
coisme 0:92bfc61fb13b 40 * }
coisme 0:92bfc61fb13b 41 * @endcode
coisme 0:92bfc61fb13b 42 */
coisme 0:92bfc61fb13b 43 class St7032i
coisme 0:92bfc61fb13b 44 {
coisme 0:92bfc61fb13b 45 public:
coisme 0:92bfc61fb13b 46 /**
coisme 0:92bfc61fb13b 47 * Return value from functions.
coisme 0:92bfc61fb13b 48 */
coisme 0:92bfc61fb13b 49 typedef enum {
coisme 0:92bfc61fb13b 50 SUCCESS, /**< Success */
coisme 0:92bfc61fb13b 51 ERROR_I2C_NO_ACK, /**< I2C error with no ACK. */
coisme 0:92bfc61fb13b 52 INPUT_OUT_OF_RANGE, /**< Given input value is out of range. */
coisme 0:92bfc61fb13b 53 } Status;
coisme 0:92bfc61fb13b 54
coisme 0:92bfc61fb13b 55 /**
coisme 0:92bfc61fb13b 56 * Constructor.
coisme 0:92bfc61fb13b 57 * @param obj Pointer to an I2C object.
coisme 0:92bfc61fb13b 58 * @return no return value.
coisme 0:92bfc61fb13b 59 */
coisme 0:92bfc61fb13b 60 St7032i(I2C *obj);
coisme 0:92bfc61fb13b 61
coisme 0:92bfc61fb13b 62
coisme 0:92bfc61fb13b 63 /**
coisme 0:92bfc61fb13b 64 * Initialize the LCD.
coisme 0:92bfc61fb13b 65 * @returns
coisme 0:92bfc61fb13b 66 * SUCCESS on the device was successfully initialized.
coisme 0:92bfc61fb13b 67 * others on error.
coisme 0:92bfc61fb13b 68 */
coisme 0:92bfc61fb13b 69 Status init();
coisme 0:92bfc61fb13b 70
coisme 0:92bfc61fb13b 71 /**
coisme 0:92bfc61fb13b 72 * Sets display's contrast.
coisme 0:92bfc61fb13b 73 * @param val Contrast (0-63)
coisme 0:92bfc61fb13b 74 * @returns
coisme 0:92bfc61fb13b 75 * SUCCESS on the device was successfully set constrast.
coisme 0:92bfc61fb13b 76 * others on error.
coisme 0:92bfc61fb13b 77 */
coisme 0:92bfc61fb13b 78 Status setContrast(uint8_t val);
coisme 0:92bfc61fb13b 79
coisme 0:92bfc61fb13b 80 /**
coisme 0:92bfc61fb13b 81 * Puts a character at the current cursor position.
coisme 0:92bfc61fb13b 82 * @param c A character to be shown.
coisme 0:92bfc61fb13b 83 * @returns
coisme 0:92bfc61fb13b 84 * SUCCESS on the device was successfully set cursor position.
coisme 0:92bfc61fb13b 85 * others on error.
coisme 0:92bfc61fb13b 86 */
coisme 0:92bfc61fb13b 87 Status putc(char c);
coisme 0:92bfc61fb13b 88
coisme 0:92bfc61fb13b 89 /**
coisme 0:92bfc61fb13b 90 * Sets the cursor position.
coisme 0:92bfc61fb13b 91 * @param col column (0-7)
coisme 0:92bfc61fb13b 92 * @param row row (0 or 1)
coisme 0:92bfc61fb13b 93 * @returns
coisme 0:92bfc61fb13b 94 * SUCCESS on the device was successfully set cursor position.
coisme 0:92bfc61fb13b 95 * others on error.
coisme 0:92bfc61fb13b 96 */
coisme 0:92bfc61fb13b 97 Status setCursorPosition(uint8_t col, uint8_t row);
coisme 0:92bfc61fb13b 98
coisme 0:92bfc61fb13b 99 /**
coisme 0:92bfc61fb13b 100 * Clears display. The instruction execution takes 1.08 ms.
coisme 0:92bfc61fb13b 101 * @param wait Waits instruction execution in this function if true.
coisme 0:92bfc61fb13b 102 * @returns
coisme 0:92bfc61fb13b 103 * SUCCESS on the device was successfully cleared.
coisme 0:92bfc61fb13b 104 * others on error.
coisme 0:92bfc61fb13b 105 */
coisme 0:92bfc61fb13b 106 Status clear(bool wait = true);
coisme 0:92bfc61fb13b 107
coisme 0:92bfc61fb13b 108 /**
coisme 0:92bfc61fb13b 109 * Puts a string from the position (0,0). The characters exceeds the display
coisme 0:92bfc61fb13b 110 * range will be ignored.
coisme 0:92bfc61fb13b 111 * @param str Pointer to a string to be shown.
coisme 0:92bfc61fb13b 112 * @param wrap Automatically move to the second line if true.
coisme 0:92bfc61fb13b 113 * @returns
coisme 0:92bfc61fb13b 114 * SUCCESS on the device put the gievn string successfully.
coisme 0:92bfc61fb13b 115 * others on error.
coisme 0:92bfc61fb13b 116 */
coisme 0:92bfc61fb13b 117 Status puts(const char *str, bool wrap = true);
coisme 0:92bfc61fb13b 118
coisme 0:92bfc61fb13b 119 private:
coisme 0:92bfc61fb13b 120 /**
coisme 0:92bfc61fb13b 121 * Holds a pointer to an I2C object.
coisme 0:92bfc61fb13b 122 */
coisme 0:92bfc61fb13b 123 I2C *i2c;
coisme 0:92bfc61fb13b 124
coisme 0:92bfc61fb13b 125 };
coisme 0:92bfc61fb13b 126
coisme 0:92bfc61fb13b 127 #endif // __ST7072I_H__