![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
wss
Dependencies: mbed Adafruit_GFX DS1820
Diff: main.cpp
- Revision:
- 6:23dfd7b0e58c
- Parent:
- 5:0e6b049208d8
- Child:
- 7:296b42f24d44
--- a/main.cpp Mon Dec 13 19:09:00 2021 +0000 +++ b/main.cpp Mon Dec 13 19:51:37 2021 +0000 @@ -1,7 +1,23 @@ #include "mbed.h" #include "hcsr04.h" +#include "Adafruit_SSD1306.h" + +class I2CPreInit : public I2C +{ +public: + I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) + { + frequency(100000); + start(); + }; +}; +I2CPreInit gI2C(PB_9,PB_8); + +// an SPI sub-class that provides a constructed default + +Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128); Serial pc(USBTX, USBRX); // tx, rx Ticker tickerMideDistancia; @@ -97,18 +113,30 @@ //} contador++; + gOled.clearDisplay(); + gOled.printf("numero %d\n",contador); + gOled.display(); + gOled.setTextCursor(0,0); + //wait(1.000); + } int main() { pc.baud(115200); tickerMideDistancia.attach(&mideDistancia, 0.5); + gOled.begin(); + gOled.clearDisplay(); estado=cerrada; //pc.printf("Estado cerrada\n"); - + gOled.printf("Buenos dias\n"); + + + while(1) { distancia=usensor.get_dist_cm(); + switch ( estado ) { case cerrada: estadoCerrada(); @@ -124,6 +152,10 @@ break; default: break; + } + + } + }