-
Notifications
You must be signed in to change notification settings - Fork 1
API
PlotterController has following architecture:
+---+--------------------+
| 5 | Client program |
+---+------+------+------+
| 4 | Text | HPGL | |
+---+------+------+ |
| 3 | Graph |
+---+--------------------+
| 2 | Printer |
+---+---------+------+---+
| 1 | Parport | GPIO |...|
+---+---------+------+---+
API is split between following four parts:
- Printer
- Graph
- Text
- HPGL
Printer layer supports basic commands related to particular plotter like
printer initialization, information about current pen location and so on.
Prototypes can be found in printer.h file.
For printer instance creation use follofing function. Function pr_create_printer returns PRINTER handle.
PRINTER *pr_create_printer(interface_t i, char *param)Examples of usage in different systems:
- In Linux
pr_create_printer(PARPORT, "/dev/parport0") - In FreeBSD
pr_create_printer(PARPORT, "/dev/ppi0") - In DOS
pr_create_printer(PARPORT, "0x378") - In RPi v1
pr_create_printer(GPIO, "1") - In RPi v2
pr_create_printer(GPIO, "2")
At the end of work you should release and close printer.
void pr_close_printer(PRINTER *p);The first operation you should call after you get printer handle is to call printer initialization. It will look for paper origin and setup all internal values.
void pr_init(PRINTER *p);Sometime you can need to know maximal supporting size of drawing area. In this case you can call pr_get_max_position.
POSITION pr_get_max_position(PRINTER *p)This function returns max x and y drawing size in POSITION structure.
typedef struct {
int x;
int y;
} POSITION;If you need to find current position you can call pr_get_current_position.
POSITION pr_get_current_position(PRINTER *p)Sometime you can need to move origin position [0,0] to somewhere inside drawing area. In this case you will use pr_set_origin_position.
void pr_set_origin_position(PRINTER *p, int x, int y)If you will need to learn where origin position is currently placed then you will call pr_get_origin_position.
POSITION pr_get_origin_position(PRINTER *p)To set pen position you can call pr_set_moving_buffer. This function set moving buffer, but pen will not move physicaly until you don't call some drawing function.
void pr_set_moving_buffer(PRINTER *p, int x, int y)To learn current drawing buffer you can call pr_get_moving_buffer function.
POSITION pr_get_moving_buffer(PRINTER *p)To set drawing velocity you can call pr_set_velocity function. Velocity can be from 0 to 9. Default value is 8.
void pr_set_velocity(PRINTER *p, int v)To move pen down and up you can call pr_pen function.
void pr_pen(PRINTER *p, value_pen_t value);Value is UP or DOWN.
typedef enum {
UP = 0,
DOWN = 1
} value_pen_t;To move you can call pr_move function but this is very low-level function and you should prefer drawing functions from graph, text or hpgl section.
void pr_move(PRINTER *p, value_xy_t xy, value_direction_t direction, int repeat);Graphics layer supports basic drawing commands. Prototypes can be found in
graph.h file.
Text layer supports basic text drawing commands. Prototypes can be found in
text.h file.
PlotterController also supports basic HPGL commands. Prototypes can be found in
hpgl.h file.