SSD1306 LCD 96x16 model

Dependents:   testSoftware8_alles_display

Fork of ssd1306_library by Miguel Angel Rodriguez Jodar

Committer:
rodriguj
Date:
Wed Oct 25 15:56:50 2017 +0000
Revision:
1:c5cf4ca5939f
Parent:
0:3d84b3bfb794
Child:
2:7f1160c1a741
Added line. Fixed some compile errors.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rodriguj 0:3d84b3bfb794 1 #include "ssd1306.h"
rodriguj 0:3d84b3bfb794 2 #include "mbed.h"
rodriguj 0:3d84b3bfb794 3
rodriguj 0:3d84b3bfb794 4 static const char charset[2048] = {
rodriguj 0:3d84b3bfb794 5 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81,
rodriguj 0:3d84b3bfb794 6 0x95, 0xB1, 0xB1, 0x95, 0x81, 0x7E, 0x7E, 0xFF, 0xEB, 0xCF,
rodriguj 0:3d84b3bfb794 7 0xCF, 0xEB, 0xFF, 0x7E, 0x0E, 0x1F, 0x3F, 0x7E, 0x3F, 0x1F,
rodriguj 0:3d84b3bfb794 8 0x0E, 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, 0x00,
rodriguj 0:3d84b3bfb794 9 0x38, 0x3A, 0x9F, 0xFF, 0x9F, 0x3A, 0x38, 0x00, 0x18, 0x3C,
rodriguj 0:3d84b3bfb794 10 0xBE, 0xFF, 0xBE, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x3C,
rodriguj 0:3d84b3bfb794 11 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7,
rodriguj 0:3d84b3bfb794 12 0xFF, 0xFF, 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
rodriguj 0:3d84b3bfb794 13 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, 0x70, 0xF8,
rodriguj 0:3d84b3bfb794 14 0x88, 0x88, 0xFD, 0x7F, 0x07, 0x0F, 0x00, 0x4E, 0x5F, 0xF1,
rodriguj 0:3d84b3bfb794 15 0xF1, 0x5F, 0x4E, 0x00, 0xC0, 0xE0, 0xFF, 0x7F, 0x05, 0x05,
rodriguj 0:3d84b3bfb794 16 0x07, 0x07, 0xC0, 0xFF, 0x7F, 0x05, 0x05, 0x65, 0x7F, 0x3F,
rodriguj 0:3d84b3bfb794 17 0x5A, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x5A, 0x7F, 0x3E,
rodriguj 0:3d84b3bfb794 18 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x00, 0x08, 0x08, 0x1C, 0x1C,
rodriguj 0:3d84b3bfb794 19 0x3E, 0x3E, 0x7F, 0x00, 0x00, 0x24, 0x66, 0xFF, 0xFF, 0x66,
rodriguj 0:3d84b3bfb794 20 0x24, 0x00, 0x00, 0x5F, 0x5F, 0x00, 0x00, 0x5F, 0x5F, 0x00,
rodriguj 0:3d84b3bfb794 21 0x06, 0x0F, 0x09, 0x7F, 0x7F, 0x01, 0x7F, 0x7F, 0x40, 0x9A,
rodriguj 0:3d84b3bfb794 22 0xBF, 0xA5, 0xA5, 0xFD, 0x59, 0x02, 0x00, 0x70, 0x70, 0x70,
rodriguj 0:3d84b3bfb794 23 0x70, 0x70, 0x70, 0x00, 0x80, 0x94, 0xB6, 0xFF, 0xFF, 0xB6,
rodriguj 0:3d84b3bfb794 24 0x94, 0x80, 0x00, 0x04, 0x06, 0x7F, 0x7F, 0x06, 0x04, 0x00,
rodriguj 0:3d84b3bfb794 25 0x00, 0x10, 0x30, 0x7F, 0x7F, 0x30, 0x10, 0x00, 0x08, 0x08,
rodriguj 0:3d84b3bfb794 26 0x08, 0x2A, 0x3E, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x3E, 0x2A,
rodriguj 0:3d84b3bfb794 27 0x08, 0x08, 0x08, 0x00, 0x3C, 0x3C, 0x20, 0x20, 0x20, 0x20,
rodriguj 0:3d84b3bfb794 28 0x20, 0x00, 0x08, 0x1C, 0x3E, 0x08, 0x08, 0x3E, 0x1C, 0x08,
rodriguj 0:3d84b3bfb794 29 0x30, 0x38, 0x3C, 0x3E, 0x3E, 0x3C, 0x38, 0x30, 0x06, 0x0E,
rodriguj 0:3d84b3bfb794 30 0x1E, 0x3E, 0x3E, 0x1E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5F, 0x5F, 0x06,
rodriguj 0:3d84b3bfb794 32 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x07, 0x03, 0x00,
rodriguj 0:3d84b3bfb794 33 0x14, 0x7F, 0x7F, 0x14, 0x7F, 0x7F, 0x14, 0x00, 0x00, 0x24,
rodriguj 0:3d84b3bfb794 34 0x2E, 0x6B, 0x6B, 0x3A, 0x12, 0x00, 0x46, 0x66, 0x30, 0x18,
rodriguj 0:3d84b3bfb794 35 0x0C, 0x66, 0x62, 0x00, 0x30, 0x7A, 0x4F, 0x5D, 0x37, 0x7A,
rodriguj 0:3d84b3bfb794 36 0x48, 0x00, 0x00, 0x00, 0x04, 0x07, 0x03, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 37 0x00, 0x00, 0x1C, 0x3E, 0x63, 0x41, 0x00, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 38 0x41, 0x63, 0x3E, 0x1C, 0x00, 0x00, 0x08, 0x2A, 0x3E, 0x1C,
rodriguj 0:3d84b3bfb794 39 0x1C, 0x3E, 0x2A, 0x08, 0x00, 0x08, 0x08, 0x3E, 0x3E, 0x08,
rodriguj 0:3d84b3bfb794 40 0x08, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x60, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 41 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 42 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C,
rodriguj 0:3d84b3bfb794 43 0x06, 0x03, 0x01, 0x00, 0x1C, 0x3E, 0x63, 0x49, 0x63, 0x3E,
rodriguj 0:3d84b3bfb794 44 0x1C, 0x00, 0x00, 0x40, 0x42, 0x7F, 0x7F, 0x40, 0x40, 0x00,
rodriguj 0:3d84b3bfb794 45 0x42, 0x63, 0x71, 0x59, 0x49, 0x6F, 0x66, 0x00, 0x22, 0x63,
rodriguj 0:3d84b3bfb794 46 0x49, 0x49, 0x49, 0x7F, 0x36, 0x00, 0x18, 0x1C, 0x16, 0x53,
rodriguj 0:3d84b3bfb794 47 0x7F, 0x7F, 0x50, 0x00, 0x2F, 0x6F, 0x49, 0x49, 0x49, 0x79,
rodriguj 0:3d84b3bfb794 48 0x31, 0x00, 0x3C, 0x7E, 0x4B, 0x49, 0x49, 0x78, 0x30, 0x00,
rodriguj 0:3d84b3bfb794 49 0x03, 0x03, 0x71, 0x79, 0x0D, 0x07, 0x03, 0x00, 0x36, 0x7F,
rodriguj 0:3d84b3bfb794 50 0x49, 0x49, 0x49, 0x7F, 0x36, 0x00, 0x06, 0x4F, 0x49, 0x49,
rodriguj 0:3d84b3bfb794 51 0x69, 0x3F, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00,
rodriguj 0:3d84b3bfb794 52 0x00, 0x00, 0x00, 0x00, 0x80, 0xE6, 0x66, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 53 0x00, 0x00, 0x08, 0x1C, 0x36, 0x63, 0x41, 0x00, 0x00, 0x24,
rodriguj 0:3d84b3bfb794 54 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x41, 0x63, 0x36,
rodriguj 0:3d84b3bfb794 55 0x1C, 0x08, 0x00, 0x00, 0x02, 0x03, 0x01, 0x59, 0x5D, 0x07,
rodriguj 0:3d84b3bfb794 56 0x02, 0x00, 0x3E, 0x7F, 0x41, 0x5D, 0x5D, 0x1F, 0x1E, 0x00,
rodriguj 0:3d84b3bfb794 57 0x7C, 0x7E, 0x0B, 0x09, 0x0B, 0x7E, 0x7C, 0x00, 0x41, 0x7F,
rodriguj 0:3d84b3bfb794 58 0x7F, 0x49, 0x49, 0x7F, 0x36, 0x00, 0x1C, 0x3E, 0x63, 0x41,
rodriguj 0:3d84b3bfb794 59 0x41, 0x63, 0x22, 0x00, 0x41, 0x7F, 0x7F, 0x41, 0x63, 0x3E,
rodriguj 0:3d84b3bfb794 60 0x1C, 0x00, 0x41, 0x7F, 0x7F, 0x49, 0x5D, 0x41, 0x63, 0x00,
rodriguj 0:3d84b3bfb794 61 0x41, 0x7F, 0x7F, 0x49, 0x1D, 0x01, 0x03, 0x00, 0x1C, 0x3E,
rodriguj 0:3d84b3bfb794 62 0x63, 0x41, 0x51, 0x33, 0x72, 0x00, 0x7F, 0x7F, 0x08, 0x08,
rodriguj 0:3d84b3bfb794 63 0x08, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x7F, 0x41,
rodriguj 0:3d84b3bfb794 64 0x00, 0x00, 0x30, 0x70, 0x40, 0x41, 0x7F, 0x3F, 0x01, 0x00,
rodriguj 0:3d84b3bfb794 65 0x41, 0x7F, 0x7F, 0x08, 0x1C, 0x77, 0x63, 0x00, 0x41, 0x7F,
rodriguj 0:3d84b3bfb794 66 0x7F, 0x41, 0x40, 0x60, 0x70, 0x00, 0x7F, 0x7F, 0x0E, 0x1C,
rodriguj 0:3d84b3bfb794 67 0x0E, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x06, 0x0C, 0x18, 0x7F,
rodriguj 0:3d84b3bfb794 68 0x7F, 0x00, 0x3E, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x3E, 0x00,
rodriguj 0:3d84b3bfb794 69 0x41, 0x7F, 0x7F, 0x49, 0x09, 0x0F, 0x06, 0x00, 0x3E, 0x7F,
rodriguj 0:3d84b3bfb794 70 0x41, 0x41, 0xE1, 0xFF, 0xBE, 0x00, 0x41, 0x7F, 0x7F, 0x09,
rodriguj 0:3d84b3bfb794 71 0x19, 0x7F, 0x66, 0x00, 0x00, 0x22, 0x67, 0x4D, 0x59, 0x73,
rodriguj 0:3d84b3bfb794 72 0x22, 0x00, 0x00, 0x07, 0x43, 0x7F, 0x7F, 0x43, 0x07, 0x00,
rodriguj 0:3d84b3bfb794 73 0x3F, 0x7F, 0x40, 0x40, 0x40, 0x7F, 0x3F, 0x00, 0x1F, 0x3F,
rodriguj 0:3d84b3bfb794 74 0x60, 0x40, 0x60, 0x3F, 0x1F, 0x00, 0x3F, 0x7F, 0x60, 0x38,
rodriguj 0:3d84b3bfb794 75 0x60, 0x7F, 0x3F, 0x00, 0x63, 0x77, 0x1C, 0x08, 0x1C, 0x77,
rodriguj 0:3d84b3bfb794 76 0x63, 0x00, 0x00, 0x07, 0x4F, 0x78, 0x78, 0x4F, 0x07, 0x00,
rodriguj 0:3d84b3bfb794 77 0x47, 0x63, 0x71, 0x59, 0x4D, 0x67, 0x73, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 78 0x7F, 0x7F, 0x41, 0x41, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C,
rodriguj 0:3d84b3bfb794 79 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x41, 0x41, 0x7F, 0x7F,
rodriguj 0:3d84b3bfb794 80 0x00, 0x00, 0x08, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x08, 0x00,
rodriguj 0:3d84b3bfb794 81 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 82 0x01, 0x03, 0x06, 0x04, 0x00, 0x00, 0x20, 0x74, 0x54, 0x54,
rodriguj 0:3d84b3bfb794 83 0x3C, 0x78, 0x40, 0x00, 0x41, 0x7F, 0x3F, 0x44, 0x44, 0x7C,
rodriguj 0:3d84b3bfb794 84 0x38, 0x00, 0x38, 0x7C, 0x44, 0x44, 0x44, 0x6C, 0x28, 0x00,
rodriguj 0:3d84b3bfb794 85 0x38, 0x7C, 0x44, 0x45, 0x3F, 0x7F, 0x40, 0x00, 0x38, 0x7C,
rodriguj 0:3d84b3bfb794 86 0x54, 0x54, 0x54, 0x5C, 0x18, 0x00, 0x48, 0x7E, 0x7F, 0x49,
rodriguj 0:3d84b3bfb794 87 0x09, 0x03, 0x02, 0x00, 0x98, 0xBC, 0xA4, 0xA4, 0xF8, 0x7C,
rodriguj 0:3d84b3bfb794 88 0x04, 0x00, 0x41, 0x7F, 0x7F, 0x08, 0x04, 0x7C, 0x78, 0x00,
rodriguj 0:3d84b3bfb794 89 0x00, 0x00, 0x44, 0x7D, 0x7D, 0x40, 0x00, 0x00, 0x00, 0x60,
rodriguj 0:3d84b3bfb794 90 0xE0, 0x80, 0x80, 0xFD, 0x7D, 0x00, 0x41, 0x7F, 0x7F, 0x10,
rodriguj 0:3d84b3bfb794 91 0x38, 0x6C, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x7F, 0x40,
rodriguj 0:3d84b3bfb794 92 0x00, 0x00, 0x7C, 0x7C, 0x0C, 0x78, 0x0C, 0x7C, 0x78, 0x00,
rodriguj 0:3d84b3bfb794 93 0x04, 0x7C, 0x78, 0x04, 0x04, 0x7C, 0x78, 0x00, 0x38, 0x7C,
rodriguj 0:3d84b3bfb794 94 0x44, 0x44, 0x44, 0x7C, 0x38, 0x00, 0x84, 0xFC, 0xF8, 0xA4,
rodriguj 0:3d84b3bfb794 95 0x24, 0x3C, 0x18, 0x00, 0x18, 0x3C, 0x24, 0xA4, 0xF8, 0xFC,
rodriguj 0:3d84b3bfb794 96 0x84, 0x00, 0x44, 0x7C, 0x78, 0x4C, 0x04, 0x0C, 0x08, 0x00,
rodriguj 0:3d84b3bfb794 97 0x48, 0x5C, 0x54, 0x54, 0x54, 0x74, 0x24, 0x00, 0x04, 0x04,
rodriguj 0:3d84b3bfb794 98 0x3F, 0x7F, 0x44, 0x64, 0x20, 0x00, 0x3C, 0x7C, 0x40, 0x40,
rodriguj 0:3d84b3bfb794 99 0x3C, 0x7C, 0x40, 0x00, 0x1C, 0x3C, 0x60, 0x40, 0x60, 0x3C,
rodriguj 0:3d84b3bfb794 100 0x1C, 0x00, 0x3C, 0x7C, 0x60, 0x38, 0x60, 0x7C, 0x3C, 0x00,
rodriguj 0:3d84b3bfb794 101 0x44, 0x6C, 0x38, 0x10, 0x38, 0x6C, 0x44, 0x00, 0x9C, 0xBC,
rodriguj 0:3d84b3bfb794 102 0xA0, 0xA0, 0xA0, 0xFC, 0x7C, 0x00, 0x00, 0x4C, 0x64, 0x74,
rodriguj 0:3d84b3bfb794 103 0x5C, 0x4C, 0x64, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x77, 0x41,
rodriguj 0:3d84b3bfb794 104 0x41, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 105 0x00, 0x41, 0x41, 0x77, 0x3E, 0x08, 0x08, 0x00, 0x02, 0x03,
rodriguj 0:3d84b3bfb794 106 0x01, 0x03, 0x02, 0x03, 0x01, 0x00, 0x70, 0x78, 0x4C, 0x46,
rodriguj 0:3d84b3bfb794 107 0x4C, 0x78, 0x70, 0x00, 0x1E, 0xBF, 0xA1, 0xA1, 0xE1, 0x73,
rodriguj 0:3d84b3bfb794 108 0x12, 0x00, 0x3D, 0x7D, 0x40, 0x40, 0x3D, 0x7D, 0x40, 0x00,
rodriguj 0:3d84b3bfb794 109 0x38, 0x7C, 0x54, 0x56, 0x57, 0x5D, 0x18, 0x00, 0x22, 0x75,
rodriguj 0:3d84b3bfb794 110 0x55, 0x55, 0x3D, 0x79, 0x42, 0x00, 0x21, 0x75, 0x54, 0x54,
rodriguj 0:3d84b3bfb794 111 0x3C, 0x79, 0x41, 0x00, 0x20, 0x74, 0x55, 0x57, 0x3E, 0x78,
rodriguj 0:3d84b3bfb794 112 0x40, 0x00, 0x20, 0x74, 0x57, 0x57, 0x3C, 0x78, 0x40, 0x00,
rodriguj 0:3d84b3bfb794 113 0x18, 0x3C, 0xA4, 0xA4, 0xE4, 0x64, 0x24, 0x00, 0x3A, 0x7D,
rodriguj 0:3d84b3bfb794 114 0x55, 0x55, 0x55, 0x5D, 0x1A, 0x00, 0x39, 0x7D, 0x54, 0x54,
rodriguj 0:3d84b3bfb794 115 0x54, 0x5D, 0x19, 0x00, 0x38, 0x7C, 0x55, 0x57, 0x56, 0x5C,
rodriguj 0:3d84b3bfb794 116 0x18, 0x00, 0x00, 0x01, 0x45, 0x7C, 0x7C, 0x41, 0x01, 0x00,
rodriguj 0:3d84b3bfb794 117 0x02, 0x01, 0x45, 0x7D, 0x7D, 0x41, 0x02, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 118 0x49, 0x7B, 0x7A, 0x40, 0x00, 0x00, 0x79, 0x7D, 0x16, 0x12,
rodriguj 0:3d84b3bfb794 119 0x16, 0x7D, 0x79, 0x00, 0x78, 0x7E, 0x17, 0x15, 0x17, 0x7E,
rodriguj 0:3d84b3bfb794 120 0x78, 0x00, 0x7C, 0x7C, 0x56, 0x57, 0x55, 0x44, 0x44, 0x00,
rodriguj 0:3d84b3bfb794 121 0x20, 0x74, 0x54, 0x7C, 0x7C, 0x54, 0x54, 0x00, 0x7C, 0x7E,
rodriguj 0:3d84b3bfb794 122 0x0B, 0x09, 0x7F, 0x7F, 0x49, 0x00, 0x3A, 0x7D, 0x45, 0x45,
rodriguj 0:3d84b3bfb794 123 0x45, 0x7D, 0x3A, 0x00, 0x39, 0x7D, 0x44, 0x44, 0x44, 0x7D,
rodriguj 0:3d84b3bfb794 124 0x39, 0x00, 0x38, 0x7C, 0x45, 0x47, 0x46, 0x7C, 0x38, 0x00,
rodriguj 0:3d84b3bfb794 125 0x3A, 0x79, 0x41, 0x41, 0x39, 0x7A, 0x40, 0x00, 0x3C, 0x7D,
rodriguj 0:3d84b3bfb794 126 0x43, 0x42, 0x3C, 0x7C, 0x40, 0x00, 0x9D, 0xBD, 0xA0, 0xA0,
rodriguj 0:3d84b3bfb794 127 0xA0, 0xFD, 0x7D, 0x00, 0x19, 0x3D, 0x66, 0x42, 0x66, 0x3D,
rodriguj 0:3d84b3bfb794 128 0x19, 0x00, 0x3D, 0x7D, 0x40, 0x40, 0x40, 0x7D, 0x3D, 0x00,
rodriguj 0:3d84b3bfb794 129 0x18, 0x3C, 0x24, 0xE7, 0xE7, 0x24, 0x24, 0x00, 0x48, 0x7E,
rodriguj 0:3d84b3bfb794 130 0x7F, 0x49, 0x43, 0x66, 0x20, 0x00, 0x00, 0x2B, 0x2F, 0xFC,
rodriguj 0:3d84b3bfb794 131 0xFC, 0x2F, 0x2B, 0x00, 0xFF, 0xFF, 0x09, 0x09, 0x2F, 0xF6,
rodriguj 0:3d84b3bfb794 132 0xF8, 0xA0, 0x20, 0x60, 0x48, 0x7E, 0x3F, 0x09, 0x03, 0x02,
rodriguj 0:3d84b3bfb794 133 0x20, 0x74, 0x56, 0x57, 0x3D, 0x78, 0x40, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 134 0x48, 0x7A, 0x7B, 0x41, 0x00, 0x00, 0x38, 0x7C, 0x44, 0x46,
rodriguj 0:3d84b3bfb794 135 0x47, 0x7D, 0x38, 0x00, 0x3C, 0x7C, 0x42, 0x43, 0x3D, 0x7C,
rodriguj 0:3d84b3bfb794 136 0x40, 0x00, 0x0A, 0x7B, 0x71, 0x0B, 0x0A, 0x7B, 0x71, 0x00,
rodriguj 0:3d84b3bfb794 137 0x7A, 0x7B, 0x19, 0x33, 0x62, 0x7B, 0x79, 0x00, 0x00, 0x26,
rodriguj 0:3d84b3bfb794 138 0x2F, 0x29, 0x2F, 0x2F, 0x28, 0x00, 0x00, 0x26, 0x2F, 0x29,
rodriguj 0:3d84b3bfb794 139 0x2F, 0x26, 0x00, 0x00, 0x00, 0x20, 0x70, 0x5D, 0x4D, 0x40,
rodriguj 0:3d84b3bfb794 140 0x60, 0x20, 0x38, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
rodriguj 0:3d84b3bfb794 141 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x38, 0x00, 0x42, 0x6F,
rodriguj 0:3d84b3bfb794 142 0x3F, 0x18, 0xCC, 0xEE, 0xBB, 0x91, 0x42, 0x6F, 0x3F, 0x58,
rodriguj 0:3d84b3bfb794 143 0x6C, 0xD6, 0xFB, 0x41, 0x00, 0x00, 0x30, 0x7D, 0x7D, 0x30,
rodriguj 0:3d84b3bfb794 144 0x00, 0x00, 0x08, 0x1C, 0x36, 0x22, 0x08, 0x1C, 0x36, 0x22,
rodriguj 0:3d84b3bfb794 145 0x22, 0x36, 0x1C, 0x08, 0x22, 0x36, 0x1C, 0x08, 0xAA, 0x00,
rodriguj 0:3d84b3bfb794 146 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00, 0xAA, 0x55, 0xAA, 0x55,
rodriguj 0:3d84b3bfb794 147 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xFF, 0x55, 0xFF, 0xAA, 0xFF,
rodriguj 0:3d84b3bfb794 148 0x55, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 149 0x10, 0x10, 0x10, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x14, 0x14,
rodriguj 0:3d84b3bfb794 150 0x14, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0xFF, 0xFF,
rodriguj 0:3d84b3bfb794 151 0x00, 0xFF, 0xFF, 0x00, 0x10, 0x10, 0xF0, 0xF0, 0x10, 0xF0,
rodriguj 0:3d84b3bfb794 152 0xF0, 0x00, 0x14, 0x14, 0x14, 0xFC, 0xFC, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 153 0x14, 0x14, 0xF7, 0xF7, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 154 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x14, 0x14, 0xF4, 0xF4,
rodriguj 0:3d84b3bfb794 155 0x04, 0xFC, 0xFC, 0x00, 0x14, 0x14, 0x17, 0x17, 0x10, 0x1F,
rodriguj 0:3d84b3bfb794 156 0x1F, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x1F, 0x1F, 0x00,
rodriguj 0:3d84b3bfb794 157 0x14, 0x14, 0x14, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x10, 0x10,
rodriguj 0:3d84b3bfb794 158 0x10, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
rodriguj 0:3d84b3bfb794 159 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x1F, 0x10,
rodriguj 0:3d84b3bfb794 160 0x10, 0x10, 0x10, 0x10, 0x10, 0xF0, 0xF0, 0x10, 0x10, 0x10,
rodriguj 0:3d84b3bfb794 161 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10,
rodriguj 0:3d84b3bfb794 162 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF,
rodriguj 0:3d84b3bfb794 163 0xFF, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x14,
rodriguj 0:3d84b3bfb794 164 0x14, 0x14, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x10,
rodriguj 0:3d84b3bfb794 165 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x17, 0x17, 0x14, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 166 0xFC, 0xFC, 0x04, 0xF4, 0xF4, 0x14, 0x14, 0x14, 0x17, 0x17,
rodriguj 0:3d84b3bfb794 167 0x10, 0x17, 0x17, 0x14, 0x14, 0x14, 0xF4, 0xF4, 0x04, 0xF4,
rodriguj 0:3d84b3bfb794 168 0xF4, 0x14, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xF7, 0xF7, 0x14,
rodriguj 0:3d84b3bfb794 169 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
rodriguj 0:3d84b3bfb794 170 0xF7, 0xF7, 0x00, 0xF7, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x17,
rodriguj 0:3d84b3bfb794 171 0x17, 0x14, 0x14, 0x14, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x1F,
rodriguj 0:3d84b3bfb794 172 0x1F, 0x10, 0x14, 0x14, 0x14, 0xF4, 0xF4, 0x14, 0x14, 0x14,
rodriguj 0:3d84b3bfb794 173 0x10, 0x10, 0xF0, 0xF0, 0x10, 0xF0, 0xF0, 0x10, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 174 0x1F, 0x1F, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00, 0x1F,
rodriguj 0:3d84b3bfb794 175 0x1F, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x14,
rodriguj 0:3d84b3bfb794 176 0x14, 0x14, 0x00, 0x00, 0xF0, 0xF0, 0x10, 0xF0, 0xF0, 0x10,
rodriguj 0:3d84b3bfb794 177 0x10, 0x10, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0x10, 0x14, 0x14,
rodriguj 0:3d84b3bfb794 178 0x14, 0xFF, 0xFF, 0x14, 0x14, 0x14, 0x10, 0x10, 0x10, 0x1F,
rodriguj 0:3d84b3bfb794 179 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x10,
rodriguj 0:3d84b3bfb794 180 0x10, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
rodriguj 0:3d84b3bfb794 181 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF,
rodriguj 0:3d84b3bfb794 182 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 183 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
rodriguj 0:3d84b3bfb794 184 0x0F, 0x0F, 0x38, 0x7C, 0x44, 0x6C, 0x38, 0x6C, 0x44, 0x00,
rodriguj 0:3d84b3bfb794 185 0x7E, 0x7F, 0x01, 0x09, 0x5F, 0x76, 0x20, 0x00, 0x7F, 0x7F,
rodriguj 0:3d84b3bfb794 186 0x01, 0x01, 0x01, 0x03, 0x03, 0x00, 0x04, 0x7C, 0x7C, 0x04,
rodriguj 0:3d84b3bfb794 187 0x7C, 0x7C, 0x04, 0x00, 0x63, 0x77, 0x5D, 0x49, 0x41, 0x63,
rodriguj 0:3d84b3bfb794 188 0x63, 0x00, 0x38, 0x7C, 0x44, 0x7C, 0x3C, 0x04, 0x04, 0x00,
rodriguj 0:3d84b3bfb794 189 0x80, 0xFC, 0x7C, 0x40, 0x40, 0x7C, 0x3C, 0x00, 0x04, 0x06,
rodriguj 0:3d84b3bfb794 190 0x02, 0x7E, 0x7C, 0x06, 0x02, 0x00, 0x00, 0x99, 0xBD, 0xE7,
rodriguj 0:3d84b3bfb794 191 0xE7, 0xBD, 0x99, 0x00, 0x1C, 0x3E, 0x6B, 0x49, 0x6B, 0x3E,
rodriguj 0:3d84b3bfb794 192 0x1C, 0x00, 0x4C, 0x7E, 0x73, 0x01, 0x73, 0x7E, 0x4C, 0x00,
rodriguj 0:3d84b3bfb794 193 0x00, 0x30, 0x78, 0x4A, 0x4F, 0x7D, 0x39, 0x00, 0x18, 0x3C,
rodriguj 0:3d84b3bfb794 194 0x24, 0x3C, 0x3C, 0x24, 0x3C, 0x18, 0x98, 0xFC, 0x64, 0x3C,
rodriguj 0:3d84b3bfb794 195 0x3E, 0x27, 0x3D, 0x18, 0x00, 0x1C, 0x3E, 0x6B, 0x49, 0x49,
rodriguj 0:3d84b3bfb794 196 0x49, 0x00, 0x7C, 0x7E, 0x02, 0x02, 0x02, 0x7E, 0x7C, 0x00,
rodriguj 0:3d84b3bfb794 197 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, 0x00, 0x44,
rodriguj 0:3d84b3bfb794 198 0x44, 0x5F, 0x5F, 0x44, 0x44, 0x00, 0x00, 0x40, 0x51, 0x5B,
rodriguj 0:3d84b3bfb794 199 0x4E, 0x44, 0x40, 0x00, 0x00, 0x40, 0x44, 0x4E, 0x5B, 0x51,
rodriguj 0:3d84b3bfb794 200 0x40, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x07, 0x06,
rodriguj 0:3d84b3bfb794 201 0x60, 0xE0, 0x80, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x08,
rodriguj 0:3d84b3bfb794 202 0x08, 0x2A, 0x2A, 0x08, 0x08, 0x00, 0x24, 0x36, 0x12, 0x36,
rodriguj 0:3d84b3bfb794 203 0x24, 0x36, 0x12, 0x00, 0x00, 0x06, 0x0F, 0x09, 0x0F, 0x06,
rodriguj 0:3d84b3bfb794 204 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 205 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x10, 0x30,
rodriguj 0:3d84b3bfb794 206 0x70, 0xC0, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x01, 0x1F, 0x1E,
rodriguj 0:3d84b3bfb794 207 0x01, 0x1F, 0x1E, 0x00, 0x00, 0x11, 0x19, 0x1D, 0x17, 0x12,
rodriguj 0:3d84b3bfb794 208 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00,
rodriguj 0:3d84b3bfb794 209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
rodriguj 0:3d84b3bfb794 210 };
rodriguj 0:3d84b3bfb794 211
rodriguj 0:3d84b3bfb794 212
rodriguj 0:3d84b3bfb794 213 SSD1306::SSD1306 (PinName sda, PinName scl)
rodriguj 0:3d84b3bfb794 214 {
rodriguj 0:3d84b3bfb794 215 idxfb = 0;
rodriguj 0:3d84b3bfb794 216 fb = new char[1024];
rodriguj 0:3d84b3bfb794 217 if (!fb)
rodriguj 0:3d84b3bfb794 218 {
rodriguj 0:3d84b3bfb794 219 printf ("SSD1306: Framebuffer allocation failed!\r\n");
rodriguj 0:3d84b3bfb794 220 for (;;) { }
rodriguj 0:3d84b3bfb794 221 }
rodriguj 0:3d84b3bfb794 222
rodriguj 0:3d84b3bfb794 223 bus = new I2C (sda, scl);
rodriguj 0:3d84b3bfb794 224 ssd1306_i2c_addr = scan();
rodriguj 0:3d84b3bfb794 225 if (ssd1306_i2c_addr != 0x78 && ssd1306_i2c_addr != 0x7A)
rodriguj 0:3d84b3bfb794 226 {
rodriguj 0:3d84b3bfb794 227 printf ("SSD1306: slave not found!. ");
rodriguj 0:3d84b3bfb794 228 if (ssd1306_i2c_addr != 0)
rodriguj 0:3d84b3bfb794 229 printf ("Found I2C slave at 0x%02.2X\r\n", ssd1306_i2c_addr);
rodriguj 0:3d84b3bfb794 230 else
rodriguj 0:3d84b3bfb794 231 printf ("\r\n");
rodriguj 0:3d84b3bfb794 232 for (;;) { }
rodriguj 0:3d84b3bfb794 233 }
rodriguj 0:3d84b3bfb794 234 #ifdef SSD1306_DEBUG
rodriguj 0:3d84b3bfb794 235 printf ("SSD1306 debug: fb = 0x%08.8X\r\n", fb);
rodriguj 0:3d84b3bfb794 236 printf ("SSD1306 debug: I2C addr = 0x%02.2X\r\n", ssd1306_i2c_addr);
rodriguj 0:3d84b3bfb794 237 #endif
rodriguj 0:3d84b3bfb794 238
rodriguj 0:3d84b3bfb794 239
rodriguj 0:3d84b3bfb794 240 }
rodriguj 0:3d84b3bfb794 241
rodriguj 0:3d84b3bfb794 242 void SSD1306::speed (I2CSpeed spd)
rodriguj 0:3d84b3bfb794 243 {
rodriguj 0:3d84b3bfb794 244 switch (spd)
rodriguj 0:3d84b3bfb794 245 {
rodriguj 1:c5cf4ca5939f 246 case Low: bus->frequency(100000); break;
rodriguj 1:c5cf4ca5939f 247 case Medium: bus->frequency(400000); break;
rodriguj 1:c5cf4ca5939f 248 case Fast: bus->frequency(1000000); break;
rodriguj 0:3d84b3bfb794 249 }
rodriguj 0:3d84b3bfb794 250 }
rodriguj 0:3d84b3bfb794 251
rodriguj 0:3d84b3bfb794 252 char SSD1306::scan (void)
rodriguj 0:3d84b3bfb794 253 {
rodriguj 0:3d84b3bfb794 254 int addr;
rodriguj 0:3d84b3bfb794 255 int res;
rodriguj 0:3d84b3bfb794 256 char i2caddr = 0;
rodriguj 0:3d84b3bfb794 257
rodriguj 0:3d84b3bfb794 258 for (addr=0; addr<256; addr++) {
rodriguj 0:3d84b3bfb794 259 res = bus->write (addr, NULL, 0);
rodriguj 0:3d84b3bfb794 260 if (res == 0)
rodriguj 0:3d84b3bfb794 261 i2caddr = addr & 0xFE;
rodriguj 0:3d84b3bfb794 262 }
rodriguj 0:3d84b3bfb794 263 return i2caddr;
rodriguj 0:3d84b3bfb794 264 }
rodriguj 0:3d84b3bfb794 265
rodriguj 0:3d84b3bfb794 266 int SSD1306::command_data (char c, char c_or_d, char lastitem)
rodriguj 0:3d84b3bfb794 267 {
rodriguj 0:3d84b3bfb794 268 int res;
rodriguj 0:3d84b3bfb794 269
rodriguj 0:3d84b3bfb794 270 bus->start();
rodriguj 0:3d84b3bfb794 271 res = bus->write(ssd1306_i2c_addr); if (!res) goto terminate_transaction;
rodriguj 0:3d84b3bfb794 272 res = bus->write(c_or_d | lastitem); if (!res) goto terminate_transaction;
rodriguj 0:3d84b3bfb794 273 res = bus->write(c); if (!res) goto terminate_transaction;
rodriguj 0:3d84b3bfb794 274
rodriguj 0:3d84b3bfb794 275 terminate_transaction:
rodriguj 0:3d84b3bfb794 276 bus->stop();
rodriguj 0:3d84b3bfb794 277 return res;
rodriguj 0:3d84b3bfb794 278 }
rodriguj 0:3d84b3bfb794 279
rodriguj 0:3d84b3bfb794 280 int SSD1306::command (char c)
rodriguj 0:3d84b3bfb794 281 {
rodriguj 0:3d84b3bfb794 282 return command_data (c, IS_COMMAND, IS_LAST);
rodriguj 0:3d84b3bfb794 283 }
rodriguj 0:3d84b3bfb794 284
rodriguj 0:3d84b3bfb794 285 int SSD1306::data (char d)
rodriguj 0:3d84b3bfb794 286 {
rodriguj 0:3d84b3bfb794 287 return command_data (d, IS_DATA, IS_LAST);
rodriguj 0:3d84b3bfb794 288 }
rodriguj 0:3d84b3bfb794 289
rodriguj 0:3d84b3bfb794 290 int SSD1306::init (void)
rodriguj 0:3d84b3bfb794 291 {
rodriguj 0:3d84b3bfb794 292 static char comando[] = {0x80, SSD1306_DISPLAYOFF, 0x80, SSD1306_CHARGEPUMP, 0x80, 0x14, 0x80, SSD1306_MEMORYMODE, 0x80, 0x00, 0x80, SSD1306_SEGREMAP | 0x1,
rodriguj 0:3d84b3bfb794 293 0x80, SSD1306_COMSCANDEC, 0x80, SSD1306_SETCONTRAST, 0x80, 0x7F, 0x00, SSD1306_DISPLAYON
rodriguj 0:3d84b3bfb794 294 };
rodriguj 0:3d84b3bfb794 295
rodriguj 0:3d84b3bfb794 296 return bus->write (ssd1306_i2c_addr, comando, sizeof comando);
rodriguj 0:3d84b3bfb794 297 }
rodriguj 0:3d84b3bfb794 298
rodriguj 1:c5cf4ca5939f 299 void SSD1306::scroll (bool refresh)
rodriguj 0:3d84b3bfb794 300 {
rodriguj 0:3d84b3bfb794 301 int i;
rodriguj 0:3d84b3bfb794 302
rodriguj 0:3d84b3bfb794 303 for (i=128; i<1024; i++)
rodriguj 0:3d84b3bfb794 304 fb[i-128] = fb[i];
rodriguj 0:3d84b3bfb794 305 for (i=896; i<1024; i++)
rodriguj 0:3d84b3bfb794 306 fb[i] = 0;
rodriguj 1:c5cf4ca5939f 307 if (refresh)
rodriguj 1:c5cf4ca5939f 308 display();
rodriguj 0:3d84b3bfb794 309 }
rodriguj 0:3d84b3bfb794 310
rodriguj 1:c5cf4ca5939f 311 void SSD1306::putchar (char c, bool refresh)
rodriguj 0:3d84b3bfb794 312 {
rodriguj 0:3d84b3bfb794 313 int idx,i;
rodriguj 0:3d84b3bfb794 314
rodriguj 0:3d84b3bfb794 315 idx = c*8;
rodriguj 0:3d84b3bfb794 316 for (i=0; i<8; i++) {
rodriguj 0:3d84b3bfb794 317 fb[idxfb] = charset[idx+i];
rodriguj 0:3d84b3bfb794 318 idxfb++;
rodriguj 0:3d84b3bfb794 319 if (idxfb == 1024) {
rodriguj 1:c5cf4ca5939f 320 scroll(refresh);
rodriguj 0:3d84b3bfb794 321 idxfb = 896;
rodriguj 0:3d84b3bfb794 322 }
rodriguj 0:3d84b3bfb794 323 }
rodriguj 1:c5cf4ca5939f 324 if (refresh)
rodriguj 1:c5cf4ca5939f 325 display();
rodriguj 0:3d84b3bfb794 326 }
rodriguj 0:3d84b3bfb794 327
rodriguj 0:3d84b3bfb794 328 void SSD1306::display(void)
rodriguj 0:3d84b3bfb794 329 {
rodriguj 0:3d84b3bfb794 330 int i;
rodriguj 0:3d84b3bfb794 331
rodriguj 0:3d84b3bfb794 332 command (0xb0);
rodriguj 0:3d84b3bfb794 333 command (SSD1306_SETLOWCOLUMN | 0x0); // low col = 0
rodriguj 0:3d84b3bfb794 334 command (SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0
rodriguj 0:3d84b3bfb794 335 command (SSD1306_SETSTARTLINE | 0x0); // line #0
rodriguj 0:3d84b3bfb794 336
rodriguj 0:3d84b3bfb794 337 bus->start();
rodriguj 0:3d84b3bfb794 338 bus->write (ssd1306_i2c_addr);
rodriguj 0:3d84b3bfb794 339 bus->write (0x40);
rodriguj 0:3d84b3bfb794 340 for (i=0; i<1024; i++) {
rodriguj 0:3d84b3bfb794 341 bus->write (fb[i]);
rodriguj 0:3d84b3bfb794 342 }
rodriguj 0:3d84b3bfb794 343 bus->stop();
rodriguj 0:3d84b3bfb794 344 }
rodriguj 0:3d84b3bfb794 345
rodriguj 0:3d84b3bfb794 346 void SSD1306::set_contrast (char v)
rodriguj 0:3d84b3bfb794 347 {
rodriguj 0:3d84b3bfb794 348 command (SSD1306_SETCONTRAST);
rodriguj 0:3d84b3bfb794 349 command (v);
rodriguj 0:3d84b3bfb794 350 }
rodriguj 0:3d84b3bfb794 351
rodriguj 1:c5cf4ca5939f 352 void SSD1306::cls (char *bkground, bool refresh)
rodriguj 0:3d84b3bfb794 353 {
rodriguj 0:3d84b3bfb794 354 int i;
rodriguj 1:c5cf4ca5939f 355
rodriguj 1:c5cf4ca5939f 356 if (!bkground)
rodriguj 1:c5cf4ca5939f 357 {
rodriguj 1:c5cf4ca5939f 358 for (i=0; i<1024; i++)
rodriguj 1:c5cf4ca5939f 359 fb[i] = 0;
rodriguj 1:c5cf4ca5939f 360 }
rodriguj 1:c5cf4ca5939f 361 else
rodriguj 1:c5cf4ca5939f 362 {
rodriguj 1:c5cf4ca5939f 363 for (i=0; i<1024; i++)
rodriguj 1:c5cf4ca5939f 364 fb[i] = bkground[i];
rodriguj 0:3d84b3bfb794 365 }
rodriguj 0:3d84b3bfb794 366 idxfb = 0;
rodriguj 1:c5cf4ca5939f 367 if (refresh)
rodriguj 1:c5cf4ca5939f 368 display();
rodriguj 0:3d84b3bfb794 369 }
rodriguj 0:3d84b3bfb794 370
rodriguj 1:c5cf4ca5939f 371 void SSD1306::plot (char x, char y, PlotStyle modo, bool refresh)
rodriguj 0:3d84b3bfb794 372 {
rodriguj 0:3d84b3bfb794 373 x = x % 128;
rodriguj 0:3d84b3bfb794 374 y = y % 64;
rodriguj 0:3d84b3bfb794 375
rodriguj 0:3d84b3bfb794 376 switch (modo)
rodriguj 0:3d84b3bfb794 377 {
rodriguj 1:c5cf4ca5939f 378 case Normal: fb[(y/8)*128+x] |= (1<<(y%8)); break;
rodriguj 1:c5cf4ca5939f 379 case Inverse: fb[(y/8)*128+x] &= ~(1<<(y%8)); break;
rodriguj 1:c5cf4ca5939f 380 case Xor: fb[(y/8)*128+x] ^= (1<<(y%8)); break;
rodriguj 0:3d84b3bfb794 381 }
rodriguj 1:c5cf4ca5939f 382 if (refresh)
rodriguj 1:c5cf4ca5939f 383 display();
rodriguj 0:3d84b3bfb794 384 }
rodriguj 1:c5cf4ca5939f 385
rodriguj 1:c5cf4ca5939f 386 void SSD1306::line (char x0, char y0, char x1, char y1, PlotStyle modo, bool refresh)
rodriguj 1:c5cf4ca5939f 387 {
rodriguj 1:c5cf4ca5939f 388 int dx = abs (x1 - x0), sx = x0 < x1 ? 1 : -1;
rodriguj 1:c5cf4ca5939f 389 int dy = -abs (y1 - y0), sy = y0 < y1 ? 1 : -1;
rodriguj 1:c5cf4ca5939f 390 int err = dx + dy, e2; /* error value e_xy */
rodriguj 1:c5cf4ca5939f 391
rodriguj 1:c5cf4ca5939f 392 for (;;)
rodriguj 1:c5cf4ca5939f 393 { /* loop */
rodriguj 1:c5cf4ca5939f 394 plot (x0, y0, modo, false);
rodriguj 1:c5cf4ca5939f 395 if (x0 == x1 && y0 == y1) break;
rodriguj 1:c5cf4ca5939f 396 e2 = 2 * err;
rodriguj 1:c5cf4ca5939f 397 if (e2 >= dy) { err += dy; x0 += sx; } /* e_xy+e_x > 0 */
rodriguj 1:c5cf4ca5939f 398 if (e2 <= dx) { err += dx; y0 += sy; } /* e_xy+e_y < 0 */
rodriguj 1:c5cf4ca5939f 399 }
rodriguj 1:c5cf4ca5939f 400 if (refresh)
rodriguj 1:c5cf4ca5939f 401 display();
rodriguj 1:c5cf4ca5939f 402 }