Richard Kuo
/
NTOUEE-mbed-I2C_LCD_printLine
mbed I2C LCD print line
Revision 0:f60fdf2bec92, committed 2016-10-21
- Comitter:
- rkuo2000
- Date:
- Fri Oct 21 02:48:52 2016 +0000
- Commit message:
- mbed I2C LCD print line
Changed in this revision
diff -r 000000000000 -r f60fdf2bec92 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r f60fdf2bec92 Font5x7.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Font5x7.h Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,101 @@ +// standard ascii 5x7 font +// defines ascii characters 0x20-0x7F (32-127) +const unsigned char Font5x7[96*5] = { + 0x00, 0x00, 0x00, 0x00, 0x00,// (space) + 0x00, 0x00, 0x5F, 0x00, 0x00,// ! + 0x00, 0x07, 0x00, 0x07, 0x00,// " + 0x14, 0x7F, 0x14, 0x7F, 0x14,// # + 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ + 0x23, 0x13, 0x08, 0x64, 0x62,// % + 0x36, 0x49, 0x55, 0x22, 0x50,// & + 0x00, 0x05, 0x03, 0x00, 0x00,// ' + 0x00, 0x1C, 0x22, 0x41, 0x00,// ( + 0x00, 0x41, 0x22, 0x1C, 0x00,// ) + 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * + 0x08, 0x08, 0x3E, 0x08, 0x08,// + + 0x00, 0x50, 0x30, 0x00, 0x00,// , + 0x08, 0x08, 0x08, 0x08, 0x08,// - + 0x00, 0x60, 0x60, 0x00, 0x00,// . + 0x20, 0x10, 0x08, 0x04, 0x02,// / + 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 + 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 + 0x42, 0x61, 0x51, 0x49, 0x46,// 2 + 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 + 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 + 0x27, 0x45, 0x45, 0x45, 0x39,// 5 + 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 + 0x01, 0x71, 0x09, 0x05, 0x03,// 7 + 0x36, 0x49, 0x49, 0x49, 0x36,// 8 + 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 + 0x00, 0x36, 0x36, 0x00, 0x00,// : + 0x00, 0x56, 0x36, 0x00, 0x00,// ; + 0x00, 0x08, 0x14, 0x22, 0x41,// < + 0x14, 0x14, 0x14, 0x14, 0x14,// = + 0x41, 0x22, 0x14, 0x08, 0x00,// > + 0x02, 0x01, 0x51, 0x09, 0x06,// ? + 0x32, 0x49, 0x79, 0x41, 0x3E,// @ + 0x7E, 0x11, 0x11, 0x11, 0x7E,// A + 0x7F, 0x49, 0x49, 0x49, 0x36,// B + 0x3E, 0x41, 0x41, 0x41, 0x22,// C + 0x7F, 0x41, 0x41, 0x22, 0x1C,// D + 0x7F, 0x49, 0x49, 0x49, 0x41,// E + 0x7F, 0x09, 0x09, 0x01, 0x01,// F + 0x3E, 0x41, 0x41, 0x51, 0x32,// G + 0x7F, 0x08, 0x08, 0x08, 0x7F,// H + 0x00, 0x41, 0x7F, 0x41, 0x00,// I + 0x20, 0x40, 0x41, 0x3F, 0x01,// J + 0x7F, 0x08, 0x14, 0x22, 0x41,// K + 0x7F, 0x40, 0x40, 0x40, 0x40,// L + 0x7F, 0x02, 0x04, 0x02, 0x7F,// M + 0x7F, 0x04, 0x08, 0x10, 0x7F,// N + 0x3E, 0x41, 0x41, 0x41, 0x3E,// O + 0x7F, 0x09, 0x09, 0x09, 0x06,// P + 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q + 0x7F, 0x09, 0x19, 0x29, 0x46,// R + 0x46, 0x49, 0x49, 0x49, 0x31,// S + 0x01, 0x01, 0x7F, 0x01, 0x01,// T + 0x3F, 0x40, 0x40, 0x40, 0x3F,// U + 0x1F, 0x20, 0x40, 0x20, 0x1F,// V + 0x7F, 0x20, 0x18, 0x20, 0x7F,// W + 0x63, 0x14, 0x08, 0x14, 0x63,// X + 0x03, 0x04, 0x78, 0x04, 0x03,// Y + 0x61, 0x51, 0x49, 0x45, 0x43,// Z + 0x00, 0x00, 0x7F, 0x41, 0x41,// [ + 0x02, 0x04, 0x08, 0x10, 0x20,// "\" + 0x41, 0x41, 0x7F, 0x00, 0x00,// ] + 0x04, 0x02, 0x01, 0x02, 0x04,// ^ + 0x40, 0x40, 0x40, 0x40, 0x40,// _ + 0x00, 0x01, 0x02, 0x04, 0x00,// ` + 0x20, 0x54, 0x54, 0x54, 0x78,// a + 0x7F, 0x48, 0x44, 0x44, 0x38,// b + 0x38, 0x44, 0x44, 0x44, 0x20,// c + 0x38, 0x44, 0x44, 0x48, 0x7F,// d + 0x38, 0x54, 0x54, 0x54, 0x18,// e + 0x08, 0x7E, 0x09, 0x01, 0x02,// f + 0x08, 0x14, 0x54, 0x54, 0x3C,// g + 0x7F, 0x08, 0x04, 0x04, 0x78,// h + 0x00, 0x44, 0x7D, 0x40, 0x00,// i + 0x20, 0x40, 0x44, 0x3D, 0x00,// j + 0x00, 0x7F, 0x10, 0x28, 0x44,// k + 0x00, 0x41, 0x7F, 0x40, 0x00,// l + 0x7C, 0x04, 0x18, 0x04, 0x78,// m + 0x7C, 0x08, 0x04, 0x04, 0x78,// n + 0x38, 0x44, 0x44, 0x44, 0x38,// o + 0x7C, 0x14, 0x14, 0x14, 0x08,// p + 0x08, 0x14, 0x14, 0x18, 0x7C,// q + 0x7C, 0x08, 0x04, 0x04, 0x08,// r + 0x48, 0x54, 0x54, 0x54, 0x20,// s + 0x04, 0x3F, 0x44, 0x40, 0x20,// t + 0x3C, 0x40, 0x40, 0x20, 0x7C,// u + 0x1C, 0x20, 0x40, 0x20, 0x1C,// v + 0x3C, 0x40, 0x30, 0x40, 0x3C,// w + 0x44, 0x28, 0x10, 0x28, 0x44,// x + 0x0C, 0x50, 0x50, 0x50, 0x3C,// y + 0x44, 0x64, 0x54, 0x4C, 0x44,// z + 0x00, 0x08, 0x36, 0x41, 0x00,// { + 0x00, 0x00, 0x7F, 0x00, 0x00,// | + 0x00, 0x41, 0x36, 0x08, 0x00,// } + 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> + 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- +}; +
diff -r 000000000000 -r f60fdf2bec92 Font8x16.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Font8x16.h Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,241 @@ +const unsigned char Font8x16[]={ +/* */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +, +/* ! */ +0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +/* " */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x00,0x00, +/* # */ +0x00,0x00,0x00,0xC0,0x30,0xC0,0x30,0x00,0xC8,0x39,0xCF,0x39,0x0F,0x09,0x01,0x00, +/* $ */ +0xE0,0x10,0x10,0xF8,0x10,0x10,0x60,0x00,0x30,0x41,0x42,0xFF,0x42,0x44,0x38,0x00, +/* % */ +0xC0,0x20,0x10,0xE0,0x20,0xE0,0x18,0x00,0x01,0xC2,0x31,0x0C,0x73,0x88,0x44,0x38 +, +/* & */ +0x00,0xE0,0x10,0x10,0xE0,0x00,0x00,0x00,0x78,0x85,0x82,0x8D,0x70,0xA2,0x9E,0x42 +, +/* ' */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +, +/* ( */ +0xC0,0x30,0x08,0x04,0x00,0x00,0x00,0x00,0x1F,0x60,0x80,0x00,0x00,0x00,0x00,0x00 +, +/* ) */ +0x04,0x08,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x1F,0x00,0x00,0x00,0x00 +, +/* * */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFE,0x28,0x44,0x00,0x00,0x00 +, +/* + */ +0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x00, +/* , */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,0x00 +, +/* - */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00 +, +/* . */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00 +, +/* / */ +0x00,0x00,0x80,0x70,0x00,0x00,0x00,0x00,0xE0,0x1C,0x03,0x00,0x00,0x00,0x00,0x00 +, +/* 0 */ +0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x3F,0x40,0x80,0x80,0x40,0x3F,0x00,0x00, +/* 1 */ +0x20,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,0x00,0x00, +/* 2 */ +0x60,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0xC0,0xA0,0x90,0x88,0x86,0xC1,0x00,0x00 +, +/* 3 */ +0x20,0x10,0x10,0x10,0xE0,0x00,0x00,0x00,0x80,0x80,0x82,0x83,0x44,0x38,0x00,0x00 +, +/* 4 */ +0x00,0x00,0x80,0x60,0xF0,0x00,0x00,0x00,0x18,0x16,0x11,0x10,0xFF,0x10,0x00,0x00, +/* 5 */ +0x00,0xF0,0x10,0x10,0x10,0x10,0x00,0x00,0x80,0x81,0x81,0x81,0x42,0x3C,0x00,0x00 +, +/* 6 */ +0x80,0x40,0x20,0x10,0x10,0x10,0x00,0x00,0x3F,0x42,0x81,0x81,0x42,0x3C,0x00,0x00 +, +/* 7 */ +0x70,0x10,0x10,0x10,0x90,0x70,0x00,0x00,0x00,0x00,0xE0,0x1C,0x03,0x00,0x00,0x00 +, +/* 8 */ +0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x38,0x45,0x82,0x82,0x45,0x38,0x00,0x00 +, +/* 9 */ +0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x83,0x84,0x88,0x48,0x24,0x1F,0x00,0x00 +, +/* : */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00,0x00 +, +/* ; */ +0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,0x00 +, +/* < */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x28,0x44,0x44,0x82,0x00,0x00 +, +/* = */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88 +, +/* > */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x44,0x44,0x28,0x28,0x10,0x00,0x00 +, +/* ? */ +0xE0,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x00,0x00,0xD8,0x06,0x01,0x00,0x00,0x00 +, +/* @ */ +0xC0,0x20,0x10,0x90,0x90,0x10,0xA0,0xC0,0x3F,0x40,0x8F,0x90,0x90,0x8F,0x50,0x5F, +/* A */ +0x00,0x00,0x80,0x70,0x80,0x00,0x00,0x00,0x80,0xF0,0x8F,0x08,0x8F,0xF0,0x80,0x00, +/* B */ +0x10,0xF0,0x10,0x10,0x10,0x20,0xC0,0x00,0x80,0xFF,0x82,0x82,0x82,0x45,0x38,0x00, +/* C */ +0xC0,0x20,0x10,0x10,0x10,0x20,0x70,0x00,0x3F,0x40,0x80,0x80,0x80,0x80,0x40,0x00 +, +/* D */ +0x10,0xF0,0x10,0x10,0x10,0x60,0x80,0x00,0x80,0xFF,0x80,0x80,0x80,0x60,0x1F,0x00, +/* E */ +0x10,0xF0,0x10,0x10,0x10,0x10,0x70,0x00,0x80,0xFF,0x82,0x82,0x82,0x87,0xE0,0x00, +/* F */ +0x10,0xF0,0x10,0x10,0x10,0x10,0x70,0x00,0x80,0xFF,0x82,0x02,0x02,0x07,0x00,0x00, +/* G */ +0xC0,0x20,0x10,0x10,0x20,0x70,0x00,0x00,0x3F,0x40,0x80,0x80,0x84,0x7C,0x04,0x00 +, +/* H */ +0x10,0xF0,0x10,0x00,0x10,0xF0,0x10,0x00,0x80,0xFF,0x82,0x02,0x82,0xFF,0x80,0x00, +/* I */ +0x10,0xF0,0x10,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,0x00,0x00, +/* J */ +0x00,0x00,0x10,0xF0,0x10,0x00,0x00,0x00,0x40,0x80,0x80,0x7F,0x00,0x00,0x00,0x00, +/* K */ +0x10,0xF0,0x10,0x80,0x50,0x30,0x10,0x00,0x80,0xFF,0x83,0x0C,0xB0,0xC0,0x80,0x00, +/* L */ +0x10,0xF0,0x10,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x80,0x80,0xC0,0x20,0x00, +/* M */ +0x10,0xF0,0x80,0x00,0x80,0xF0,0x10,0x00,0x80,0xFF,0x83,0x3C,0x83,0xFF,0x80,0x00, +/* N */ +0x10,0xF0,0xC0,0x00,0x10,0xF0,0x10,0x00,0x80,0xFF,0x80,0x0F,0x30,0xFF,0x00,0x00, +/* O */ +0x80,0x60,0x10,0x10,0x10,0x60,0x80,0x00,0x1F,0x60,0x80,0x80,0x80,0x60,0x1F,0x00, +/* P */ +0x10,0xF0,0x10,0x10,0x10,0x20,0xC0,0x00,0x80,0xFF,0x84,0x04,0x04,0x02,0x01,0x00, +/* Q */ +0xE0,0x18,0x04,0x04,0x04,0x18,0xE0,0x00,0x07,0x18,0x20,0x20,0x60,0x98,0x87,0x00 +, +/* R */ +0x10,0xF0,0x10,0x10,0x10,0x20,0xC0,0x00,0x80,0xFF,0x84,0x0C,0x34,0xC2,0x81,0x00, +/* S */ +0xC0,0x20,0x10,0x10,0x10,0x20,0x70,0x00,0xE0,0x41,0x82,0x82,0x84,0x48,0x30,0x00 +, +/* T */ +0x30,0x10,0x10,0xF0,0x10,0x10,0x30,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00, +/* U */ +0x10,0xF0,0x10,0x00,0x10,0xF0,0x10,0x00,0x00,0x7F,0x80,0x80,0x80,0x7F,0x00,0x00, +/* V */ +0x10,0xF0,0x10,0x00,0x10,0xF0,0x10,0x00,0x00,0x01,0x1E,0xE0,0x1E,0x01,0x00,0x00, +/* W */ +0x10,0xF0,0x10,0xC0,0x10,0xF0,0x10,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x0F,0x00,0x00, +/* X */ +0x10,0x70,0x90,0x00,0x90,0x70,0x10,0x00,0x80,0xE0,0x99,0x06,0x99,0xE0,0x80,0x00 +, +/* Y */ +0x10,0x70,0x90,0x00,0x90,0x70,0x10,0x00,0x00,0x00,0x83,0xFC,0x83,0x00,0x00,0x00 +, +/* Z */ +0x70,0x10,0x10,0x10,0x10,0xD0,0x30,0x00,0xC0,0xB0,0x88,0x86,0x81,0x80,0xE0,0x00 +, +/* [ */ +0xFC,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x80,0x00,0x00,0x00,0x00,0x00, +/* \ */ +0x70,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x1C,0xE0,0x00,0x00,0x00,0x00 +, +/* ] */ +0x04,0x04,0xFC,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0x00,0x00,0x00,0x00,0x00, +/* ^ */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x06,0x18,0x60,0x80,0x00 +, +/* _ */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 +, +/* ` */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x60,0x40,0x80,0x00,0x00,0x00,0x00 +, +/* a */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x91,0x89,0x49,0xFE,0x80,0x00,0x00 +, +/* b */ +0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x81,0x81,0x42,0x3C,0x00,0x00, +/* c */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x81,0x81,0x81,0x42,0x00,0x00 +, +/* d */ +0x00,0x00,0x00,0x10,0xF0,0x00,0x00,0x00,0x3C,0x42,0x81,0x81,0x7F,0x80,0x00,0x00, +/* e */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x4A,0x89,0x89,0x8A,0x4C,0x00,0x00 +, +/* f */ +0x00,0x00,0xE0,0x10,0x10,0x20,0x00,0x00,0x01,0x81,0xFF,0x81,0x01,0x00,0x00,0x00, +/* g */ +0x80,0x40,0x40,0x40,0x80,0x40,0x00,0x00,0x53,0xAC,0xA4,0xA4,0xA3,0x40,0x00,0x00, +/* h */ +0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x01,0x01,0xFE,0x80,0x00,0x00, +/* i */ +0x00,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFF,0x80,0x00,0x00,0x00,0x00,0x00, +/* j */ +0x00,0x00,0x80,0xCC,0x00,0x00,0x00,0x00,0x40,0x80,0x80,0x7F,0x00,0x00,0x00,0x00 +, +/* k */ +0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x98,0x25,0xC3,0x81,0x00,0x00, +/* l */ +0x10,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x00,0x00,0x00,0x00, +/* m */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x80,0x00, +/* n */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFE,0x01,0x01,0xFE,0x80,0x00,0x00, +/* o */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x81,0x81,0x42,0x3C,0x00,0x00 +, +/* p */ +0x40,0x80,0x40,0x40,0x80,0x00,0x00,0x00,0x80,0xFF,0xA0,0x20,0x10,0x0F,0x00,0x00, +/* q */ +0x00,0x80,0x40,0x40,0x80,0x40,0x00,0x00,0x0F,0x10,0x20,0xA0,0xFF,0x80,0x00,0x00, +/* r */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFF,0x82,0x01,0x01,0x00,0x00,0x00, +/* s */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE6,0x49,0x89,0x91,0x92,0x67,0x00,0x00 +, +/* t */ +0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x7F,0x81,0x81,0x40,0x00,0x00 +, +/* u */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x7F,0x80,0x81,0x7F,0x80,0x00,0x00, +/* v */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x39,0xC0,0x39,0x07,0x01,0x00 +, +/* w */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1F,0xE1,0x1C,0xE1,0x1F,0x01,0x00, +/* x */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xE7,0x18,0x18,0xE7,0x81,0x00,0x00 +, +/* y */ +0x40,0xC0,0x40,0x00,0x40,0xC0,0x40,0x00,0x80,0x81,0x46,0x38,0x06,0x01,0x00,0x00 +, +/* z */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC3,0xA1,0x91,0x89,0x85,0xC3,0x00,0x00 +, +/* { */ +0x00,0xF0,0x08,0x00,0x00,0x00,0x00,0x00,0x02,0x7D,0x80,0x00,0x00,0x00,0x00,0x00 +, +/* | */ +0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +/* } */ +0x08,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x7D,0x02,0x00,0x00,0x00,0x00,0x00 +, +/* ~ */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x20,0x60,0xC0,0x80,0x80,0x60 +}; +
diff -r 000000000000 -r f60fdf2bec92 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,19 @@ +// using NuMaker-PFM-NUC472 I2C1 to print text on LCD +#include "mbed.h" +#include "ssd1306.h" + +I2C i2c1(PD_12, PD_10); // I2C1_SDA, I2C1_SCL + +SSD1306 LCD; + +int main() { + i2c1.frequency(400000); + + LCD.initialize(); + LCD.clearscreen(); + + LCD.printLine(0,"NuMaker - NUC472"); + LCD.printLine(1,"ARM mbed OS 5.x "); + LCD.printLine(2,"SSD1306 I2C-OLED"); + LCD.printLine(3,"printLine Demo "); +}
diff -r 000000000000 -r f60fdf2bec92 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#a6f3fd1a60d5df59246d7caf3f108c4d34e1808e
diff -r 000000000000 -r f60fdf2bec92 ssd1306.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssd1306.cpp Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,411 @@ +// SSD1306Z LCD Driver: 0.96" lcd LY096BG30 +#include "mbed.h" +#include "ssd1306.h" +#include "Font8x16.h" +#include "Font5x7.h" + +I2C ssd1306_i2c(PD_12, PD_10); // I2C1_SDA, I2C1_SCL + +char DisplayBuffer[128*8]; + +void lcdWriteCommand(uint8_t lcd_Command) +{ + char data[2]; + data[0]=0x00; + data[1]=lcd_Command; + ssd1306_i2c.write(SSD1306_slave_addr, data, 2, 0); +} + +void lcdWriteData(uint8_t lcd_Data) +{ + char data[2]; + data[0]=0x40; + data[1]=lcd_Data; + ssd1306_i2c.write(SSD1306_slave_addr, data, 2, 0); +} + +void lcdSetAddr(uint8_t column, uint8_t page) +{ + lcdWriteCommand(0xb0+page); // set page address + lcdWriteCommand(0x10 | ((column & 0xf0) >> 4)); // set column address MSB + lcdWriteCommand(0x00 | (column & 0x0f) ); // set column address LSB +} + +void SSD1306::initialize(void) +{ + lcdWriteCommand(0xae); //display off + lcdWriteCommand(0x20); //Set Memory Addressing Mode + lcdWriteCommand(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid + lcdWriteCommand(0xb0); //Set Page Start Address for Page Addressing Mode,0-7 + lcdWriteCommand(0xc8); //Set COM Output Scan Direction + lcdWriteCommand(0x00);//---set low column address + lcdWriteCommand(0x10);//---set high column address + lcdWriteCommand(0x40);//--set start line address + lcdWriteCommand(0x81);//--set contrast control register + lcdWriteCommand(0x7f); + lcdWriteCommand(0xa1);//--set segment re-map 0 to 127 + lcdWriteCommand(0xa6);//--set normal display + lcdWriteCommand(0xa8);//--set multiplex ratio(1 to 64) + lcdWriteCommand(0x3F);// + lcdWriteCommand(0xa4);//0xa4,Output follows RAM content;0xa5,Output ignores RAM content + lcdWriteCommand(0xd3);//-set display offset + lcdWriteCommand(0x00);//-not offset + lcdWriteCommand(0xd5);//--set display clock divide ratio/oscillator frequency + lcdWriteCommand(0xf0);//--set divide ratio + lcdWriteCommand(0xd9);//--set pre-charge period + lcdWriteCommand(0x22); // + lcdWriteCommand(0xda);//--set com pins hardware configuration + lcdWriteCommand(0x12); + lcdWriteCommand(0xdb);//--set vcomh + lcdWriteCommand(0x20);//0x20,0.77xVcc + lcdWriteCommand(0x8d);//--set DC-DC enable + lcdWriteCommand(0x14);// + lcdWriteCommand(0xaf);//--turn on lcd panel +} + +void SSD1306::clearscreen(void) +{ + int16_t x, Y; + for (Y=0;Y<LCD_Ymax/8;Y++) + { + lcdSetAddr(0, Y); + for (x=0;x<LCD_Xmax;x++) + lcdWriteData(0x00); + } +} + +// print char function using Font5x7 +void SSD1306::printC_5x7 (int x, int y, unsigned char ascii_code) +{ + int8_t i; + if (x<(LCD_Xmax-5) && y<(LCD_Ymax-7)) { + if (ascii_code<0x20) ascii_code=0x20; + else if (ascii_code>0x7F) ascii_code=0x20; + for (i=0;i<5;i++) { + lcdSetAddr((x+i), (y/8)); + lcdWriteData(Font5x7[(ascii_code-0x20)*5+i]); + } + } +} + +void SSD1306::printC(int Line, int Col, unsigned char ascii_code) +{ + uint8_t j, i, tmp; + for (j=0;j<2;j++) { + lcdSetAddr(Col*8, Line*2+j); + for (i=0;i<8;i++) { + tmp=Font8x16[(ascii_code-0x20)*16+j*8+i]; + lcdWriteData(tmp); + } + } +} + +void SSD1306::printLine(int line, char text[]) +{ + uint8_t Col; + for (Col=0; Col<strlen(text); Col++) + printC(line, Col, text[Col]); +} + +void SSD1306::printS(int x, int y, char text[]) +{ + int8_t i; + for (i=0;i<strlen(text);i++) + printC(x+i*8, y,text[i]); +} + +void SSD1306::printS_5x7(int x, int y, char text[]) +{ + int8_t i; + for (i=0;i<strlen(text);i++) { + printC_5x7(x,y,text[i]); + x=x+5; + } +} + +void SSD1306::drawPixel(int x, int y, int fgColor, int bgColor) +{ + if (fgColor!=0) + DisplayBuffer[x+y/8*LCD_Xmax] |= (0x01<<(y%8)); + else + DisplayBuffer[x+y/8*LCD_Xmax] &= (0xFE<<(y%8)); + + lcdSetAddr(x, y/8); + lcdWriteData(DisplayBuffer[x+y/8*LCD_Xmax]); +} + +void SSD1306::drawBmp8x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,k, kx,ky; + if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check + for (i=0;i<8;i++){ + kx=x+i; + t=bitmap[i]; + for (k=0;k<8;k++) { + ky=y+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } +} + +void SSD1306::drawBmp32x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,k, kx,ky; + if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check + for (i=0;i<32;i++){ + kx=x+i; + t=bitmap[i]; + for (k=0;k<8;k++) { + ky=y+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } +} + +void SSD1306::drawBmp120x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,k, kx,ky; + if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check + for (i=0;i<120;i++){ + kx=x+i; + t=bitmap[i]; + for (k=0;k<8;k++) { + ky=y+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } +} + +void SSD1306::drawBmp8x16(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,k, kx,ky; + if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check + for (i=0;i<8;i++){ + kx=x+i; + t=bitmap[i]; + for (k=0;k<8;k++) { + ky=y+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + t=bitmap[i+8]; + for (k=0;k<8;k++) { + ky=y+k+8; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } +} + +void SSD1306::drawBmp16x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,k,kx,ky; + if (x<(LCD_Xmax-15) && y<(LCD_Ymax-7)) // boundary check + for (i=0;i<16;i++) + { + kx=x+i; + t=bitmap[i]; + for (k=0;k<8;k++) { + ky=y+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } +} + +void SSD1306::drawBmp16x16(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,j,k, kx,ky; + if (x<(LCD_Xmax-15) && y<(LCD_Ymax-15)) // boundary check + for (j=0;j<2; j++){ + for (i=0;i<16;i++) { + kx=x+i; + t=bitmap[i+j*16]; + for (k=0;k<8;k++) { + ky=y+j*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp16x24(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,j,k, kx,ky; + if (x<(LCD_Xmax-15) && y<(LCD_Ymax-15)) // boundary check + for (j=0;j<3; j++){ + for (i=0;i<16;i++) { + kx=x+i; + t=bitmap[i+j*16]; + for (k=0;k<8;k++) { + ky=y+j*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp16x32(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t, i,j,k, kx,ky; + if (x<(LCD_Xmax-15) && y<(LCD_Ymax-31)) // boundary check + for (j=0;j<4; j++) { + for (i=0;i<16;i++) { + kx=x+i; + t=bitmap[i+j*16]; + for (k=0;k<8;k++) { + ky=y+j*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp16x40(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t, i,j,k, kx,ky; + if (x<(LCD_Xmax-15) && y<(LCD_Ymax-31)) // boundary check + for (j=0;j<5; j++) { + for (i=0;i<16;i++) { + kx=x+i; + t=bitmap[i+j*16]; + for (k=0;k<8;k++) { + ky=y+j*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp16x48(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,j,k,kx,ky; + if (x<(LCD_Xmax-15) && y<(LCD_Ymax-47)) // boundary check + for (j=0;j<6; j++) { + k=x; + for (i=0;i<16;i++) { + kx=x+i; + t=bitmap[i+j*16]; + for (k=0;k<8;k++) { + ky=y+j*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp16x64(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,j,k,kx,ky; + if (x<(LCD_Xmax-15) && y==0) // boundary check + for (j=0;j<8; j++) { + k=x; + for (i=0;i<16;i++) { + kx=x+i; + t=bitmap[i+j*16]; + for (k=0;k<8;k++) { + ky=y+j*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp32x16(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,jx,jy,k,kx,ky; + if (x<(LCD_Xmax-31) && y<(LCD_Ymax-15)) // boundary check + for (jy=0;jy<2;jy++) + for (jx=0;jx<2;jx++) { + k=x; + for (i=0;i<16;i++) { + kx=x+jx*16+i; + t=bitmap[i+jx*16+jy*32]; + for (k=0;k<8;k++) { + ky=y+jy*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp32x32(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,jx,jy,k, kx,ky; + if (x<(LCD_Xmax-31) && y<(LCD_Ymax-31)) // boundary check + for (jy=0;jy<4;jy++) + for (jx=0;jx<2;jx++) { + k=x; + for (i=0;i<16;i++) { + kx=x+jx*16+i; + t=bitmap[i+jx*16+jy*32]; + for (k=0;k<8;k++) { + ky=y+jy*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp32x48(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,jx,jy,k, kx,ky; + if (x<(LCD_Xmax-31) && y<(LCD_Ymax-47)) // boundary check + for (jy=0;jy<6;jy++) + for (jx=0;jx<2;jx++) { + k=x; + for (i=0;i<16;i++) { + kx=x+jx*16+i; + t=bitmap[i+jx*16+jy*32]; + for (k=0;k<8;k++) { + ky=y+jy*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp32x64(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t,i,jx,jy,k, kx,ky; + if (x<(LCD_Xmax-31) && y==0) // boundary check + for (jy=0;jy<8;jy++) + for (jx=0;jx<2;jx++) { + k=x; + for (i=0;i<16;i++) { + kx=x+jx*16+i; + t=bitmap[i+jx*16+jy*32]; + for (k=0;k<8;k++) { + ky=y+jy*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBmp64x64(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]) +{ + uint8_t t, i,jx,jy,k, kx,ky; + if (x<(LCD_Xmax-63) && y==0) // boundary check + for (jy=0;jy<8;jy++) + for (jx=0;jx<4;jx++) { + k=x; + for (i=0;i<16;i++) { + kx=x+jx*16+i; + t=bitmap[i+jx*16+jy*64]; + for (k=0;k<8;k++) { + ky=y+jy*8+k; + if (t&(0x01<<k)) drawPixel(kx,ky,fgColor,bgColor); + } + } + } +} + +void SSD1306::drawBMP(unsigned char *buffer) +{ + uint8_t x,y; + for (x=0; x<LCD_Xmax; x++) { + for (y=0; y<(LCD_Ymax/8); y++) { + lcdSetAddr(x ,y); + lcdWriteData(buffer[x+y*LCD_Xmax]); + } + } +} +
diff -r 000000000000 -r f60fdf2bec92 ssd1306.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssd1306.h Fri Oct 21 02:48:52 2016 +0000 @@ -0,0 +1,35 @@ +#define LCD_Xmax 128 +#define LCD_Ymax 64 +#define FG_COLOR 0xFFFF +#define BG_COLOR 0x0000 + +#define SSD1306_slave_addr 0x78 + +class SSD1306 { + public: + void initialize(void); + void clearscreen(void); + void printC_5x7(int x, int y, unsigned char ascii_code); + void printC(int x, int y, unsigned char ascii_code); + void printLine(int line, char text[]); + void printS(int x, int y, char text[]); + void printS_5x7(int x, int y, char text[]); + void drawPixel(int x, int y, int fgColor, int bgColor); + void drawBmp8x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp32x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp120x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp8x16(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x8(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x16(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x24(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x32(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x40(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x48(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp16x64(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp32x16(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp32x32(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp32x48(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp32x64(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBmp64x64(int x, int y, int fgColor, int bgColor, unsigned char bitmap[]); + void drawBMP(unsigned char *buffer); +}; \ No newline at end of file