I2C 接続の LCD AQM1602XA-RN-GBW 用のライブラリ. Library for LCD 1602XA-RN-GBW connected using I2C interface.
Dependents: UIT2_MovingAv_Intr UIT2_VariableFIR UIT2_VowelSynthesizer UIT2_ALE_LeakyLMS ... more
Diff: AQM1602.hpp
- Revision:
- 0:f177013dc4fc
- Child:
- 1:18cd1c4212c3
diff -r 000000000000 -r f177013dc4fc AQM1602.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AQM1602.hpp Fri Jun 05 06:43:51 2015 +0000 @@ -0,0 +1,69 @@ +//------------------------------------------------------- +// Class for LCD, AQM1602XA-RN-GBW (Header) +// +// +// Default pin assignments +// D14 SDA ---- to pin4 of LCD module +// D15 SCL ---- to pin3 of LCD module +// +// Assignment of I2C ports +// SDA SCL +// I2C1 PB_7 or PB_9(D14) PB_6(D10) or PB_8(D15) +// I2C2 PB_3(D3) PB_10(D6) +// I2C3 PB_4(D5) or PC_9 PA_8(D7) +// +// 2014/05/30, Copyright (c) 2015 MIKAMI, Naoki +//------------------------------------------------------- + +#ifndef AQM1602I2C_HPP +#define AQM1602I2C_HPP + +#include "mbed.h" + +namespace Mikami +{ + class Aqm1602 + { + public: + // Constructor + Aqm1602(PinName sda = D14, // SDA + PinName scl = D15, // SCL + uint32_t clock = 100000, // clock: 100 kHz + bool cursor = false, // cursor: off + bool blink = false); // blink: off + + // All clear + void Clear(); + // Send command + void WriteCmd(uint8_t cmd) { LcdTx(0x00, cmd); } + // Write character (Not 0x80 but 0x40) + void WriteChar(char data) { LcdTx(0x40, data); } + // Specify display position, x: 0 - 7, y: 0, 1 + void SetXY(uint8_t x = 0, uint8_t y = 0) + { WriteCmd(x + y*0x40 | 0x80);} + // Write string + void WriteString(const char str[]); + // Write string from specified position + void WriteStringXY(const char str[], uint8_t x, uint8_t); + // Clear of specified line + void ClearLine(uint8_t line); +// { WriteStringXY(" ", 0, line); } + void SetContrast(uint8_t c); + + private: + // Slave address of AQM0802A + // left-justified 7-bit address + static const uint8_t LCD_ADDRESS_ = 0x7C; + static const uint8_t N_CHR = 16; + + I2C i2c_; // Object of I2C + + void LcdTx(uint8_t cmdData, uint8_t data); + + // Forbid to use copy constructor + Aqm1602(const Aqm1602&); + // Forbid to use substitution operator + Aqm1602& operator=(const Aqm1602&); + }; +} +#endif // AQM0802I2C_HPP