a library for laser printer based on https://os.mbed.com/users/xmwmx/code/wmx_laser_copy/
Dependents: Example_for_learning_easy
laser.h@2:35089485bc89, 2018-10-16 (annotated)
- Committer:
- Dennis_Yu
- Date:
- Tue Oct 16 07:40:46 2018 +0000
- Revision:
- 2:35089485bc89
- Parent:
- 1:9cfdf3c372b5
all function added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dennis_Yu | 2:35089485bc89 | 1 | #pragma once |
Dennis_Yu | 0:5e881997f4b5 | 2 | #ifndef LASER_H |
Dennis_Yu | 0:5e881997f4b5 | 3 | #define LASER_H |
Dennis_Yu | 0:5e881997f4b5 | 4 | |
Dennis_Yu | 0:5e881997f4b5 | 5 | #include "mbed.h" |
Dennis_Yu | 0:5e881997f4b5 | 6 | #include <math.h> |
Dennis_Yu | 0:5e881997f4b5 | 7 | #include <cstring> |
Dennis_Yu | 0:5e881997f4b5 | 8 | #include <stdlib.h> |
Dennis_Yu | 0:5e881997f4b5 | 9 | #include "SDFileSystem.h" |
Dennis_Yu | 0:5e881997f4b5 | 10 | #include "esp8266.h" |
Dennis_Yu | 0:5e881997f4b5 | 11 | |
Dennis_Yu | 1:9cfdf3c372b5 | 12 | extern Serial ser2usb; |
Dennis_Yu | 0:5e881997f4b5 | 13 | |
Dennis_Yu | 2:35089485bc89 | 14 | //步进电机 |
Dennis_Yu | 2:35089485bc89 | 15 | DigitalOut step[2] = {DigitalOut(PC_5), DigitalOut(PA_5)}; //0--x P9,1--y P17 |
Dennis_Yu | 2:35089485bc89 | 16 | DigitalOut dir[2] = {DigitalOut(PC_4), DigitalOut(PA_4)}; //0--x,1--y |
Dennis_Yu | 2:35089485bc89 | 17 | DigitalOut en[2] = {DigitalOut(PD_2), DigitalOut(PA_2)}; //0--x,1--y |
Dennis_Yu | 2:35089485bc89 | 18 | |
Dennis_Yu | 1:9cfdf3c372b5 | 19 | class laser |
Dennis_Yu | 1:9cfdf3c372b5 | 20 | { |
Dennis_Yu | 1:9cfdf3c372b5 | 21 | public: |
Dennis_Yu | 2:35089485bc89 | 22 | laser(Esp8266 & iClient, SDFileSystem & iSD); |
Dennis_Yu | 2:35089485bc89 | 23 | void draw(); |
Dennis_Yu | 1:9cfdf3c372b5 | 24 | private: |
Dennis_Yu | 1:9cfdf3c372b5 | 25 | Esp8266 & client; |
Dennis_Yu | 2:35089485bc89 | 26 | SDFileSystem & sd; |
Dennis_Yu | 2:35089485bc89 | 27 | |
Dennis_Yu | 2:35089485bc89 | 28 | void moveto(float x, float y); |
Dennis_Yu | 2:35089485bc89 | 29 | void rotate(int id ,int pix); |
Dennis_Yu | 2:35089485bc89 | 30 | void markdot(float value); |
Dennis_Yu | 2:35089485bc89 | 31 | |
Dennis_Yu | 2:35089485bc89 | 32 | //电子开关,激光开关 |
Dennis_Yu | 2:35089485bc89 | 33 | DigitalOut switch_GS; |
Dennis_Yu | 2:35089485bc89 | 34 | //行程开关 |
Dennis_Yu | 2:35089485bc89 | 35 | DigitalIn switch_pos1; //P25 |
Dennis_Yu | 2:35089485bc89 | 36 | DigitalIn switch_pos2; //P26 |
Dennis_Yu | 2:35089485bc89 | 37 | DigitalIn switch_pos3; //P27 |
Dennis_Yu | 2:35089485bc89 | 38 | |
Dennis_Yu | 2:35089485bc89 | 39 | //运行中的全局变量 |
Dennis_Yu | 2:35089485bc89 | 40 | volatile bool Working, Getawork, Isend, Dataused, Getdata; |
Dennis_Yu | 2:35089485bc89 | 41 | FILE *fp_drawing; // 存储图案的文件 |
Dennis_Yu | 2:35089485bc89 | 42 | int status; //0: 初始化; 1:建立通信; 2:等候任务; 3:等待数据 4:正在执行一个任务 |
Dennis_Yu | 2:35089485bc89 | 43 | int now_x, now_y; |
Dennis_Yu | 2:35089485bc89 | 44 | int Endoffile; |
Dennis_Yu | 2:35089485bc89 | 45 | |
Dennis_Yu | 2:35089485bc89 | 46 | // float thedata[50][3]; |
Dennis_Yu | 2:35089485bc89 | 47 | // char sdata[1024]; |
Dennis_Yu | 2:35089485bc89 | 48 | int Nofdata; |
Dennis_Yu | 2:35089485bc89 | 49 | bool ifreceive; |
Dennis_Yu | 2:35089485bc89 | 50 | |
Dennis_Yu | 2:35089485bc89 | 51 | //与实际有关参数 |
Dennis_Yu | 2:35089485bc89 | 52 | float Lenoflattice ;//mm 取1mm为xy单元 unit_xy/Lenoflattice=100 |
Dennis_Yu | 2:35089485bc89 | 53 | int unit_xy; //单位长度(xy移动一格)对应unit_xy转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step |
Dennis_Yu | 2:35089485bc89 | 54 | int unit_x; //单位长度(xy移动一格)对应unit_x转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step |
Dennis_Yu | 2:35089485bc89 | 55 | int unit_y; //单位长度(xy移动一格)对应unit_y转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step |
Dennis_Yu | 2:35089485bc89 | 56 | ///Ticker ticker_step; |
Dennis_Yu | 2:35089485bc89 | 57 | float step_halfperiod;//0.0002; |
Dennis_Yu | 2:35089485bc89 | 58 | int max_x, max_y; |
Dennis_Yu | 2:35089485bc89 | 59 | int dir_x;///调试时调整 |
Dennis_Yu | 2:35089485bc89 | 60 | int dir_y;///调试时调整 |
Dennis_Yu | 2:35089485bc89 | 61 | int dot_max; //灰度最大值对应多少次激光点击 |
Dennis_Yu | 2:35089485bc89 | 62 | float dot_last; //每次激光点击持续多久 |
Dennis_Yu | 2:35089485bc89 | 63 | int H_max; //灰度值最大值 |
Dennis_Yu | 2:35089485bc89 | 64 | double k; //缩放比例 |
Dennis_Yu | 2:35089485bc89 | 65 | double y;//图片y边长 |
Dennis_Yu | 2:35089485bc89 | 66 | double x;//图片x边长 |
Dennis_Yu | 2:35089485bc89 | 67 | int key;//判断变量 |
Dennis_Yu | 2:35089485bc89 | 68 | int dot;//点计数 |
Dennis_Yu | 2:35089485bc89 | 69 | int flag; |
Dennis_Yu | 2:35089485bc89 | 70 | int numbers[100][3]; |
Dennis_Yu | 2:35089485bc89 | 71 | //char buf[100]; |
Dennis_Yu | 1:9cfdf3c372b5 | 72 | }; |
Dennis_Yu | 0:5e881997f4b5 | 73 | |
Dennis_Yu | 2:35089485bc89 | 74 | |
Dennis_Yu | 0:5e881997f4b5 | 75 | #endif |