
Just a test
Dependencies: BSP_DISCO_F769NI LCD_DISCO_F769NI lcd_log esp8266-driver
Fork of mbed-os-example-blinky-5 by
Revision 3:7c7587c666e1, committed 2017-05-28
- Comitter:
- joschaihl
- Date:
- Sun May 28 11:16:16 2017 +0000
- Parent:
- 2:6a613cb4b302
- Child:
- 4:7876f757c6e8
- Commit message:
- Records events on other targets
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F769NI.lib Sun May 28 11:16:16 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/ST/code/LCD_DISCO_F769NI/#fd7c63b20d54
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd_log.lib Sun May 28 11:16:16 2017 +0000 @@ -0,0 +1,1 @@ +lcd_log#a9366f354506
--- a/main.cpp Sun May 28 04:03:18 2017 +0000 +++ b/main.cpp Sun May 28 11:16:16 2017 +0000 @@ -1,31 +1,51 @@ +#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 "stm32f769i_discovery_audio.h" - -#include <string> // std::string -#include <iostream> // std::cout, std::ostream, std::hex -#include <sstream> // std::stringbuf +#include "EthernetInterface.h" +#include "TCPServer.h" +#include "TCPSocket.h" +#include "LCD_DISCO_F769NI.h" +#include "lcd_log.h" +#include <iostream> using namespace std; -TS_StateTypeDef TS_State = {0}; - +#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 uc(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) { - if(pc.readable()) { - uc.putc(pc.getc()); - } - if(uc.readable()) { - pc.putc(uc.getc()); - } + Thread::wait(1000); + printf("Hallo Welt!!!\n"); } } @@ -33,149 +53,123 @@ while(true) { Thread::wait(200); led1 = !led1; - pc.printf("Hallo LEDS\r\n"); } } -void gui_thread() { +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; - BSP_LCD_Init(); - BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); - + TS_StateTypeDef state; /* Touchscreen initialization */ if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) { printf("BSP_TS_Init error\n"); } - - /* Clear the LCD */ - BSP_LCD_Clear(LCD_COLOR_WHITE); - - /* Set Touchscreen Demo1 description */ - BSP_LCD_SetTextColor(LCD_COLOR_BLUE); - BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40); - BSP_LCD_SetTextColor(LCD_COLOR_WHITE); - BSP_LCD_SetBackColor(LCD_COLOR_BLUE); - BSP_LCD_SetFont(&Font24); - BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Touchscreen basic example", CENTER_MODE); - while (1) { - BSP_TS_GetState(&TS_State); - if(TS_State.touchDetected) { + // 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\r\n", x1, y1); - stringbuf touchstr; - std::ostream os (&touchstr); - os << "Touch detected x=" << x1 << ", y"; // + y1; - //string touchStr = - BSP_LCD_DisplayStringAt(0, 2, (uint8_t *) touchstr.str().c_str(), LEFT_MODE); + // 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); - Thread::wait(10); - } + 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()); + } +} - const uint16_t BSIZE = 10000; - uint16_t buf[BSIZE]; - - +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); -void audio_thread(Thread *thisThread) -{ - for(int i = 0; i < BSIZE; i++) { - // buf[i] = i*2; - } - /* const uint32_t SCRATCH_BUFF_SIZE = 128; - const uint32_t RECORD_BUFFER_SIZE = 512; - - typedef enum { - BUFFER_OFFSET_NONE = 0, - BUFFER_OFFSET_HALF = 1, - BUFFER_OFFSET_FULL = 2, - } BUFFER_StateTypeDef; -*/ - //olatile uint32_t audio_rec_buffer_state = BUFFER_OFFSET_NONE; - //int32_t Scratch[SCRATCH_BUFF_SIZE]; - /* Buffer containing the PCM samples coming from the microphone */ - //int16_t RecordBuffer[RECORD_BUFFER_SIZE]; - /* Buffer used to stream the recorded PCM samples towards the audio codec. */ - - // uint32_t audio_loop_back_init = RESET ; - - pc.printf("Stacksize audiothread = %d\r\n", thisThread->stack_size()); - pc.printf("Stacksize audiothread max = %d\r\n", thisThread->max_stack()); - printf("\n\nAUDIO LOOPBACK EXAMPLE FOR DISCO-F769NI START:\n"); - - BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE, 100, AUDIO_FREQUENCY_48K); - - BSP_AUDIO_OUT_Play(buf, BSIZE); while(1) { - + } - // const REAL_TIME_FREQUENCY = 220; -//const ANGULAR_FREQUENCY = REAL_TIME_FREQUENCY * 2 * Math.PI; - - /* Initialize Audio Recorder with 4 channels to be used */ - /* if (BSP_AUDIO_IN_AllocScratch(Scratch, SCRATCH_BUFF_SIZE) == AUDIO_OK) { - printf("Scratch allokiert mit %d\r\n", SCRATCH_BUFF_SIZE); - if(BSP_AUDIO_IN_Record(RecordBuffer, RECORD_BUFFER_SIZE)==AUDIO_OK) { - printf("RecordBuffer initialisiert\r\n"); - if(BSP_AUDIO_IN_Init(BSP_AUDIO_FREQUENCY_44K, 16, 1) == AUDIO_OK ) { - printf("BSP_AUDIO_IN_AllocScratch\n"); - - while (1) { - - } - } - } - }*/ } - -int main() -{ - pc.baud(115200); - pc.printf("\f*** Joscha ***\r\n"); - - - - - //pc.printf("\tCreating printthread...\n"); - //Thread printThread(print_thread, NULL, osPriorityRealtime ); - - //pc.printf("\tCreating ledthread...\r\n"); - //Thread ledThrea - - - - - - /* pc.printf("\tCreating ledthread...\n"); - Thread ledThread(osPriorityRealtime); - ledThread.start(&led_thread);*/ - - - - /* pc.printf("\tCreating guithread...\n"); - Thread guiThread(osPriorityHigh); - guiThread.start(&gui_thread);*/ - - pc.printf("\tCreating audiothread...\r\n"); - Thread audioThread(osPriorityRealtime); - audioThread.start(&audio_thread, &audioThread); - - - - - while(true) { - } - - -}