51 lines
1 KiB
C++
51 lines
1 KiB
C++
// plotter.h
|
|
|
|
#ifndef _PLOTTER_h
|
|
#define _PLOTTER_h
|
|
|
|
#include<util/delay.h>
|
|
#include "writepin.h"
|
|
#include "point.h"
|
|
#include "pwm.h"
|
|
#include "writepin.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "serial.h"
|
|
|
|
class Plotter
|
|
{
|
|
private:
|
|
Pwm16b _pwm;
|
|
Point currentPos = {0, 0};
|
|
|
|
uint16_t _prevDiamondAngle = 60000;
|
|
uint16_t _prevSteps = 10;
|
|
|
|
volatile unsigned char *_penPort;
|
|
char _penPin;
|
|
|
|
Serial* _serial;
|
|
|
|
bool highPrecision=false;
|
|
|
|
uint16_t diamondAngle(int16_t y, int16_t x);
|
|
uint16_t calculateDelayTime(uint16_t currentDiamondAngle, uint16_t prevDiamondAngle, uint16_t prevSteps);
|
|
|
|
|
|
public:
|
|
Plotter(volatile unsigned char *penPort, const char penPin, Serial* serial);
|
|
void demo();
|
|
void basicposition();
|
|
void pd();
|
|
void pu();
|
|
void setHighPrecision(bool in);
|
|
void moveto(Point *pt);
|
|
void moveto(uint16_t nx,uint16_t ny);
|
|
void moveRelative(int32_t deltaX, int32_t deltaY);
|
|
Point getCurrentPos();
|
|
};
|
|
|
|
|
|
#endif
|
|
|