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.
Dependencies: mbed
main.cpp
00001 /*** INCLUDE BIBLIOTHEQUES ***/ 00002 #include "mbed.h" 00003 #include "Adafruit_SSD1306.h" 00004 #include <string> 00005 #include <sstream> 00006 #include <map> 00007 00008 00009 using namespace std; 00010 00011 /*** GLOBAL VARIABLES ***/ 00012 I2C i2c(PB_9, PB_8); 00013 Adafruit_SSD1306_I2c oled(i2c,PC_13); 00014 00015 00016 /*** FUNCTIONS DECLARATIONS ***/ 00017 void OLED_writeString(string str, int x, int y); 00018 void OLED_drawSmile(); 00019 void OLED_drawIdle(); 00020 void OLED_drawSleep(int); 00021 void OLED_drawDead(); 00022 00023 00024 /*** Main***/ 00025 int main() 00026 { 00027 oled.clearDisplay(); 00028 oled.splash(); oled.display(); wait(10); 00029 oled.setTextSize(1); // changer la taille de text 00030 OLED_writeString("hello world", 32 , 12);// x , y la position de de but de l'écritude et la taille de l'ecran est 128x32 00031 oled.clearDisplay(); 00032 while(1){ } 00033 } 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 void OLED_writeString(string str, int x, int y) { 00050 oled.setTextCursor(x, y); 00051 oled.fillRect(x, y, 128, 8, 0); // int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color 00052 for (int i = 0; i < str.length(); i++) { 00053 oled.writeChar(str[i]); 00054 } 00055 00056 oled.display(); 00057 } 00058 00059 00060 00061 00062 00063 00064 void OLED_drawSmile() { 00065 oled.clearDisplay(); 00066 oled.drawCircle(12, 20, 9, 1); 00067 oled.fillRect(0, 5, 22, 15, 0); 00068 oled.fillTriangle(2, 15, 10, 15, 6, 7, 1); 00069 oled.fillTriangle(3, 15, 9, 15, 6, 8, 0); 00070 oled.fillTriangle(14, 15, 22, 15, 18, 7, 1); 00071 oled.fillTriangle(15, 15, 21, 15, 18, 8, 0); 00072 oled.clearDisplay(); 00073 oled.setTextSize(1.5); 00074 OLED_writeString("please place your hand", 1, 1); 00075 } 00076 00077 00078 void OLED_drawIdle() 00079 { 00080 oled.clearDisplay(); 00081 oled.drawCircle(12, 20, 9, 1); 00082 oled.fillRect(0, 5, 22, 15, 0); 00083 oled.fillRect(7, 6, 2, 10, 1); 00084 oled.fillRect(16, 6, 2, 10, 1); 00085 oled.setTextSize(2); 00086 OLED_writeString("All ok!", 40, 10); 00087 } 00088 00089 00090 void OLED_drawSleep(int animationSwitch) { 00091 oled.clearDisplay(); 00092 oled.drawCircle(10, 23, 3, 1); 00093 oled.fillRect(2, 12, 8, 2, 1); 00094 oled.fillRect(15, 12, 8, 2, 1); 00095 oled.setTextSize(1); 00096 OLED_writeString("z", 35, 16 + animationSwitch * 3); 00097 oled.setTextSize(2); 00098 OLED_writeString("z", 45, 11 - animationSwitch * 3); 00099 oled.setTextSize(3); 00100 OLED_writeString("z", 65, 6 + animationSwitch * 3); 00101 oled.setTextSize(4); 00102 OLED_writeString("z", 90, 1 - animationSwitch * 3); 00103 wait(1); 00104 } 00105 00106 00107 void OLED_drawDead() { 00108 oled.clearDisplay(); 00109 oled.drawCircle(13, 27, 7, 1); 00110 oled.fillRect(0, 28, 22, 15, 0); 00111 oled.drawLine(2, 15, 10, 7, 1); 00112 oled.drawLine(2, 7, 10, 15, 1); 00113 oled.drawLine(16, 15, 24, 7, 1); 00114 oled.drawLine(16, 7, 24, 15, 1); 00115 oled.setTextSize(2); 00116 OLED_writeString("Heelp!", 40, 6); 00117 oled.setTextSize(1); 00118 OLED_writeString("Need water!!", 40, 22); 00119 } 00120 00121
Generated on Mon Jul 25 2022 03:54:50 by
