Skip to content

Commit

Permalink
update build-CI (#3)
Browse files Browse the repository at this point in the history
* update build-CI, update readme.md (badges)
  • Loading branch information
RobTillaart authored Oct 19, 2021
1 parent 1b26669 commit bd06823
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 28 deletions.
7 changes: 6 additions & 1 deletion .arduino-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
# - due
# - zero
- leonardo

# - m4
# - esp32
# - esp8266
- mega2560
10 changes: 7 additions & 3 deletions .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]

jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/[email protected]
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb
15 changes: 9 additions & 6 deletions AsyncAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
// https://www.avrfreaks.net/forum/tut-c-newbies-guide-avr-adc?name=PNphpBB2&file=viewtopic&t=56429
//
// HISTORY:
// 0.1.0 2018-09-05 initial version, based upon analogRead()
// 0.1.1 2020-03-26 minor refactor
// 0.1.2 2020-05-27 update library.json
// 0.1.3 2020-12-12 added Arduino CI, minor fixes
// 0.1.0 2018-09-05 initial version, based upon analogRead()
// 0.1.1 2020-03-26 minor refactor
// 0.1.2 2020-05-27 update library.json
// 0.1.3 2020-12-12 added Arduino CI, minor fixes
// 0.1.4 2020-12-12 update Arduino CI, minor fixes


#include "AsyncAnalog.h"
Expand All @@ -29,6 +30,7 @@ AsyncAnalog::AsyncAnalog(const uint8_t pin)
#endif
}


void AsyncAnalog::start()
{
#if defined(ADCSRB) && defined(MUX5)
Expand All @@ -38,7 +40,7 @@ void AsyncAnalog::start()
#endif

#if defined(ADMUX)
// set the analog reference (high two bits of ADMUX) and select the
// set the analogue reference (high two bits of ADMUX) and select the
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
// to 0 (the default).
ADMUX = (DEFAULT << 6) | (_pin & 0x07);
Expand Down Expand Up @@ -69,4 +71,5 @@ int AsyncAnalog::value()

#endif // ARDUINO_ARCH_AVR

// -- END OF FILE --

// -- END OF FILE --
10 changes: 6 additions & 4 deletions AsyncAnalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
//
// FILE: AsyncAnalog.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// VERSION: 0.1.4
// DATE: 2018-09-05
// PURPOSE: async version of analogRead
// PURPOSE: async version of analogRead for AVR
// URL: https://github.com/RobTillaart/AsyncAnalog
//


#if !defined(ARDUINO_ARCH_AVR)

#error “AsyncAnalog library 0.1.3 only supports boards with an AVR processor .”
Expand All @@ -21,12 +22,13 @@
#include "wiring_private.h"
#include "pins_arduino.h"

#define ASYNCANALOG_LIB_VERSION "0.1.3"
#define ASYNCANALOG_LIB_VERSION (F("0.1.4"))


class AsyncAnalog
{
public:
AsyncAnalog(uint8_t pin);
AsyncAnalog(const uint8_t pin);

void start();
bool ready();
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@

[![Arduino CI](https://github.com/RobTillaart/AsyncAnalog/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/AsyncAnalog/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AsyncAnalog/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/AsyncAnalog/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AsyncAnalog/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AsyncAnalog/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AsyncAnalog.svg?maxAge=3600)](https://github.com/RobTillaart/AsyncAnalog/releases)


# AsyncAnalog

Arduino Library for async reading of an analog pin. **\[AVR ONLY\]**
Arduino Library for async reading of an analogue pin. **\[AVR ONLY\]**


## Description
AsyncAnalog is a library to read the analog port in an asynchronous way.

AsyncAnalog is a library to read the analogue port of an AVR in an asynchronous way.
This means that the user must explicitly **start** the ADC, check if it is **ready**
and read out its **value**.

Expand All @@ -18,25 +22,30 @@ By using this class, the user prevents the (~112 uSec) blocking of the

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

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

## Interface

- **AsyncAnalog(uint8_t pin)** constructor, defines the analog pin to use.

The library consists of three main function:
## Interface

- **AsyncAnalog(uint8_t pin)** constructor, defines the analogue pin to use.
- **void start()** triggers a new ADC reading.
- **bool ready()** returns true if sample is complete
- **int value()** returns the value


## Operation

The example **asyncAnalogTest2.ino** shows a loop of 1000 analogReads and prints
over Serial at 115200 baud. The async test does this in less time. Note that faster
baudrates shows an even bigger difference.
baud rates shows an even bigger difference.

During the printing, the sampling continues.


## Future

- investigate other platforms
- fall back to normal analogRead for non AVR platforms ?
-

6 changes: 5 additions & 1 deletion examples/asyncAnalogTest/asyncAnalogTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
// VERSION: 0.1.1
// DATE: 2018-09-05


#include "AsyncAnalog.h"


AsyncAnalog AA(A0);

uint32_t start = 0;
Expand All @@ -22,6 +24,7 @@ void setup()
start = micros();
}


void loop()
{

Expand All @@ -48,4 +51,5 @@ void loop()
count++;
}

// END OF FILE

// -- END OF FILE --
5 changes: 4 additions & 1 deletion examples/asyncAnalogTest2/asyncAnalogTest2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
// VERSION: 0.1.0
// DATE: 2020-03-27


#include "AsyncAnalog.h"


AsyncAnalog AA(A0);

uint32_t start = 0;
Expand Down Expand Up @@ -70,4 +72,5 @@ void async_test()
Serial.print("\n\n");
}

// END OF FILE

// -- END OF FILE --
4 changes: 2 additions & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Syntax Coloring Map For AsyncAnalog
# Syntax Colouring Map For AsyncAnalog

# Datatypes (KEYWORD1)
# Data types (KEYWORD1)
AsyncAnalog KEYWORD1


Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/AsyncAnalog.git"
},
"version": "0.1.3",
"version": "0.1.4",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AsyncAnalog
version=0.1.3
version=0.1.4
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino Library for async reading of an analog pin
Expand Down
6 changes: 6 additions & 0 deletions test/unit_test_001.cpp_no_valid_test
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,30 @@
// assertFalse(actual)
// assertNull(actual)


#include <ArduinoUnitTests.h>

#include "Arduino.h"
#include "AsyncAnalog.h"


unittest_setup()
{
}


unittest_teardown()
{
}


unittest(test_none)
{
fprintf(stderr, "ASYNCANALOG_LIB_VERSION: %s\n", (char *) ASYNCANALOG_LIB_VERSION);
fprintf(stderr, "no unit test defined as library is HW specific");
}


unittest_main()

// --------

0 comments on commit bd06823

Please sign in to comment.