nRF51822_OBS + mocro:bit_ADV

Dependencies:   mbed BLE_API Adafruit_GFX nRF51822

Тесты по созданию связи между micro:bit и nRF51822 & BLE400 эта часть под nRF51822

Revision:
12:0f6e700ca698
Parent:
11:f6274e2a0b07
Child:
13:ae46f7a91beb
--- a/main.cpp	Sun Dec 15 06:28:38 2019 +0000
+++ b/main.cpp	Sun Dec 15 13:50:21 2019 +0000
@@ -17,6 +17,10 @@
 #include "mbed.h"
 #include "BLE.h"
 //#include "TMP_nrf51/TMP_nrf51.h"
+#include "Adafruit_SSD1306.h"
+
+#define SDA P0_0
+#define SCL P0_1
 
 #define APP_SPECIFIC_ID_TEST 0x0059 //0xFEFE
 
@@ -37,6 +41,19 @@
 };
 #pragma pack()
 
+class I2C2 : public I2C
+{
+public:
+    I2C2(PinName sda, PinName scl) : I2C(sda, scl)
+    {
+        frequency(400000);
+        start();
+    };
+};
+
+I2C2 gI2C(SDA,SCL);
+Adafruit_SSD1306_I2c gOled2(gI2C, NC, 0x78, 64, 128);
+
 BLE        ble;
 DigitalOut led1(LED1);
 
@@ -61,6 +78,10 @@
                 pc.printf("From [%02x %02x %02x %02x %02x %02x], ", params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0]);
                 if(params->peerAddr[0] == 0x38) {
                     pc.printf("Temp is %.02f\r", (float)pAppData->tmpSensorValue);
+                    gOled2.setTextCursor(1, 16);
+                    gOled2.setTextSize(2);
+                    gOled2.printf("Temp: %.01f", (float)pAppData->tmpSensorValue);
+                    gOled2.display();
                 } else {
                     pc.printf("XZ is %.02f\r", (float)pAppData->tmpSensorValue);
                 }
@@ -86,6 +107,13 @@
     pc.baud(9600);
     pc.printf("Observer Init \r\n");
 
+    gOled2.clearDisplay();
+    gOled2.display();
+    gOled2.setTextCursor(1, 1);
+    gOled2.setTextSize(1);
+    gOled2.printf("Observer Init \r");
+    gOled2.display();
+
     while (true) {
         ble.waitForEvent();
     }