User | Revision | Line number | New contents of line |
daan |
0:01be2d5eaf72
|
1
|
#ifndef OL_VECTOR_H
|
daan |
0:01be2d5eaf72
|
2
|
#define OL_VECTOR_H
|
daan |
0:01be2d5eaf72
|
3
|
|
daan |
0:01be2d5eaf72
|
4
|
#include "stdint.h"
|
daan |
0:01be2d5eaf72
|
5
|
|
daan |
0:01be2d5eaf72
|
6
|
namespace olc {
|
daan |
0:01be2d5eaf72
|
7
|
|
daan |
0:01be2d5eaf72
|
8
|
#define OL_DEVICE_RECEIVING_PORT 3000
|
daan |
0:01be2d5eaf72
|
9
|
#define OL_DEVICE_SENDING_PORT 3001
|
daan |
0:01be2d5eaf72
|
10
|
|
daan |
0:01be2d5eaf72
|
11
|
|
daan |
0:01be2d5eaf72
|
12
|
|
daan |
0:01be2d5eaf72
|
13
|
|
daan |
0:01be2d5eaf72
|
14
|
/**
|
daan |
0:01be2d5eaf72
|
15
|
* the protocol so far.
|
daan |
0:01be2d5eaf72
|
16
|
*
|
daan |
0:01be2d5eaf72
|
17
|
* it is packet based. packets should not be longer than 1024 bytes due to hardware
|
daan |
0:01be2d5eaf72
|
18
|
* restrictions. We assume udp should be error free enough being the only device on the
|
daan |
0:01be2d5eaf72
|
19
|
* cable.
|
daan |
0:01be2d5eaf72
|
20
|
|
daan |
0:01be2d5eaf72
|
21
|
* MOVE_TO move mirrors to position x,y
|
daan |
0:01be2d5eaf72
|
22
|
* LINE_TO move mirrors to position x,y and laser on
|
daan |
0:01be2d5eaf72
|
23
|
* these commands are 5 bytes long (uint8 opcode, uint16 x, uint16 y)
|
daan |
0:01be2d5eaf72
|
24
|
|
daan |
0:01be2d5eaf72
|
25
|
* H_MOVE_TO move mirror horizontaly to position x
|
daan |
0:01be2d5eaf72
|
26
|
* use imagination for V_MOVE_TO, H_LINE_TO, V_LINE_TO
|
daan |
0:01be2d5eaf72
|
27
|
* these commands are 3 bytes long (uint8 opcode, uint16 l)
|
daan |
0:01be2d5eaf72
|
28
|
|
daan |
0:01be2d5eaf72
|
29
|
* LASER_POWER sets the laser intensity (uint8 opcode, uint16 power)
|
daan |
0:01be2d5eaf72
|
30
|
* we can extend if we need color.
|
daan |
0:01be2d5eaf72
|
31
|
|
daan |
0:01be2d5eaf72
|
32
|
* (not implemented) FAST_MODE (uint8) Sets the laser in fast mode.
|
daan |
0:01be2d5eaf72
|
33
|
in fast mode, the motion commands will be set, and the galvo goes to the new position
|
daan |
0:01be2d5eaf72
|
34
|
as fast as possible.
|
daan |
0:01be2d5eaf72
|
35
|
// i guess we should have a precise timing parameters.
|
daan |
0:01be2d5eaf72
|
36
|
|
daan |
0:01be2d5eaf72
|
37
|
----- slow speed ------
|
daan |
0:01be2d5eaf72
|
38
|
* (not implemented) SLOW_MODE (uint8 opcode) (default) Sets the laser in slow mode.
|
daan |
0:01be2d5eaf72
|
39
|
in slow mode means that we go step for step over each pixel with a line raster algorithm.
|
daan |
0:01be2d5eaf72
|
40
|
|
daan |
0:01be2d5eaf72
|
41
|
|
daan |
0:01be2d5eaf72
|
42
|
* STEP_SIZE (uint8 opcode, uint16 size) sets the galvo step size when drawing lines.
|
daan |
0:01be2d5eaf72
|
43
|
using cheap optics and a short throw the laser spot size is probably a few orders of
|
daan |
0:01be2d5eaf72
|
44
|
maginitude larger than the theoretical step size of the galvo. This parameter allows
|
daan |
0:01be2d5eaf72
|
45
|
you to control the step size when going slow.
|
daan |
0:01be2d5eaf72
|
46
|
|
daan |
0:01be2d5eaf72
|
47
|
* STEP_DELAY (uint8 opcode, uint16 delay) sets an optional delay when drawing each pixels.
|
daan |
0:01be2d5eaf72
|
48
|
this is sometimes neccesairy for extra illumination of the surface.
|
daan |
0:01be2d5eaf72
|
49
|
*/
|
daan |
0:01be2d5eaf72
|
50
|
|
daan |
0:01be2d5eaf72
|
51
|
// bit 7 (128) means pen_down
|
daan |
0:01be2d5eaf72
|
52
|
//
|
daan |
0:01be2d5eaf72
|
53
|
// laser_power r,g,b
|
daan |
0:01be2d5eaf72
|
54
|
|
daan |
0:01be2d5eaf72
|
55
|
|
daan |
0:01be2d5eaf72
|
56
|
enum PathCommands {
|
daan |
0:01be2d5eaf72
|
57
|
E_STOP = 0, // 1 uint8 opcode
|
daan |
0:01be2d5eaf72
|
58
|
PEN_DOWN = 128,
|
daan |
0:01be2d5eaf72
|
59
|
|
daan |
0:01be2d5eaf72
|
60
|
MOVE_TO = 1, // 5 uint8 opcode, uint16 x, uint16 y
|
daan |
0:01be2d5eaf72
|
61
|
H_MOVE_TO = 2, // 3 uint8 opcode, uint16 x
|
daan |
0:01be2d5eaf72
|
62
|
V_MOVE_TO = 3, // 3 uint8 opcode, uint16 y
|
daan |
0:01be2d5eaf72
|
63
|
|
daan |
0:01be2d5eaf72
|
64
|
STEP_SIZE = 10, // 3 uint8 opcode, uint16 step_size
|
daan |
0:01be2d5eaf72
|
65
|
STEP_DELAY = 11, // 3 uint8 opcode, uint16 step_delay
|
daan |
0:01be2d5eaf72
|
66
|
|
daan |
0:01be2d5eaf72
|
67
|
PEN_UP = 15, // 1 uint8 opcode
|
daan |
0:01be2d5eaf72
|
68
|
READY = 16, // 1 uint8 opcode
|
daan |
0:01be2d5eaf72
|
69
|
SCAN = 17, // 1 uint8 opcode uint16 top_x, uint16 left_y, uint16 bottom_x, uint16 right_y
|
daan |
0:01be2d5eaf72
|
70
|
POINT = 18, // 1 unit8 opcode uint16 x, uint16 y
|
daan |
0:01be2d5eaf72
|
71
|
|
daan |
0:01be2d5eaf72
|
72
|
AYT = 19, // 1 uint8 opcode :::: ARE YOU THERE
|
daan |
0:01be2d5eaf72
|
73
|
|
daan |
0:01be2d5eaf72
|
74
|
MESSAGE = 20, // 3+x uint8 opcode, level, length, x bytes
|
daan |
0:01be2d5eaf72
|
75
|
BUFFER_LEFT_REPORT = 21, // opcode, uint16_t
|
daan |
0:01be2d5eaf72
|
76
|
WAIT = 22, // opcode,
|
daan |
0:01be2d5eaf72
|
77
|
|
daan |
0:01be2d5eaf72
|
78
|
|
daan |
0:01be2d5eaf72
|
79
|
LINE_TO = PEN_DOWN + MOVE_TO, // 5 uint8 opcode, uint16 x, uint16 y
|
daan |
0:01be2d5eaf72
|
80
|
H_LINE_TO = PEN_DOWN + H_MOVE_TO, // 3 uint8 opcode, uint16 x
|
daan |
0:01be2d5eaf72
|
81
|
V_LINE_TO = PEN_DOWN + H_MOVE_TO, // 3 uint8 opcode, uint16 y
|
daan |
0:01be2d5eaf72
|
82
|
|
daan |
0:01be2d5eaf72
|
83
|
LASER_POWER = 100, // 3 uint8 opcode, uint16 power
|
daan |
0:01be2d5eaf72
|
84
|
LASER_POWER_RGB = 101, // 7 uint8 opcode, 3x uint16 power r,g,b
|
daan |
0:01be2d5eaf72
|
85
|
|
daan |
0:01be2d5eaf72
|
86
|
// writing bitmaps. horizontally. based on step_size.
|
daan |
0:01be2d5eaf72
|
87
|
BITMAPU8 = 150, // variable uint8 opcode, uint8 size, max 256 uint8 power
|
daan |
0:01be2d5eaf72
|
88
|
// BITMAP16_RGB = 151, // 49 uint8 opcode, 16 x 3 x uint8 power r,g,b
|
daan |
0:01be2d5eaf72
|
89
|
|
daan |
0:01be2d5eaf72
|
90
|
NOTHING = 255
|
daan |
0:01be2d5eaf72
|
91
|
};
|
daan |
0:01be2d5eaf72
|
92
|
|
daan |
0:01be2d5eaf72
|
93
|
}; // end namespace
|
daan |
0:01be2d5eaf72
|
94
|
|
daan |
0:01be2d5eaf72
|
95
|
#endif
|
daan |
0:01be2d5eaf72
|
96
|
|