Skip to content

Commit

Permalink
update readme.md (#5)
Browse files Browse the repository at this point in the history
- update readme.md (badges)
- add changelog.md
- minor edits
  • Loading branch information
RobTillaart authored Oct 17, 2023
1 parent 902c872 commit 1247671
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 38 deletions.
38 changes: 15 additions & 23 deletions AsyncAnalog.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
//
// FILE: AsyncAnalog.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.5
// VERSION: 0.1.6
// DATE: 2018-09-05
// PURPOSE: async version of analogRead, prevent blocking wait
//
// backgrounder
// 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.4 2020-12-12 update Arduino CI, minor fixes
// 0.1.5 2021-12-13 update library.json, license, readme
// PURPOSE: Async version of analogRead, prevent blocking wait
// URL: https://github.com/RobTillaart/AsyncAnalog


#include "AsyncAnalog.h"


#if defined(ARDUINO_ARCH_AVR)

AsyncAnalog::AsyncAnalog(const uint8_t pin)
Expand Down Expand Up @@ -60,17 +51,18 @@ bool AsyncAnalog::ready()

int AsyncAnalog::value()
{
// we have to read ADCL first; doing so locks both ADCL
// and ADCH until ADCH is read. reading ADCL second would
// cause the results of each conversion to be discarded,
// as ADCL and ADCH would be locked when it completed.
int low = ADCL;
int high = ADCH;
// combine the two bytes
return (high << 8) | low;
// ADCL has to be read first.
// Doing so locks both ADCL and ADCH until ADCH is read.
// Reading ADCL second would cause the results of each conversion to
// be discarded as ADCL and ADCH would be locked when it completed.
uint16_t lo = ADCL;
uint16_t hi = ADCH;
// Combine two parts.
// _lastValue = (hi * 256) + lo;
return (hi * 256) + lo;
}

#endif // ARDUINO_ARCH_AVR
#endif // ARDUINO_ARCH_AVR


// -- END OF FILE --
// -- END OF FILE --
19 changes: 11 additions & 8 deletions AsyncAnalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
//
// FILE: AsyncAnalog.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.5
// VERSION: 0.1.6
// DATE: 2018-09-05
// PURPOSE: async version of analogRead for AVR
// PURPOSE: Async version of analogRead for AVR
// URL: https://github.com/RobTillaart/AsyncAnalog
//


#if !defined(ARDUINO_ARCH_AVR)

#error “AsyncAnalog library only supports boards with an AVR processor .”

#else

// (ARDUINO_ARCH_SAM) future
// (ARDUINO_ARCH_ESP32) future
// (ARDUINO_ARCH_ESP8266) future


#include "Arduino.h"
#include "wiring_private.h"
#include "pins_arduino.h"

#define ASYNCANALOG_LIB_VERSION (F("0.1.5"))
#define ASYNCANALOG_LIB_VERSION (F("0.1.6"))


class AsyncAnalog
Expand All @@ -35,9 +36,11 @@ class AsyncAnalog
int value();

private:
uint8_t _pin;
uint8_t _pin;
// uint16_t _lastValue;
};

#endif
#endif // defined(ARDUINO_ARCH_AVR)


// -- END OF FILE --
// -- END OF FILE --
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Change Log AsyncAnalog

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.6] - 2023-10-17
- update readme.md
- add changelog.md
- minor edits


## [0.1.5] - 2021-12-13
- update library.json
- update license
- update readme.md

## [0.1.4] - 2020-12-12
- update Arduino CI
- minor fixes

## [0.1.3] - 2020-12-12
- added Arduino CI
- minor fixes

## [0.1.2] - 2020-05-27
- update library.json

## [0.1.1] - 2020-03-26
- minor refactor

## [0.1.0] - 2018-09-05
- initial version, based upon analogRead()

33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[![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)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/AsyncAnalog.svg)](https://github.com/RobTillaart/AsyncAnalog/issues)

[![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)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/AsyncAnalog.svg)](https://registry.platformio.org/libraries/robtillaart/AsyncAnalog)


# AsyncAnalog
Expand All @@ -13,7 +16,7 @@ Arduino Library for async reading of an analogue pin. **\[AVR ONLY\]**.

## Description

AsyncAnalog is a library to read the analogue port of an AVR 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 @@ -22,13 +25,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.

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

**Use with care**


## Interface
## Interface

```cpp
#include "AsynAnalog,h"
```

- **AsyncAnalog(uint8_t pin)** constructor, defines the analogue pin to use.
- **void start()** triggers a new ADC reading.
Expand All @@ -44,12 +52,29 @@ over Serial at 115200 baud.

## Future

#### Must

#### Should

- improve documentation.

#### Could

- investigate the performance gain.
- asyncAnalogTest2.ino is no good test.
- asyncAnalogTest2.ino is not a good test.
- create examples
- real world examples preferred.
- investigate other platforms
- fall back to normal analogRead for non AVR platforms ?
-
- better have specific code per platform.

#### Wont

## Support

If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.

Thank you,

4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/AsyncAnalog.git"
},
"version": "0.1.5",
"version": "0.1.6",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "AsyncAnalog.h"
}
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.5
version=0.1.6
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino Library for async reading of an analog pin
Expand Down

0 comments on commit 1247671

Please sign in to comment.