Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Jan 15, 2024
1 parent c7dccc6 commit 06ae576
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ACS712.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ float ACS712::mA_DC(uint16_t cycles)
value = (value + _analogRead(_pin))/2;
}
// for RTOS
if (i % 2 == 1) yield();
if ((i & 0x0001) == 0x0001) // every 2nd iteration
{
yield();
}
sum += (value - _midPoint);
}
float mA = sum * _mAPerStep;
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.3.9] - 2024-01-11
- add yield() in multiple reads to better support RTOS
- update readme.md (empty compatibility table)
- add yield() to improve the behaviour under RTOS
- update readme.md (add compatibility table).
- minor edits


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ This function is intended for signals with unknown Form Factor.
- **float mA_DC(uint16_t samples = 1)** blocks < 1 ms (Arduino UNO) as it calls **analogRead()** twice.
A negative value indicates the current flows in the opposite direction.
- 0.2.8 the parameter samples allow to average over a number of samples.
- 0.3.9 calls yield() every 3 analogRead's to support RTOS (a bit).
- 0.3.9 calls yield() every 2nd iteration to improve behaviour under RTOS.


#### mA_AC_sampling performance trick.
Expand Down

0 comments on commit 06ae576

Please sign in to comment.