STM32F103C8T6-Cayenne-WIZnet_SD1306_BMP280

Dependencies:   Cayenne-MQTT-mbed mbed Cayenne-WIZnet_Library WIZnet_Library BME280

Files at this revision

API Documentation at this revision

Comitter:
dadangjia
Date:
Mon Apr 23 13:43:45 2018 +0000
Parent:
8:be2ac38e5bb9
Child:
10:63b5e5d19bee
Commit message:
STM32F103C8T6?BME280?MPU6050?OLED,W5500

Changed in this revision

BME280.lib Show annotated file Show diff for this revision Revisions of this file
Cayenne-WIZnet_Library.lib Show annotated file Show diff for this revision Revisions of this file
MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
OLED/CriusOLED.h Show annotated file Show diff for this revision Revisions of this file
OLED/data.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BME280.lib	Mon Apr 23 13:43:45 2018 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/MACRUM/code/BME280/#ddcaa259e65b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cayenne-WIZnet_Library.lib	Mon Apr 23 13:43:45 2018 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/myDevicesIoT/code/Cayenne-WIZnet_Library/#be2ac38e5bb9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.lib	Mon Apr 23 13:43:45 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/BaserK/code/MPU6050/#b2f689b5fb63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OLED/CriusOLED.h	Mon Apr 23 13:43:45 2018 +0000
@@ -0,0 +1,272 @@
+/* ============================================
+Modified Code from Crius
+The CriusOLED Hardware MUST be modified for correct function of ACK
+Copyright (c) 2014 Michael Ruck michael@ruck.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+===============================================
+*/
+#include "./data.h"
+#define OLED_ADDR    (0x78)
+
+I2C i2c(PB_9, PB_8);
+
+void displayOn(void);
+void displayOff(void);
+void SendByte(unsigned char data);
+void sendcommand(unsigned char com);
+void SendByte(unsigned char com);
+void printBigNumber(unsigned char s, int X, int Y);
+void SendByteXY(unsigned char data, int X, int Y);
+
+
+//==========================================================//
+// Turns display on.
+void displayOn(void)
+{
+    sendcommand(0xaf);        //display on
+}
+
+//==========================================================//
+// Turns display off.
+void displayOff(void)
+{
+    sendcommand(0xae);        //display off
+}
+//==========================================================//
+// Actually this sends a byte, not a char to draw in the display.
+// Display's chars uses 8 byte font the small ones and 96 bytes
+// for the big number font.
+void SendByte(unsigned char data)
+{
+    //Create a temporary buffer
+    char buff[2];
+
+    //Load the control byte and 8-bit data
+    buff[0] = (0x40);
+    buff[1] = data;
+
+    //Write the data
+    i2c.write(OLED_ADDR, buff, 2);
+
+}
+
+//==========================================================//
+// Used to send commands to the display.
+void sendcommand(unsigned char com)
+{
+    //Create a temporary buffer
+    char buff[2];
+
+    //Load the control byte and 8-bit command
+    buff[0] = 0x00;
+    buff[1] = com;
+
+    //Write the command
+    i2c.write(OLED_ADDR, buff, 2);
+}
+//==========================================================//
+// Set the cursor position in a 16 COL * 8 ROW map.
+void setXY(unsigned char row,unsigned char col)
+{
+    sendcommand(0xb0+row);                //set page address
+    sendcommand(0x00+(8*col&0x0f));       //set low col address
+    sendcommand(0x10+((8*col>>4)&0x0f));  //set high col address
+}
+//==========================================================//
+// Clears the display by sendind 0 to all the screen map.
+void clear_display(void)
+{
+    unsigned char i,k;
+    for(k=0; k<8; k++) {
+        setXY(k,0);
+        {
+            for(i=0; i<128; i++) { //clear all COL
+                SendByte(0);         //clear all COL
+                //delay(10);
+            }
+        }
+    }
+}
+//==========================================================//
+// Resets display depending on the actual mode.
+void reset_display(void)
+{
+    displayOff();
+    clear_display();
+
+
+    displayOn();
+}
+//==========================================================//
+
+void sendImage()
+{
+    reset_display();
+    for(int i=0; i<128*8; i++)   // show 128* 64 Logo
+        SendByte(logo[i]);
+
+}
+//==========================================================//
+void printBigTime(char *s)
+{
+
+    int Y=0;
+    int lon = strlen(s);
+    if(lon == 3) {
+        Y = 0;
+    } else if (lon == 2) {
+        Y = 3;
+    } else if (lon == 1) {
+        Y = 6;
+    }
+
+    int X = 2;
+    while(*s) {
+        printBigNumber(*s, X, Y);
+
+        Y+=3;
+        X=2;
+        setXY(X,Y);
+        *s++;
+    }
+}
+
+
+//==========================================================//
+// Prints a display big number (96 bytes) in coordinates X Y,
+// being multiples of 8. This means we have 16 COLS (0-15)
+// and 8 ROWS (0-7).
+void printBigNumber(unsigned char s, int X, int Y)
+{
+    setXY(X,Y);
+    int salto=0;
+    for(int i=0; i<96; i++) {
+        if(s == ' ') {
+            SendByte(0);
+        } else
+            SendByte(bigNumbers[s-0x30][i]);
+
+        if(salto == 23) {
+            salto = 0;
+            X++;
+            setXY(X,Y);
+        } else {
+            salto++;
+        }
+    }
+}
+//==========================================================//
+// Prints a display char (not just a byte) in coordinates X Y,
+// being multiples of 8. This means we have 16 COLS (0-15)
+// and 8 ROWS (0-7).
+void SendByteXY(unsigned char data, int X, int Y)
+{
+    i2c.start();
+    i2c.write(OLED_ADDR);
+    i2c.write(0x40);
+
+    for(int i=0; i<8; i++)
+        i2c.write((int)(myFont[data-0x20]+i)); // <<-------------------------------------
+
+    i2c.stop();     // stop transmitting
+}
+//==========================================================//
+// Prints a string regardless the cursor position.
+void sendStr(unsigned char *s)
+{
+    unsigned char i=0;
+    while(*s) {
+        for(i=0; i<8; i++) {
+            SendByte(myFont[*s-0x20][i]);
+        }
+        *s++;
+    }
+}
+//==========================================================//
+// Prints a string in coordinates X Y, being multiples of 8.
+// This means we have 16 COLS (0-15) and 8 ROWS (0-7).
+void sendStrXY( char *s, int X, int Y)
+{
+    setXY(X,Y);
+    unsigned char i=0;
+    while(*s) {
+        for(i=0; i<8; i++) {
+            SendByte(myFont[*s-0x20][i]);
+        }
+        *s++;
+    }
+}
+
+
+//==========================================================//
+// Inits oled and draws logo at startup
+void init_OLED(void)
+{
+    sendcommand(0xae);        //display off
+    sendcommand(0xa6);            //Set Normal Display (default)
+    // Adafruit Init sequence for 128x64 OLED module
+    sendcommand(0xAE);             //DISPLAYOFF
+    sendcommand(0xD5);            //SETDISPLAYCLOCKDIV
+    sendcommand(0x80);            // the suggested ratio 0x80
+    sendcommand(0xA8);            //SSD1306_SETMULTIPLEX
+    sendcommand(0x3F);
+    sendcommand(0xD3);            //SETDISPLAYOFFSET
+    sendcommand(0x0);             //no offset
+    sendcommand(0x40 | 0x0);      //SETSTARTLINE
+    sendcommand(0x8D);            //CHARGEPUMP
+    sendcommand(0x14);
+    sendcommand(0x20);             //MEMORYMODE
+    sendcommand(0x00);             //0x0 act like ks0108
+
+    sendcommand(0xA0 | 0x1);      //SEGREMAP   //Rotate screen 180 deg
+    //sendcommand(0xA0);
+
+    sendcommand(0xC8);            //COMSCANDEC  Rotate screen 180 Deg
+    //sendcommand(0xC0);
+
+    sendcommand(0xDA);            //0xDA
+    sendcommand(0x12);           //COMSCANDEC
+    sendcommand(0x81);           //SETCONTRAS
+    sendcommand(0xCF);           //
+    sendcommand(0xd9);          //SETPRECHARGE
+    sendcommand(0xF1);
+    sendcommand(0xDB);        //SETVCOMDETECT
+    sendcommand(0x40);
+    sendcommand(0xA4);        //DISPLAYALLON_RESUME
+    sendcommand(0xA6);        //NORMALDISPLAY
+
+    clear_display();
+    sendcommand(0x2e);            // stop scroll
+    //----------------------------REVERSE comments----------------------------//
+    //  sendcommand(0xa0);        //seg re-map 0->127(default)
+    //  sendcommand(0xa1);        //seg re-map 127->0
+    //  sendcommand(0xc8);
+    //  delay(1000);
+    //----------------------------REVERSE comments----------------------------//
+    // sendcommand(0xa7);  //Set Inverse Display
+    // sendcommand(0xae);     //display off
+    sendcommand(0x20);            //Set Memory Addressing Mode
+    sendcommand(0x00);            //Set Memory Addressing Mode ab Horizontal addressing mode
+    //  sendcommand(0x02);         // Set Memory Addressing Mode ab Page addressing mode(RESET)
+
+    setXY(0,0);
+
+    sendcommand(0xaf);        //display on
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OLED/data.h	Mon Apr 23 13:43:45 2018 +0000
@@ -0,0 +1,283 @@
+/* 
+ * This file contains all the static arrays to draw things in the display.
+ */
+
+
+// GPS Logo
+char logo []  = { 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
+0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0x3C, 0x1C, 0x0E, 0x07,
+0x07, 0x83, 0x83, 0x83, 0xC3, 0xC7, 0xEF, 0xFE, 0x7C, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x00,
+0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0x78, 0x1C, 0x1E, 0x0E, 0x07, 0x07, 0x1F, 0xFB, 0xAB, 0x83,
+0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x0F, 0x3F, 0xFF, 0xFC, 0x8E, 0x0E, 0x06, 0x07,
+0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x7E, 0xFF, 0xE7, 0xE1, 0xE1, 0xE0, 0xE0, 0x60, 0x60, 0x70, 0x71, 0x71, 0x71, 0x33, 0x37,
+0x3F, 0x7E, 0xFF, 0xEF, 0x83, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x80, 0x03, 0x0E,
+0x70, 0xC0, 0x00, 0x78, 0xFC, 0xCE, 0xC6, 0xC6, 0xFE, 0xFC, 0x31, 0x07, 0x3F, 0xFE, 0xF0, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0x0F, 0x7F, 0xFC, 0xE3, 0x8F, 0x1F, 0x18, 0x18, 0x1C, 0x0F, 0x0F, 0x00, 0x80,
+0x80, 0x41, 0x6E, 0x38, 0x20, 0x11, 0x11, 0x11, 0x70, 0x10, 0x70, 0x10, 0xF0, 0xFF, 0xFF, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0xF0, 0xF0, 0x10, 0x10, 0x00, 0x00, 0xD8, 0xD8, 0x00,
+0x00, 0xC0, 0xC0, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x40, 0xF8, 0xF8, 0x00,
+0x00, 0xD8, 0xD8, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x80, 0xC0, 0x40, 0x40, 0x80, 0x00, 0x80, 0xC0, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0xC0,
+0xC0, 0x40, 0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xFE, 0xE7, 0xC7, 0xE7, 0x7E, 0x7C, 0x00, 0x00,
+0x00, 0x00, 0x80, 0xE0, 0xF8, 0x7D, 0x1F, 0x87, 0xCF, 0xFE, 0xFC, 0xFC, 0xF4, 0xE2, 0xC1, 0x81,
+0x00, 0x10, 0x18, 0x18, 0x1C, 0x1C, 0x9E, 0x8E, 0xC7, 0xC0, 0xE0, 0xF0, 0x7F, 0x3F, 0x1F, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00,
+0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x1F, 0x1F, 0x00,
+0x00, 0x1F, 0x1F, 0x00, 0x00, 0x0F, 0x1F, 0x12, 0x12, 0x13, 0x0B, 0x00, 0x00, 0x18, 0x18, 0x00,
+0x00, 0x0F, 0x1F, 0x10, 0x10, 0x08, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x1F,
+0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x06, 0x0E, 0x0E, 0xFE, 0xFF, 0x0F, 0x7F, 0xFF, 0xF7, 0x87, 0x06, 0x00,
+0xE0, 0xFE, 0xFF, 0x0F, 0x01, 0x00, 0x0F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+0x3F, 0x1E, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE7, 0x7F, 0x7E, 0x78, 0x31, 0x33, 0x3F, 0x3E, 0x7E,
+0xFF, 0xEF, 0xC0, 0xE0, 0x60, 0x60, 0x70, 0x60, 0x60, 0xE0, 0xE0, 0xC0, 0x90, 0xE5, 0xFF, 0xC3,
+0xE0, 0xE0, 0x60, 0x60, 0x70, 0x60, 0x60, 0xE0, 0xC0, 0xFF, 0xFF, 0x3F, 0x30, 0x30, 0x70, 0x70,
+0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x7E, 0x7F, 0x67, 0x61, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78,
+0x7F, 0x7F, 0x61, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x7F, 0x7F, 0x7F, 0x61,
+0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x7F, 0x7F, 0x78, 0x60, 0x60, 0x60, 0x60,
+0x60, 0x61, 0x67, 0x7F, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+
+// Big numbers font, from 0 to 9. 96 byte each.
+char bigNumbers [][96] = {
+{0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF0,
+0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
+0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xC1, 0xC0, 0xC0, 0xC0,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x87, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+0x03, 0x03, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xC1, 0xC0, 0xC0, 0xC0,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x81, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87,
+0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
+0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0x81, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x81, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87,
+0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0x81, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x87, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87,
+0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xE1,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x87, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87,
+0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
+0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1,
+0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
+0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00},
+
+{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+};
+
+// Big numbers minus simbol.
+char minus [] = {
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x0C, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
+0x1E, 0x1E, 0x1E, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+// Km/h in big font. This avoids to create an entirely new big font and saves flash space.
+char kmh []  = {
+0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x80,
+0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xF0, 0xF8, 0xFC,
+0x9E, 0x0E, 0x06, 0xE0, 0xF0, 0xF0, 0xF0, 0x70, 0xF0, 0xE0, 0xF0, 0xF0, 0x70, 0xF0, 0xE0, 0xC0,
+0x00, 0x00, 0xE0, 0xFE, 0x1F, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x18, 0x18, 0xF8, 0xF0, 0xF0, 0x00,
+0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x01, 0x03, 0x07, 0x07, 0x06, 0x07, 0x07, 0x07, 0x00, 0x00,
+0x07, 0x07, 0x07, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x07,
+0x07, 0x07, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00
+};
+
+// degrees, outside the ascii table myFont
+char myDregree [8]  = {
+0x00,0x00,0x0C,0x12,0x12,0x0C,0x00,0x00
+};
+
+
+// Small 8x8 font
+char myFont[][8]  = {
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+{0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
+{0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
+{0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
+{0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
+{0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
+{0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
+{0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
+{0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
+{0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
+{0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
+{0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
+{0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
+{0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
+{0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
+{0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
+{0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
+{0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
+{0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
+{0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
+{0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
+{0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
+{0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
+{0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
+{0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
+{0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
+{0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
+{0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
+{0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
+{0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
+{0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
+{0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
+{0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
+{0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
+{0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
+{0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
+{0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
+{0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
+{0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
+{0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
+{0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
+{0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
+{0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
+{0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
+{0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
+{0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
+{0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
+{0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
+{0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
+{0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
+{0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
+{0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
+{0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
+{0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
+{0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
+{0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
+{0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
+{0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
+{0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
+{0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
+{0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
+{0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
+{0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
+{0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
+{0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
+{0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
+{0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
+{0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
+{0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
+{0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
+{0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
+{0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
+{0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
+{0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
+{0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
+{0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
+{0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
+{0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
+{0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
+{0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
+{0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
+{0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
+{0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
+{0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
+{0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
+{0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
+{0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
+{0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
+{0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
+{0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
+{0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
+{0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
+{0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
+{0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
+{0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
+{0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} 
+};
+
+//*************************************************************************************************
\ No newline at end of file
--- a/main.cpp	Fri Nov 11 18:26:34 2016 +0000
+++ b/main.cpp	Mon Apr 23 13:43:45 2018 +0000
@@ -5,58 +5,104 @@
 * NOTE: The WIZnet_Library defaults to using code for W5500. If you want to use a W5100 or W5200 code you need to 
 * set the appropriate define in wiznet.h.
 */
-
 #include "MQTTTimer.h"
 #include "CayenneMQTTClient.h"
 #include "MQTTNetwork.h"
 #include "WIZnetInterface.h"
-	
 // Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
-char* username = "MQTT_USERNAME";
-char* password = "MQTT_PASSWORD";
-char* clientID = "CLIENT_ID";
+char* username = "c5495b90-ff04-11e6-a6b3-05972afbabc2";
+char* password = "084cdefbc6a98c0b5b781716c9d102ce06b62cc4";
+char* clientID = "267e1460-8aff-11e7-a5d9-9de9b49680ec";
+#define USE_DHCP    1
+                                                                                         
+Serial pc(USBTX, USBRX);  //TX RX
 
 SPI spi(D11, D12, D13);
-WIZnetInterface interface(&spi, D10, D5); // SPI, SEL, Reset
-MQTTNetwork<WIZnetInterface> network(interface);
+WIZnetInterface ethernet(&spi, PB_0, PB_1); // SPI, SEL, Reset
+MQTTNetwork<WIZnetInterface> network(ethernet);
 CayenneMQTT::MQTTClient<MQTTNetwork<WIZnetInterface>, MQTTTimer> mqttClient(network, username, password, clientID);
+char buffer[7][20];
+float Temperature,Pressure;
+long ADC_VALUE[3]; 
+AnalogIn ADC_MQ2(A0);       //ADC1,MQ2空气质量检测
+AnalogIn ADC_MQ3(A1);      //ADC2,MQ3空气质量检测
+AnalogIn analog_value(A2); // ADC3,可调电位器
 
+#include "CriusOLED.h"
+void OLED_INIT()
+{
+    i2c.frequency(400000);
+    init_OLED();
+    displayOn();
+    reset_display();
+}
+
+#include "MPU6050.h"
+//MPU6050采集数据 
+Ticker ticker;  
+MPU6050 mpu6050;
+float pitchAngle = 0;float rollAngle = 0;
+float tickerTime = 0.5;
+void compFilter() {mpu6050.complementaryFilter(&pitchAngle, &rollAngle);}
+
+#include "BME280.h"
+BME280 sensor(PB_9, PB_8);
+void bme280_dat()
+{
+  Temperature=sensor.getTemperature();
+  Pressure=sensor.getPressure()*100;
+  ADC_VALUE[0] = (long)(ADC_MQ2.read() * 3300); 
+  ADC_VALUE[1] = (long)(ADC_MQ3.read() * 3300);
+  ADC_VALUE[2] = (long)(analog_value.read()* 3300); 
+  snprintf(buffer[0],sizeof(buffer[0]), "%2.2fC %6.0fPa",Temperature, Pressure); 
+  sendStrXY(buffer[0],0,0);  
+}
+
+void Stm32f103c8t6_ticker()
+{
+ compFilter();
+ bme280_dat();
+}
 /**
 * Print the message info.
 * @param[in] message The message received from the Cayenne server.
 */
 void outputMessage(CayenneMQTT::MessageData& message)
 {
+    size_t j;
     switch (message.topic)  {
     case COMMAND_TOPIC:
-        printf("topic=Command");
+        pc.printf("topic=Command");
         break;
     case CONFIG_TOPIC:
-        printf("topic=Config");
+        pc.printf("topic=Config");
         break;
     default:
-        printf("topic=%d", message.topic);
+        pc.printf("topic=%d", message.topic);
         break;
     }
-    printf(" channel=%d", message.channel);
+    pc.printf(" channel=%d", message.channel);
     if (message.clientID) {
-        printf(" clientID=%s", message.clientID);
+        pc.printf(" clientID=%s", message.clientID);
     }
     if (message.type) {
-        printf(" type=%s", message.type);
+        pc.printf(" type=%s", message.type);
     }
     for (size_t i = 0; i < message.valueCount; ++i) {
 		if (message.getValue(i)) {
-			printf(" value=%s", message.getValue(i));
+			pc.printf(" value=%s", message.getValue(i));
+			j = i;
 		}
 		if (message.getUnit(i)) {
-			printf(" unit=%s", message.getUnit(i));
+			pc.printf(" unit=%s", message.getUnit(i));
 		}
     }
     if (message.id) {
-        printf(" id=%s", message.id);
+        pc.printf(" id=%s", message.id);
     }
-    printf("\n");
+    pc.printf("\n");
+    
+   
 }
 
 /**
@@ -73,13 +119,13 @@
 		// If this is a command message we publish a response to show we recieved it. Here we are just sending a default 'OK' response.
 		// An error response should be sent if there are issues processing the message.
 		if ((error = mqttClient.publishResponse(message.id, NULL, message.clientID)) != CAYENNE_SUCCESS) {
-			printf("Response failure, error: %d\n", error);
+			pc.printf("Response failure, error: %d\n", error);
 		}
 			
 		// Send the updated state for the channel so it is reflected in the Cayenne dashboard. If a command is successfully processed
 		// the updated state will usually just be the value received in the command message.
 		if ((error = mqttClient.publishData(DATA_TOPIC, message.channel, NULL, NULL, message.getValue())) != CAYENNE_SUCCESS) {
-			printf("Publish state failure, error: %d\n", error);
+			pc.printf("Publish state failure, error: %d\n", error);
 		}
 	}
 }
@@ -92,24 +138,24 @@
 {
     int error = 0;
     // Connect to the server.
-    printf("Connecting to %s:%d\n", CAYENNE_DOMAIN, CAYENNE_PORT);
+    pc.printf("Connecting to %s:%d\n", CAYENNE_DOMAIN, CAYENNE_PORT);
     while ((error = network.connect(CAYENNE_DOMAIN, CAYENNE_PORT)) != 0) {
-        printf("TCP connect failed, error: %d\n", error);
+        pc.printf("TCP connect failed, error: %d\n", error);
         wait(2);
     }
 
     if ((error = mqttClient.connect()) != MQTT::SUCCESS) {
-        printf("MQTT connect failed, error: %d\n", error);
+        pc.printf("MQTT connect failed, error: %d\n", error);
         return error;
     }
-    printf("Connected\n");
+    pc.printf("Connected\n");
 
     // Subscribe to required topics.
     if ((error = mqttClient.subscribe(COMMAND_TOPIC, CAYENNE_ALL_CHANNELS)) != CAYENNE_SUCCESS) {
-        printf("Subscription to Command topic failed, error: %d\n", error);
+        pc.printf("Subscription to Command topic failed, error: %d\n", error);
     }
     if ((error = mqttClient.subscribe(CONFIG_TOPIC, CAYENNE_ALL_CHANNELS)) != CAYENNE_SUCCESS) {
-        printf("Subscription to Config topic failed, error:%d\n", error);
+        pc.printf("Subscription to Config topic failed, error:%d\n", error);
     }
 
     // Send device info. Here we just send some example values for the system info. These should be changed to use actual system data, or removed if not needed.
@@ -137,53 +183,108 @@
         if (!network.connected() || !mqttClient.connected()) {
             network.disconnect();
             mqttClient.disconnect();
-            printf("Reconnecting\n");
+            pc.printf("Reconnecting\n");
             while (connectClient() != CAYENNE_SUCCESS) {
                 wait(2);
-                printf("Reconnect failed, retrying\n");
+                pc.printf("Reconnect failed, retrying\n");
             }
         }
 
         // Publish some example data every few seconds. This should be changed to send your actual data to Cayenne.
         if (timer.expired()) {
-            int error = 0;
-            if ((error = mqttClient.publishData(DATA_TOPIC, 0, TYPE_TEMPERATURE, UNIT_CELSIUS, 30.5)) != CAYENNE_SUCCESS) {
-                printf("Publish temperature failed, error: %d\n", error);
+            int error=0;
+            if ((error = mqttClient.publishData(DATA_TOPIC, 0, TYPE_TEMPERATURE, UNIT_CELSIUS, Temperature)) != CAYENNE_SUCCESS) {
+                pc.printf("T:%2.2fC\n",Temperature);
+            }
+            if ((error = mqttClient.publishData(DATA_TOPIC, 1, TYPE_LUMINOSITY, UNIT_LUX, (long)Pressure)) != CAYENNE_SUCCESS) {
+                pc.printf("P:%6.0fPa\n",Pressure);
+            }
+            if ((error = mqttClient.publishData(DATA_TOPIC, 2, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, ax)) != CAYENNE_SUCCESS) {
+                pc.printf("x:%03.2f\n", ax);
             }
-            if ((error = mqttClient.publishData(DATA_TOPIC, 1, TYPE_LUMINOSITY, UNIT_LUX, 1000)) != CAYENNE_SUCCESS) {
-                printf("Publish luminosity failed, error: %d\n", error);
+            if ((error = mqttClient.publishData(DATA_TOPIC, 3, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, ay)) != CAYENNE_SUCCESS) {
+                pc.printf("y:%03.2f\n", ay);
+            } 
+            if ((error = mqttClient.publishData(DATA_TOPIC, 4, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, az)) != CAYENNE_SUCCESS) {
+                pc.printf("z:%03.2f\n", az);
+            } 
+            if ((error = mqttClient.publishData(DATA_TOPIC, 14, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, gx)) != CAYENNE_SUCCESS) {
+                pc.printf("X:%03.2f\n", gx);
             }
-            if ((error = mqttClient.publishData(DATA_TOPIC, 2, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, 800)) != CAYENNE_SUCCESS) {
-                printf("Publish barometric pressure failed, error: %d\n", error);
+            if ((error = mqttClient.publishData(DATA_TOPIC, 15, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, gy)) != CAYENNE_SUCCESS) {
+                pc.printf("Y:%03.2f\n", gy);
+            } 
+            if ((error = mqttClient.publishData(DATA_TOPIC, 16, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, gz)) != CAYENNE_SUCCESS) {
+                pc.printf("Z:%03.2f\n", gz);
             }
+             
+            if ((error = mqttClient.publishData(DATA_TOPIC, 8, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, ADC_VALUE[0])) != CAYENNE_SUCCESS) {
+                pc.printf("A0:%4dmV\n", ADC_VALUE[0]);
+            }
+            if ((error = mqttClient.publishData(DATA_TOPIC, 9, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, ADC_VALUE[1])) != CAYENNE_SUCCESS) {
+                pc.printf("A1:%4dmV\n", ADC_VALUE[1]);
+            }
+            if ((error = mqttClient.publishData(DATA_TOPIC, 10, TYPE_BAROMETRIC_PRESSURE, UNIT_HECTOPASCAL, ADC_VALUE[2])) != CAYENNE_SUCCESS) {
+                pc.printf("A2:%4dmV\n", ADC_VALUE[2]);
+            }
+                                                                                 
             // Restart the countdown timer for publishing data every 5 seconds. Change the timeout parameter to publish at a different interval.
             timer.countdown_ms(5000);
         }
     }
 }
 
+char * IP_Addr    = "192.168.0.194";
+char * IP_Subnet  = "255.255.255.0";
+char * IP_Gateway = "192.168.0.1";
+unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56};
+void W5500_init()
+{
+        #if USE_DHCP
+        int ret = ethernet.init(MAC_Addr);
+        #else
+        int ret = ethernet.init(MAC_Addr,IP_Addr,IP_Subnet,IP_Gateway);
+        #endif
+        if (!ret) {
+            pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress());
+            ret = ethernet.connect();
+            if (!ret) {
+                pc.printf("IP: %s, MASK: %s, GW: %s\r\n",
+                          ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway()); 
+                sendStrXY("IP:",1,0); 
+                sendStrXY(ethernet.getIPAddress(),1,3);                                   
+            } else {
+                pc.printf("Error ethernet.connect() - ret = %d\r\n", ret);
+                exit(0);
+            }
+        } else {
+            pc.printf("Error ethernet.init() - ret = %d\r\n", ret);
+            exit(0);
+        }       
+}
 /**
 * Main function.
 */
 int main()
 {
-    printf("Initializing interface\n");
+    pc.baud(921600);
+    pc.printf("Stm32f103k3t6-w5500-Cayeme-ethernet\n");
+    OLED_INIT();
+    mpu6050.whoAmI();                           // Communication test: WHO_AM_I register reading   
+    mpu6050.calibrate(accelBias,gyroBias);      // Calibrate MPU6050 and load biases into bias registers
+    mpu6050.init(); 
+    ticker.attach(&Stm32f103c8t6_ticker, tickerTime); 
     // Set the correct SPI frequency for your shield, if necessary. For example, 42000000 for Arduino Ethernet Shield W5500 or 20000000 for Arduino Ethernet Shield W5100.
-    spi.frequency(42000000);
-	unsigned char MAC_Addr[6] = {0xFE,0x08,0xDC,0x12,0x34,0x56};
-    mbed_mac_address((char *)MAC_Addr); // Use mbed mac address
-    interface.init(MAC_Addr);   
-
+    W5500_init();
     // Set the default function that receives Cayenne messages.
     mqttClient.setDefaultMessageHandler(messageArrived);
-
     // Connect to Cayenne.
     if (connectClient() == CAYENNE_SUCCESS) {
         // Run main loop.
         loop();
     }
     else {
-        printf("Connection failed, exiting\n");
+        pc.printf("Connection failed, exiting\n");
     }
 
     if (mqttClient.connected())