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-05-28
- Revision:
- 3:7c7587c666e1
- Parent:
- 2:6a613cb4b302
- Child:
- 4:7876f757c6e8
File content as of revision 3:7c7587c666e1:
#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 <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); #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() { while(true) { Thread::wait(200); led1 = !led1; } } extern void LCD_LOG_SetHeader(uint8_t *Title); void clock_thread() { char timestr[64] = ""; while(1) { time_t seconds = time(NULL); sprintf(timestr, "Time = %s\0", 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 *) "Das ist ein Test"); //LCD_LOG_Init(); while(1) { led1 = 0; led_green = 1; printf("Test %d\n",i++ ); led1 = 1; led_green = 0; } } 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*2); //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); touchThread.start(touch_thread); clockThread.start(clock_thread); // espThread.start(esp_thread); // Thread tsrv; // tsrv.start(srvLoop); while(1) { } }