mbed I2C IMU+LCD

Files at this revision

API Documentation at this revision

Comitter:
rkuo2000
Date:
Thu Oct 20 13:26:43 2016 +0000
Parent:
1:efa4c7817836
Commit message:
mbed I2C IMU+LCD

Changed in this revision

Font5x7.h Show annotated file Show diff for this revision Revisions of this file
Font8x16.h Show annotated file Show diff for this revision Revisions of this file
draw2D.cpp Show annotated file Show diff for this revision Revisions of this file
draw2D.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
ssd1306.cpp Show annotated file Show diff for this revision Revisions of this file
ssd1306.h Show annotated file Show diff for this revision Revisions of this file
diff -r efa4c7817836 -r 6b9ce9b7f08a Font5x7.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Font5x7.h	Thu Oct 20 13:26:43 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 efa4c7817836 -r 6b9ce9b7f08a Font8x16.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Font8x16.h	Thu Oct 20 13:26:43 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 efa4c7817836 -r 6b9ce9b7f08a draw2D.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/draw2D.cpp	Thu Oct 20 13:26:43 2016 +0000
@@ -0,0 +1,87 @@
+#include <mbed.h>
+#include "draw2D.h"
+#include "ssd1306.h"
+
+SSD1306  LCD_2D;
+
+// draw Bresenham Line
+void Draw2D::drawLine(int x1, int y1, int x2, int y2, int fgColor, int bgColor)
+{
+    int dy = y2 - y1;
+    int dx = x2 - x1;
+    int stepx, stepy;
+
+    if (dy < 0) { dy = -dy;  stepy = -1; } else { stepy = 1; }
+    if (dx < 0) { dx = -dx;  stepx = -1; } else { stepx = 1; }
+    dy <<= 1;        // dy is now 2*dy
+    dx <<= 1;        // dx is now 2*dx
+
+    LCD_2D.drawPixel(x1,y1, fgColor, bgColor);
+    if (dx > dy) 
+    {
+        int fraction = dy - (dx >> 1);  // same as 2*dy - dx
+        while (x1 != x2) 
+        {
+           if (fraction >= 0) 
+           {
+               y1 += stepy;
+               fraction -= dx;          // same as fraction -= 2*dx
+           }
+           x1 += stepx;
+           fraction += dy;              // same as fraction -= 2*dy
+           LCD_2D.drawPixel(x1, y1, fgColor, bgColor);
+        }
+     } else {
+        int fraction = dx - (dy >> 1);
+        while (y1 != y2) {
+           if (fraction >= 0) {
+               x1 += stepx;
+               fraction -= dy;
+           }
+           y1 += stepy;
+           fraction += dx;
+           LCD_2D.drawPixel(x1, y1, fgColor, bgColor);
+        }
+     }
+}
+
+// draw Bresenham Circle
+void Draw2D::drawCircle(int xc, int yc, int r, int fgColor, int bgColor)
+{
+    int x = 0; 
+    int y = r; 
+    int p = 3 - 2 * r;
+    if (!r) return;     
+    while (y >= x) // only formulate 1/8 of circle
+    {
+        LCD_2D.drawPixel(xc-x, yc-y, fgColor, bgColor);//upper left left
+        LCD_2D.drawPixel(xc-y, yc-x, fgColor, bgColor);//upper upper left
+        LCD_2D.drawPixel(xc+y, yc-x, fgColor, bgColor);//upper upper right
+        LCD_2D.drawPixel(xc+x, yc-y, fgColor, bgColor);//upper right right
+        LCD_2D.drawPixel(xc-x, yc+y, fgColor, bgColor);//lower left left
+        LCD_2D.drawPixel(xc-y, yc+x, fgColor, bgColor);//lower lower left
+        LCD_2D.drawPixel(xc+y, yc+x, fgColor, bgColor);//lower lower right
+        LCD_2D.drawPixel(xc+x, yc+y, fgColor, bgColor);//lower right right
+        if (p < 0) p += 4*(x++) + 6; 
+        else p += 4*((x++) - y--) + 10; 
+     } 
+}
+
+void Draw2D::drawRectangle(int x0, int y0, int x1, int y1, int fgColor, int bgColor)
+{
+    int x,y, tmp;
+    if (x0>x1) { tmp = x1; x1 = x0; x0 = tmp; }
+    if (y0>y1) { tmp = y1; y1 = y0; y0 = tmp; }
+    for (x=x0; x<=x1; x++) LCD_2D.drawPixel(x,y0,fgColor, bgColor);
+    for (y=y0; y<=y1; y++) LCD_2D.drawPixel(x0,y,fgColor, bgColor);
+    for (x=x0; x<=x1; x++) LCD_2D.drawPixel(x,y1,fgColor, bgColor);
+    for (y=y0; y<=y1; y++) LCD_2D.drawPixel(x1,y,fgColor, bgColor);       
+}
+
+void Draw2D::drawTriangle(int x0, int y0, int x1, int y1, int x2, int y2, int fgColor, int bgColor)
+{
+    drawLine(x0, y0, x1, y1, fgColor, bgColor);
+    drawLine(x1, y1, x2, y2, fgColor, bgColor);
+    drawLine(x0, y0, x2, y2, fgColor, bgColor);
+}
+
diff -r efa4c7817836 -r 6b9ce9b7f08a draw2D.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/draw2D.h	Thu Oct 20 13:26:43 2016 +0000
@@ -0,0 +1,9 @@
+
+class Draw2D {
+    public:
+    void drawLine(int x1, int y1, int x2, int y2, int fgColor, int bgColor);
+    void drawCircle(int xc, int yc, int r, int fgColor, int bgColor);
+    void drawRectangle(int x0, int y0, int x1, int y1, int fgColor, int bgColor);
+    void drawTriangle(int x0, int y0, int x1, int y1, int x2, int y2, int fgColor, int bgColor);
+};
+
diff -r efa4c7817836 -r 6b9ce9b7f08a main.cpp
--- a/main.cpp	Thu Oct 20 13:19:15 2016 +0000
+++ b/main.cpp	Thu Oct 20 13:26:43 2016 +0000
@@ -1,32 +1,77 @@
-// using NuMaker-PFM-NUC472 I2C0 to read IMU and calculate tilt angle
+// using NuMaker-PFM-NUC472 I2C LCD+IMU control the direction of moving pointer
 #include "mbed.h"
 #include "math.h"
 #include "mpu6500.h"
+#include "ssd1306.h"
+#include "draw2D.h"
 
-#define PI 3.14159265359
+#define PI 3.1415926535
 
-I2C i2c0(PC_9, PA_15); // I2C0_SDA, I2C0_SCL
+#define X0 64       // initial point
+#define Y0 32       // initial point
 
-MPU6500 IMU; // IMU use on-board MPU6500
+I2C i2c0(PC_9 , PA_15); // I2C0_SDA, I2C0_SCL
+I2C i2c1(PD_12, PD_10); // I2C1_SDA, I2C1_SCL
+
+MPU6500 IMU; // IMU connected on I2C0 (on-board MPU6500)
+SSD1306 LCD; // LCD connected on I2C1
+Draw2D  D2D;  // Draw2D library
 
 int main() {
-    int16_t accX,  accY,  accZ;
-    float X2, Y2, Z2;
-    float theta, psi, phi;
+    int   accX, accY, accZ;
+    float theta, psi;
+
+    int dirX, dirY;
+    int movX, movY;
+    int x, y, r;
+    
+    i2c0.frequency(400000);
+    i2c1.frequency(400000); 
     
-    i2c0.frequency(400000);    
     IMU.initialize();
+    LCD.initialize();
+    LCD.clearscreen();
+
+    x = X0;    // cross center x
+    y = Y0;    // cross center y
+    r = 2;     // cross length
     
+    movX = 2;  // x movement
+    movY = 2;  // y movement
+    dirX = 1;  // x direction
+    dirY = 1;  // y direction
+         
     while(true) {
+       D2D.drawLine(x-2, y, x+2, y, FG_COLOR, BG_COLOR); // draw a line
+       D2D.drawLine(x, y-2, x, y+2, FG_COLOR, BG_COLOR); // draw a line
+                            
+       Thread::wait(10);
+       
+       D2D.drawLine(x-2, y, x+2, y, BG_COLOR, BG_COLOR); // draw a line
+       D2D.drawLine(x, y-2, x, y+2, BG_COLOR, BG_COLOR); // draw a line
+
+       // read Accelerometer to calculate tilt angle
        accX = IMU.getAccelXvalue();
        accY = IMU.getAccelYvalue();
        accZ = IMU.getAccelZvalue();
-       printf("Acc: %6d, %6d, %6d, ",   accX, accY, accZ);
-       // calculate tilt (degree = radians *180 / PI)
-       X2 = pow(accX,2.0); Y2 = pow(accY, 2.0); Z2 = pow(accZ,2.0);
-       theta = atan(accX / sqrt(Y2 + Z2)) *180 /PI;
-       psi   = atan(accY / sqrt(Z2 + X2)) *180 /PI;
-       phi   = atan(sqrt(X2 + Y2) / accZ) *180 /PI;
-       printf("theta=%d, psi=%d, phi=%d\n\r", (int) theta, (int) psi, (int) phi);              
-    }
+       theta = atan(accX / sqrt(pow(accY,2.0) + pow(accZ,2.0))) *180 /PI;
+       psi   = atan(accY / sqrt(pow(accZ,2.0) + pow(accX,2.0))) *180 /PI;          
+              
+       if      (theta<-20) dirX= 1;
+       else if (theta> 20) dirX=-1;
+       else                dirX= 0;
+       if      (psi  <-20) dirY= 1;
+       else if (psi  > 20) dirY=-1;
+       else                dirY= 0;       
+             
+       x = x + dirX * movX; // change x of circle center
+       y = y + dirY * movY; // change y of circle center
+
+       // boundary check for changing direction       
+       if      ((x-r) <=0)        {dirX= 1; x= x + dirX*movX;}
+       else if ((x+r) >=LCD_Xmax) {dirX=-1; x= x + dirX*movX;}
+       
+       if      ((y-r) <=0)        {dirY= 1; y= y + dirY*movY;}
+       else if ((y+r) >=LCD_Ymax) {dirY=-1; y= y + dirY*movY;}
+   }       
 }
diff -r efa4c7817836 -r 6b9ce9b7f08a ssd1306.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ssd1306.cpp	Thu Oct 20 13:26:43 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 efa4c7817836 -r 6b9ce9b7f08a ssd1306.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ssd1306.h	Thu Oct 20 13:26:43 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