daniel saakes / Olc
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VectorFormat.h Source File

VectorFormat.h

00001 #ifndef OLC_VECTOR_H
00002 #define OLC_VECTOR_H
00003 
00004 #include "stdint.h"
00005 
00006 namespace olc {
00007   
00008 #define OLC_DEVICE_RECEIVING_PORT 3000
00009 #define OLC_DEVICE_SENDING_PORT 3001  
00010   
00011   /**
00012    *   the protocol so far.
00013    *
00014    *   it is packet based. packets should not be longer than 1024 bytes due to hardware
00015    *   restrictions. We assume udp should be error free enough being the only device on the
00016    *   cable.
00017    
00018    *   MOVE_TO  move mirrors to position x,y
00019    *   LINE_TO  move mirrors to position x,y and laser on
00020    *   these commands are 5 bytes long  (uint8 opcode, uint16 x, uint16 y)
00021    
00022    *   H_MOVE_TO move mirror horizontaly to position x
00023    *   use imagination for V_MOVE_TO, H_LINE_TO, V_LINE_TO
00024    *   these commands are 3 bytes long (uint8 opcode, uint16 l)
00025    
00026    *   LASER_POWER sets the laser intensity (uint8 opcode, uint16 power)
00027    *   we can extend if we need color.
00028    
00029    *   (not implemented) FAST_MODE (uint8) Sets the laser in fast mode.
00030    in fast mode, the motion commands will be set, and the galvo goes to the new position
00031    as fast as possible.
00032    // i guess we should have a precise timing parameters.
00033    
00034    ----- slow speed ------
00035    *   (not implemented) SLOW_MODE (uint8 opcode) (default) Sets the laser in slow mode.
00036    in slow mode means that we go step for step over each pixel with a line raster algorithm.
00037    
00038    
00039    *   STEP_SIZE (uint8 opcode, uint16 size) sets the galvo step size when drawing lines.
00040    using cheap optics and a short throw the laser spot size is probably a few orders of
00041    maginitude larger than the theoretical step size of the galvo. This parameter allows
00042    you to control the step size when going slow.
00043    
00044    *   STEP_DELAY (uint8 opcode, uint16 delay) sets an optional delay when drawing each pixels.
00045    this is sometimes neccesairy for extra illumination of the surface.
00046    */
00047   
00048   // bit 7 (128) means pen_down
00049   // 
00050   // laser_power r,g,b
00051   
00052   
00053   enum PathCommands {
00054     E_STOP = 0,         // 1 uint8 opcode
00055     PEN_DOWN = 128,     // 1 uint8 opcode
00056 
00057     
00058     MOVE_TO   = 1,     // 5 uint8 opcode, uint16 x, uint16 y
00059     H_MOVE_TO = 2,     // 3 uint8 opcode, uint16 x
00060     V_MOVE_TO = 3,     // 3 uint8 opcode, uint16 y
00061     
00062     STEP_SIZE   = 10,   // 3 uint8 opcode, uint16 step_size
00063     STEP_DELAY  = 11,    // 3 uint8 opcode, uint16 step_delay
00064 
00065     PEN_UP = 15,     // 1 uint8 opcode
00066     READY = 16,      // 1 uint8 opcode
00067     
00068     CALIBRATION_SCAN = 17, // 1 uint8 opcode uint16 top_x, uint16 left_y, uint16 bottom_x, uint16 right_y
00069     POINT = 18, // 1 unit8 opcode uint16 x, uint16 y
00070     
00071     READ_COLOR = 19, // 1 uint8 opcode uint8
00072     
00073     MESSAGE = 20, // 3+x uint8 opcode, level, length of message, x bytes
00074     BUFFER_LEFT_REPORT = 21, // opcode, uint16_t
00075     WAIT = 22, // opcode, uint16t time
00076     AYT = 23, // are you there
00077         
00078     REPORT_COLOR = 25, // 1 + 3 x uint8    
00079 
00080         
00081     REPORT_BUFFER_IN_SIZE = 26,   // 1 + uint16 size
00082     BUFFER_IN_SIZE = 27,         // 1 
00083 
00084     ACK = 30,
00085     NACK = 31,
00086         
00087     LINE_TO   = PEN_DOWN + MOVE_TO,   // 5 uint8 opcode, uint16 x, uint16 y
00088     H_LINE_TO = PEN_DOWN + H_MOVE_TO, // 3 uint8 opcode, uint16 x
00089     V_LINE_TO = PEN_DOWN + H_MOVE_TO, // 3 uint8 opcode, uint16 y
00090     
00091     LASER_POWER = 100,        // 3 uint8 opcode, uint16 power
00092     LASER_POWER_RGB = 101,    // 4 uint8 opcode, 3x uint8 power r,g,b
00093     
00094     // writing bitmaps. horizontally. based on step_size.   
00095     BITMAPU8 = 150,     // variable uint8 opcode, uint8 size, max 256 uint8 power
00096     //  BITMAP16_RGB = 151, // 49 uint8 opcode, 16 x 3 x uint8 power r,g,b
00097     
00098     NOTHING = 255
00099   };
00100   
00101 }; // end namespace
00102 
00103 #endif