mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.0 A1301
This commit is contained in:
parent
bfed88b7a0
commit
01e4b45636
28
libraries/A1301/.arduino-ci.yml
Normal file
28
libraries/A1301/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
- esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
4
libraries/A1301/.github/FUNDING.yml
vendored
Normal file
4
libraries/A1301/.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: RobTillaart
|
||||
|
13
libraries/A1301/.github/workflows/arduino-lint.yml
vendored
Normal file
13
libraries/A1301/.github/workflows/arduino-lint.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
name: Arduino-lint
|
||||
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
compliance: strict
|
17
libraries/A1301/.github/workflows/arduino_test_runner.yml
vendored
Normal file
17
libraries/A1301/.github/workflows/arduino_test_runner.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Arduino CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
18
libraries/A1301/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/A1301/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
151
libraries/A1301/A1301.cpp
Normal file
151
libraries/A1301/A1301.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
//
|
||||
// FILE: A1301.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// DATE: 2010-07-22
|
||||
// PURPOSE: Arduino library for A1301 A1302 magnetometer.
|
||||
|
||||
|
||||
#include "A1301.h"
|
||||
|
||||
|
||||
HALL::HALL(uint8_t pin)
|
||||
{
|
||||
_pin = pin;
|
||||
_midPoint = 512;
|
||||
_lastGauss = 0;
|
||||
_mVGauss = 2.5;
|
||||
_mVStep = 5000.0 / 1023; // default 10 bit 5V ADC
|
||||
}
|
||||
|
||||
|
||||
void HALL::begin(float voltage, uint16_t steps)
|
||||
{
|
||||
_mVStep = voltage / steps;
|
||||
}
|
||||
|
||||
|
||||
void HALL::setMidPoint(float midPoint)
|
||||
{
|
||||
_midPoint = midPoint;
|
||||
}
|
||||
|
||||
|
||||
float HALL::getMidPoint()
|
||||
{
|
||||
return _midPoint;
|
||||
}
|
||||
|
||||
|
||||
void HALL::setSensitivity(float sensitivity)
|
||||
{
|
||||
_mVGauss = sensitivity;
|
||||
}
|
||||
|
||||
|
||||
float HALL::getSensitivity()
|
||||
{
|
||||
return _mVGauss;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// READ
|
||||
//
|
||||
float HALL::raw(uint8_t times)
|
||||
{
|
||||
float sum = 0;
|
||||
if (times == 0) times = 1;
|
||||
for (int i = 0; i < times; i++)
|
||||
{
|
||||
sum += analogRead(_pin);
|
||||
}
|
||||
if (times > 1) sum /= times;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
float HALL::read(uint8_t times)
|
||||
{
|
||||
float milliVolts = (raw(times) - _midPoint) * _mVStep;
|
||||
_prevGauss = _lastGauss;
|
||||
_lastGauss = milliVolts / _mVGauss;
|
||||
return _lastGauss;
|
||||
}
|
||||
|
||||
|
||||
float HALL::readExt(float raw)
|
||||
{
|
||||
float milliVolts = (raw - _midPoint) * _mVStep;
|
||||
_prevGauss = _lastGauss;
|
||||
_lastGauss = milliVolts / _mVGauss;
|
||||
return _lastGauss;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ANALYSE
|
||||
//
|
||||
boolean HALL::isNorth()
|
||||
{
|
||||
return (_lastGauss > 0);
|
||||
}
|
||||
|
||||
|
||||
boolean HALL::isSouth()
|
||||
{
|
||||
return (_lastGauss < 0);
|
||||
}
|
||||
|
||||
|
||||
float HALL::lastGauss()
|
||||
{
|
||||
return _lastGauss;
|
||||
}
|
||||
|
||||
|
||||
float HALL::prevGauss()
|
||||
{
|
||||
return _prevGauss;
|
||||
}
|
||||
|
||||
|
||||
// CONVERTORs
|
||||
float HALL::Tesla(float Gauss)
|
||||
{
|
||||
return Gauss * 0.0001;
|
||||
}
|
||||
|
||||
|
||||
float HALL::mTesla(float Gauss)
|
||||
{
|
||||
return Gauss * 0.1;
|
||||
}
|
||||
|
||||
|
||||
float HALL::uTesla(float Gauss)
|
||||
{
|
||||
return Gauss * 100;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DERIVED
|
||||
//
|
||||
A1301::A1301(uint8_t pin) : HALL(pin)
|
||||
{
|
||||
_mVGauss = 2.5;
|
||||
}
|
||||
|
||||
|
||||
A1302::A1302(uint8_t pin) : HALL(pin)
|
||||
{
|
||||
_mVGauss = 1.3;
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
85
libraries/A1301/A1301.h
Normal file
85
libraries/A1301/A1301.h
Normal file
@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
//
|
||||
// FILE: A1301.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// DATE: 2010-07-22
|
||||
// PURPOSE: Arduino library for A1301 A1302 magnetometer.
|
||||
|
||||
// always check datasheet.
|
||||
// PIN A1301
|
||||
// ===============
|
||||
// 1 GND
|
||||
// 2 DATA
|
||||
// 3 VDD +5V
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#define A1301_LIB_VERSION (F("0.1.0"))
|
||||
|
||||
|
||||
class HALL
|
||||
{
|
||||
public:
|
||||
HALL(uint8_t pin);
|
||||
|
||||
// ADC parameters
|
||||
void begin(float voltage, uint16_t steps);
|
||||
|
||||
// midpoint depends on ADC.
|
||||
void setMidPoint(float midPoint);
|
||||
float getMidPoint();
|
||||
// to overrule default sensitivity
|
||||
void setSensitivity(float sensitivity);
|
||||
float getSensitivity();
|
||||
|
||||
|
||||
// READ
|
||||
// times > 1 ==> more stable read / averaging.
|
||||
// uses internal ADC
|
||||
float raw(uint8_t times = 1); // return Gauss
|
||||
float read(uint8_t times = 1); // return Gauss
|
||||
// for external ADC
|
||||
float readExt(float raw);
|
||||
|
||||
// ANALYSE
|
||||
boolean isNorth();
|
||||
boolean isSouth();
|
||||
float lastGauss();
|
||||
float prevGauss();
|
||||
// CONVERTERs
|
||||
float Tesla(float Gauss);
|
||||
float mTesla(float Gauss);
|
||||
float uTesla(float Gauss);
|
||||
|
||||
|
||||
protected:
|
||||
uint8_t _pin = 0;
|
||||
float _midPoint = 512;
|
||||
float _prevGauss = 0;
|
||||
float _lastGauss = 0;
|
||||
float _mVGauss = 2.5;
|
||||
float _mVStep = 5000.0 / 1023;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// DERIVED
|
||||
//
|
||||
class A1301 : public HALL
|
||||
{
|
||||
public:
|
||||
A1301(uint8_t pin);
|
||||
};
|
||||
|
||||
|
||||
class A1302 : public HALL
|
||||
{
|
||||
public:
|
||||
A1302(uint8_t pin);
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
16
libraries/A1301/CHANGELOG.md
Normal file
16
libraries/A1301/CHANGELOG.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Change Log A1301
|
||||
|
||||
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.0] - 2022-12-01
|
||||
- initial version
|
||||
- rewrite whole class.
|
||||
|
||||
----
|
||||
|
||||
## [0.0.1] - 2010-07-22
|
||||
- first light (not released)
|
21
libraries/A1301/LICENSE
Normal file
21
libraries/A1301/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2010-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
123
libraries/A1301/README.md
Normal file
123
libraries/A1301/README.md
Normal file
@ -0,0 +1,123 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/A1301/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/A1301/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/A1301/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/A1301/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/A1301/actions/workflows/jsoncheck.yml)
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/A1301/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/A1301.svg?maxAge=3600)](https://github.com/RobTillaart/A1301/releases)
|
||||
|
||||
|
||||
# A1301
|
||||
|
||||
Arduino library for A1301 and A1302 magnetometer.
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
The A1301 and A1302 are continuous-time, ratiometric, linear
|
||||
Hall-effect sensors. They are optimized to accurately provide
|
||||
a voltage output that is proportional to an applied magnetic
|
||||
field. These devices have a quiescent output voltage that is
|
||||
50% of the supply voltage. Two output sensitivity options are
|
||||
provided: 2.5 mV/G typical for the A1301, and 1.3 mV/G
|
||||
typical for the A1302. (from datasheet)
|
||||
|
||||
|
||||
| sensor | sensitivity | support |
|
||||
|:---------|:---------------:|:---------:|
|
||||
| A1301 | 2.5 mV/Gauss | Y |
|
||||
| A1302 | 1.3 mV/Gauss | Y |
|
||||
| A1324 | 5.000 mV/Gauss | N |
|
||||
| A1325 | 3.125 mV/Gauss | N |
|
||||
| A1326 | 2.500 mV/Gauss | N |
|
||||
|
||||
Other, more or less, compatible sensors are welcome.
|
||||
(see future)
|
||||
|
||||
The library is experimental and need more testing.
|
||||
Feedback, issues and improvements are welcome,
|
||||
Please open an issue on GitHub.
|
||||
|
||||
|
||||
## Connection
|
||||
|
||||
```
|
||||
// always check datasheet.
|
||||
// PIN A1301
|
||||
// ===============
|
||||
// 1 GND
|
||||
// 2 DATA
|
||||
// 3 VDD +5V
|
||||
```
|
||||
|
||||
|
||||
## Interface
|
||||
|
||||
#### Constructor
|
||||
|
||||
- **HALL(uint8_t pin)** base class constructor.
|
||||
pin is the analogPin to read from.
|
||||
- **A1301(uint8_t pin)** constructor.
|
||||
- **A1302(uint8_t pin)** constructor.
|
||||
|
||||
#### Configuration
|
||||
|
||||
- **void begin(float voltage, uint16_t steps)**
|
||||
Sets the parameters voltage and number of steps of the internal ADC.
|
||||
Note this allows to update the voltage runtime.
|
||||
- **void setMidPoint(float midPoint)** the value of midPoint depends on the internal ADC.
|
||||
It is the value where there is no (zero) magnetic field.
|
||||
Note it does not need to be a whole value.
|
||||
This allows quite precise tuning.
|
||||
- **float getMidPoint()** returns the current midPoint.
|
||||
- **void setSensitivity(float sensitivity)** overrule default sensitivity.
|
||||
Use with care.
|
||||
- **float getSensitivity()** return current sensitivity.
|
||||
|
||||
|
||||
#### Read
|
||||
|
||||
- **float raw(uint8_t times = 1)** raw analog measurement.
|
||||
- **float read(uint8_t times = 1)** raw measurement converted to Gauss.
|
||||
Can be positive (North) or negative (South).
|
||||
- **float readExt(float raw)** to be used with external ADC.
|
||||
Can be positive (North) or negative (South).
|
||||
|
||||
|
||||
#### Analyse
|
||||
|
||||
- **boolean isNorth()** idem.
|
||||
- **boolean isSouth()** idem.
|
||||
- **float lastGauss()** returns last measurement in Gauss.
|
||||
- **float prevGauss()** returns previous measurement in Gauss.
|
||||
- **float Tesla(float Gauss)** convenience convertor.
|
||||
- **float mTesla(float Gauss)** convenience convertor.
|
||||
- **float uTesla(float Gauss)** convenience convertor.
|
||||
|
||||
|
||||
## Operation
|
||||
|
||||
The examples show the basic working of the functions.
|
||||
|
||||
|
||||
## Future
|
||||
|
||||
#### Must
|
||||
- improve documentation
|
||||
- buy hardware A1301 / A1302 / ...
|
||||
- test with hardware (again)
|
||||
|
||||
#### Should
|
||||
- plotter example
|
||||
- unit tests
|
||||
|
||||
#### Could
|
||||
- **boolean isSaturated()**
|
||||
- **float findZero()** how exactly.
|
||||
- printable interface
|
||||
- Possible compatible
|
||||
- HoneyWell - SS39ET/SS49E/SS59ET
|
||||
- HoneyWell - SS490 Series
|
||||
- add derived classes for - A1324/25/26 ?
|
||||
|
||||
#### Won't
|
||||
|
48
libraries/A1301/examples/A1301_demo/A1301_demo.ino
Normal file
48
libraries/A1301/examples/A1301_demo/A1301_demo.ino
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// FILE: A1301_demo
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo A1301 A1302 magnetometer.
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "A1301.h"
|
||||
|
||||
A1301 mm(A0);
|
||||
|
||||
uint32_t lastTime = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("A1301_LIB_VERSION: ");
|
||||
Serial.println(A1301_LIB_VERSION);
|
||||
|
||||
mm.begin(5000, 1023);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastTime >= 1000)
|
||||
{
|
||||
lastTime = millis();
|
||||
Serial.print(mm.raw());
|
||||
Serial.print("\t");
|
||||
Serial.print(mm.read());
|
||||
Serial.print("\t");
|
||||
Serial.print(mm.isNorth());
|
||||
Serial.print("\t");
|
||||
Serial.print(mm.isSouth());
|
||||
Serial.print("\t");
|
||||
Serial.print(mm.prevGauss());
|
||||
Serial.print("\t");
|
||||
Serial.print(mm.lastGauss());
|
||||
Serial.print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
16
libraries/A1301/keywords.txt
Normal file
16
libraries/A1301/keywords.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# Syntax Colouring Map For A1301
|
||||
|
||||
# Data types (KEYWORD1)
|
||||
A1301 KEYWORD1
|
||||
A1302 KEYWORD1
|
||||
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
begin KEYWORD2
|
||||
xxxxx KEYWORD2
|
||||
|
||||
|
||||
# Constants (LITERAL1)
|
||||
A1301_LIB_VERSION LITERAL1
|
||||
|
||||
|
23
libraries/A1301/library.json
Normal file
23
libraries/A1301/library.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "A1301",
|
||||
"keywords": "A1301, A1302, magnetic",
|
||||
"description": "Arduino library for A1301 A1302 magnetometer.",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "Rob Tillaart",
|
||||
"email": "Rob.Tillaart@gmail.com",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/A1301.git"
|
||||
},
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
"headers": "A1301.h"
|
||||
}
|
11
libraries/A1301/library.properties
Normal file
11
libraries/A1301/library.properties
Normal file
@ -0,0 +1,11 @@
|
||||
name=A1301
|
||||
version=0.1.0
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for A1301 A1302 magnetometer.
|
||||
paragraph=A1301, A1302, magnetic.
|
||||
category=Signal Input/Output
|
||||
url=https://github.com/RobTillaart/A1301
|
||||
architectures=*
|
||||
includes=A1301.h
|
||||
depends=
|
119
libraries/A1301/test/unit_test_001.cpp
Normal file
119
libraries/A1301/test/unit_test_001.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
//
|
||||
// FILE: unit_test_001.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2022-12-01
|
||||
// PURPOSE: unit tests for the A1301 magnetic sensor
|
||||
// https://github.com/RobTillaart/A1301
|
||||
// https://www.adafruit.com/product/2857
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual)
|
||||
// assertNotEqual(expected, actual)
|
||||
// assertLess(expected, actual)
|
||||
// assertMore(expected, actual)
|
||||
// assertLessOrEqual(expected, actual)
|
||||
// assertMoreOrEqual(expected, actual)
|
||||
// assertTrue(actual)
|
||||
// assertFalse(actual)
|
||||
// assertNull(actual)
|
||||
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "A1301.h"
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "A1301_LIB_VERSION: %s\n", (char *) A1301_LIB_VERSION);
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_constants)
|
||||
{
|
||||
assertEqualFloat(1, 1, 0.001);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
HALL H(4);
|
||||
A1301 A(5);
|
||||
A1302 B(6);
|
||||
|
||||
H.begin(3.3, 4095);
|
||||
A.begin(5.0, 1023);
|
||||
B.begin(5.0, 1023);
|
||||
|
||||
assertEqualFloat(2.500, H.getSensitivity(), 0.001);
|
||||
assertEqualFloat(2.500, A.getSensitivity(), 0.001);
|
||||
assertEqualFloat(1.300, B.getSensitivity(), 0.001);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_midPoint)
|
||||
{
|
||||
HALL H(4);
|
||||
|
||||
H.begin(3.3, 4095);
|
||||
H.setMidPoint(2020);
|
||||
assertEqual(2020, H.getMidPoint());
|
||||
}
|
||||
|
||||
|
||||
unittest(test_sensitivity)
|
||||
{
|
||||
HALL H(4);
|
||||
|
||||
H.begin(3.3, 4095);
|
||||
|
||||
assertEqualFloat(2.500, H.getSensitivity(), 0.001);
|
||||
H.setSensitivity(2.480);
|
||||
assertEqualFloat(2.480, H.getSensitivity(), 0.001);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_read_external_ADC)
|
||||
{
|
||||
HALL H(4);
|
||||
|
||||
H.begin(3.3, 4095);
|
||||
H.setMidPoint(2047);
|
||||
|
||||
assertEqualFloat(-0.337494, H.readExt(1000.0), 0.01);
|
||||
assertTrue(H.isSouth());
|
||||
assertEqualFloat(-0.176322, H.readExt(1500.0), 0.01);
|
||||
assertTrue(H.isSouth());
|
||||
assertEqualFloat(-0.0151502, H.readExt(2000.0), 0.01);
|
||||
assertTrue(H.isSouth());
|
||||
assertEqualFloat(0.307194, H.readExt(3000.0), 0.01);
|
||||
assertTrue(H.isNorth());
|
||||
}
|
||||
|
||||
|
||||
unittest(test_converters)
|
||||
{
|
||||
HALL H(4);
|
||||
|
||||
H.begin(3.3, 4095);
|
||||
H.setMidPoint(2047);
|
||||
|
||||
assertEqualFloat(0.005, H.Tesla(50), 0.01);
|
||||
assertEqualFloat(5.00, H.mTesla(50), 0.01);
|
||||
assertEqualFloat(5000, H.uTesla(50), 0.01);
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
Loading…
Reference in New Issue
Block a user