SSD1306 LCD 96x16 model
Dependents: testSoftware8_alles_display
Fork of ssd1306_library by
ssd1306.cpp@12:42a98fa363b4, 2018-09-12 (annotated)
- Committer:
- mikevd1
- Date:
- Wed Sep 12 11:09:35 2018 +0000
- Revision:
- 12:42a98fa363b4
- Parent:
- 11:1b5a69808460
- Child:
- 13:e52c5cb758ca
veranderingen aangebracht voor het display menu
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rodriguj | 3:bb6fba3e84ff | 1 | /* |
rodriguj | 4:35757c8b7625 | 2 | * ssd1306.h |
rodriguj | 3:bb6fba3e84ff | 3 | * |
rodriguj | 3:bb6fba3e84ff | 4 | * Created on: 20 oct. 2017 |
rodriguj | 3:bb6fba3e84ff | 5 | * Author: Miguel Angel Rodriguez Jodar |
rodriguj | 3:bb6fba3e84ff | 6 | * |
rodriguj | 3:bb6fba3e84ff | 7 | * Based upon Adafruit library. |
rodriguj | 3:bb6fba3e84ff | 8 | * GPL licensed. |
rodriguj | 3:bb6fba3e84ff | 9 | * |
rodriguj | 3:bb6fba3e84ff | 10 | */ |
rodriguj | 3:bb6fba3e84ff | 11 | |
rodriguj | 0:3d84b3bfb794 | 12 | #include "ssd1306.h" |
rodriguj | 0:3d84b3bfb794 | 13 | #include "mbed.h" |
rodriguj | 0:3d84b3bfb794 | 14 | |
rodriguj | 4:35757c8b7625 | 15 | /* I believe this charset was taken from the compilation from Joseph Gil years ago |
rodriguj | 4:35757c8b7625 | 16 | * when I needed a charset for a different (FPGA) project, but I cannot remember |
rodriguj | 4:35757c8b7625 | 17 | * exactly the website I took it from. |
rodriguj | 4:35757c8b7625 | 18 | * What I do remember is that the owner of the website claimed that this charset |
rodriguj | 4:35757c8b7625 | 19 | * is in the public domain. |
rodriguj | 4:35757c8b7625 | 20 | * This a complete (256 ASCII codes) 8x8 charset, using the 437 page code (original IBM) |
rodriguj | 4:35757c8b7625 | 21 | * so you can use its graphic blocks to build decent text based GUIs without the need |
rodriguj | 4:35757c8b7625 | 22 | * to use plot, line and circle primitives |
rodriguj | 4:35757c8b7625 | 23 | */ |
rodriguj | 0:3d84b3bfb794 | 24 | static const char charset[2048] = { |
rodriguj | 0:3d84b3bfb794 | 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, |
rodriguj | 0:3d84b3bfb794 | 26 | 0x95, 0xB1, 0xB1, 0x95, 0x81, 0x7E, 0x7E, 0xFF, 0xEB, 0xCF, |
rodriguj | 0:3d84b3bfb794 | 27 | 0xCF, 0xEB, 0xFF, 0x7E, 0x0E, 0x1F, 0x3F, 0x7E, 0x3F, 0x1F, |
rodriguj | 0:3d84b3bfb794 | 28 | 0x0E, 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, 0x00, |
rodriguj | 0:3d84b3bfb794 | 29 | 0x38, 0x3A, 0x9F, 0xFF, 0x9F, 0x3A, 0x38, 0x00, 0x18, 0x3C, |
rodriguj | 0:3d84b3bfb794 | 30 | 0xBE, 0xFF, 0xBE, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x3C, |
rodriguj | 0:3d84b3bfb794 | 31 | 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, |
rodriguj | 0:3d84b3bfb794 | 32 | 0xFF, 0xFF, 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, |
rodriguj | 0:3d84b3bfb794 | 33 | 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, 0x70, 0xF8, |
rodriguj | 0:3d84b3bfb794 | 34 | 0x88, 0x88, 0xFD, 0x7F, 0x07, 0x0F, 0x00, 0x4E, 0x5F, 0xF1, |
rodriguj | 0:3d84b3bfb794 | 35 | 0xF1, 0x5F, 0x4E, 0x00, 0xC0, 0xE0, 0xFF, 0x7F, 0x05, 0x05, |
rodriguj | 0:3d84b3bfb794 | 36 | 0x07, 0x07, 0xC0, 0xFF, 0x7F, 0x05, 0x05, 0x65, 0x7F, 0x3F, |
rodriguj | 0:3d84b3bfb794 | 37 | 0x5A, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x5A, 0x7F, 0x3E, |
rodriguj | 0:3d84b3bfb794 | 38 | 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x00, 0x08, 0x08, 0x1C, 0x1C, |
rodriguj | 0:3d84b3bfb794 | 39 | 0x3E, 0x3E, 0x7F, 0x00, 0x00, 0x24, 0x66, 0xFF, 0xFF, 0x66, |
rodriguj | 0:3d84b3bfb794 | 40 | 0x24, 0x00, 0x00, 0x5F, 0x5F, 0x00, 0x00, 0x5F, 0x5F, 0x00, |
rodriguj | 0:3d84b3bfb794 | 41 | 0x06, 0x0F, 0x09, 0x7F, 0x7F, 0x01, 0x7F, 0x7F, 0x40, 0x9A, |
rodriguj | 0:3d84b3bfb794 | 42 | 0xBF, 0xA5, 0xA5, 0xFD, 0x59, 0x02, 0x00, 0x70, 0x70, 0x70, |
rodriguj | 0:3d84b3bfb794 | 43 | 0x70, 0x70, 0x70, 0x00, 0x80, 0x94, 0xB6, 0xFF, 0xFF, 0xB6, |
rodriguj | 0:3d84b3bfb794 | 44 | 0x94, 0x80, 0x00, 0x04, 0x06, 0x7F, 0x7F, 0x06, 0x04, 0x00, |
rodriguj | 0:3d84b3bfb794 | 45 | 0x00, 0x10, 0x30, 0x7F, 0x7F, 0x30, 0x10, 0x00, 0x08, 0x08, |
rodriguj | 0:3d84b3bfb794 | 46 | 0x08, 0x2A, 0x3E, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x3E, 0x2A, |
rodriguj | 0:3d84b3bfb794 | 47 | 0x08, 0x08, 0x08, 0x00, 0x3C, 0x3C, 0x20, 0x20, 0x20, 0x20, |
rodriguj | 0:3d84b3bfb794 | 48 | 0x20, 0x00, 0x08, 0x1C, 0x3E, 0x08, 0x08, 0x3E, 0x1C, 0x08, |
rodriguj | 0:3d84b3bfb794 | 49 | 0x30, 0x38, 0x3C, 0x3E, 0x3E, 0x3C, 0x38, 0x30, 0x06, 0x0E, |
rodriguj | 0:3d84b3bfb794 | 50 | 0x1E, 0x3E, 0x3E, 0x1E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5F, 0x5F, 0x06, |
rodriguj | 0:3d84b3bfb794 | 52 | 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x07, 0x03, 0x00, |
rodriguj | 0:3d84b3bfb794 | 53 | 0x14, 0x7F, 0x7F, 0x14, 0x7F, 0x7F, 0x14, 0x00, 0x00, 0x24, |
rodriguj | 0:3d84b3bfb794 | 54 | 0x2E, 0x6B, 0x6B, 0x3A, 0x12, 0x00, 0x46, 0x66, 0x30, 0x18, |
rodriguj | 0:3d84b3bfb794 | 55 | 0x0C, 0x66, 0x62, 0x00, 0x30, 0x7A, 0x4F, 0x5D, 0x37, 0x7A, |
rodriguj | 0:3d84b3bfb794 | 56 | 0x48, 0x00, 0x00, 0x00, 0x04, 0x07, 0x03, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 57 | 0x00, 0x00, 0x1C, 0x3E, 0x63, 0x41, 0x00, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 58 | 0x41, 0x63, 0x3E, 0x1C, 0x00, 0x00, 0x08, 0x2A, 0x3E, 0x1C, |
rodriguj | 0:3d84b3bfb794 | 59 | 0x1C, 0x3E, 0x2A, 0x08, 0x00, 0x08, 0x08, 0x3E, 0x3E, 0x08, |
rodriguj | 0:3d84b3bfb794 | 60 | 0x08, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x60, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 61 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 62 | 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, |
rodriguj | 0:3d84b3bfb794 | 63 | 0x06, 0x03, 0x01, 0x00, 0x1C, 0x3E, 0x63, 0x49, 0x63, 0x3E, |
rodriguj | 0:3d84b3bfb794 | 64 | 0x1C, 0x00, 0x00, 0x40, 0x42, 0x7F, 0x7F, 0x40, 0x40, 0x00, |
rodriguj | 0:3d84b3bfb794 | 65 | 0x42, 0x63, 0x71, 0x59, 0x49, 0x6F, 0x66, 0x00, 0x22, 0x63, |
rodriguj | 0:3d84b3bfb794 | 66 | 0x49, 0x49, 0x49, 0x7F, 0x36, 0x00, 0x18, 0x1C, 0x16, 0x53, |
rodriguj | 0:3d84b3bfb794 | 67 | 0x7F, 0x7F, 0x50, 0x00, 0x2F, 0x6F, 0x49, 0x49, 0x49, 0x79, |
rodriguj | 0:3d84b3bfb794 | 68 | 0x31, 0x00, 0x3C, 0x7E, 0x4B, 0x49, 0x49, 0x78, 0x30, 0x00, |
rodriguj | 0:3d84b3bfb794 | 69 | 0x03, 0x03, 0x71, 0x79, 0x0D, 0x07, 0x03, 0x00, 0x36, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 70 | 0x49, 0x49, 0x49, 0x7F, 0x36, 0x00, 0x06, 0x4F, 0x49, 0x49, |
rodriguj | 0:3d84b3bfb794 | 71 | 0x69, 0x3F, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, |
rodriguj | 0:3d84b3bfb794 | 72 | 0x00, 0x00, 0x00, 0x00, 0x80, 0xE6, 0x66, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 73 | 0x00, 0x00, 0x08, 0x1C, 0x36, 0x63, 0x41, 0x00, 0x00, 0x24, |
rodriguj | 0:3d84b3bfb794 | 74 | 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x41, 0x63, 0x36, |
rodriguj | 0:3d84b3bfb794 | 75 | 0x1C, 0x08, 0x00, 0x00, 0x02, 0x03, 0x01, 0x59, 0x5D, 0x07, |
rodriguj | 0:3d84b3bfb794 | 76 | 0x02, 0x00, 0x3E, 0x7F, 0x41, 0x5D, 0x5D, 0x1F, 0x1E, 0x00, |
rodriguj | 0:3d84b3bfb794 | 77 | 0x7C, 0x7E, 0x0B, 0x09, 0x0B, 0x7E, 0x7C, 0x00, 0x41, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 78 | 0x7F, 0x49, 0x49, 0x7F, 0x36, 0x00, 0x1C, 0x3E, 0x63, 0x41, |
rodriguj | 0:3d84b3bfb794 | 79 | 0x41, 0x63, 0x22, 0x00, 0x41, 0x7F, 0x7F, 0x41, 0x63, 0x3E, |
rodriguj | 0:3d84b3bfb794 | 80 | 0x1C, 0x00, 0x41, 0x7F, 0x7F, 0x49, 0x5D, 0x41, 0x63, 0x00, |
rodriguj | 0:3d84b3bfb794 | 81 | 0x41, 0x7F, 0x7F, 0x49, 0x1D, 0x01, 0x03, 0x00, 0x1C, 0x3E, |
rodriguj | 0:3d84b3bfb794 | 82 | 0x63, 0x41, 0x51, 0x33, 0x72, 0x00, 0x7F, 0x7F, 0x08, 0x08, |
rodriguj | 0:3d84b3bfb794 | 83 | 0x08, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x7F, 0x41, |
rodriguj | 0:3d84b3bfb794 | 84 | 0x00, 0x00, 0x30, 0x70, 0x40, 0x41, 0x7F, 0x3F, 0x01, 0x00, |
rodriguj | 0:3d84b3bfb794 | 85 | 0x41, 0x7F, 0x7F, 0x08, 0x1C, 0x77, 0x63, 0x00, 0x41, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 86 | 0x7F, 0x41, 0x40, 0x60, 0x70, 0x00, 0x7F, 0x7F, 0x0E, 0x1C, |
rodriguj | 0:3d84b3bfb794 | 87 | 0x0E, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x06, 0x0C, 0x18, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 88 | 0x7F, 0x00, 0x3E, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x3E, 0x00, |
rodriguj | 0:3d84b3bfb794 | 89 | 0x41, 0x7F, 0x7F, 0x49, 0x09, 0x0F, 0x06, 0x00, 0x3E, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 90 | 0x41, 0x41, 0xE1, 0xFF, 0xBE, 0x00, 0x41, 0x7F, 0x7F, 0x09, |
rodriguj | 0:3d84b3bfb794 | 91 | 0x19, 0x7F, 0x66, 0x00, 0x00, 0x22, 0x67, 0x4D, 0x59, 0x73, |
rodriguj | 0:3d84b3bfb794 | 92 | 0x22, 0x00, 0x00, 0x07, 0x43, 0x7F, 0x7F, 0x43, 0x07, 0x00, |
rodriguj | 0:3d84b3bfb794 | 93 | 0x3F, 0x7F, 0x40, 0x40, 0x40, 0x7F, 0x3F, 0x00, 0x1F, 0x3F, |
rodriguj | 0:3d84b3bfb794 | 94 | 0x60, 0x40, 0x60, 0x3F, 0x1F, 0x00, 0x3F, 0x7F, 0x60, 0x38, |
rodriguj | 0:3d84b3bfb794 | 95 | 0x60, 0x7F, 0x3F, 0x00, 0x63, 0x77, 0x1C, 0x08, 0x1C, 0x77, |
rodriguj | 0:3d84b3bfb794 | 96 | 0x63, 0x00, 0x00, 0x07, 0x4F, 0x78, 0x78, 0x4F, 0x07, 0x00, |
rodriguj | 0:3d84b3bfb794 | 97 | 0x47, 0x63, 0x71, 0x59, 0x4D, 0x67, 0x73, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 98 | 0x7F, 0x7F, 0x41, 0x41, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, |
rodriguj | 0:3d84b3bfb794 | 99 | 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x41, 0x41, 0x7F, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 100 | 0x00, 0x00, 0x08, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x08, 0x00, |
rodriguj | 0:3d84b3bfb794 | 101 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 102 | 0x01, 0x03, 0x06, 0x04, 0x00, 0x00, 0x20, 0x74, 0x54, 0x54, |
rodriguj | 0:3d84b3bfb794 | 103 | 0x3C, 0x78, 0x40, 0x00, 0x41, 0x7F, 0x3F, 0x44, 0x44, 0x7C, |
rodriguj | 0:3d84b3bfb794 | 104 | 0x38, 0x00, 0x38, 0x7C, 0x44, 0x44, 0x44, 0x6C, 0x28, 0x00, |
rodriguj | 0:3d84b3bfb794 | 105 | 0x38, 0x7C, 0x44, 0x45, 0x3F, 0x7F, 0x40, 0x00, 0x38, 0x7C, |
rodriguj | 0:3d84b3bfb794 | 106 | 0x54, 0x54, 0x54, 0x5C, 0x18, 0x00, 0x48, 0x7E, 0x7F, 0x49, |
rodriguj | 0:3d84b3bfb794 | 107 | 0x09, 0x03, 0x02, 0x00, 0x98, 0xBC, 0xA4, 0xA4, 0xF8, 0x7C, |
rodriguj | 0:3d84b3bfb794 | 108 | 0x04, 0x00, 0x41, 0x7F, 0x7F, 0x08, 0x04, 0x7C, 0x78, 0x00, |
rodriguj | 0:3d84b3bfb794 | 109 | 0x00, 0x00, 0x44, 0x7D, 0x7D, 0x40, 0x00, 0x00, 0x00, 0x60, |
rodriguj | 0:3d84b3bfb794 | 110 | 0xE0, 0x80, 0x80, 0xFD, 0x7D, 0x00, 0x41, 0x7F, 0x7F, 0x10, |
rodriguj | 0:3d84b3bfb794 | 111 | 0x38, 0x6C, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x7F, 0x40, |
rodriguj | 0:3d84b3bfb794 | 112 | 0x00, 0x00, 0x7C, 0x7C, 0x0C, 0x78, 0x0C, 0x7C, 0x78, 0x00, |
rodriguj | 0:3d84b3bfb794 | 113 | 0x04, 0x7C, 0x78, 0x04, 0x04, 0x7C, 0x78, 0x00, 0x38, 0x7C, |
rodriguj | 0:3d84b3bfb794 | 114 | 0x44, 0x44, 0x44, 0x7C, 0x38, 0x00, 0x84, 0xFC, 0xF8, 0xA4, |
rodriguj | 0:3d84b3bfb794 | 115 | 0x24, 0x3C, 0x18, 0x00, 0x18, 0x3C, 0x24, 0xA4, 0xF8, 0xFC, |
rodriguj | 0:3d84b3bfb794 | 116 | 0x84, 0x00, 0x44, 0x7C, 0x78, 0x4C, 0x04, 0x0C, 0x08, 0x00, |
rodriguj | 0:3d84b3bfb794 | 117 | 0x48, 0x5C, 0x54, 0x54, 0x54, 0x74, 0x24, 0x00, 0x04, 0x04, |
rodriguj | 0:3d84b3bfb794 | 118 | 0x3F, 0x7F, 0x44, 0x64, 0x20, 0x00, 0x3C, 0x7C, 0x40, 0x40, |
rodriguj | 0:3d84b3bfb794 | 119 | 0x3C, 0x7C, 0x40, 0x00, 0x1C, 0x3C, 0x60, 0x40, 0x60, 0x3C, |
rodriguj | 0:3d84b3bfb794 | 120 | 0x1C, 0x00, 0x3C, 0x7C, 0x60, 0x38, 0x60, 0x7C, 0x3C, 0x00, |
rodriguj | 0:3d84b3bfb794 | 121 | 0x44, 0x6C, 0x38, 0x10, 0x38, 0x6C, 0x44, 0x00, 0x9C, 0xBC, |
rodriguj | 0:3d84b3bfb794 | 122 | 0xA0, 0xA0, 0xA0, 0xFC, 0x7C, 0x00, 0x00, 0x4C, 0x64, 0x74, |
rodriguj | 0:3d84b3bfb794 | 123 | 0x5C, 0x4C, 0x64, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x77, 0x41, |
rodriguj | 0:3d84b3bfb794 | 124 | 0x41, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 125 | 0x00, 0x41, 0x41, 0x77, 0x3E, 0x08, 0x08, 0x00, 0x02, 0x03, |
rodriguj | 0:3d84b3bfb794 | 126 | 0x01, 0x03, 0x02, 0x03, 0x01, 0x00, 0x70, 0x78, 0x4C, 0x46, |
rodriguj | 0:3d84b3bfb794 | 127 | 0x4C, 0x78, 0x70, 0x00, 0x1E, 0xBF, 0xA1, 0xA1, 0xE1, 0x73, |
rodriguj | 0:3d84b3bfb794 | 128 | 0x12, 0x00, 0x3D, 0x7D, 0x40, 0x40, 0x3D, 0x7D, 0x40, 0x00, |
rodriguj | 0:3d84b3bfb794 | 129 | 0x38, 0x7C, 0x54, 0x56, 0x57, 0x5D, 0x18, 0x00, 0x22, 0x75, |
rodriguj | 0:3d84b3bfb794 | 130 | 0x55, 0x55, 0x3D, 0x79, 0x42, 0x00, 0x21, 0x75, 0x54, 0x54, |
rodriguj | 0:3d84b3bfb794 | 131 | 0x3C, 0x79, 0x41, 0x00, 0x20, 0x74, 0x55, 0x57, 0x3E, 0x78, |
rodriguj | 0:3d84b3bfb794 | 132 | 0x40, 0x00, 0x20, 0x74, 0x57, 0x57, 0x3C, 0x78, 0x40, 0x00, |
rodriguj | 0:3d84b3bfb794 | 133 | 0x18, 0x3C, 0xA4, 0xA4, 0xE4, 0x64, 0x24, 0x00, 0x3A, 0x7D, |
rodriguj | 0:3d84b3bfb794 | 134 | 0x55, 0x55, 0x55, 0x5D, 0x1A, 0x00, 0x39, 0x7D, 0x54, 0x54, |
rodriguj | 0:3d84b3bfb794 | 135 | 0x54, 0x5D, 0x19, 0x00, 0x38, 0x7C, 0x55, 0x57, 0x56, 0x5C, |
rodriguj | 0:3d84b3bfb794 | 136 | 0x18, 0x00, 0x00, 0x01, 0x45, 0x7C, 0x7C, 0x41, 0x01, 0x00, |
rodriguj | 0:3d84b3bfb794 | 137 | 0x02, 0x01, 0x45, 0x7D, 0x7D, 0x41, 0x02, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 138 | 0x49, 0x7B, 0x7A, 0x40, 0x00, 0x00, 0x79, 0x7D, 0x16, 0x12, |
rodriguj | 0:3d84b3bfb794 | 139 | 0x16, 0x7D, 0x79, 0x00, 0x78, 0x7E, 0x17, 0x15, 0x17, 0x7E, |
rodriguj | 0:3d84b3bfb794 | 140 | 0x78, 0x00, 0x7C, 0x7C, 0x56, 0x57, 0x55, 0x44, 0x44, 0x00, |
rodriguj | 0:3d84b3bfb794 | 141 | 0x20, 0x74, 0x54, 0x7C, 0x7C, 0x54, 0x54, 0x00, 0x7C, 0x7E, |
rodriguj | 0:3d84b3bfb794 | 142 | 0x0B, 0x09, 0x7F, 0x7F, 0x49, 0x00, 0x3A, 0x7D, 0x45, 0x45, |
rodriguj | 0:3d84b3bfb794 | 143 | 0x45, 0x7D, 0x3A, 0x00, 0x39, 0x7D, 0x44, 0x44, 0x44, 0x7D, |
rodriguj | 0:3d84b3bfb794 | 144 | 0x39, 0x00, 0x38, 0x7C, 0x45, 0x47, 0x46, 0x7C, 0x38, 0x00, |
rodriguj | 0:3d84b3bfb794 | 145 | 0x3A, 0x79, 0x41, 0x41, 0x39, 0x7A, 0x40, 0x00, 0x3C, 0x7D, |
rodriguj | 0:3d84b3bfb794 | 146 | 0x43, 0x42, 0x3C, 0x7C, 0x40, 0x00, 0x9D, 0xBD, 0xA0, 0xA0, |
rodriguj | 0:3d84b3bfb794 | 147 | 0xA0, 0xFD, 0x7D, 0x00, 0x19, 0x3D, 0x66, 0x42, 0x66, 0x3D, |
rodriguj | 0:3d84b3bfb794 | 148 | 0x19, 0x00, 0x3D, 0x7D, 0x40, 0x40, 0x40, 0x7D, 0x3D, 0x00, |
rodriguj | 0:3d84b3bfb794 | 149 | 0x18, 0x3C, 0x24, 0xE7, 0xE7, 0x24, 0x24, 0x00, 0x48, 0x7E, |
rodriguj | 0:3d84b3bfb794 | 150 | 0x7F, 0x49, 0x43, 0x66, 0x20, 0x00, 0x00, 0x2B, 0x2F, 0xFC, |
rodriguj | 0:3d84b3bfb794 | 151 | 0xFC, 0x2F, 0x2B, 0x00, 0xFF, 0xFF, 0x09, 0x09, 0x2F, 0xF6, |
rodriguj | 0:3d84b3bfb794 | 152 | 0xF8, 0xA0, 0x20, 0x60, 0x48, 0x7E, 0x3F, 0x09, 0x03, 0x02, |
rodriguj | 0:3d84b3bfb794 | 153 | 0x20, 0x74, 0x56, 0x57, 0x3D, 0x78, 0x40, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 154 | 0x48, 0x7A, 0x7B, 0x41, 0x00, 0x00, 0x38, 0x7C, 0x44, 0x46, |
rodriguj | 0:3d84b3bfb794 | 155 | 0x47, 0x7D, 0x38, 0x00, 0x3C, 0x7C, 0x42, 0x43, 0x3D, 0x7C, |
rodriguj | 0:3d84b3bfb794 | 156 | 0x40, 0x00, 0x0A, 0x7B, 0x71, 0x0B, 0x0A, 0x7B, 0x71, 0x00, |
rodriguj | 0:3d84b3bfb794 | 157 | 0x7A, 0x7B, 0x19, 0x33, 0x62, 0x7B, 0x79, 0x00, 0x00, 0x26, |
rodriguj | 0:3d84b3bfb794 | 158 | 0x2F, 0x29, 0x2F, 0x2F, 0x28, 0x00, 0x00, 0x26, 0x2F, 0x29, |
rodriguj | 0:3d84b3bfb794 | 159 | 0x2F, 0x26, 0x00, 0x00, 0x00, 0x20, 0x70, 0x5D, 0x4D, 0x40, |
rodriguj | 0:3d84b3bfb794 | 160 | 0x60, 0x20, 0x38, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, |
rodriguj | 0:3d84b3bfb794 | 161 | 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x38, 0x00, 0x42, 0x6F, |
rodriguj | 0:3d84b3bfb794 | 162 | 0x3F, 0x18, 0xCC, 0xEE, 0xBB, 0x91, 0x42, 0x6F, 0x3F, 0x58, |
rodriguj | 0:3d84b3bfb794 | 163 | 0x6C, 0xD6, 0xFB, 0x41, 0x00, 0x00, 0x30, 0x7D, 0x7D, 0x30, |
rodriguj | 0:3d84b3bfb794 | 164 | 0x00, 0x00, 0x08, 0x1C, 0x36, 0x22, 0x08, 0x1C, 0x36, 0x22, |
rodriguj | 0:3d84b3bfb794 | 165 | 0x22, 0x36, 0x1C, 0x08, 0x22, 0x36, 0x1C, 0x08, 0xAA, 0x00, |
rodriguj | 0:3d84b3bfb794 | 166 | 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00, 0xAA, 0x55, 0xAA, 0x55, |
rodriguj | 0:3d84b3bfb794 | 167 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xFF, 0x55, 0xFF, 0xAA, 0xFF, |
rodriguj | 0:3d84b3bfb794 | 168 | 0x55, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 169 | 0x10, 0x10, 0x10, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x14, 0x14, |
rodriguj | 0:3d84b3bfb794 | 170 | 0x14, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0xFF, 0xFF, |
rodriguj | 0:3d84b3bfb794 | 171 | 0x00, 0xFF, 0xFF, 0x00, 0x10, 0x10, 0xF0, 0xF0, 0x10, 0xF0, |
rodriguj | 0:3d84b3bfb794 | 172 | 0xF0, 0x00, 0x14, 0x14, 0x14, 0xFC, 0xFC, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 173 | 0x14, 0x14, 0xF7, 0xF7, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 174 | 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x14, 0x14, 0xF4, 0xF4, |
rodriguj | 0:3d84b3bfb794 | 175 | 0x04, 0xFC, 0xFC, 0x00, 0x14, 0x14, 0x17, 0x17, 0x10, 0x1F, |
rodriguj | 0:3d84b3bfb794 | 176 | 0x1F, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x1F, 0x1F, 0x00, |
rodriguj | 0:3d84b3bfb794 | 177 | 0x14, 0x14, 0x14, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x10, 0x10, |
rodriguj | 0:3d84b3bfb794 | 178 | 0x10, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, |
rodriguj | 0:3d84b3bfb794 | 179 | 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x1F, 0x10, |
rodriguj | 0:3d84b3bfb794 | 180 | 0x10, 0x10, 0x10, 0x10, 0x10, 0xF0, 0xF0, 0x10, 0x10, 0x10, |
rodriguj | 0:3d84b3bfb794 | 181 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, |
rodriguj | 0:3d84b3bfb794 | 182 | 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, |
rodriguj | 0:3d84b3bfb794 | 183 | 0xFF, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x14, |
rodriguj | 0:3d84b3bfb794 | 184 | 0x14, 0x14, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x10, |
rodriguj | 0:3d84b3bfb794 | 185 | 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x17, 0x17, 0x14, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 186 | 0xFC, 0xFC, 0x04, 0xF4, 0xF4, 0x14, 0x14, 0x14, 0x17, 0x17, |
rodriguj | 0:3d84b3bfb794 | 187 | 0x10, 0x17, 0x17, 0x14, 0x14, 0x14, 0xF4, 0xF4, 0x04, 0xF4, |
rodriguj | 0:3d84b3bfb794 | 188 | 0xF4, 0x14, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xF7, 0xF7, 0x14, |
rodriguj | 0:3d84b3bfb794 | 189 | 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, |
rodriguj | 0:3d84b3bfb794 | 190 | 0xF7, 0xF7, 0x00, 0xF7, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x17, |
rodriguj | 0:3d84b3bfb794 | 191 | 0x17, 0x14, 0x14, 0x14, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x1F, |
rodriguj | 0:3d84b3bfb794 | 192 | 0x1F, 0x10, 0x14, 0x14, 0x14, 0xF4, 0xF4, 0x14, 0x14, 0x14, |
rodriguj | 0:3d84b3bfb794 | 193 | 0x10, 0x10, 0xF0, 0xF0, 0x10, 0xF0, 0xF0, 0x10, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 194 | 0x1F, 0x1F, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00, 0x1F, |
rodriguj | 0:3d84b3bfb794 | 195 | 0x1F, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x14, |
rodriguj | 0:3d84b3bfb794 | 196 | 0x14, 0x14, 0x00, 0x00, 0xF0, 0xF0, 0x10, 0xF0, 0xF0, 0x10, |
rodriguj | 0:3d84b3bfb794 | 197 | 0x10, 0x10, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0x10, 0x14, 0x14, |
rodriguj | 0:3d84b3bfb794 | 198 | 0x14, 0xFF, 0xFF, 0x14, 0x14, 0x14, 0x10, 0x10, 0x10, 0x1F, |
rodriguj | 0:3d84b3bfb794 | 199 | 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x10, |
rodriguj | 0:3d84b3bfb794 | 200 | 0x10, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
rodriguj | 0:3d84b3bfb794 | 201 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, |
rodriguj | 0:3d84b3bfb794 | 202 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 203 | 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, |
rodriguj | 0:3d84b3bfb794 | 204 | 0x0F, 0x0F, 0x38, 0x7C, 0x44, 0x6C, 0x38, 0x6C, 0x44, 0x00, |
rodriguj | 0:3d84b3bfb794 | 205 | 0x7E, 0x7F, 0x01, 0x09, 0x5F, 0x76, 0x20, 0x00, 0x7F, 0x7F, |
rodriguj | 0:3d84b3bfb794 | 206 | 0x01, 0x01, 0x01, 0x03, 0x03, 0x00, 0x04, 0x7C, 0x7C, 0x04, |
rodriguj | 0:3d84b3bfb794 | 207 | 0x7C, 0x7C, 0x04, 0x00, 0x63, 0x77, 0x5D, 0x49, 0x41, 0x63, |
rodriguj | 0:3d84b3bfb794 | 208 | 0x63, 0x00, 0x38, 0x7C, 0x44, 0x7C, 0x3C, 0x04, 0x04, 0x00, |
rodriguj | 0:3d84b3bfb794 | 209 | 0x80, 0xFC, 0x7C, 0x40, 0x40, 0x7C, 0x3C, 0x00, 0x04, 0x06, |
rodriguj | 0:3d84b3bfb794 | 210 | 0x02, 0x7E, 0x7C, 0x06, 0x02, 0x00, 0x00, 0x99, 0xBD, 0xE7, |
rodriguj | 0:3d84b3bfb794 | 211 | 0xE7, 0xBD, 0x99, 0x00, 0x1C, 0x3E, 0x6B, 0x49, 0x6B, 0x3E, |
rodriguj | 0:3d84b3bfb794 | 212 | 0x1C, 0x00, 0x4C, 0x7E, 0x73, 0x01, 0x73, 0x7E, 0x4C, 0x00, |
rodriguj | 0:3d84b3bfb794 | 213 | 0x00, 0x30, 0x78, 0x4A, 0x4F, 0x7D, 0x39, 0x00, 0x18, 0x3C, |
rodriguj | 0:3d84b3bfb794 | 214 | 0x24, 0x3C, 0x3C, 0x24, 0x3C, 0x18, 0x98, 0xFC, 0x64, 0x3C, |
rodriguj | 0:3d84b3bfb794 | 215 | 0x3E, 0x27, 0x3D, 0x18, 0x00, 0x1C, 0x3E, 0x6B, 0x49, 0x49, |
rodriguj | 0:3d84b3bfb794 | 216 | 0x49, 0x00, 0x7C, 0x7E, 0x02, 0x02, 0x02, 0x7E, 0x7C, 0x00, |
rodriguj | 0:3d84b3bfb794 | 217 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, 0x00, 0x44, |
rodriguj | 0:3d84b3bfb794 | 218 | 0x44, 0x5F, 0x5F, 0x44, 0x44, 0x00, 0x00, 0x40, 0x51, 0x5B, |
rodriguj | 0:3d84b3bfb794 | 219 | 0x4E, 0x44, 0x40, 0x00, 0x00, 0x40, 0x44, 0x4E, 0x5B, 0x51, |
rodriguj | 0:3d84b3bfb794 | 220 | 0x40, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x07, 0x06, |
rodriguj | 0:3d84b3bfb794 | 221 | 0x60, 0xE0, 0x80, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x08, |
rodriguj | 0:3d84b3bfb794 | 222 | 0x08, 0x2A, 0x2A, 0x08, 0x08, 0x00, 0x24, 0x36, 0x12, 0x36, |
rodriguj | 0:3d84b3bfb794 | 223 | 0x24, 0x36, 0x12, 0x00, 0x00, 0x06, 0x0F, 0x09, 0x0F, 0x06, |
rodriguj | 0:3d84b3bfb794 | 224 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 225 | 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x10, 0x30, |
rodriguj | 0:3d84b3bfb794 | 226 | 0x70, 0xC0, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x01, 0x1F, 0x1E, |
rodriguj | 0:3d84b3bfb794 | 227 | 0x01, 0x1F, 0x1E, 0x00, 0x00, 0x11, 0x19, 0x1D, 0x17, 0x12, |
rodriguj | 0:3d84b3bfb794 | 228 | 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, |
rodriguj | 0:3d84b3bfb794 | 229 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
rodriguj | 0:3d84b3bfb794 | 230 | }; |
rodriguj | 0:3d84b3bfb794 | 231 | |
rodriguj | 0:3d84b3bfb794 | 232 | |
rodriguj | 3:bb6fba3e84ff | 233 | SSD1306::SSD1306 (PinName sda, PinName scl, char ssd1306_addr) |
rodriguj | 0:3d84b3bfb794 | 234 | { |
rodriguj | 0:3d84b3bfb794 | 235 | idxfb = 0; |
mikevd1 | 11:1b5a69808460 | 236 | fb = new char[196]; |
rodriguj | 2:7f1160c1a741 | 237 | if (!fb) { |
rodriguj | 0:3d84b3bfb794 | 238 | printf ("SSD1306: Framebuffer allocation failed!\r\n"); |
rodriguj | 0:3d84b3bfb794 | 239 | for (;;) { } |
rodriguj | 0:3d84b3bfb794 | 240 | } |
rodriguj | 2:7f1160c1a741 | 241 | |
rodriguj | 0:3d84b3bfb794 | 242 | bus = new I2C (sda, scl); |
rodriguj | 3:bb6fba3e84ff | 243 | ssd1306_i2c_addr = ssd1306_addr; |
rodriguj | 3:bb6fba3e84ff | 244 | do_not_delete_bus = 0; |
rodriguj | 0:3d84b3bfb794 | 245 | #ifdef SSD1306_DEBUG |
rodriguj | 0:3d84b3bfb794 | 246 | printf ("SSD1306 debug: fb = 0x%08.8X\r\n", fb); |
rodriguj | 0:3d84b3bfb794 | 247 | #endif |
rodriguj | 3:bb6fba3e84ff | 248 | } |
rodriguj | 2:7f1160c1a741 | 249 | |
rodriguj | 3:bb6fba3e84ff | 250 | SSD1306::SSD1306 (I2C &busi2c, char ssd1306_addr) |
rodriguj | 3:bb6fba3e84ff | 251 | { |
rodriguj | 3:bb6fba3e84ff | 252 | bus = &busi2c; |
rodriguj | 3:bb6fba3e84ff | 253 | idxfb = 0; |
mikevd1 | 11:1b5a69808460 | 254 | fb = new char[196]; |
rodriguj | 3:bb6fba3e84ff | 255 | if (!fb) { |
rodriguj | 3:bb6fba3e84ff | 256 | printf ("SSD1306: Framebuffer allocation failed!\r\n"); |
rodriguj | 3:bb6fba3e84ff | 257 | for (;;) { } |
rodriguj | 3:bb6fba3e84ff | 258 | } |
rodriguj | 3:bb6fba3e84ff | 259 | ssd1306_i2c_addr = ssd1306_addr; |
rodriguj | 3:bb6fba3e84ff | 260 | do_not_delete_bus = 1; |
rodriguj | 0:3d84b3bfb794 | 261 | } |
rodriguj | 0:3d84b3bfb794 | 262 | |
rodriguj | 0:3d84b3bfb794 | 263 | void SSD1306::speed (I2CSpeed spd) |
rodriguj | 0:3d84b3bfb794 | 264 | { |
rodriguj | 2:7f1160c1a741 | 265 | switch (spd) { |
rodriguj | 4:35757c8b7625 | 266 | case Slow: |
rodriguj | 2:7f1160c1a741 | 267 | bus->frequency(100000); |
rodriguj | 2:7f1160c1a741 | 268 | break; |
rodriguj | 2:7f1160c1a741 | 269 | case Medium: |
rodriguj | 2:7f1160c1a741 | 270 | bus->frequency(400000); |
rodriguj | 2:7f1160c1a741 | 271 | break; |
rodriguj | 2:7f1160c1a741 | 272 | case Fast: |
rodriguj | 2:7f1160c1a741 | 273 | bus->frequency(1000000); |
rodriguj | 2:7f1160c1a741 | 274 | break; |
rodriguj | 0:3d84b3bfb794 | 275 | } |
rodriguj | 0:3d84b3bfb794 | 276 | } |
rodriguj | 0:3d84b3bfb794 | 277 | |
rodriguj | 0:3d84b3bfb794 | 278 | char SSD1306::scan (void) |
rodriguj | 0:3d84b3bfb794 | 279 | { |
rodriguj | 0:3d84b3bfb794 | 280 | int addr; |
rodriguj | 0:3d84b3bfb794 | 281 | int res; |
rodriguj | 0:3d84b3bfb794 | 282 | char i2caddr = 0; |
rodriguj | 2:7f1160c1a741 | 283 | |
rodriguj | 0:3d84b3bfb794 | 284 | for (addr=0; addr<256; addr++) { |
rodriguj | 0:3d84b3bfb794 | 285 | res = bus->write (addr, NULL, 0); |
rodriguj | 0:3d84b3bfb794 | 286 | if (res == 0) |
rodriguj | 0:3d84b3bfb794 | 287 | i2caddr = addr & 0xFE; |
rodriguj | 0:3d84b3bfb794 | 288 | } |
rodriguj | 0:3d84b3bfb794 | 289 | return i2caddr; |
rodriguj | 0:3d84b3bfb794 | 290 | } |
rodriguj | 0:3d84b3bfb794 | 291 | |
rodriguj | 0:3d84b3bfb794 | 292 | int SSD1306::command_data (char c, char c_or_d, char lastitem) |
rodriguj | 0:3d84b3bfb794 | 293 | { |
rodriguj | 0:3d84b3bfb794 | 294 | int res; |
rodriguj | 2:7f1160c1a741 | 295 | |
rodriguj | 0:3d84b3bfb794 | 296 | bus->start(); |
rodriguj | 2:7f1160c1a741 | 297 | res = bus->write(ssd1306_i2c_addr); |
rodriguj | 2:7f1160c1a741 | 298 | if (!res) goto terminate_transaction; |
rodriguj | 2:7f1160c1a741 | 299 | res = bus->write(c_or_d | lastitem); |
rodriguj | 2:7f1160c1a741 | 300 | if (!res) goto terminate_transaction; |
rodriguj | 2:7f1160c1a741 | 301 | res = bus->write(c); |
rodriguj | 2:7f1160c1a741 | 302 | if (!res) goto terminate_transaction; |
rodriguj | 2:7f1160c1a741 | 303 | |
rodriguj | 2:7f1160c1a741 | 304 | terminate_transaction: |
rodriguj | 2:7f1160c1a741 | 305 | bus->stop(); |
rodriguj | 0:3d84b3bfb794 | 306 | return res; |
rodriguj | 0:3d84b3bfb794 | 307 | } |
rodriguj | 0:3d84b3bfb794 | 308 | |
rodriguj | 0:3d84b3bfb794 | 309 | int SSD1306::command (char c) |
rodriguj | 0:3d84b3bfb794 | 310 | { |
rodriguj | 4:35757c8b7625 | 311 | return command_data (c, SSD1306_IS_COMMAND, SSD1306_IS_LAST); |
rodriguj | 0:3d84b3bfb794 | 312 | } |
rodriguj | 0:3d84b3bfb794 | 313 | |
rodriguj | 0:3d84b3bfb794 | 314 | int SSD1306::data (char d) |
rodriguj | 0:3d84b3bfb794 | 315 | { |
rodriguj | 4:35757c8b7625 | 316 | return command_data (d, SSD1306_IS_DATA, SSD1306_IS_LAST); |
rodriguj | 0:3d84b3bfb794 | 317 | } |
rodriguj | 0:3d84b3bfb794 | 318 | |
rodriguj | 0:3d84b3bfb794 | 319 | int SSD1306::init (void) |
rodriguj | 0:3d84b3bfb794 | 320 | { |
mikevd1 | 11:1b5a69808460 | 321 | |
rodriguj | 3:bb6fba3e84ff | 322 | static const char comando[] = {0x80, SSD1306_DISPLAYOFF, |
mikevd1 | 11:1b5a69808460 | 323 | 0x80, SSD1306_SETDISPLAYCLOCKDIV, |
mikevd1 | 11:1b5a69808460 | 324 | 0x80, 0x80, |
mikevd1 | 11:1b5a69808460 | 325 | 0x80, SSD1306_SETMULTIPLEX, |
mikevd1 | 11:1b5a69808460 | 326 | 0x80, 0x0F, |
mikevd1 | 11:1b5a69808460 | 327 | 0x80, SSD1306_SETDISPLAYOFFSET, |
mikevd1 | 11:1b5a69808460 | 328 | 0x80, 0x00, |
mikevd1 | 11:1b5a69808460 | 329 | 0x80, SSD1306_SETSTARTLINE, |
mikevd1 | 11:1b5a69808460 | 330 | |
mikevd1 | 11:1b5a69808460 | 331 | 0x80, SSD1306_MEMORYMODE, |
mikevd1 | 11:1b5a69808460 | 332 | 0x80, 0x00, |
mikevd1 | 11:1b5a69808460 | 333 | |
mikevd1 | 11:1b5a69808460 | 334 | 0x80, SSD1306_SETCOLUMNADRESS, |
mikevd1 | 11:1b5a69808460 | 335 | 0x80, 0x00, |
mikevd1 | 11:1b5a69808460 | 336 | 0x80, 0x60, |
mikevd1 | 11:1b5a69808460 | 337 | 0x80, SSD1306_SETPAGEADRESS, |
mikevd1 | 11:1b5a69808460 | 338 | 0x80, 0x00, |
mikevd1 | 11:1b5a69808460 | 339 | 0x80, 0x01, |
mikevd1 | 11:1b5a69808460 | 340 | |
rodriguj | 3:bb6fba3e84ff | 341 | 0x80, SSD1306_CHARGEPUMP, |
rodriguj | 3:bb6fba3e84ff | 342 | 0x80, 0x14, |
rodriguj | 3:bb6fba3e84ff | 343 | 0x80, SSD1306_SEGREMAP | 0x1, |
mikevd1 | 11:1b5a69808460 | 344 | 0x80, SSD1306_COMSCANDEC, |
mikevd1 | 11:1b5a69808460 | 345 | 0x80, SSD1306_SETCOMPINS, |
mikevd1 | 12:42a98fa363b4 | 346 | 0x80, 0x00, |
rodriguj | 3:bb6fba3e84ff | 347 | 0x80, SSD1306_SETCONTRAST, |
mikevd1 | 12:42a98fa363b4 | 348 | 0x80, 0xFF, |
mikevd1 | 11:1b5a69808460 | 349 | 0x80, SSD1306_SETPRECHARGE, |
mikevd1 | 11:1b5a69808460 | 350 | 0x80, 0xF1, |
mikevd1 | 11:1b5a69808460 | 351 | 0x80, SSD1306_SETVCOMDETECT, |
mikevd1 | 11:1b5a69808460 | 352 | 0x80, 0x20, |
mikevd1 | 11:1b5a69808460 | 353 | 0x80, SSD1306_DISPLAYALLON_RESUME, |
mikevd1 | 11:1b5a69808460 | 354 | 0x80, SSD1306_NORMALDISPLAY, |
rodriguj | 3:bb6fba3e84ff | 355 | 0x00, SSD1306_DISPLAYON |
rodriguj | 3:bb6fba3e84ff | 356 | }; |
mikevd1 | 11:1b5a69808460 | 357 | |
rodriguj | 0:3d84b3bfb794 | 358 | return bus->write (ssd1306_i2c_addr, comando, sizeof comando); |
rodriguj | 0:3d84b3bfb794 | 359 | } |
rodriguj | 0:3d84b3bfb794 | 360 | |
rodriguj | 1:c5cf4ca5939f | 361 | void SSD1306::scroll (bool refresh) |
rodriguj | 0:3d84b3bfb794 | 362 | { |
rodriguj | 0:3d84b3bfb794 | 363 | int i; |
rodriguj | 2:7f1160c1a741 | 364 | |
mikevd1 | 11:1b5a69808460 | 365 | for (i=98; i<196; i++) |
mikevd1 | 11:1b5a69808460 | 366 | fb[i-98] = fb[i]; |
mikevd1 | 11:1b5a69808460 | 367 | for (i=98; i<196; i++) |
rodriguj | 0:3d84b3bfb794 | 368 | fb[i] = 0; |
rodriguj | 1:c5cf4ca5939f | 369 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 370 | redraw(); |
rodriguj | 2:7f1160c1a741 | 371 | } |
rodriguj | 2:7f1160c1a741 | 372 | |
rodriguj | 2:7f1160c1a741 | 373 | void SSD1306::locate (char row, char column) |
rodriguj | 2:7f1160c1a741 | 374 | { |
mikevd1 | 11:1b5a69808460 | 375 | idxfb = row*97+column*8; |
rodriguj | 0:3d84b3bfb794 | 376 | } |
rodriguj | 0:3d84b3bfb794 | 377 | |
rodriguj | 1:c5cf4ca5939f | 378 | void SSD1306::putchar (char c, bool refresh) |
rodriguj | 0:3d84b3bfb794 | 379 | { |
rodriguj | 0:3d84b3bfb794 | 380 | int idx,i; |
rodriguj | 2:7f1160c1a741 | 381 | |
rodriguj | 0:3d84b3bfb794 | 382 | idx = c*8; |
mikevd1 | 11:1b5a69808460 | 383 | if (idxfb == 196) { |
rodriguj | 2:7f1160c1a741 | 384 | scroll(refresh); |
mikevd1 | 11:1b5a69808460 | 385 | idxfb = 97; |
rodriguj | 2:7f1160c1a741 | 386 | } |
rodriguj | 0:3d84b3bfb794 | 387 | for (i=0; i<8; i++) { |
rodriguj | 0:3d84b3bfb794 | 388 | fb[idxfb] = charset[idx+i]; |
rodriguj | 0:3d84b3bfb794 | 389 | idxfb++; |
rodriguj | 0:3d84b3bfb794 | 390 | } |
rodriguj | 1:c5cf4ca5939f | 391 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 392 | redraw(); |
rodriguj | 2:7f1160c1a741 | 393 | } |
rodriguj | 2:7f1160c1a741 | 394 | |
rodriguj | 2:7f1160c1a741 | 395 | void SSD1306::puts (char *s, bool refresh) |
rodriguj | 2:7f1160c1a741 | 396 | { |
rodriguj | 2:7f1160c1a741 | 397 | while (*s) putchar (*s++, refresh); |
rodriguj | 0:3d84b3bfb794 | 398 | } |
rodriguj | 0:3d84b3bfb794 | 399 | |
rodriguj | 4:35757c8b7625 | 400 | void SSD1306::printf (const char *fmt,...) |
rodriguj | 3:bb6fba3e84ff | 401 | { |
mikevd1 | 11:1b5a69808460 | 402 | char *s = new char[98]; |
rodriguj | 3:bb6fba3e84ff | 403 | va_list args; |
rodriguj | 3:bb6fba3e84ff | 404 | |
rodriguj | 3:bb6fba3e84ff | 405 | va_start (args, fmt); |
mikevd1 | 11:1b5a69808460 | 406 | vsnprintf (s, 97, fmt, args); |
rodriguj | 3:bb6fba3e84ff | 407 | puts (s, false); |
rodriguj | 3:bb6fba3e84ff | 408 | delete[] s; |
rodriguj | 3:bb6fba3e84ff | 409 | va_end (args); |
rodriguj | 3:bb6fba3e84ff | 410 | } |
rodriguj | 3:bb6fba3e84ff | 411 | |
rodriguj | 3:bb6fba3e84ff | 412 | |
rodriguj | 8:09b1578f93d9 | 413 | void SSD1306::redraw (void) |
rodriguj | 0:3d84b3bfb794 | 414 | { |
rodriguj | 0:3d84b3bfb794 | 415 | int i; |
rodriguj | 2:7f1160c1a741 | 416 | |
rodriguj | 0:3d84b3bfb794 | 417 | command (0xb0); |
mikevd1 | 11:1b5a69808460 | 418 | command (SSD1306_SETLOWCOLUMN | 0x00); // low col = 0 |
mikevd1 | 11:1b5a69808460 | 419 | command (SSD1306_SETHIGHCOLUMN | 0x00); // hi col = 0 |
mikevd1 | 11:1b5a69808460 | 420 | command (SSD1306_SETSTARTLINE | 0x00); // line #0 |
rodriguj | 2:7f1160c1a741 | 421 | |
rodriguj | 0:3d84b3bfb794 | 422 | bus->start(); |
rodriguj | 0:3d84b3bfb794 | 423 | bus->write (ssd1306_i2c_addr); |
rodriguj | 0:3d84b3bfb794 | 424 | bus->write (0x40); |
mikevd1 | 11:1b5a69808460 | 425 | for (i=0; i < 195 ; i++) |
mikevd1 | 11:1b5a69808460 | 426 | { |
rodriguj | 0:3d84b3bfb794 | 427 | bus->write (fb[i]); |
rodriguj | 0:3d84b3bfb794 | 428 | } |
rodriguj | 0:3d84b3bfb794 | 429 | bus->stop(); |
rodriguj | 0:3d84b3bfb794 | 430 | } |
rodriguj | 0:3d84b3bfb794 | 431 | |
rodriguj | 8:09b1578f93d9 | 432 | void SSD1306::display (void) |
rodriguj | 8:09b1578f93d9 | 433 | { |
rodriguj | 8:09b1578f93d9 | 434 | redraw(); |
rodriguj | 8:09b1578f93d9 | 435 | } |
rodriguj | 8:09b1578f93d9 | 436 | |
rodriguj | 0:3d84b3bfb794 | 437 | void SSD1306::set_contrast (char v) |
rodriguj | 0:3d84b3bfb794 | 438 | { |
rodriguj | 0:3d84b3bfb794 | 439 | command (SSD1306_SETCONTRAST); |
rodriguj | 0:3d84b3bfb794 | 440 | command (v); |
rodriguj | 0:3d84b3bfb794 | 441 | } |
rodriguj | 0:3d84b3bfb794 | 442 | |
mikevd1 | 11:1b5a69808460 | 443 | |
mikevd1 | 11:1b5a69808460 | 444 | |
rodriguj | 1:c5cf4ca5939f | 445 | void SSD1306::cls (char *bkground, bool refresh) |
rodriguj | 0:3d84b3bfb794 | 446 | { |
rodriguj | 0:3d84b3bfb794 | 447 | int i; |
mikevd1 | 12:42a98fa363b4 | 448 | if (!bkground) |
mikevd1 | 12:42a98fa363b4 | 449 | { |
mikevd1 | 11:1b5a69808460 | 450 | for (i=0; i<196; i++) |
mikevd1 | 11:1b5a69808460 | 451 | { |
mikevd1 | 12:42a98fa363b4 | 452 | fb[i] = 0x00 ; //0x81; |
mikevd1 | 11:1b5a69808460 | 453 | } |
mikevd1 | 12:42a98fa363b4 | 454 | } |
mikevd1 | 12:42a98fa363b4 | 455 | else |
mikevd1 | 12:42a98fa363b4 | 456 | { |
mikevd1 | 12:42a98fa363b4 | 457 | for (i=0; i<196; i++) |
mikevd1 | 11:1b5a69808460 | 458 | { |
mikevd1 | 12:42a98fa363b4 | 459 | fb[i] = 0x00 ; //FF ; //0x81; |
mikevd1 | 11:1b5a69808460 | 460 | } |
mikevd1 | 12:42a98fa363b4 | 461 | } |
rodriguj | 0:3d84b3bfb794 | 462 | idxfb = 0; |
rodriguj | 1:c5cf4ca5939f | 463 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 464 | redraw(); |
rodriguj | 0:3d84b3bfb794 | 465 | } |
rodriguj | 0:3d84b3bfb794 | 466 | |
mikevd1 | 10:346065d26cc9 | 467 | void SSD1306::bitMap (char *bkground, bool refresh) |
mikevd1 | 11:1b5a69808460 | 468 | { |
mikevd1 | 10:346065d26cc9 | 469 | int i; |
mikevd1 | 10:346065d26cc9 | 470 | static int l = 3 ; |
mikevd1 | 10:346065d26cc9 | 471 | |
mikevd1 | 11:1b5a69808460 | 472 | if (!bkground) |
mikevd1 | 11:1b5a69808460 | 473 | { |
mikevd1 | 10:346065d26cc9 | 474 | for (i=0; i<1024; i++) |
mikevd1 | 11:1b5a69808460 | 475 | { |
mikevd1 | 10:346065d26cc9 | 476 | if ( l == 0) |
mikevd1 | 10:346065d26cc9 | 477 | { |
mikevd1 | 11:1b5a69808460 | 478 | //fb[i] = nunu_logo0[i]; |
mikevd1 | 10:346065d26cc9 | 479 | } |
mikevd1 | 10:346065d26cc9 | 480 | else if ( l == 1) |
mikevd1 | 10:346065d26cc9 | 481 | { |
mikevd1 | 11:1b5a69808460 | 482 | //fb[i] = nunu_logo1[i]; |
mikevd1 | 10:346065d26cc9 | 483 | } |
mikevd1 | 10:346065d26cc9 | 484 | else if ( l == 2) |
mikevd1 | 10:346065d26cc9 | 485 | { |
mikevd1 | 11:1b5a69808460 | 486 | //fb[i] = nunu_logo2[i]; |
mikevd1 | 10:346065d26cc9 | 487 | } |
mikevd1 | 10:346065d26cc9 | 488 | else |
mikevd1 | 10:346065d26cc9 | 489 | { |
mikevd1 | 11:1b5a69808460 | 490 | //fb[i] = nunu_logo3[i]; |
mikevd1 | 10:346065d26cc9 | 491 | } |
mikevd1 | 10:346065d26cc9 | 492 | if ( l == 4 ) |
mikevd1 | 10:346065d26cc9 | 493 | { |
mikevd1 | 10:346065d26cc9 | 494 | l = 0 ; |
mikevd1 | 10:346065d26cc9 | 495 | } |
mikevd1 | 11:1b5a69808460 | 496 | } |
mikevd1 | 11:1b5a69808460 | 497 | } |
mikevd1 | 11:1b5a69808460 | 498 | else |
mikevd1 | 11:1b5a69808460 | 499 | { |
mikevd1 | 11:1b5a69808460 | 500 | for (i=0; i<1024; i++) |
mikevd1 | 11:1b5a69808460 | 501 | { |
mikevd1 | 11:1b5a69808460 | 502 | //fb[i] = nunu_logo1[i]; |
mikevd1 | 11:1b5a69808460 | 503 | } |
mikevd1 | 10:346065d26cc9 | 504 | |
mikevd1 | 10:346065d26cc9 | 505 | } |
mikevd1 | 10:346065d26cc9 | 506 | idxfb = 0; |
mikevd1 | 10:346065d26cc9 | 507 | if (refresh) |
mikevd1 | 10:346065d26cc9 | 508 | redraw(); |
mikevd1 | 10:346065d26cc9 | 509 | } |
mikevd1 | 10:346065d26cc9 | 510 | |
rodriguj | 4:35757c8b7625 | 511 | void SSD1306::plot (char x, char y, PlotStyle mode, bool refresh) |
rodriguj | 0:3d84b3bfb794 | 512 | { |
rodriguj | 0:3d84b3bfb794 | 513 | x = x % 128; |
rodriguj | 0:3d84b3bfb794 | 514 | y = y % 64; |
rodriguj | 3:bb6fba3e84ff | 515 | |
rodriguj | 4:35757c8b7625 | 516 | switch (mode) { |
rodriguj | 2:7f1160c1a741 | 517 | case Normal: |
rodriguj | 2:7f1160c1a741 | 518 | fb[(y/8)*128+x] |= (1<<(y%8)); |
rodriguj | 2:7f1160c1a741 | 519 | break; |
rodriguj | 2:7f1160c1a741 | 520 | case Inverse: |
rodriguj | 2:7f1160c1a741 | 521 | fb[(y/8)*128+x] &= ~(1<<(y%8)); |
rodriguj | 2:7f1160c1a741 | 522 | break; |
rodriguj | 2:7f1160c1a741 | 523 | case Xor: |
rodriguj | 2:7f1160c1a741 | 524 | fb[(y/8)*128+x] ^= (1<<(y%8)); |
rodriguj | 2:7f1160c1a741 | 525 | break; |
rodriguj | 0:3d84b3bfb794 | 526 | } |
rodriguj | 1:c5cf4ca5939f | 527 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 528 | redraw(); |
rodriguj | 0:3d84b3bfb794 | 529 | } |
rodriguj | 1:c5cf4ca5939f | 530 | |
rodriguj | 3:bb6fba3e84ff | 531 | bool SSD1306::point (char x, char y) |
rodriguj | 3:bb6fba3e84ff | 532 | { |
rodriguj | 3:bb6fba3e84ff | 533 | x = x % 128; |
rodriguj | 3:bb6fba3e84ff | 534 | y = y % 64; |
rodriguj | 3:bb6fba3e84ff | 535 | |
rodriguj | 3:bb6fba3e84ff | 536 | if ( fb[(y/8)*128+x] & (1<<(y%8)) ) |
rodriguj | 3:bb6fba3e84ff | 537 | return true; |
rodriguj | 3:bb6fba3e84ff | 538 | else |
rodriguj | 3:bb6fba3e84ff | 539 | return false; |
rodriguj | 3:bb6fba3e84ff | 540 | } |
rodriguj | 3:bb6fba3e84ff | 541 | |
rodriguj | 4:35757c8b7625 | 542 | void SSD1306::line (char x0, char y0, char x1, char y1, PlotStyle mode, bool refresh) |
rodriguj | 1:c5cf4ca5939f | 543 | { |
rodriguj | 1:c5cf4ca5939f | 544 | int dx = abs (x1 - x0), sx = x0 < x1 ? 1 : -1; |
rodriguj | 1:c5cf4ca5939f | 545 | int dy = -abs (y1 - y0), sy = y0 < y1 ? 1 : -1; |
rodriguj | 1:c5cf4ca5939f | 546 | int err = dx + dy, e2; /* error value e_xy */ |
rodriguj | 1:c5cf4ca5939f | 547 | |
rodriguj | 2:7f1160c1a741 | 548 | for (;;) { |
rodriguj | 2:7f1160c1a741 | 549 | /* loop */ |
rodriguj | 4:35757c8b7625 | 550 | plot (x0, y0, mode, false); |
rodriguj | 1:c5cf4ca5939f | 551 | if (x0 == x1 && y0 == y1) break; |
rodriguj | 1:c5cf4ca5939f | 552 | e2 = 2 * err; |
rodriguj | 2:7f1160c1a741 | 553 | if (e2 >= dy) { |
rodriguj | 2:7f1160c1a741 | 554 | err += dy; /* e_xy+e_x > 0 */ |
rodriguj | 2:7f1160c1a741 | 555 | x0 += sx; |
rodriguj | 2:7f1160c1a741 | 556 | } |
rodriguj | 2:7f1160c1a741 | 557 | if (e2 <= dx) { |
rodriguj | 2:7f1160c1a741 | 558 | err += dx; /* e_xy+e_y < 0 */ |
rodriguj | 2:7f1160c1a741 | 559 | y0 += sy; |
rodriguj | 2:7f1160c1a741 | 560 | } |
rodriguj | 1:c5cf4ca5939f | 561 | } |
rodriguj | 1:c5cf4ca5939f | 562 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 563 | redraw(); |
rodriguj | 1:c5cf4ca5939f | 564 | } |
rodriguj | 3:bb6fba3e84ff | 565 | |
rodriguj | 4:35757c8b7625 | 566 | void SSD1306::circle (char x0, char y0, char r, PlotStyle mode, bool refresh) |
rodriguj | 3:bb6fba3e84ff | 567 | { |
rodriguj | 3:bb6fba3e84ff | 568 | int x = r-1; |
rodriguj | 3:bb6fba3e84ff | 569 | int y = 0; |
rodriguj | 3:bb6fba3e84ff | 570 | int dx = 1; |
rodriguj | 3:bb6fba3e84ff | 571 | int dy = 1; |
rodriguj | 3:bb6fba3e84ff | 572 | int err = dx - 2*r; |
rodriguj | 3:bb6fba3e84ff | 573 | |
rodriguj | 3:bb6fba3e84ff | 574 | while (x >= y) |
rodriguj | 3:bb6fba3e84ff | 575 | { |
rodriguj | 4:35757c8b7625 | 576 | plot (x0 + x, y0 + y, mode); |
rodriguj | 4:35757c8b7625 | 577 | plot (x0 + y, y0 + x, mode); |
rodriguj | 4:35757c8b7625 | 578 | plot (x0 - y, y0 + x, mode); |
rodriguj | 4:35757c8b7625 | 579 | plot (x0 - x, y0 + y, mode); |
rodriguj | 4:35757c8b7625 | 580 | plot (x0 - x, y0 - y, mode); |
rodriguj | 4:35757c8b7625 | 581 | plot (x0 - y, y0 - x, mode); |
rodriguj | 4:35757c8b7625 | 582 | plot (x0 + y, y0 - x, mode); |
rodriguj | 4:35757c8b7625 | 583 | plot (x0 + x, y0 - y, mode); |
rodriguj | 3:bb6fba3e84ff | 584 | |
rodriguj | 3:bb6fba3e84ff | 585 | if (err <= 0) |
rodriguj | 3:bb6fba3e84ff | 586 | { |
rodriguj | 3:bb6fba3e84ff | 587 | y++; |
rodriguj | 3:bb6fba3e84ff | 588 | err += dy; |
rodriguj | 3:bb6fba3e84ff | 589 | dy += 2; |
rodriguj | 3:bb6fba3e84ff | 590 | } |
rodriguj | 3:bb6fba3e84ff | 591 | if (err > 0) |
rodriguj | 3:bb6fba3e84ff | 592 | { |
rodriguj | 3:bb6fba3e84ff | 593 | x--; |
rodriguj | 3:bb6fba3e84ff | 594 | dx += 2; |
rodriguj | 3:bb6fba3e84ff | 595 | err += dx - 2*r; |
rodriguj | 3:bb6fba3e84ff | 596 | } |
rodriguj | 3:bb6fba3e84ff | 597 | } |
rodriguj | 3:bb6fba3e84ff | 598 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 599 | redraw(); |
rodriguj | 3:bb6fba3e84ff | 600 | } |
rodriguj | 8:09b1578f93d9 | 601 | |
rodriguj | 8:09b1578f93d9 | 602 | void SSD1306::fill (char x, char y, bool refresh) |
rodriguj | 8:09b1578f93d9 | 603 | { |
rodriguj | 8:09b1578f93d9 | 604 | unsigned char rqueue = 0, wqueue = 1; |
rodriguj | 8:09b1578f93d9 | 605 | char *qpixel_x = new char[256]; |
rodriguj | 8:09b1578f93d9 | 606 | char *qpixel_y = new char[256]; |
rodriguj | 8:09b1578f93d9 | 607 | |
rodriguj | 8:09b1578f93d9 | 608 | if (!qpixel_x || !qpixel_y) |
rodriguj | 8:09b1578f93d9 | 609 | { |
rodriguj | 8:09b1578f93d9 | 610 | if (qpixel_x) delete[] qpixel_x; |
rodriguj | 8:09b1578f93d9 | 611 | if (qpixel_y) delete[] qpixel_y; |
rodriguj | 8:09b1578f93d9 | 612 | printf ("SSD1306::fill ERROR. Not enough memory\r\n"); |
rodriguj | 8:09b1578f93d9 | 613 | return; |
rodriguj | 8:09b1578f93d9 | 614 | } |
rodriguj | 8:09b1578f93d9 | 615 | |
rodriguj | 8:09b1578f93d9 | 616 | qpixel_x[0] = x; |
rodriguj | 8:09b1578f93d9 | 617 | qpixel_y[0] = y; |
rodriguj | 9:57209a7e9cba | 618 | plot (x, y, SSD1306::Normal); |
rodriguj | 8:09b1578f93d9 | 619 | while (wqueue != rqueue) |
rodriguj | 8:09b1578f93d9 | 620 | { |
rodriguj | 8:09b1578f93d9 | 621 | x = qpixel_x[rqueue]; |
rodriguj | 8:09b1578f93d9 | 622 | y = qpixel_y[rqueue]; |
rodriguj | 8:09b1578f93d9 | 623 | rqueue++; |
rodriguj | 8:09b1578f93d9 | 624 | |
rodriguj | 9:57209a7e9cba | 625 | if (x!=127 && !point (x+1,y)) |
rodriguj | 8:09b1578f93d9 | 626 | { |
rodriguj | 9:57209a7e9cba | 627 | plot (x+1, y, SSD1306::Normal); |
rodriguj | 8:09b1578f93d9 | 628 | qpixel_x[wqueue] = x+1; |
rodriguj | 8:09b1578f93d9 | 629 | qpixel_y[wqueue] = y; |
rodriguj | 8:09b1578f93d9 | 630 | wqueue++; |
rodriguj | 8:09b1578f93d9 | 631 | } |
rodriguj | 8:09b1578f93d9 | 632 | |
rodriguj | 9:57209a7e9cba | 633 | if (x!=0 && !point (x-1,y)) |
rodriguj | 8:09b1578f93d9 | 634 | { |
rodriguj | 9:57209a7e9cba | 635 | plot (x-1, y, SSD1306::Normal); |
rodriguj | 8:09b1578f93d9 | 636 | qpixel_x[wqueue] = x-1; |
rodriguj | 8:09b1578f93d9 | 637 | qpixel_y[wqueue] = y; |
rodriguj | 8:09b1578f93d9 | 638 | wqueue++; |
rodriguj | 8:09b1578f93d9 | 639 | } |
rodriguj | 8:09b1578f93d9 | 640 | |
rodriguj | 9:57209a7e9cba | 641 | if (y!=63 && !point (x,y+1)) |
rodriguj | 8:09b1578f93d9 | 642 | { |
rodriguj | 9:57209a7e9cba | 643 | plot (x, y+1, SSD1306::Normal); |
rodriguj | 8:09b1578f93d9 | 644 | qpixel_x[wqueue] = x; |
rodriguj | 8:09b1578f93d9 | 645 | qpixel_y[wqueue] = y+1; |
rodriguj | 8:09b1578f93d9 | 646 | wqueue++; |
rodriguj | 8:09b1578f93d9 | 647 | } |
rodriguj | 8:09b1578f93d9 | 648 | |
rodriguj | 9:57209a7e9cba | 649 | if (y!=0 && !point (x,y-1)) |
rodriguj | 8:09b1578f93d9 | 650 | { |
rodriguj | 9:57209a7e9cba | 651 | plot (x, y-1, SSD1306::Normal); |
rodriguj | 8:09b1578f93d9 | 652 | qpixel_x[wqueue] = x; |
rodriguj | 8:09b1578f93d9 | 653 | qpixel_y[wqueue] = y-1; |
rodriguj | 8:09b1578f93d9 | 654 | wqueue++; |
rodriguj | 8:09b1578f93d9 | 655 | } |
rodriguj | 8:09b1578f93d9 | 656 | } |
rodriguj | 8:09b1578f93d9 | 657 | delete[] qpixel_x; |
rodriguj | 8:09b1578f93d9 | 658 | delete[] qpixel_y; |
rodriguj | 8:09b1578f93d9 | 659 | |
rodriguj | 8:09b1578f93d9 | 660 | if (refresh) |
rodriguj | 8:09b1578f93d9 | 661 | redraw(); |
rodriguj | 8:09b1578f93d9 | 662 | } |