-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add arduino-ci * add unittest - not 100% OK, issue made * improve readme.md
- Loading branch information
1 parent
5da7057
commit 8c44680
Showing
8 changed files
with
238 additions
and
49 deletions.
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,7 @@ | ||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
platforms: | ||
- uno | ||
- leonardo | ||
- due | ||
- zero |
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 CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
arduino_ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Arduino-CI/action@master | ||
# Arduino-CI/[email protected] |
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=ACS712 | ||
version=0.2.0 | ||
version=0.2.1 | ||
author=Rob Tillaart <[email protected]>, Pete Thompson <[email protected]> | ||
maintainer=Rob Tillaart <[email protected]> | ||
sentence=ACS712 library for Arduino. | ||
|
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,126 @@ | ||
// | ||
// FILE: unit_test_001.cpp | ||
// AUTHOR: Rob Tillaart | ||
// VERSION: 0.1.0 | ||
// DATE: 2020-12-06 | ||
// PURPOSE: unit tests for the SHT31 temperature and humidity sensor | ||
// https://github.com/RobTillaart/SHT31 | ||
// https://www.adafruit.com/product/2857 | ||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md | ||
// | ||
|
||
// supported assertions | ||
// ---------------------------- | ||
// assertEqual(expected, actual) | ||
// assertNotEqual(expected, actual) | ||
// assertLess(expected, actual) | ||
// assertMore(expected, actual) | ||
// assertLessOrEqual(expected, actual) | ||
// assertMoreOrEqual(expected, actual) | ||
// assertTrue(actual) | ||
// assertFalse(actual) | ||
// assertNull(actual) | ||
|
||
#include <ArduinoUnitTests.h> | ||
|
||
#include "Arduino.h" | ||
#include "ACS712.h" | ||
|
||
#define A0 0 | ||
|
||
unittest_setup() | ||
{ | ||
} | ||
|
||
unittest_teardown() | ||
{ | ||
} | ||
|
||
|
||
unittest(test_mA) | ||
{ | ||
ACS712 ACS(A0, 5.0, 1023, 100); // analogPin, volts, maxADC, mVperA | ||
|
||
/* | ||
float maac50 = ACS.mA_AC(50); | ||
assertEqual(0, maac50); | ||
float maac60 = ACS.mA_AC(60); | ||
assertEqual(0, maac60); | ||
float madc = ACS.mA_DC(); | ||
assertEqual(0, madc); | ||
*/ | ||
} | ||
|
||
unittest(test_midPoint) | ||
{ | ||
ACS712 ACS(A0, 5.0, 1023, 100); // analogPin, volts, maxADC, mVperA | ||
|
||
/* | ||
ACS.autoMidPoint(50); | ||
float amp50 = ACS.getMidPoint(); | ||
assertEqual(0, amp50); | ||
ACS.autoMidPoint(60); | ||
float amp60 = ACS.getMidPoint(); | ||
assertEqual(0, amp60); | ||
*/ | ||
|
||
ACS.setMidPoint(1000); | ||
float amp = ACS.getMidPoint(); | ||
assertEqual(1000, amp); | ||
|
||
ACS.incMidPoint(); | ||
amp = ACS.getMidPoint(); | ||
assertEqual(1001, amp); | ||
|
||
ACS.decMidPoint(); | ||
amp = ACS.getMidPoint(); | ||
assertEqual(1000, amp); | ||
} | ||
|
||
unittest(test_formFactor) | ||
{ | ||
ACS712 ACS(A0, 5.0, 1023, 100); | ||
|
||
// default 0.5 * sqrt(2) | ||
float ff = ACS.getFormFactor(); | ||
float eff = 0.5 * sqrt(2); | ||
float delta = abs(eff - ff); | ||
assertMoreOrEqual(0.0001, delta); | ||
|
||
ACS.setFormFactor(0.8); | ||
ff = ACS.getFormFactor(); | ||
eff = 0.8; | ||
delta = abs(eff - ff); | ||
assertMoreOrEqual(0.0001, delta); | ||
} | ||
|
||
unittest(test_Noise) | ||
{ | ||
ACS712 ACS(A0, 5.0, 1023, 100); | ||
|
||
int nmv = ACS.getNoisemV(); | ||
assertEqual(21, nmv); // default value.. | ||
|
||
ACS.setNoisemV(100); | ||
nmv = ACS.getNoisemV(); | ||
assertEqual(100, nmv); | ||
} | ||
|
||
unittest(test_mVperAmp) | ||
{ | ||
ACS712 ACS(A0, 5.0, 1023, 100); | ||
|
||
int mpa = ACS.getmVperAmp(); | ||
assertEqual(100, mpa); // default value.. | ||
|
||
ACS.setmVperAmp(50); | ||
mpa = ACS.getmVperAmp(); | ||
assertEqual(50, mpa); | ||
} | ||
|
||
unittest_main() | ||
|
||
// -------- |