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.
Fork of TextLCD_SB1602E by
Revision 1:39110c58e55c, committed 2014-05-03
- Comitter:
- masato
- Date:
- Sat May 03 13:33:42 2014 +0000
- Parent:
- 0:694061176edf
- Commit message:
- add puticon() for SB1602B
Changed in this revision
diff -r 694061176edf -r 39110c58e55c TextLCD_SB1602E.h --- 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 - - - - - - - -
diff -r 694061176edf -r 39110c58e55c TextLCD_SB1602E_test.cpp --- a/TextLCD_SB1602E_test.cpp Sat Jan 23 13:45:18 2010 +0000 +++ b/TextLCD_SB1602E_test.cpp Sat May 03 13:33:42 2014 +0000 @@ -28,9 +28,13 @@ #define PUTS_TEST_WITH_ESCAPE #define PUTS_TEST_WITHOUT_ESCAPE #define PUTC_TEST - +#define ICON_TEST +#if defined(TARGET_LPC1768) I2C i2c( p9, p10 ); // sda, scl +#else // +I2C i2c( D14, D15 ); // sda, scl +#endif Serial pc( USBTX, USBRX ); // tx, rx TextLCD_SB1602E lcd( &i2c ); @@ -224,6 +228,19 @@ wait( DEFAULT_TIME_INTERVAL_PUTx ); } #endif +#ifdef ICON_TEST + pc.printf( " ICON_TEST\n" ); + lcd.clear(); + lcd.puts( 1, "\x07\x07\x07\x07\x07\x07 puticon()\r" ); + unsigned short flg = 0; + for (i = 0; i < 13; i++) { + flg |= (1 << i); + lcd.puticon(flg); + wait( DEFAULT_TIME_INTERVAL_PUTx ); + } + wait( DEFAULT_TIME_INTERVAL ); + lcd.puticon(0); +#endif } void set_lines_fixed_value( char line, char value ) {
diff -r 694061176edf -r 39110c58e55c mbed.bld --- a/mbed.bld Sat Jan 23 13:45:18 2010 +0000 +++ b/mbed.bld Sat May 03 13:33:42 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0 +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file