Just a test
Dependencies: BSP_DISCO_F769NI LCD_DISCO_F769NI lcd_log esp8266-driver
Fork of mbed-os-example-blinky-5 by
main.cpp
- Committer:
- joschaihl
- Date:
- 2017-11-15
- Revision:
- 7:8c5ef9c24734
- Parent:
- 6:37ebd143b246
- Child:
- 8:084f05e528ba
File content as of revision 7:8c5ef9c24734:
#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> 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); #define WIFI_RX PC_12 #define WIFI_TX PD_2 //Serial wifi(WIFI_TX, WIFI_RX); DigitalOut led1(LED1); LCD_DISCO_F769NI lcd; DigitalOut led_green(LED2); void print_thread() { while (true) { Thread::wait(1000); printf("Hallo Welt!!!\n"); } } void led_thread() { led_green = !led_green; while(true) { Thread::wait(200); led1 = !led1; led_green = !led_green; } } extern void LCD_LOG_SetHeader(uint8_t *Title); void clock_thread() { char timestr[64] = ""; while(1) { time_t seconds; time(&seconds); sprintf(timestr, "Time = %s", ctime(&seconds)); LCD_LOG_SetHeader((uint8_t *) timestr); Thread::wait(1000); } } 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(ð); /* 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); //wifi.baud(115200); cout << "Hallo Joscha!!!" << endl; Thread printThread(osPriorityNormal), ledThread(osPriorityNormal), guiThread(osPriorityNormal), touchThread(osPriorityNormal), clockThread(osPriorityNormal), espThread(osPriorityNormal); // printThread.start(print_thread); ledThread.start(led_thread); guiThread.start(gui_thread2); // guiThread.start(gui_scope); // touchThread.start(touch_thread); clockThread.start(clock_thread); // espThread.start(esp_thread); // Thread tsrv; // tsrv.start(srvLoop); while(1) { } }