![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Write the OLED(using I2C) l432KCc PIN sda scl reset
Dependencies: Adafruit_GFX mbed
Fork of I2C_SSD1306_Helloworld_WIZwiki-W7500 by
main.cpp@14:d7bc532b2133, 2018-09-21 (annotated)
- Committer:
- bibi94
- Date:
- Fri Sep 21 08:24:56 2018 +0000
- Revision:
- 14:d7bc532b2133
- Parent:
- 13:52e9c29e2f88
Change pin for nucleo l432kc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaizen | 0:81a58b2fb28e | 1 | #include "mbed.h" |
kaizen | 0:81a58b2fb28e | 2 | #include "Adafruit_SSD1306.h" |
IOP | 8:e61e86355653 | 3 | |
bibi94 | 14:d7bc532b2133 | 4 | #define NUMFLAKES 10 |
bibi94 | 14:d7bc532b2133 | 5 | #define XPOS 0 |
bibi94 | 14:d7bc532b2133 | 6 | #define YPOS 1 |
bibi94 | 14:d7bc532b2133 | 7 | #define DELTAY 2 |
bibi94 | 14:d7bc532b2133 | 8 | |
bibi94 | 14:d7bc532b2133 | 9 | |
bibi94 | 14:d7bc532b2133 | 10 | #define LOGO16_GLCD_HEIGHT 16 |
bibi94 | 14:d7bc532b2133 | 11 | #define LOGO16_GLCD_WIDTH 16 |
bibi94 | 14:d7bc532b2133 | 12 | //static const unsigned char PROGMEM logo16_glcd_bmp[] ={ B00000000, B00110000 }; |
bibi94 | 14:d7bc532b2133 | 13 | uint8_t logo16_glcd_bmp[32] = |
bibi94 | 14:d7bc532b2133 | 14 | { |
bibi94 | 14:d7bc532b2133 | 15 | 0x00, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x03, 0xE0, 0xE3, 0xE0, 0xFE, 0xF8, 0xFE, 0xFF, 0x33, 0x9F, 0x1F, 0xFC, 0x0D, 0x70, 0x1B, 0xA0, 0x3F, 0xE0, 0x3F, 0xF0, 0x7C, 0xF0, 0x70, 0x70, 0x00, 0x30 |
bibi94 | 14:d7bc532b2133 | 16 | }; |
bibi94 | 14:d7bc532b2133 | 17 | DigitalOut myled_R(LED1); |
bibi94 | 14:d7bc532b2133 | 18 | |
bibi94 | 14:d7bc532b2133 | 19 | I2C i2c(PA_10,PA_9);//sda,scl(PA_10,PA_9) |
bibi94 | 14:d7bc532b2133 | 20 | |
bibi94 | 14:d7bc532b2133 | 21 | Adafruit_SSD1306_I2c myOled(i2c,PB_7,0x7A,64,128);//0x3D+SA0+RW |
bibi94 | 14:d7bc532b2133 | 22 | Serial pc(SERIAL_TX, SERIAL_RX); |
bibi94 | 14:d7bc532b2133 | 23 | |
bibi94 | 14:d7bc532b2133 | 24 | void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { |
bibi94 | 14:d7bc532b2133 | 25 | uint8_t icons[NUMFLAKES][3]; |
bibi94 | 14:d7bc532b2133 | 26 | |
bibi94 | 14:d7bc532b2133 | 27 | // initialize |
bibi94 | 14:d7bc532b2133 | 28 | for (uint8_t f=0; f< NUMFLAKES; f++) { |
bibi94 | 14:d7bc532b2133 | 29 | icons[f][XPOS] = rand()%myOled.width(); |
bibi94 | 14:d7bc532b2133 | 30 | icons[f][YPOS] = 0; |
bibi94 | 14:d7bc532b2133 | 31 | icons[f][DELTAY] = rand()%5 + 1; |
bibi94 | 14:d7bc532b2133 | 32 | |
bibi94 | 14:d7bc532b2133 | 33 | pc.printf("x: %d",icons[f][XPOS]); |
bibi94 | 14:d7bc532b2133 | 34 | // pc.printf(icons[f][XPOS], DEC); |
bibi94 | 14:d7bc532b2133 | 35 | pc.printf(" y: %d",icons[f][YPOS]); |
bibi94 | 14:d7bc532b2133 | 36 | //pc.printf(icons[f][YPOS], DEC); |
bibi94 | 14:d7bc532b2133 | 37 | pc.printf(" dy: %d",icons[f][DELTAY]); |
bibi94 | 14:d7bc532b2133 | 38 | //pc.printfln(icons[f][DELTAY], DEC); |
bibi94 | 14:d7bc532b2133 | 39 | } |
bibi94 | 14:d7bc532b2133 | 40 | |
bibi94 | 14:d7bc532b2133 | 41 | while (1) { |
bibi94 | 14:d7bc532b2133 | 42 | // draw each icon |
bibi94 | 14:d7bc532b2133 | 43 | for (uint8_t f=0; f< NUMFLAKES; f++) { |
bibi94 | 14:d7bc532b2133 | 44 | myOled.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE); |
bibi94 | 14:d7bc532b2133 | 45 | } |
bibi94 | 14:d7bc532b2133 | 46 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 47 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 48 | |
bibi94 | 14:d7bc532b2133 | 49 | // then erase it + move it |
bibi94 | 14:d7bc532b2133 | 50 | for (uint8_t f=0; f< NUMFLAKES; f++) { |
bibi94 | 14:d7bc532b2133 | 51 | myOled.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK); |
bibi94 | 14:d7bc532b2133 | 52 | // move it |
bibi94 | 14:d7bc532b2133 | 53 | icons[f][YPOS] += icons[f][DELTAY]; |
bibi94 | 14:d7bc532b2133 | 54 | // if its gone, reinit |
bibi94 | 14:d7bc532b2133 | 55 | if (icons[f][YPOS] > myOled.height()) { |
bibi94 | 14:d7bc532b2133 | 56 | icons[f][XPOS] = rand()%myOled.width(); |
bibi94 | 14:d7bc532b2133 | 57 | icons[f][YPOS] = 0; |
bibi94 | 14:d7bc532b2133 | 58 | icons[f][DELTAY] = rand()%5 + 1; |
bibi94 | 14:d7bc532b2133 | 59 | } |
bibi94 | 14:d7bc532b2133 | 60 | } |
bibi94 | 14:d7bc532b2133 | 61 | } |
bibi94 | 14:d7bc532b2133 | 62 | } |
bibi94 | 14:d7bc532b2133 | 63 | |
bibi94 | 14:d7bc532b2133 | 64 | |
bibi94 | 14:d7bc532b2133 | 65 | void testdrawchar(void) { |
bibi94 | 14:d7bc532b2133 | 66 | myOled.setTextSize(1); |
bibi94 | 14:d7bc532b2133 | 67 | myOled.setTextColor(WHITE); |
bibi94 | 14:d7bc532b2133 | 68 | myOled.setTextCursor(0,0); |
bibi94 | 14:d7bc532b2133 | 69 | for (uint8_t i=0; i < 168; i++) { |
bibi94 | 14:d7bc532b2133 | 70 | if (i == '\n') continue; |
bibi94 | 14:d7bc532b2133 | 71 | myOled.writeChar(i); |
bibi94 | 14:d7bc532b2133 | 72 | if ((i > 0) && (i % 21 == 0)) |
bibi94 | 14:d7bc532b2133 | 73 | myOled.printf("\n"); |
bibi94 | 14:d7bc532b2133 | 74 | } |
bibi94 | 14:d7bc532b2133 | 75 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 76 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 77 | } |
bibi94 | 14:d7bc532b2133 | 78 | |
bibi94 | 14:d7bc532b2133 | 79 | void testdrawcircle(void) { |
bibi94 | 14:d7bc532b2133 | 80 | for (int16_t i=0; i<myOled.height(); i+=2) { |
bibi94 | 14:d7bc532b2133 | 81 | myOled.drawCircle(myOled.width()/2, myOled.height()/2, i, WHITE); |
bibi94 | 14:d7bc532b2133 | 82 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 83 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 84 | } |
bibi94 | 14:d7bc532b2133 | 85 | } |
bibi94 | 14:d7bc532b2133 | 86 | |
bibi94 | 14:d7bc532b2133 | 87 | void testfillrect(void) { |
bibi94 | 14:d7bc532b2133 | 88 | uint8_t color = 1; |
bibi94 | 14:d7bc532b2133 | 89 | for (int16_t i=0; i<myOled.height()/2; i+=3) { |
bibi94 | 14:d7bc532b2133 | 90 | // alternate colors |
bibi94 | 14:d7bc532b2133 | 91 | myOled.fillRect(i, i, myOled.width()-i*2, myOled.height()-i*2, color%2); |
bibi94 | 14:d7bc532b2133 | 92 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 93 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 94 | color++; |
bibi94 | 14:d7bc532b2133 | 95 | } |
bibi94 | 14:d7bc532b2133 | 96 | } |
bibi94 | 14:d7bc532b2133 | 97 | |
bibi94 | 14:d7bc532b2133 | 98 | void testdrawtriangle(void) { |
bibi94 | 14:d7bc532b2133 | 99 | for (int16_t i=0; i<min(myOled.width(),myOled.height())/2; i+=5) { |
bibi94 | 14:d7bc532b2133 | 100 | myOled.drawTriangle(myOled.width()/2, myOled.height()/2-i, |
bibi94 | 14:d7bc532b2133 | 101 | myOled.width()/2-i, myOled.height()/2+i, |
bibi94 | 14:d7bc532b2133 | 102 | myOled.width()/2+i, myOled.height()/2+i, WHITE); |
bibi94 | 14:d7bc532b2133 | 103 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 104 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 105 | } |
bibi94 | 14:d7bc532b2133 | 106 | } |
kaizen | 0:81a58b2fb28e | 107 | |
bibi94 | 14:d7bc532b2133 | 108 | void testfilltriangle(void) { |
bibi94 | 14:d7bc532b2133 | 109 | uint8_t color = WHITE; |
bibi94 | 14:d7bc532b2133 | 110 | for (int16_t i=min(myOled.width(),myOled.height())/2; i>0; i-=5) { |
bibi94 | 14:d7bc532b2133 | 111 | myOled.fillTriangle(myOled.width()/2, myOled.height()/2-i, |
bibi94 | 14:d7bc532b2133 | 112 | myOled.width()/2-i, myOled.height()/2+i, |
bibi94 | 14:d7bc532b2133 | 113 | myOled.width()/2+i, myOled.height()/2+i, WHITE); |
bibi94 | 14:d7bc532b2133 | 114 | if (color == WHITE) color = BLACK; |
bibi94 | 14:d7bc532b2133 | 115 | else color = WHITE; |
bibi94 | 14:d7bc532b2133 | 116 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 117 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 118 | } |
bibi94 | 14:d7bc532b2133 | 119 | } |
bibi94 | 14:d7bc532b2133 | 120 | |
bibi94 | 14:d7bc532b2133 | 121 | void testdrawroundrect(void) { |
bibi94 | 14:d7bc532b2133 | 122 | for (int16_t i=0; i<myOled.height()/2-2; i+=2) { |
bibi94 | 14:d7bc532b2133 | 123 | myOled.drawRoundRect(i, i, myOled.width()-2*i, myOled.height()-2*i, myOled.height()/4, WHITE); |
bibi94 | 14:d7bc532b2133 | 124 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 125 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 126 | } |
bibi94 | 14:d7bc532b2133 | 127 | } |
bibi94 | 14:d7bc532b2133 | 128 | |
bibi94 | 14:d7bc532b2133 | 129 | void testfillroundrect(void) { |
bibi94 | 14:d7bc532b2133 | 130 | uint8_t color = WHITE; |
bibi94 | 14:d7bc532b2133 | 131 | for (int16_t i=0; i<myOled.height()/2-2; i+=2) { |
bibi94 | 14:d7bc532b2133 | 132 | myOled.fillRoundRect(i, i, myOled.width()-2*i, myOled.height()-2*i, myOled.height()/4, color); |
bibi94 | 14:d7bc532b2133 | 133 | if (color == WHITE) color = BLACK; |
bibi94 | 14:d7bc532b2133 | 134 | else color = WHITE; |
bibi94 | 14:d7bc532b2133 | 135 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 136 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 137 | } |
bibi94 | 14:d7bc532b2133 | 138 | } |
bibi94 | 14:d7bc532b2133 | 139 | |
bibi94 | 14:d7bc532b2133 | 140 | void testdrawrect(void) { |
bibi94 | 14:d7bc532b2133 | 141 | for (int16_t i=0; i<myOled.height()/2; i+=2) { |
bibi94 | 14:d7bc532b2133 | 142 | myOled.drawRect(i, i, myOled.width()-2*i, myOled.height()-2*i, WHITE); |
bibi94 | 14:d7bc532b2133 | 143 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 144 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 145 | } |
bibi94 | 14:d7bc532b2133 | 146 | } |
kaizen | 0:81a58b2fb28e | 147 | |
bibi94 | 14:d7bc532b2133 | 148 | void testdrawline() { |
bibi94 | 14:d7bc532b2133 | 149 | for (int16_t i=0; i<myOled.width(); i+=4) { |
bibi94 | 14:d7bc532b2133 | 150 | myOled.drawLine(0, 0, i, myOled.height()-1, WHITE); |
bibi94 | 14:d7bc532b2133 | 151 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 152 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 153 | } |
bibi94 | 14:d7bc532b2133 | 154 | for (int16_t i=0; i<myOled.height(); i+=4) { |
bibi94 | 14:d7bc532b2133 | 155 | myOled.drawLine(0, 0, myOled.width()-1, i, WHITE); |
bibi94 | 14:d7bc532b2133 | 156 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 157 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 158 | } |
bibi94 | 14:d7bc532b2133 | 159 | wait(0.25); |
bibi94 | 14:d7bc532b2133 | 160 | |
bibi94 | 14:d7bc532b2133 | 161 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 162 | for (int16_t i=0; i<myOled.width(); i+=4) { |
bibi94 | 14:d7bc532b2133 | 163 | myOled.drawLine(0, myOled.height()-1, i, 0, WHITE); |
bibi94 | 14:d7bc532b2133 | 164 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 165 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 166 | } |
bibi94 | 14:d7bc532b2133 | 167 | for (int16_t i=myOled.height()-1; i>=0; i-=4) { |
bibi94 | 14:d7bc532b2133 | 168 | myOled.drawLine(0, myOled.height()-1, myOled.width()-1, i, WHITE); |
bibi94 | 14:d7bc532b2133 | 169 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 170 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 171 | } |
bibi94 | 14:d7bc532b2133 | 172 | wait(0.25); |
bibi94 | 14:d7bc532b2133 | 173 | |
bibi94 | 14:d7bc532b2133 | 174 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 175 | for (int16_t i=myOled.width()-1; i>=0; i-=4) { |
bibi94 | 14:d7bc532b2133 | 176 | myOled.drawLine(myOled.width()-1, myOled.height()-1, i, 0, WHITE); |
bibi94 | 14:d7bc532b2133 | 177 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 178 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 179 | } |
bibi94 | 14:d7bc532b2133 | 180 | for (int16_t i=myOled.height()-1; i>=0; i-=4) { |
bibi94 | 14:d7bc532b2133 | 181 | myOled.drawLine(myOled.width()-1, myOled.height()-1, 0, i, WHITE); |
bibi94 | 14:d7bc532b2133 | 182 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 183 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 184 | } |
bibi94 | 14:d7bc532b2133 | 185 | wait(0.25); |
WIzMatthew | 12:f7375e185594 | 186 | |
bibi94 | 14:d7bc532b2133 | 187 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 188 | for (int16_t i=0; i<myOled.height(); i+=4) { |
bibi94 | 14:d7bc532b2133 | 189 | myOled.drawLine(myOled.width()-1, 0, 0, i, WHITE); |
bibi94 | 14:d7bc532b2133 | 190 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 191 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 192 | } |
bibi94 | 14:d7bc532b2133 | 193 | for (int16_t i=0; i<myOled.width(); i+=4) { |
bibi94 | 14:d7bc532b2133 | 194 | myOled.drawLine(myOled.width()-1, 0, i, myOled.height()-1, WHITE); |
bibi94 | 14:d7bc532b2133 | 195 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 196 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 197 | } |
bibi94 | 14:d7bc532b2133 | 198 | wait(0.25); |
bibi94 | 14:d7bc532b2133 | 199 | } |
bibi94 | 14:d7bc532b2133 | 200 | |
bibi94 | 14:d7bc532b2133 | 201 | void testscrolltext(void) { |
bibi94 | 14:d7bc532b2133 | 202 | myOled.setTextSize(2); |
bibi94 | 14:d7bc532b2133 | 203 | myOled.setTextColor(WHITE); |
bibi94 | 14:d7bc532b2133 | 204 | myOled.setTextCursor(10,0); |
bibi94 | 14:d7bc532b2133 | 205 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 206 | myOled.printf("scroll"); |
bibi94 | 14:d7bc532b2133 | 207 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 208 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 209 | |
bibi94 | 14:d7bc532b2133 | 210 | myOled.startscrollright(0x00, 0x0F); |
bibi94 | 14:d7bc532b2133 | 211 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 212 | myOled.stopscroll(); |
bibi94 | 14:d7bc532b2133 | 213 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 214 | myOled.startscrollleft(0x00, 0x0F); |
bibi94 | 14:d7bc532b2133 | 215 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 216 | myOled.stopscroll(); |
bibi94 | 14:d7bc532b2133 | 217 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 218 | myOled.startscrolldiagright(0x00, 0x07); |
bibi94 | 14:d7bc532b2133 | 219 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 220 | myOled.startscrolldiagleft(0x00, 0x07); |
bibi94 | 14:d7bc532b2133 | 221 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 222 | myOled.stopscroll(); |
bibi94 | 14:d7bc532b2133 | 223 | } |
kaizen | 0:81a58b2fb28e | 224 | |
kaizen | 0:81a58b2fb28e | 225 | int main() |
IOP | 9:a6021ca48d2e | 226 | { |
bibi94 | 14:d7bc532b2133 | 227 | // uint16_t x=0; |
bibi94 | 14:d7bc532b2133 | 228 | // pc.printf("Hello World !\n"); |
bibi94 | 14:d7bc532b2133 | 229 | //pc.printf("%ux%u \nHellow World\r\n", myOled.width(), myOled.SD_I2C_ADDRESS()); |
IOP | 9:a6021ca48d2e | 230 | myOled.begin(); |
bibi94 | 14:d7bc532b2133 | 231 | // Show image buffer on the display hardware. |
bibi94 | 14:d7bc532b2133 | 232 | // Since the buffer is intialized with an Adafruit splashscreen |
bibi94 | 14:d7bc532b2133 | 233 | // internally, this will display the splashscreen. |
bibi94 | 14:d7bc532b2133 | 234 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 235 | wait(2); |
bibi94 | 14:d7bc532b2133 | 236 | |
bibi94 | 14:d7bc532b2133 | 237 | // Clear the buffer. |
bibi94 | 14:d7bc532b2133 | 238 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 239 | |
bibi94 | 14:d7bc532b2133 | 240 | // draw a single pixel |
bibi94 | 14:d7bc532b2133 | 241 | myOled.drawPixel(10, 10, WHITE); |
bibi94 | 14:d7bc532b2133 | 242 | // Show the display buffer on the hardware. |
bibi94 | 14:d7bc532b2133 | 243 | // NOTE: You _must_ call display after making any drawing commands |
bibi94 | 14:d7bc532b2133 | 244 | // to make them visible on the display hardware! |
bibi94 | 14:d7bc532b2133 | 245 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 246 | wait(2); |
bibi94 | 14:d7bc532b2133 | 247 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 248 | |
bibi94 | 14:d7bc532b2133 | 249 | // draw many lines |
bibi94 | 14:d7bc532b2133 | 250 | testdrawline(); |
bibi94 | 14:d7bc532b2133 | 251 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 252 | wait(2); |
bibi94 | 14:d7bc532b2133 | 253 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 254 | |
bibi94 | 14:d7bc532b2133 | 255 | // draw rectangles |
bibi94 | 14:d7bc532b2133 | 256 | testdrawrect(); |
bibi94 | 14:d7bc532b2133 | 257 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 258 | wait(1); |
bibi94 | 14:d7bc532b2133 | 259 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 260 | |
bibi94 | 14:d7bc532b2133 | 261 | // draw multiple rectangles |
bibi94 | 14:d7bc532b2133 | 262 | testfillrect(); |
bibi94 | 14:d7bc532b2133 | 263 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 264 | wait(1); |
bibi94 | 14:d7bc532b2133 | 265 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 266 | |
bibi94 | 14:d7bc532b2133 | 267 | // draw mulitple circles |
bibi94 | 14:d7bc532b2133 | 268 | testdrawcircle(); |
bibi94 | 14:d7bc532b2133 | 269 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 270 | wait(2); |
bibi94 | 14:d7bc532b2133 | 271 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 272 | |
bibi94 | 14:d7bc532b2133 | 273 | // draw a white circle, 10 pixel radius |
bibi94 | 14:d7bc532b2133 | 274 | myOled.fillCircle(myOled.width()/2, myOled.height()/2, 10, WHITE); |
bibi94 | 14:d7bc532b2133 | 275 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 276 | wait(2); |
bibi94 | 14:d7bc532b2133 | 277 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 278 | |
bibi94 | 14:d7bc532b2133 | 279 | testdrawroundrect(); |
bibi94 | 14:d7bc532b2133 | 280 | wait(2); |
bibi94 | 14:d7bc532b2133 | 281 | myOled.clearDisplay(); |
kaizen | 0:81a58b2fb28e | 282 | |
bibi94 | 14:d7bc532b2133 | 283 | testfillroundrect(); |
bibi94 | 14:d7bc532b2133 | 284 | wait(2); |
bibi94 | 14:d7bc532b2133 | 285 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 286 | |
bibi94 | 14:d7bc532b2133 | 287 | testdrawtriangle(); |
bibi94 | 14:d7bc532b2133 | 288 | wait(2); |
bibi94 | 14:d7bc532b2133 | 289 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 290 | |
bibi94 | 14:d7bc532b2133 | 291 | testfilltriangle(); |
bibi94 | 14:d7bc532b2133 | 292 | wait(2); |
bibi94 | 14:d7bc532b2133 | 293 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 294 | |
bibi94 | 14:d7bc532b2133 | 295 | // draw the first ~12 characters in the font |
bibi94 | 14:d7bc532b2133 | 296 | testdrawchar(); |
bibi94 | 14:d7bc532b2133 | 297 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 298 | wait(2); |
bibi94 | 14:d7bc532b2133 | 299 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 300 | |
bibi94 | 14:d7bc532b2133 | 301 | // draw scrolling text |
bibi94 | 14:d7bc532b2133 | 302 | testscrolltext(); |
bibi94 | 14:d7bc532b2133 | 303 | wait(2); |
bibi94 | 14:d7bc532b2133 | 304 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 305 | |
bibi94 | 14:d7bc532b2133 | 306 | // text display tests |
bibi94 | 14:d7bc532b2133 | 307 | myOled.setTextSize(1); |
bibi94 | 14:d7bc532b2133 | 308 | myOled.setTextColor(WHITE); |
bibi94 | 14:d7bc532b2133 | 309 | myOled.setTextCursor(0,0); |
bibi94 | 14:d7bc532b2133 | 310 | //myOled.setCursor(0,0); |
bibi94 | 14:d7bc532b2133 | 311 | myOled.printf("Hello, world!"); |
bibi94 | 14:d7bc532b2133 | 312 | myOled.setTextColor(BLACK, WHITE); // 'inverted' text |
bibi94 | 14:d7bc532b2133 | 313 | myOled.printf("3.141592"); |
bibi94 | 14:d7bc532b2133 | 314 | myOled.setTextSize(2); |
bibi94 | 14:d7bc532b2133 | 315 | myOled.setTextColor(WHITE); |
bibi94 | 14:d7bc532b2133 | 316 | myOled.printf("0x",0xDEADBEEF);// myOled.printf(0xDEADBEEF, HEX); |
bibi94 | 14:d7bc532b2133 | 317 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 318 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 319 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 320 | |
bibi94 | 14:d7bc532b2133 | 321 | // miniature bitmap display |
bibi94 | 14:d7bc532b2133 | 322 | //myOled.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); |
bibi94 | 14:d7bc532b2133 | 323 | myOled.display(); |
bibi94 | 14:d7bc532b2133 | 324 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 325 | |
bibi94 | 14:d7bc532b2133 | 326 | // invert the display |
bibi94 | 14:d7bc532b2133 | 327 | myOled.invertDisplay(true); |
bibi94 | 14:d7bc532b2133 | 328 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 329 | myOled.invertDisplay(false); |
bibi94 | 14:d7bc532b2133 | 330 | wait(0.5); |
bibi94 | 14:d7bc532b2133 | 331 | myOled.clearDisplay(); |
bibi94 | 14:d7bc532b2133 | 332 | |
bibi94 | 14:d7bc532b2133 | 333 | // draw a bitmap icon and 'animate' movement |
bibi94 | 14:d7bc532b2133 | 334 | testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH); |
bibi94 | 14:d7bc532b2133 | 335 | /* while(1) |
kaizen | 0:81a58b2fb28e | 336 | { |
bibi94 | 14:d7bc532b2133 | 337 | //myOled.drawPixel(x, 32, 1); |
bibi94 | 14:d7bc532b2133 | 338 | // myOled.drawCircle(64,32,20,1); |
bibi94 | 14:d7bc532b2133 | 339 | // myOled.drawFastVLine(125,2,50,1); |
bibi94 | 14:d7bc532b2133 | 340 | //myled_R = !myled_R; |
bibi94 | 14:d7bc532b2133 | 341 | //myOled.printf("%u\r",x); |
bibi94 | 14:d7bc532b2133 | 342 | //myOled.display(); |
bibi94 | 14:d7bc532b2133 | 343 | //x = x + 1; |
bibi94 | 14:d7bc532b2133 | 344 | //wait(0.5); |
bibi94 | 14:d7bc532b2133 | 345 | }*/ |
kaizen | 0:81a58b2fb28e | 346 | } |