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.
Dependents: CatPot_Main_ver1 CatPot_Main_F NuFM401 CatPot_Main_ver2 ... more
AQM0802A.h
00001 #ifndef AQM0802A_H 00002 #define AQM0802A_H 00003 00004 #include "mbed.h" 00005 00006 #define AQM0802A_ADDR 0x7C // I2C slave address 00007 #define AQM0802A_COLS 8 00008 #define AQM0802A_ROWS 2 00009 #define AQM0802A_MAX_COLS (1 << 6) 00010 #define AQM0802A_MAX_ROWS (1 << 2) 00011 #define AQM0802A_CMD_WAIT 27 // wait time after sent lcd command (us) 00012 #define I2C_FREQUENCY 400000 // I2C bus speed (uses only constructor of AQM0802A(PinName, PinName)) 00013 00014 /** 00015 * Akizuki I2C 8x2 Character LCD AQM0802A driver class.<br /> 00016 * 秋月 I2C 8x2 小型キャラクタLCD AQM0802A用 ドライバクラスです。<br /> 00017 * http://akizukidenshi.com/catalog/g/gK-06795/<br /> 00018 * Copyright(C)2014 T.Hoshino<br /> 00019 * <br /> 00020 * CAUTION: My English is very poor, it might be wrong. (I rely on Google Translate almost.) 00021 * <ul> 00022 * <li>Stream 継承なので、printf() 等も利用可能です。<br /> 00023 * This class inherits Stream, Its public methods (printf() etc.) are also available.</li> 00024 * <li>文字コード '\\r'(0x0D) の出力でカーソル位置は行頭に移動します。<br /> 00025 * When you output the character code '\\r'(0x0D), the cursor position is move to the beginning of line.</li> 00026 * <li>文字コード '\\n'(0x0A) の出力でカーソル位置は次の行の先頭に移動します。<br /> 00027 * When you output the character code '\\n'(0x0A), the cursor position is move to the beginning of next line.</li> 00028 * </ul> 00029 * @code 00030 //---------------------------------------- 00031 // Sample code for ST Nucleo F401RE 00032 //---------------------------------------- 00033 #include <mbed.h> 00034 #include <AQM0802A.h> 00035 00036 AQM0802A lcd(D14, D15); // <-- this ! 00037 Ticker ticker; 00038 00039 void tick() { 00040 static int count = 0; 00041 lcd.cls(); 00042 lcd.printf("Hello\n %d", count++); 00043 } 00044 00045 int main() { 00046 ticker.attach(&tick, 0.1); 00047 while(1) { 00048 } 00049 } 00050 * @endcode 00051 * ご自由にお使いいただけますが、無保証です。使用は自己責任でどうぞ。<br /> 00052 * The use of this is free, but no warranty. please use at your own risk.<br /> 00053 */ 00054 class AQM0802A : public Stream { 00055 public: 00056 /** 00057 * Constructor. 00058 * @param sda serial data pin 00059 * @param scl serial clock pin 00060 */ 00061 AQM0802A(PinName sda, PinName scl); 00062 00063 /** 00064 * Constructor. 00065 * @param i2c reference to i2c bus object. 00066 */ 00067 AQM0802A(I2C &i2c); 00068 00069 /** 00070 * Clear screen. 画面をクリアします。<br /> 00071 * After clear screen, the cursor position will be changed to {x:0, y:0}.<br /> 00072 * 画面クリア後、カーソル位置は {x:0, y:0} に変更されます。<br /> 00073 * @see #home() 00074 */ 00075 void cls(); 00076 00077 /** 00078 * Set cursor to home position. カーソル位置をホームポジションに移動します。<br /> 00079 * The cursor position will be changed to {x:0, y:0}. At that time, it does not clear the screen display.<br /> 00080 * カーソル位置を {x:0, y:0} に変更します。その際、画面表示はクリアしません。<br /> 00081 * @see #cls() 00082 */ 00083 void home(); 00084 00085 /** 00086 * Change the contrast of the screen. 画面のコントラストを変更します。<br /> 00087 * Practical range in about 20-40, the initial value is 32. 00088 * 実用的な範囲は20~40ぐらいで、初期値は32です。<br /> 00089 * Only the lower 6 bits are valid. 下位6ビットのみ有効です。 00090 * @param contrast 0(bright) to 63(dark). The initial value is 32. 00091 */ 00092 void setContrast(int contrast); 00093 00094 /** 00095 * Change the cursor position to {x, y}. 指定位置 {x, y} にカーソルを移動します。<br /> 00096 * The position of left top is {0, 0}. Right bottom is {7, 1}. 00097 * 左上は {0, 0}、右下は{7, 1} です。 00098 * @param x 0 to 7 : Column position of the cursor. 00099 * @param y 0 to 1 : Row position of the cursor. 00100 */ 00101 void setCursor(int x, int y); 00102 00103 protected: 00104 virtual int _putc(int); 00105 virtual int _getc(){ return 0; } 00106 00107 private: 00108 I2C* i2c; 00109 uint8_t x; 00110 uint8_t y; 00111 00112 void lcd_init(); 00113 void lcd_cmd(uint8_t cmd); 00114 void lcd_data(char data); 00115 }; 00116 00117 #endif
Generated on Wed Jul 13 2022 19:14:45 by
1.7.2