Skip to content

Commit 15d8f7e

Browse files
authored
Arduino ci (#1)
* initial arduino-ci ==> **no** unit test as lib is too HW specific
1 parent 54c31c8 commit 15d8f7e

File tree

9 files changed

+118
-25
lines changed

9 files changed

+118
-25
lines changed

.arduino-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
compile:
2+
# Choosing to run compilation tests on 2 different Arduino platforms
3+
platforms:
4+
- uno
5+
- leonardo
6+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
arduino_ci:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: Arduino-CI/action@master
13+
# Arduino-CI/action@v0.1.1

AsyncAnalog.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
//
22
// FILE: AsyncAnalog.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.2
4+
// VERSION: 0.1.3
55
// DATE: 2018-09-05
66
// PURPOSE: async version of analogRead, prevent blocking wait
77
//
88
// backgrounder
99
// https://www.avrfreaks.net/forum/tut-c-newbies-guide-avr-adc?name=PNphpBB2&file=viewtopic&t=56429
1010
//
1111
// HISTORY:
12-
// 0.1.0 2018-09-05 initial version, based upon analogRead()
13-
// 0.1.1 2020-03-26 minor refactor
14-
// 0.1.2 2020-05-27 update library.json
15-
//
12+
// 0.1.0 2018-09-05 initial version, based upon analogRead()
13+
// 0.1.1 2020-03-26 minor refactor
14+
// 0.1.2 2020-05-27 update library.json
15+
// 0.1.3 2020-12-12 added Arduino CI, minor fixes
1616

17-
#include "AsyncAnalog.h"
1817

18+
#include "AsyncAnalog.h"
1919

2020
#if defined(ARDUINO_ARCH_AVR)
2121

2222
AsyncAnalog::AsyncAnalog(const uint8_t pin)
2323
{
24-
_pin = pin;
24+
_pin = pin;
2525
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
2626
if (_pin >= 54) _pin -= 54;
2727
#else
@@ -67,6 +67,6 @@ int AsyncAnalog::value()
6767
return (high << 8) | low;
6868
}
6969

70-
#endif // ARDUINO_ARCH_AVR
70+
#endif // ARDUINO_ARCH_AVR
7171

7272
// -- END OF FILE --

AsyncAnalog.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,40 @@
22
//
33
// FILE: AsyncAnalog.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.2
5+
// VERSION: 0.1.3
66
// DATE: 2018-09-05
77
// PURPOSE: async version of analogRead
88
// URL: https://github.com/RobTillaart/AsyncAnalog
99
//
1010

1111
#if !defined(ARDUINO_ARCH_AVR)
12-
#error “AsyncAnalog library 0.1.2 only supports boards with an AVR processor .”
13-
#endif
12+
13+
#error “AsyncAnalog library 0.1.3 only supports boards with an AVR processor .”
14+
15+
#else
16+
1417
// (ARDUINO_ARCH_SAM) future
1518

1619

1720
#include "Arduino.h"
1821
#include "wiring_private.h"
1922
#include "pins_arduino.h"
2023

21-
#define ASYNCANALOG_LIB_VERSION "0.1.2"
24+
#define ASYNCANALOG_LIB_VERSION "0.1.3"
2225

2326
class AsyncAnalog
2427
{
2528
public:
26-
AsyncAnalog(uint8_t pin);
29+
AsyncAnalog(uint8_t pin);
2730

28-
void start();
29-
bool ready();
30-
int value();
31+
void start();
32+
bool ready();
33+
int value();
3134

3235
private:
33-
uint8_t _pin;
36+
uint8_t _pin;
3437
};
3538

39+
#endif
40+
3641
// -- END OF FILE --

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
[![Arduino CI](https://github.com/RobTillaart/AsyncAnalog/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AsyncAnalog/blob/master/LICENSE)
4+
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AsyncAnalog.svg?maxAge=3600)](https://github.com/RobTillaart/AsyncAnalog/releases)
5+
16
# AsyncAnalog
27

38
Arduino Library for async reading of an analog pin. **\[AVR ONLY\]**
@@ -8,23 +13,30 @@ AsyncAnalog is a library to read the analog port in an asynchronous way.
813
This means that the user must explicitly **start** the ADC, check if it is **ready**
914
and read out its **value**.
1015

11-
By using this class, the user prevents the (112 uSec) blocking of the
16+
By using this class, the user prevents the (~112 uSec) blocking of the
1217
**analogRead()** call, and gives the user the ability to do some processing.
1318

1419
The library works only for AVR boards now, other platforms might be supported in the future.
1520

1621
As the UNO has only one ADC that is multiplexed, one can only read one analog pin
1722
in async way simultaneously.
1823

19-
## Operation
24+
## Interface
25+
26+
- **AsyncAnalog(uint8_t pin)** constructor, defines the analog pin to use.
27+
2028
The library consists of three main function:
2129

22-
* **void start()**
23-
* **bool ready()**
24-
* **int value()**
30+
- **void start()** triggers a new ADC reading.
31+
- **bool ready()** returns true if sample is complete
32+
- **int value()** returns the value
33+
34+
## Operation
2535

2636
The example **asyncAnalogTest2.ino** shows a loop of 1000 analogReads and prints
2737
over Serial at 115200 baud. The async test does this in less time. Note that faster
28-
baudrates shows an even bigger difference.
38+
baudrates shows an even bigger difference.
39+
40+
During the printing, the sampling continues.
2941

3042

keywords.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Syntax Coloring Map For AsyncAnalog
2+
3+
# Datatypes (KEYWORD1)
4+
AsyncAnalog KEYWORD1
5+
6+
7+
# Methods and Functions (KEYWORD2)
8+
start KEYWORD2
9+
ready KEYWORD2
10+
value KEYWORD2
11+
12+
13+
# Constants (LITERAL1)
14+
ASYNCANALOG_LIB_VERSION LITERAL1
15+

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/AsyncAnalog.git"
1717
},
18-
"version":"0.1.2",
18+
"version":"0.1.3",
1919
"frameworks": "arduino",
2020
"platforms": "*"
2121
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AsyncAnalog
2-
version=0.1.2
2+
version=0.1.3
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino Library for async reading of an analog pin
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// FILE: unit_test_001.cpp
3+
// AUTHOR: Rob Tillaart
4+
// DATE: 2020-12-12
5+
// PURPOSE: unit tests for the AsyncAnalog
6+
// https://github.com/RobTillaart/AsyncAnalog
7+
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
8+
//
9+
10+
// supported assertions
11+
// ----------------------------
12+
// assertEqual(expected, actual)
13+
// assertNotEqual(expected, actual)
14+
// assertLess(expected, actual)
15+
// assertMore(expected, actual)
16+
// assertLessOrEqual(expected, actual)
17+
// assertMoreOrEqual(expected, actual)
18+
// assertTrue(actual)
19+
// assertFalse(actual)
20+
// assertNull(actual)
21+
22+
#include <ArduinoUnitTests.h>
23+
24+
#include "Arduino.h"
25+
#include "AsyncAnalog.h"
26+
27+
unittest_setup()
28+
{
29+
}
30+
31+
unittest_teardown()
32+
{
33+
}
34+
35+
unittest(test_none)
36+
{
37+
fprintf(stderr, "no unit test defined as library is HW specific");
38+
}
39+
40+
unittest_main()
41+
42+
// --------

0 commit comments

Comments
 (0)