2022-10-14 14:14:47 -04:00
|
|
|
#pragma once
|
|
|
|
//
|
|
|
|
// FILE: PERIPUMP.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2022-10-15 09:38:12 -04:00
|
|
|
// VERSION: 0.1.1
|
2022-10-14 14:14:47 -04:00
|
|
|
// DATE: 2022-10-13
|
|
|
|
// PURPOSE: Arduino library for peristaltic pump
|
|
|
|
//
|
|
|
|
// Tested with dfrobot peristaltic pump DFR0523
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include "Servo.h"
|
|
|
|
|
2022-10-15 09:38:12 -04:00
|
|
|
#define PERIPUMP_LIB_VERSION (F("0.1.1"))
|
2022-10-14 14:14:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
class PERIPUMP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PERIPUMP(uint8_t pumpPin);
|
|
|
|
|
2022-10-15 09:38:12 -04:00
|
|
|
void begin(float percentage = 0);
|
2022-10-14 14:14:47 -04:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// RUNNING
|
|
|
|
//
|
|
|
|
void stop();
|
2022-10-15 09:38:12 -04:00
|
|
|
// For 100% speed
|
|
|
|
void forward();
|
|
|
|
void backward();
|
|
|
|
// Fine tuning speed
|
2022-10-14 14:14:47 -04:00
|
|
|
void setPercentage(float percentage);
|
|
|
|
float getPercentage();
|
|
|
|
|
2022-10-15 09:38:12 -04:00
|
|
|
// EXPERIMENTAL / TEST
|
|
|
|
// flag to swap forward and backward in software if needed.
|
|
|
|
// easier than doing it hardware way
|
|
|
|
void setInvert(bool flag = false);
|
|
|
|
bool getInvert();
|
|
|
|
|
2022-10-14 14:14:47 -04:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// DURATION
|
|
|
|
//
|
|
|
|
float getRunTime(); // total seconds running since last reset / start.
|
|
|
|
float resetRunTime();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t _pin;
|
|
|
|
float _percentage;
|
|
|
|
Servo _myServo;
|
|
|
|
uint32_t _sumTime = 0;
|
|
|
|
uint32_t _start = 0;
|
2022-10-15 09:38:12 -04:00
|
|
|
bool _invert = false;
|
2022-10-14 14:14:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|
|
|
|
|