Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "Adafruit_SSD1306.h" 00003 00004 #define SSD1306_ADDRESS 0x78 00005 00006 // an I2C sub-class that provides a constructed default 00007 class I2CPreInit : public I2C 00008 { 00009 public: 00010 I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) 00011 { 00012 frequency(400000); 00013 start(); 00014 }; 00015 }; 00016 00017 uint8_t led_height = 64; 00018 uint8_t led_width = 128; 00019 00020 I2CPreInit gI2C(D14,D15); 00021 Adafruit_SSD1306_I2c gOled(gI2C,PA_8,SSD1306_ADDRESS,led_height,led_width); 00022 00023 DigitalOut led(LED1); 00024 00025 int main() { 00026 gOled.begin(); 00027 gOled.clearDisplay(); 00028 gOled.display(); 00029 wait(0.1); 00030 while(1){ 00031 led = !led; 00032 gOled.clearDisplay(); 00033 gOled.drawPixel(0,0,WHITE); 00034 gOled.fillCircle(63, 0, 10, WHITE); 00035 gOled.display(); 00036 wait(1); 00037 gOled.clearDisplay(); 00038 gOled.fillCircle(63, 31, 20, WHITE); 00039 gOled.display(); 00040 wait(1); 00041 gOled.clearDisplay(); 00042 gOled.fillCircle(63, 63, 30, WHITE); 00043 gOled.display(); 00044 wait(1); 00045 } 00046 }
Generated on Sun Sep 11 2022 13:26:42 by
1.7.2