-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
800 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
platforms: | ||
rpipico: | ||
board: rp2040:rp2040:rpipico | ||
package: rp2040:rp2040 | ||
gcc: | ||
features: | ||
defines: | ||
- ARDUINO_ARCH_RP2040 | ||
warnings: | ||
flags: | ||
|
||
packages: | ||
rp2040:rp2040: | ||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json | ||
|
||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
# selected only those that work | ||
platforms: | ||
- uno | ||
# - due | ||
# - zero | ||
# - leonardo | ||
# - m4 | ||
# - esp32 | ||
# - esp8266 | ||
# - mega2560 | ||
- rpipico | ||
|
||
libraries: | ||
- "Servo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
github: RobTillaart | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
name: Arduino-lint | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update | ||
compliance: strict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Arduino CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
runTest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
- run: | | ||
gem install arduino_ci | ||
arduino_ci.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: JSON check | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.json' | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: json-syntax-check | ||
uses: limitusus/json-syntax-check@v1 | ||
with: | ||
pattern: "\\.json$" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Change Log PERIPUMP | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
|
||
## [0.1.0] - 2022-10-13 | ||
|
||
- initial version | ||
- add stop(), get- and setpercentage() | ||
- add getSeconds(), resetSeconds() for simple duration management. | ||
- low percentages < 50% do not work. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// FILE: PERIPUMP.cpp | ||
// AUTHOR: Rob Tillaart | ||
// VERSION: 0.1.0 | ||
// DATE: 2022-10-13 | ||
// PURPOSE: Arduino library for peristaltic pump | ||
|
||
|
||
#include "PERIPUMP.h" | ||
|
||
|
||
// CONSTRUCTOR | ||
PERIPUMP::PERIPUMP(uint8_t pumpPin) | ||
{ | ||
_pin = pumpPin; | ||
_percentage = 0; | ||
_sumTime = 0; | ||
} | ||
|
||
|
||
void PERIPUMP::begin() | ||
{ | ||
_myServo.attach(_pin); | ||
stop(); | ||
resetRunTime(); | ||
} | ||
|
||
|
||
void PERIPUMP::stop() | ||
{ | ||
_myServo.writeMicroseconds(1500); | ||
if (_start != 0) | ||
{ | ||
_sumTime += (millis() - _start); | ||
_start = 0; | ||
} | ||
} | ||
|
||
|
||
void PERIPUMP::setPercentage(float percentage) | ||
{ | ||
// weighted runtime ? | ||
// _sumTime += (millis() - _start) * abs(_percentage); | ||
_percentage = constrain(percentage, -100, 100); | ||
|
||
uint16_t ms = 0; | ||
if (_percentage == 0) | ||
{ | ||
ms = 1500; | ||
if (_start != 0) | ||
{ | ||
_sumTime += (millis() - _start); | ||
_start = 0; | ||
} | ||
} | ||
else if (_percentage > 0) | ||
{ | ||
// 1600 - 2500 | ||
ms = 1600 + 9 * _percentage; // 9 == 900 / 100% | ||
if (_start == 0) _start = millis(); | ||
} | ||
else if (_percentage < 0) | ||
{ | ||
// 500 - 1400 | ||
ms = 1400 + 9 * _percentage; | ||
if (_start == 0) _start = millis(); | ||
} | ||
_myServo.writeMicroseconds(ms); | ||
} | ||
|
||
|
||
float PERIPUMP::getPercentage() | ||
{ | ||
return _percentage; | ||
} | ||
|
||
|
||
////////////////////////////////////////////////////// | ||
// | ||
// DURATION | ||
// | ||
float PERIPUMP::getRunTime() | ||
{ | ||
float seconds = _sumTime; | ||
if (_start != 0) seconds += (millis() - _start); | ||
return seconds * 0.001; | ||
} | ||
|
||
|
||
float PERIPUMP::resetRunTime() | ||
{ | ||
float s = getRunTime(); | ||
_sumTime = 0; | ||
_start = 0; | ||
return s; | ||
} | ||
|
||
|
||
// -- END OF FILE -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
// | ||
// FILE: PERIPUMP.h | ||
// AUTHOR: Rob Tillaart | ||
// VERSION: 0.1.0 | ||
// DATE: 2022-10-13 | ||
// PURPOSE: Arduino library for peristaltic pump | ||
// | ||
// Tested with dfrobot peristaltic pump DFR0523 | ||
// | ||
|
||
|
||
#include "Arduino.h" | ||
#include "Servo.h" | ||
|
||
#define PERIPUMP_LIB_VERSION (F("0.1.0")) | ||
|
||
|
||
class PERIPUMP | ||
{ | ||
public: | ||
PERIPUMP(uint8_t pumpPin); | ||
|
||
void begin(); | ||
|
||
////////////////////////////////////////////////////// | ||
// | ||
// RUNNING | ||
// | ||
void stop(); | ||
void setPercentage(float percentage); | ||
float getPercentage(); | ||
|
||
////////////////////////////////////////////////////// | ||
// | ||
// 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; | ||
}; | ||
|
||
|
||
// -- END OF FILE -- | ||
|
Oops, something went wrong.