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: Adafruit_GFX 19E042PIM_MB_PINS
Revision 2:bcdecb244887, committed 2021-12-11
- Comitter:
- babic_f
- Date:
- Sat Dec 11 16:18:49 2021 +0000
- Parent:
- 1:5992d7483ab2
- Commit message:
- Filip Babic 2020/0511
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed_app.json | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Dec 10 23:29:38 2021 +0000 +++ b/main.cpp Sat Dec 11 16:18:49 2021 +0000 @@ -1,25 +1,21 @@ +/* +Posto nisam uspeo start stop da uradim, probao sam da ispisujem samo vrednost sa pot 1 na display +*/ + #include "mb_pins.h" #include "mbed.h" #include "platform/mbed_thread.h" #include "MQTTClientMbedOs.h" - #include "Adafruit_GFX.h" #include "Adafruit_GFX_Config.h" #include "Adafruit_SSD1306.h" -/////////////////////////////////////////////////////////////// -#define SMALL_WAIT_MS 10 - -//I2C adress +#define SMALL_WAIT_MS 10 #define I2C_ADDRESS 0x3c -#define I2C_ADD_MBED I2C_ADDRESS << 1 - -//OLED DIMENSIONS -#define OLED_HEIGHT_PX 64 -#define OLED_WIDTH_PX 128 - -/////////////////////////////////////////////////////////////// +#define I2C_ADD_MBED I2C_ADDRESS << 1 +#define OLED_HEIGHT_PX 64 +#define OLED_WIDTH_PX 128 TCPSocket socket; MQTTClient client(&socket); @@ -29,11 +25,14 @@ I2C i2c_obj(MB_OLED_SDA, MB_OLED_SCL); Adafruit_SSD1306_I2c myOLED(i2c_obj, PB_5, I2C_ADD_MBED, OLED_HEIGHT_PX, OLED_WIDTH_PX); -char* topic_sub = "mbed-sample-sub"; +// char* topic = "pubpim"; +// char* topic_sub = "subpim"; + +//char* topic = "pubpim"; // Ovde je verovatno greska +char* topic_sub = "pubpim"; const char* hostname = "broker.hivemq.com"; int port = 1883; -/////////////////////////////////////////////////////////////// void messageArrived(MQTT::MessageData& md) { @@ -41,13 +40,10 @@ printf("Browser message: %.*s \n", message.payloadlen, (char*)message.payload); myOLED.clearDisplay(); - //myOLED.setTextCursor(0, 0); myOLED.printf("%.*s \r", message.payloadlen, (char*)message.payload); myOLED.display(); } -/////////////////////////////////////////////////////////////// - int main() { wifi = WiFiInterface::get_default_instance(); @@ -65,13 +61,13 @@ MQTTPacket_connectData data = MQTTPacket_connectData_initializer; data.MQTTVersion = 3; - data.clientID.cstring = "Mustafa"; + data.clientID.cstring = "FB"; client.connect(data); client.subscribe(topic_sub, MQTT::QOS0, messageArrived); - myOLED.begin(); //pocetak - i2c_obj.frequency(400000); //veca frekvencija slanja da ne bi ghostovalo + myOLED.begin(); + i2c_obj.frequency(400000); myOLED.clearDisplay(); myOLED.display();
--- a/mbed_app.json Fri Dec 10 23:29:38 2021 +0000 +++ b/mbed_app.json Sat Dec 11 16:18:49 2021 +0000 @@ -2,11 +2,11 @@ "config": { "wifi-ssid": { "help": "WIFI SSID", - "value": "\"Wifi SSID\"" + "value": "\"cvele97\"" }, "wifi-password": { "help": "Wifi Password", - "value": "\"Wifi PSWD\"" + "value": "\"ekonomskitigar2021\"" } }, "target_overrides": {