Deven Agrawal / Mbed OS assignment3

Dependencies:   Hexi_KW40Z BLE_API Hexi_OLED_SSD1351

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Hexi_KW40Z.h"
00003 #include "Hexi_OLED_SSD1351.h"
00004 #include "OLED_types.h"
00005 #include "OpenSans_Font.h"
00006 #include "string.h"
00007 
00008 #define LED_ON      0
00009 #define LED_OFF     1
00010 
00011 KW40Z kw(PTE24, PTE25); //24 - Tx, 25 - Rx
00012 SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */
00013 
00014 int main() {
00015     char text[20];
00016     
00017     oled.DimScreenON();
00018     
00019     oled.FillScreen(COLOR_BLACK);
00020     oled_text_properties_t textProperties = {0};
00021     oled.GetTextProperties(&textProperties);    
00022     textProperties.fontColor   = COLOR_WHITE;
00023     oled.SetTextProperties(&textProperties);
00024     
00025 //    /* Display Bluetooth Label at x=17,y=65 */ 
00026 //    strcpy((char *) text,"BLUETOOTH");
00027 //    oled.Label((uint8_t *)text,17,65);
00028     
00029 //    /* Change font color to white */ 
00030 //    textProperties.fontColor   = COLOR_WHITE;
00031 //    textProperties.alignParam = OLED_TEXT_ALIGN_CENTER;
00032 //    oled.SetTextProperties(&textProperties);
00033 //    
00034 //    /* Display Label at x=22,y=80 */ 
00035 //    strcpy((char *) text,"Tap Below");
00036 //    oled.Label((uint8_t *)text,22,80);
00037 //    strcpy((char *)text, "hello world");
00038 //    oled.TextBox((uint8_t *)text, 0,0,95, 18);
00039     sprintf(text, "%d %d %d", kw.GetPassKey(), kw.GetLinkState(), kw.GetAdvertisementMode());
00040     oled.TextBox((uint8_t *)text, 0,0,95, 18);
00041     int prev = kw.GetLinkState();
00042     kw.ToggleAdvertisementMode();
00043     while(true) {
00044         sprintf(text, "%d %d", kw.GetLinkState(), kw.GetAdvertisementMode());
00045         oled.TextBox((uint8_t *)text, 0,20,95, 18);
00046     }
00047 }