voor Arne
Dependencies: ESP8266Interface FXAS21002 FXOS8700 Hexi_OLED_SSD1351
Fork of Hexi_Magneto-v2_Example by
Diff: main.cpp
- Revision:
- 2:3c1fe1657db9
- Parent:
- 1:31908216b9ac
- Child:
- 3:e259f976e1fc
--- a/main.cpp Fri Dec 02 15:06:06 2016 +0000 +++ b/main.cpp Mon Dec 05 15:36:53 2016 +0000 @@ -3,16 +3,20 @@ #include "Hexi_OLED_SSD1351.h" #include "images.h" #include "string.h" +#include "ESP8266Interface.h" // Pin connections DigitalOut led1(LED_GREEN); // RGB LED +DigitalOut led2(PTA12); // RGB LED + + DigitalOut PWD(PTB2); DigitalOut G15(PTB11); -Serial pc(USBTX, USBRX); // Serial interface -Serial wifi(PTD3, PTD2); +//Serial pc(USBTX, USBRX); // Serial interface +//RawSerial wifi(PTD3, PTD2); FXOS8700 mag(PTC11, PTC10); SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); // SSD1351 OLED Driver (MOSI,SCLK,POWER,CS,RST,DC) @@ -25,69 +29,41 @@ char text2[20]; // Text Buffer for dynamic value displayed char text3[20]; // Text Buffer for dynamic value displayed + +//void Rx_interrupt(); +//void read_line(); + + +// Circular buffers for serial TX and RX data - used by interrupt routines +const int buffer_size = 255; +// might need to increase buffer size for high baud rates +char rx_buffer[buffer_size+1]; +// Circular buffer pointers +// volatile makes read-modify-write atomic +volatile int rx_in=0; +volatile int rx_out=0; +// Line buffers for sprintf and sscanf +char tx_line[80]; +char rx_line[80]; + +ESP8266Interface wifi(PTD3,PTD2,PTD11,"MINI","kplaetevoet",9600); // TX,RX,Reset,SSID,Password,Baud + int main() { + + /* wifi3 board reset etc */ PWD = 1; G15 = 0; /*Wifi initialisation commands */ - - wifi.baud(9600); - //wifi.format(8,"None",1); - Thread::wait(1000); - - printf("cmd -> AT\n"); - - while (!pc.readable()) - { - } - - - //wifi.printf("AT/n"); - wifi.printf("AT%c%c",0x0d,0x0A); - -Thread::wait(1000); - //char c; - //char buffer[128]; - - printf("cmd -> AT+GMR\n"); - - - wifi.printf("AT+GMR%c%c",0x0d,0x0A); - - Thread::wait(1000); - - printf("cmd -> AT+ CIPSTATUS\n"); + wifi.init(); //Reset + printf("init done"); + wifi.connect(); + wifi.getIPAddress(); - wifi.printf("AT+CIPSTATUS%c%c",0x0d,0x0A); - - - while(1) { - - //printf("send AT"); - //wifi.printf("AT/0x0D/0x0A"); - //wait(0.5); werkt niet - - if(pc.readable()) { - wifi.putc(pc.getc()); - - } - if(wifi.readable()) { - pc.putc(wifi.getc()); + //ebsocket ws("ws://192.168.1.20:8888/ws"); - } - } - - // c = wifi.getc(); - - //wifi.gets(buffer, 4); - - //pc.printf("I got '%c' and '%s'\n", c, buffer); - - // - - - /* end wifi */ + // Configure Accelerometer FXOS8700, Magnetometer FXOS8700 mag.mag_config(); @@ -161,4 +137,11 @@ led1 = !led1; Thread::wait(250); } -} \ No newline at end of file +} + + + + + + +