mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.4 AsyncAnalog
This commit is contained in:
parent
89504e50a4
commit
9ec1d36573
@ -2,5 +2,10 @@ compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
- leonardo
|
||||
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
- mega2560
|
@ -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/action@v0.1.1
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -13,6 +13,7 @@
|
||||
// 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"
|
||||
@ -29,6 +30,7 @@ AsyncAnalog::AsyncAnalog(const uint8_t pin)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void AsyncAnalog::start()
|
||||
{
|
||||
#if defined(ADCSRB) && defined(MUX5)
|
||||
@ -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);
|
||||
@ -69,4 +71,5 @@ int AsyncAnalog::value()
|
||||
|
||||
#endif // ARDUINO_ARCH_AVR
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -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 .”
|
||||
@ -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();
|
||||
|
@ -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**.
|
||||
|
||||
@ -18,19 +22,18 @@ 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:
|
||||
|
||||
- **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
|
||||
@ -40,3 +43,9 @@ baudrates shows an even bigger difference.
|
||||
During the printing, the sampling continues.
|
||||
|
||||
|
||||
## Future
|
||||
|
||||
- investigate other platforms
|
||||
- fall back to normal analogRead for non AVR platforms ?
|
||||
-
|
||||
|
||||
|
@ -4,8 +4,10 @@
|
||||
// VERSION: 0.1.1
|
||||
// DATE: 2018-09-05
|
||||
|
||||
|
||||
#include "AsyncAnalog.h"
|
||||
|
||||
|
||||
AsyncAnalog AA(A0);
|
||||
|
||||
uint32_t start = 0;
|
||||
@ -22,6 +24,7 @@ void setup()
|
||||
start = micros();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
@ -48,4 +51,5 @@ void loop()
|
||||
count++;
|
||||
}
|
||||
|
||||
// END OF FILE
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -4,8 +4,10 @@
|
||||
// VERSION: 0.1.0
|
||||
// DATE: 2020-03-27
|
||||
|
||||
|
||||
#include "AsyncAnalog.h"
|
||||
|
||||
|
||||
AsyncAnalog AA(A0);
|
||||
|
||||
uint32_t start = 0;
|
||||
@ -70,4 +72,5 @@ void async_test()
|
||||
Serial.print("\n\n");
|
||||
}
|
||||
|
||||
// END OF FILE
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Syntax Coloring Map For AsyncAnalog
|
||||
# Syntax Colouring Map For AsyncAnalog
|
||||
|
||||
# Data types (KEYWORD1)
|
||||
AsyncAnalog KEYWORD1
|
||||
|
@ -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": "*"
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AsyncAnalog
|
||||
version=0.1.3
|
||||
version=0.1.4
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino Library for async reading of an analog pin
|
||||
|
@ -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()
|
||||
|
||||
// --------
|
||||
|
Loading…
Reference in New Issue
Block a user