added puticon() for SB1602B
Fork of TextLCD_SB1602E by
Tedd OKANO さんの Strawberry Linux の i2c LCD SB1602E ライブラリに SB1602B のアイコン表示メソッドを追加。STM32 Nucleo L152RE/mbed でテストしてます。
こういう時は Pull Request すべきなのかな。
Diff: TextLCD_SB1602E.h
- Revision:
- 1:39110c58e55c
- Parent:
- 0:694061176edf
--- a/TextLCD_SB1602E.h Sat Jan 23 13:45:18 2010 +0000 +++ b/TextLCD_SB1602E.h Sat May 03 13:33:42 2014 +0000 @@ -13,8 +13,9 @@ * * revision 1.0 22-Jan-2010 a. 1st release * revision 1.1 23-Jan-2010 a. class name has been changed from lcd_SB1602E to TextLCD_SB1602E - * b. printf() added + * b. printf() added * c. copyright notice added + * revision 1.3 02-May-2014 a. puticon() added (for SB1602B) */ #ifndef MBED_TextLCD_SB1602E @@ -96,13 +97,33 @@ }; // required 30us, 2ms interval +const unsigned char icon_data[]={ + // アイコンアドレス, 該当ビット + 0x00, 0x10, // 0b10000, + 0x02, 0x10, // 0b10000, + 0x04, 0x10, // 0b10000, + 0x06, 0x10, // 0b10000, + + 0x07, 0x10, // 0b10000, + 0x07, 0x08, // 0b01000, + 0x09, 0x10, // 0b10000, + 0x0B, 0x10, // 0b10000, + + 0x0D, 0x08, // 0b01000, + 0x0D, 0x04, // 0b00100, + 0x0D, 0x02, // 0b00010, + 0x0D, 0x10, // 0b10000, + + 0x0F, 0x10, // 0b10000, // アンテナマーク +}; + class TextLCD_SB1602E : I2cBusDevice { public: explicit TextLCD_SB1602E( I2C *i2c, char dev_address = SB1602E_addr, char *init_massage = NULL ) : I2cBusDevice( i2c, dev_address ) { wait( 0.04 ); // interval after hardware reset - + i2c->frequency(400000); // max 400KHz for ( int i = 0; i < init_seq0_length; i++ ) { lcd_command( init_seq0[ i ] ); wait( 30e-6 ); @@ -199,6 +220,26 @@ puts( line, s ); } + + void puticon(unsigned short flg) + { + static unsigned char icon_buff[16]; // アイコンの編集用 + unsigned char i; + + for(i=0;i<sizeof(icon_data)/2;i++){ + if(flg & (0x1000>>i)){ // 該当ビットが立っていたら + icon_buff[icon_data[i*2]] |= icon_data[i*2+1]; // バッファを立てます。 + } else { + icon_buff[icon_data[i*2]] &= ~icon_data[i*2+1]; // バッファをクリアします。 + } + } + // 一括でLCDに書き込みます。 + for(i=0;i<16;i++){ + lcd_command(Comm_FunctionSet_Extended); // 0b00111001); // コマンド + lcd_command(Comm_SetCGRAM + i); // 0b01000000+i); // アイコン領域のアドレスを設定 + lcd_data(icon_buff[i]); // アイコンデータ + } + } private: char curs[2]; @@ -229,11 +270,3 @@ ; #endif - - - - - - - -