bunch of tesitng for F746NG

Dependencies:   BSP_DISCO_F746NG F746_GUI F7_Ethernet LCD_DISCO_F746NG SimpleSocket TMP36 GZ TS_DISCO_F746NG TextLCD WebSocketClient mbed-rtos mbed sMotor

Revision:
0:45610c4af223
Child:
1:1f4543ea364d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 11 09:46:58 2017 +0000
@@ -0,0 +1,175 @@
+#include "mbed.h"
+#include "F746_GUI.hpp"
+#include "LCD_DISCO_F746NG.h"
+#include "TextLCD.h"
+#include <string>
+#include <math.h>
+#include "EthernetInterface.h"
+#include "rtos.h"
+#include "lwip/inet.h"
+#include "lwip/netif.h"
+#include "netif/etharp.h"
+#include "lwip/dhcp.h"
+#include "eth_arch.h"
+#include "lwip/tcpip.h"
+
+#include "NTPClient.h"
+#include <stdio.h>
+
+
+//Initialization of varius connections and interfaces
+
+
+DigitalOut myled2(D4);
+
+
+int number_clicks;
+LCD_DISCO_F746NG lcd;
+EthernetInterface eth;
+Thread t1, t2;
+
+//declare external funktions and pointers
+extern void heartrate();
+extern double *h_p;
+//extern void proximity();
+NTPClient ntp;
+
+
+int main()
+{
+   
+
+    
+    //First we check if the ethernet interface was able to initialize
+    if(eth.init()!=0) {
+
+        char eth_init [40];
+        sprintf(eth_init, "EthernetInterface Initialize Error");
+        lcd.DisplayStringAt(0, LINE(10), (uint8_t *)eth_init, CENTER_MODE);
+        while (1) {
+            wait(10);
+        }
+    }
+    //check if the ethernet intercace is connected to a network.
+
+    if(eth.connect()!=0) {
+        char eth_conn[30];
+        sprintf(eth_conn, "EthernetInterface Connect Error");
+        lcd.DisplayStringAt(0, LINE(8), (uint8_t *)eth_conn, CENTER_MODE);
+        char mac_add[15];
+        sprintf(mac_add, "Mac: %s", eth.getMACAddress());
+        lcd.DisplayStringAt(0, LINE(10), (uint8_t *)mac_add, CENTER_MODE);
+        while (1) {
+            wait(10);
+        }
+    }
+    char ip_add[30];
+    char net_mask[30];
+    char gate_Way[30];
+    char dhcp_status[30];
+
+
+    /*Display the varius information achived from the dhcp server,
+    It is also possible to set all these values manually,
+    if no dhcp server is available
+    */
+    sprintf(ip_add, "IP Address is %s", eth.getIPAddress());
+    sprintf(net_mask, "NetMask is %s", eth.getNetworkMask());
+    sprintf(gate_Way, "Gateway Address is %s", eth.getGateway());
+    sprintf(dhcp_status, "Ethernet Setup OK");
+    lcd.DisplayStringAt(0, LINE(2), (uint8_t *)ip_add, CENTER_MODE);
+    lcd.DisplayStringAt(0, LINE(4), (uint8_t *)net_mask, CENTER_MODE);
+    lcd.DisplayStringAt(0, LINE(6), (uint8_t *)gate_Way, CENTER_MODE);
+    lcd.DisplayStringAt(0, LINE(8), (uint8_t *)dhcp_status, CENTER_MODE);
+    wait(5);
+    lcd.Clear(LCD_COLOR_GREEN);
+    if (ntp.setTime("1.dk.pool.ntp.org") == 0)
+            {
+            char ntp_message [50];
+            time_t ctTime;
+            ctTime = time(NULL);
+            sprintf(ntp_message, "%s \r\n", ctime(&ctTime));
+            //sprintf(ntp_message, "Time is set to : %s \r\n", ctime(&ctTime));
+            lcd.DisplayStringAt(-10, LINE(8), (uint8_t *)ntp_message, CENTER_MODE);
+            
+            }
+        else
+        {
+        
+            lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"Error getting time", CENTER_MODE);
+        }
+    wait(2);
+    lcd.Clear(LCD_COLOR_GREEN);
+
+
+
+    //This is the main tasks included in the programm
+    Button b1(300, 3, 70, 40, "Hjerterytme", Font16);
+    Button b2(200, 3, 70, 40, "Lyd og temp", Font16);
+    lcd.DisplayStringAt(0, LINE(10), (uint8_t *)ip_add, CENTER_MODE);
+    while(1) {
+       
+        
+       
+        
+       
+       
+        
+
+        lcd.SetTextColor(LCD_COLOR_BLACK);
+        lcd.SetBackColor(LCD_COLOR_WHITE);
+        //print raw text to the LCD display
+        lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Commence Initial Testing...", CENTER_MODE);
+        //shows the number of times the button was clicked
+       
+        lcd.DisplayStringAt(0, LINE(6), (uint8_t *) "Christoffer Bisander", CENTER_MODE);
+       
+       
+//t1.start(testing);
+//t1.detach();
+//input_functions fact;
+        //t1.start(proximity);
+        //t1.join();
+
+
+        
+
+
+
+
+        //Check if the button was clicked and then increments the number_clicks with one
+        if (b1.Touched()) { // if user touched "MODE" panel then return
+            lcd.SetTextColor(LCD_COLOR_RED);
+            
+            t2.start(heartrate);
+        lcd.Clear(LCD_COLOR_GREEN);
+        char heart_rate_current[50];
+        double hr;
+        while(1) {
+            hr = *h_p;
+
+//t2.start(input_functions::heartrate, fact);
+            sprintf(heart_rate_current, "hjerterytme: %f", hr);
+            lcd.DisplayStringAt(0, LINE(14), (uint8_t *)heart_rate_current, CENTER_MODE);
+            wait(0.1);
+        }
+        t2.join();
+
+            
+            wait(0.5);
+            lcd.Clear(LCD_COLOR_BLACK);
+        }
+        
+        //----------------------------------------------------------------------------//
+        //analog sound sensor.
+        //read the voltage from the sound sensor
+        
+
+    }
+
+}
+
+
+
+
+