Laser_SD_W5500
Dependencies: MQTT SDFileSystem WIZnet_Library mbed
Fork of EthW5500 by
Diff: main.cpp
- Revision:
- 5:48c44bebe8fb
- Parent:
- 4:ae6f380a5b41
--- a/main.cpp Sun Jul 22 15:53:24 2018 +0000 +++ b/main.cpp Mon Jul 23 04:23:25 2018 +0000 @@ -103,61 +103,37 @@ void moveto(float x, float y) { - rotate(0, (x - now_x)*unit_xy); + rotate(0, (x - now_x)*unit_xy); //电机旋转 rotate(1, (y - now_y)*unit_xy); now_x = x; now_y = y; } -void fuwei() -{ - moveto(0, 0); - status = 1; -} void markdot(float value) { //switch_GS=1; int Ndot = floor(value * dot_max / H_max); for (int i = 0; i < Ndot; i++) { - switch_GS = 1; - wait(dot_last); - switch_GS = 0; + switch_GS = 1; // 开激光 + wait(dot_last); // 等待 + switch_GS = 0; // 关激光 } } -/* -void dealdata(){ - ser2usb.printf("getdata: %s \r\n",sdata); - int data_size = 0;//strlen(pch); - char * pch; - pch = strtok (sdata,"\r\n ,.-)("); - while (pch != NULL) - { - thedata[data_size/3][data_size%3]=atof(pch); - pch = strtok (NULL, "\r\n ,.-)("); - data_size++; - } - Nofdata = (data_size)/3; -} -void usbprintdata(){ - ser2usb.printf("dealdata: \r\n <<<<<<<<<<<<<<<<"); - for(int i=0;i<Nofdata;i++){ - ser2usb.printf("<<< i: %i x: %f y: %f v: %f \r\n",i,thedata[i][0],thedata[i][1],thedata[i][2]); - } - ser2usb.printf("dealdata done! \r\n >>>>>>>>>>>>"); -} -*/ void draw() { float x, y, v; - fp_drawing = fopen("/sd/write.txt", "r"); + fp_drawing = fopen("/sd/write.txt", "r"); // 打开文件 for (int i = 0; fscanf(fp_drawing, "(%f,%f,%f)", &x, &y, &v) == 3; i++) { pc.printf("(%f,%f,%f)\r\n", x, y, v); - moveto(x, y); - markdot(v); - // moveto(thedata[i][0],thedata[i][1]); - // markdot(thedata[i][2]); + moveto(x, y); // 移动到坐标位置 + markdot(v); // 打点 } - fclose(fp_drawing); + fclose(fp_drawing); // 关闭文件 +} +void fuwei() +{ + moveto(0, 0); + status = 1; } void on_control_cmd(const char* actuator_name, const char* control_value) @@ -241,10 +217,10 @@ pc.printf("Drawing.. \r\n"); // usbprintdata(); draw(); + pc.printf("Finished\r\n"); publish_value(client, "report", "done."); status = 2; } client.yield(1000); } - }