Just a test

Dependencies:   BSP_DISCO_F769NI LCD_DISCO_F769NI lcd_log esp8266-driver

Fork of mbed-os-example-blinky-5 by Joscha Ihl

Files at this revision

API Documentation at this revision

Comitter:
joschaihl
Date:
Wed Nov 15 20:45:07 2017 +0000
Parent:
7:8c5ef9c24734
Child:
9:adfdb4ba838b
Commit message:
test

Changed in this revision

http.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
scope.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/http.h	Wed Nov 15 20:45:07 2017 +0000
@@ -0,0 +1,54 @@
+#if !FEATURE_LWIP
+    #error [NOT_SUPPORTED] LWIP not supported for this target
+#endif
+
+
+#include "EthernetInterface.h"
+#include "TCPServer.h"
+#include "TCPSocket.h"
+
+#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
+#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
+#define HTTP_MESSAGE_BODY ""                                     \
+"<html>" "\r\n"                                                  \
+"  <body style=\"display:flex;text-align:center\">" "\r\n"       \
+"    <div style=\"margin:auto\">" "\r\n"                         \
+"      <h1>Hello World</h1>" "\r\n"                              \
+"      <p>It works !</p>" "\r\n"                                 \
+"    </div>" "\r\n"                                              \
+"  </body>" "\r\n"                                               \
+"</html>"
+
+#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n"   \
+                      HTTP_HEADER_FIELDS "\r\n" \
+                      "\r\n"                    \
+                      HTTP_MESSAGE_BODY "\r\n"
+
+void srvLoop()
+{
+    printf("Basic HTTP server example\n");
+
+    EthernetInterface eth;
+    eth.connect();
+
+    printf("The target IP address is '%s'\n", eth.get_ip_address());
+
+    TCPServer srv;
+    TCPSocket clt_sock;
+    SocketAddress clt_addr;
+
+    /* Open the server on ethernet stack */
+    srv.open(&eth);
+
+    /* Bind the HTTP port (TCP 80) to the server */
+    srv.bind(eth.get_ip_address(), 80);
+
+    /* Can handle 5 simultaneous connections */
+    srv.listen(5);
+
+    while (true) {
+        srv.accept(&clt_sock, &clt_addr);
+        printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
+        clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE));
+    }
+}
\ No newline at end of file
--- a/main.cpp	Wed Nov 15 20:06:02 2017 +0000
+++ b/main.cpp	Wed Nov 15 20:45:07 2017 +0000
@@ -1,41 +1,12 @@
-#if !FEATURE_LWIP
-    #error [NOT_SUPPORTED] LWIP not supported for this target
-#endif
-
 #include "mbed.h"
-#include "stm32f769i_discovery.h"
-#include "stm32f769i_discovery_ts.h"
-#include "stm32f769i_discovery_lcd.h"
-#include "EthernetInterface.h"
-#include "TCPServer.h"
-#include "TCPSocket.h"
-#include "LCD_DISCO_F769NI.h"
-#include "lcd_log.h"
 #include "ESP8266.h"
 #include <stdio.h>
 #include <time.h>
 #include <math.h>
 #include <iostream>
+#include "scope.h"
 using namespace std;
 
-#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
-#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
-#define HTTP_MESSAGE_BODY ""                                     \
-"<html>" "\r\n"                                                  \
-"  <body style=\"display:flex;text-align:center\">" "\r\n"       \
-"    <div style=\"margin:auto\">" "\r\n"                         \
-"      <h1>Hello World</h1>" "\r\n"                              \
-"      <p>It works !</p>" "\r\n"                                 \
-"    </div>" "\r\n"                                              \
-"  </body>" "\r\n"                                               \
-"</html>"
-
-#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n"   \
-                      HTTP_HEADER_FIELDS "\r\n" \
-                      "\r\n"                    \
-                      HTTP_MESSAGE_BODY "\r\n"
-
-TS_StateTypeDef  TS_State = {0};
 Serial pc(USBTX, USBRX);
 
 Serial targ(D1, D0);
@@ -45,7 +16,7 @@
 //Serial wifi(WIFI_TX, WIFI_RX);
 
 DigitalOut led1(LED1);
-LCD_DISCO_F769NI lcd;
+
 DigitalOut led_green(LED2);
 
 void print_thread()
@@ -79,129 +50,12 @@
 
 }
 
-void gui_thread2() {
-
-     uint32_t i = 0;
-     BSP_LCD_Init();
-     BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
-    LCD_LOG_SetHeader((uint8_t *) "Serielle Schnittstelle");
-    //LCD_LOG_Init();
-
-    while(1) {
-        pc.printf("%c", targ.getc());
-
-    }
-}
-
-void gui_scope() {
-  lcd.DisplayOn();
-  /*  BSP_LCD_Init();
-    BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
-    LCD_LOG_SetHeader((uint8_t *) "Oszilloskop");*/
-
-        double pi = 3.141592;
-        double a = 0.0;
-        double inc = pi/25.0;
-        double abstand = lcd.GetYSize() / 2;
-        double prev_x = 0, prev_y = abstand, x, y;
-
-        lcd.SetBackColor((uint32_t) 0x00000000);
-        lcd.SetTextColor((uint32_t) 0xffffffff);
-        //lcd.DrawLine(0, 0, 100, 100);
-        //for(int i=0; i<1000; i=i+4)
-        int i;
-        while(1){
-          x = i;
-          y = abstand + sin(a) * 200.0;
-
-          //lcd.Clear((uint32_t) 0xffffffff);
-          //lcd.SetColorKeying(1, (uint32_t) 0xff000000);
-          lcd.DrawLine(prev_x, prev_y, x, y);
-          prev_x = x;
-          prev_y = y;
-          a = a + inc;
-          i+=8;
-          if(i>lcd.GetXSize()) {
-            i = 0;
-            lcd.Clear((uint32_t) 0x00000000);
-            wait_ms(10);
-            //lcd.SetBackColor((uint32_t) 0x00000000);
-            //lcd.SetTextColor((uint32_t) 0xffffffff);
-          }
-        }
-        //lcd.LayerDefaultInit(0, LCD_FB_START_ADDRESS);
-        //LCD_SetTextColor((uint32_t) 0xffffffff);
-       //LCD_DrawLine(120, 70, 2, 30);
-       // LCD_DrawLine(122, 68, 2, 50);
-        //LCD_DrawLine(122, 72, 2, 60);
-
-       // lcd.DrawLine(100, 100, 100, 100);
-    while(1) {
-    }
-}
-
-void touch_thread() {
-    uint16_t x1, y1;
-    TS_StateTypeDef state;
-    /* Touchscreen initialization */
-    if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) {
-        printf("BSP_TS_Init error\n");
-    }
-    while (1) {
-       // BSP_TS_GetState(&TS_State);
-      //  if(TS_State.touchDetected) {
-            /* One or dual touch have been detected          */
-
-            /* Get X and Y position of the first touch post calibrated */
-        //    x1 = TS_State.touchX[0];
-       //     y1 = TS_State.touchY[0];
-       //     printf("Touch Detected x=%d y=%d\n", x1, y1);
-
-            //BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
-            //BSP_LCD_FillCircle(x1, y1, 20);
-
-            wait_ms(10);
-       //}
-    }
-
-}
-
-void srvLoop()
-{
-    printf("Basic HTTP server example\n");
-
-    EthernetInterface eth;
-    eth.connect();
-
-    printf("The target IP address is '%s'\n", eth.get_ip_address());
-
-    TCPServer srv;
-    TCPSocket clt_sock;
-    SocketAddress clt_addr;
-
-    /* Open the server on ethernet stack */
-    srv.open(&eth);
-
-    /* Bind the HTTP port (TCP 80) to the server */
-    srv.bind(eth.get_ip_address(), 80);
-
-    /* Can handle 5 simultaneous connections */
-    srv.listen(5);
-
-    while (true) {
-        srv.accept(&clt_sock, &clt_addr);
-        printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
-        clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE));
-    }
-}
-
 void esp_thread() {
 
     while(1) {
        // pc.putc(wifi.getc());
     }
 }
-
 int main(void) {
     pc.baud(115200);
     targ.baud(115200);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scope.h	Wed Nov 15 20:45:07 2017 +0000
@@ -0,0 +1,98 @@
+#include "stm32f769i_discovery.h"
+#include "stm32f769i_discovery_ts.h"
+#include "stm32f769i_discovery_lcd.h"
+
+#include "LCD_DISCO_F769NI.h"
+#include "lcd_log.h"
+TS_StateTypeDef  TS_State = {0};
+
+LCD_DISCO_F769NI lcd;
+
+void gui_thread2() {
+
+     uint32_t i = 0;
+     BSP_LCD_Init();
+     BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
+    LCD_LOG_SetHeader((uint8_t *) "Serielle Schnittstelle");
+    //LCD_LOG_Init();
+
+    while(1) {
+       // pc.printf("%c", targ.getc());
+    }
+}
+
+void gui_scope() {
+  lcd.DisplayOn();
+  /*  BSP_LCD_Init();
+    BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
+    LCD_LOG_SetHeader((uint8_t *) "Oszilloskop");*/
+
+        double pi = 3.141592;
+        double a = 0.0;
+        double inc = pi/25.0;
+        double abstand = lcd.GetYSize() / 2;
+        double prev_x = 0, prev_y = abstand, x, y;
+
+        lcd.SetBackColor((uint32_t) 0x00000000);
+        lcd.SetTextColor((uint32_t) 0xffffffff);
+        //lcd.DrawLine(0, 0, 100, 100);
+        //for(int i=0; i<1000; i=i+4)
+        int i;
+        while(1){
+          x = i;
+          y = abstand + sin(a) * 200.0;
+
+          //lcd.Clear((uint32_t) 0xffffffff);
+          //lcd.SetColorKeying(1, (uint32_t) 0xff000000);
+          lcd.DrawLine(prev_x, prev_y, x, y);
+          prev_x = x;
+          prev_y = y;
+          a = a + inc;
+          i+=8;
+          if(i>lcd.GetXSize()) {
+            i = 0;
+            lcd.Clear((uint32_t) 0x00000000);
+            wait_ms(10);
+            //lcd.SetBackColor((uint32_t) 0x00000000);
+            //lcd.SetTextColor((uint32_t) 0xffffffff);
+          }
+        }
+        //lcd.LayerDefaultInit(0, LCD_FB_START_ADDRESS);
+        //LCD_SetTextColor((uint32_t) 0xffffffff);
+       //LCD_DrawLine(120, 70, 2, 30);
+       // LCD_DrawLine(122, 68, 2, 50);
+        //LCD_DrawLine(122, 72, 2, 60);
+
+       // lcd.DrawLine(100, 100, 100, 100);
+    while(1) {
+    }
+}
+
+void touch_thread() {
+    uint16_t x1, y1;
+    TS_StateTypeDef state;
+    /* Touchscreen initialization */
+    if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) {
+        printf("BSP_TS_Init error\n");
+    }
+    while (1) {
+       // BSP_TS_GetState(&TS_State);
+      //  if(TS_State.touchDetected) {
+            /* One or dual touch have been detected          */
+
+            /* Get X and Y position of the first touch post calibrated */
+        //    x1 = TS_State.touchX[0];
+       //     y1 = TS_State.touchY[0];
+       //     printf("Touch Detected x=%d y=%d\n", x1, y1);
+
+            //BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
+            //BSP_LCD_FillCircle(x1, y1, 20);
+
+            wait_ms(10);
+       //}
+    }
+
+}
+
+
+