From 4f56779c5a353e81407944f15062eb4cca617694 Mon Sep 17 00:00:00 2001 From: rob tillaart Date: Sun, 19 Dec 2021 13:57:35 +0100 Subject: [PATCH] 0.3.1 HMC6352 --- libraries/hmc6352/.arduino-ci.yml | 10 ++++--- .../.github/workflows/arduino_test_runner.yml | 10 ++++--- libraries/hmc6352/LICENSE | 2 +- libraries/hmc6352/README.md | 16 +++++++++-- .../continuousDemo/continuousDemo.ino | 16 +++++------ .../examples/hmc6352Config/hmc6352Config.ino | 21 +++++++++------ .../hmc6352/examples/queryDemo/queryDemo.ino | 16 +++++------ .../set2continuous/set2continuous.ino | 14 +++++----- .../hmc6352/examples/set2query/set2query.ino | 14 +++++----- .../examples/set2standby/set2standby.ino | 14 +++++----- .../examples/standbyDemo/standbyDemo.ino | 11 +++----- libraries/hmc6352/hmc6352.cpp | 5 ++-- libraries/hmc6352/hmc6352.h | 27 ++++++++++--------- libraries/hmc6352/keywords.txt | 7 +++-- libraries/hmc6352/library.json | 5 ++-- libraries/hmc6352/library.properties | 2 +- libraries/hmc6352/test/unit_test_001.cpp | 5 +--- 17 files changed, 105 insertions(+), 90 deletions(-) diff --git a/libraries/hmc6352/.arduino-ci.yml b/libraries/hmc6352/.arduino-ci.yml index ff5659b9..cecf5850 100644 --- a/libraries/hmc6352/.arduino-ci.yml +++ b/libraries/hmc6352/.arduino-ci.yml @@ -2,6 +2,10 @@ compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: - uno - - leonardo - - due - - zero + # - due + # - zero + # - leonardo + - m4 + - esp32 + # - esp8266 + # - mega2560 diff --git a/libraries/hmc6352/.github/workflows/arduino_test_runner.yml b/libraries/hmc6352/.github/workflows/arduino_test_runner.yml index 476456bb..096b975b 100644 --- a/libraries/hmc6352/.github/workflows/arduino_test_runner.yml +++ b/libraries/hmc6352/.github/workflows/arduino_test_runner.yml @@ -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 diff --git a/libraries/hmc6352/LICENSE b/libraries/hmc6352/LICENSE index cfc58f98..8a10ac68 100644 --- a/libraries/hmc6352/LICENSE +++ b/libraries/hmc6352/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2011-2021 Rob Tillaart +Copyright (c) 2011-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 diff --git a/libraries/hmc6352/README.md b/libraries/hmc6352/README.md index 709b871b..5b7af691 100644 --- a/libraries/hmc6352/README.md +++ b/libraries/hmc6352/README.md @@ -1,19 +1,23 @@ [![Arduino CI](https://github.com/RobTillaart/HMC6352/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) +[![Arduino-lint](https://github.com/RobTillaart/HMC6352/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/HMC6352/actions/workflows/arduino-lint.yml) +[![JSON check](https://github.com/RobTillaart/HMC6352/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/HMC6352/actions/workflows/jsoncheck.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/HMC6352/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/HMC6352.svg?maxAge=3600)](https://github.com/RobTillaart/HMC6352/releases) + # HMC6352 Arduino library for HMC6352 compass sensor + ## Description **BETA: WARNING: BETA: WARNING: BETA: WARNING: BETA:** This library is BETA, only tested partially and not thoroughly No guarantees, use at own risk, all disclaimers apply -The example sketch can be used to config the compass. +The example sketch can be used to configuration the compass. For switching operational mode one must reboot the device. **WARNING: BETA: WARNING: BETA: WARNING: BETA: WARNING:** @@ -30,7 +34,6 @@ For switching operational mode one must reboot the device. - **bool isConnected()** Returns true if address can be seen on the I2C bus. Can be used as 1st order diagnostics. - ### Base calls standby mode - **int getHeading()** is a combination of **askHeading()** and **readHeading()** @@ -80,3 +83,12 @@ Warning: use with care: read the datasheet for the details ## Operation See examples + + +## Future + +- update documentation +- testing AVR +- testing ESP32 +- test examples => more specific? + diff --git a/libraries/hmc6352/examples/continuousDemo/continuousDemo.ino b/libraries/hmc6352/examples/continuousDemo/continuousDemo.ino index dd298f85..7d0ac33b 100644 --- a/libraries/hmc6352/examples/continuousDemo/continuousDemo.ino +++ b/libraries/hmc6352/examples/continuousDemo/continuousDemo.ino @@ -1,14 +1,8 @@ // // FILE: continuousDemo.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo app HMC6352 library - continuous mode for Arduino -// -// HISTORY: -// 0.1.0 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino -// 0.2.0 2020-06-13 match 0.2.0 version of lib -// + #include @@ -16,6 +10,7 @@ hmc6352 Compass(0x21); // 0x21 <==> 33 <==> 66 >> 1 int heading; + void setup() { Serial.begin(115200); @@ -24,7 +19,7 @@ void setup() Serial.println(HMC6352_LIB_VERSION); Compass.begin(); - + Serial.print("Output modus: "); Serial.println(Compass.getOutputModus()); @@ -33,6 +28,7 @@ void setup() Serial.println(heading); } + void loop() { // in continuous mode it is not needed to ask for a new reading every time @@ -44,4 +40,6 @@ void loop() delay(1000); } -// END OF FILE + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/examples/hmc6352Config/hmc6352Config.ino b/libraries/hmc6352/examples/hmc6352Config/hmc6352Config.ino index 3f1918ce..7b59af95 100644 --- a/libraries/hmc6352/examples/hmc6352Config/hmc6352Config.ino +++ b/libraries/hmc6352/examples/hmc6352Config/hmc6352Config.ino @@ -1,19 +1,14 @@ // // FILE: hmc6352Config.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: test HMC6352 library for Arduino -// -// HISTORY: -// 0.1.0 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino; -// 0.2.0 2020-06-13 match lib version 0.2.0 -// + #include hmc6352 Compass(33); + void setup() { Serial.begin(115200); @@ -26,6 +21,7 @@ void setup() dumpEEPROM(); } + void loop() { // SHOWMENU @@ -128,6 +124,7 @@ void loop() } } + void OutPutModusMenu() { Serial.println(Compass.getOutputModus()); @@ -146,6 +143,7 @@ void OutPutModusMenu() Serial.println(x); } + void askHeading() { int x = Compass.askHeading(); @@ -153,6 +151,7 @@ void askHeading() Serial.println(x); } + void readHeading() { int heading = Compass.readHeading(); @@ -160,12 +159,14 @@ void readHeading() Serial.println(heading); } + void factoryReset() { Compass.factoryReset(); Serial.println("Reboot Arduino"); } + void dumpRAM() { Serial.println("\nDUMP RAM: (decimal values)"); @@ -186,6 +187,7 @@ void dumpRAM() Serial.println(); } + void dumpEEPROM() { Serial.println("\nDUMP EEPROM: (decimal values)"); @@ -217,6 +219,7 @@ void dumpEEPROM() Serial.println(Compass.getOutputModus(), BIN); } + void setI2Caddress() { Serial.print("Current I2C address : "); @@ -241,4 +244,6 @@ void setI2Caddress() } -// END OF FILE + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/examples/queryDemo/queryDemo.ino b/libraries/hmc6352/examples/queryDemo/queryDemo.ino index f89e829c..0aee9abc 100644 --- a/libraries/hmc6352/examples/queryDemo/queryDemo.ino +++ b/libraries/hmc6352/examples/queryDemo/queryDemo.ino @@ -1,14 +1,8 @@ // // FILE: queryDemo.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo HMC6352 library - query mode for Arduino -// -// HISTORY: -// 0.1.00 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino -// 0.2.0 2020-06-13 match lib version 0.2.0 -// + #include @@ -16,6 +10,7 @@ hmc6352 Compass(0x21); int heading; + void setup() { Serial.begin(115200); @@ -24,7 +19,7 @@ void setup() Serial.println(HMC6352_LIB_VERSION); Compass.begin(); - + Serial.print("Output modus: "); Serial.println(Compass.getOutputModus()); @@ -33,6 +28,7 @@ void setup() Serial.println(heading); } + void loop() { // in query mode it is not needed to ask for a new reading every time @@ -45,4 +41,6 @@ void loop() delay(1000); } -// END OF FILE + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/examples/set2continuous/set2continuous.ino b/libraries/hmc6352/examples/set2continuous/set2continuous.ino index 96095468..b39a467e 100644 --- a/libraries/hmc6352/examples/set2continuous/set2continuous.ino +++ b/libraries/hmc6352/examples/set2continuous/set2continuous.ino @@ -1,14 +1,8 @@ // // FILE: set2continuous.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: Reset HMC6352 to continuous mode without library -// -// HISTORY: -// 0.1.0 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino; fix wire.receive -// 0.2.0 2020-06-13 refactor -// + #include @@ -16,6 +10,7 @@ int HMC = 0x21; int ledPin = 13; boolean ledState = LOW; + void setup() { Serial.begin(115200); @@ -30,6 +25,7 @@ void setup() delay(1000); // give all things time to start } + void loop() { // flashing means not blocking @@ -67,4 +63,6 @@ void loop() } } -// END OF FILE + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/examples/set2query/set2query.ino b/libraries/hmc6352/examples/set2query/set2query.ino index b7e1f216..1bc8d2af 100644 --- a/libraries/hmc6352/examples/set2query/set2query.ino +++ b/libraries/hmc6352/examples/set2query/set2query.ino @@ -1,14 +1,8 @@ // // FILE: Set2query.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: Reset HMC6352 to query mode without library -// -// HISTORY: -// 0.1.00 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino; fix receive -// 0.2.0 2020-06-13 refactor -// + #include @@ -16,6 +10,7 @@ int HMC = 0x21; int ledPin = 13; boolean ledState = LOW; + void setup() { Serial.begin(115200); @@ -30,6 +25,7 @@ void setup() delay(1000); // give all things time to start } + void loop() { // flashing means not blocking @@ -68,4 +64,6 @@ void loop() } } -// END OF FILE + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/examples/set2standby/set2standby.ino b/libraries/hmc6352/examples/set2standby/set2standby.ino index 19b46ead..0cfd12f6 100644 --- a/libraries/hmc6352/examples/set2standby/set2standby.ino +++ b/libraries/hmc6352/examples/set2standby/set2standby.ino @@ -1,15 +1,9 @@ // // FILE: set2standby.pde // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: Reset HMC6352 to standby mode without library // (esp if it is struck in continuous mode - Arduino) -// -// HISTORY: -// 0.1.00 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino; fix wire.receive -// 0.2.0 2020-06-13 refactor -// + #include @@ -17,6 +11,7 @@ int HMC = 0x21; int ledPin = 13; boolean ledState = LOW; + void setup() { Serial.begin(115200); @@ -31,6 +26,7 @@ void setup() delay(1000); // give all things time to start } + void loop() { // flashing means not blocking @@ -69,4 +65,6 @@ void loop() } } -// END OF FILE + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/examples/standbyDemo/standbyDemo.ino b/libraries/hmc6352/examples/standbyDemo/standbyDemo.ino index 2f3f661d..d184cbf3 100644 --- a/libraries/hmc6352/examples/standbyDemo/standbyDemo.ino +++ b/libraries/hmc6352/examples/standbyDemo/standbyDemo.ino @@ -1,14 +1,7 @@ // // FILE: standbyDemo.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo app HMC6352 library - standby mode for Arduino -// -// HISTORY: -// 0.1.00 - 2011-04-12 initial version -// 0.1.1 - 2017-09-13 renamed to .ino; -// 0.2.0 2020-06-13 refactor -// #include @@ -27,7 +20,7 @@ void setup() Wire.begin(); Compass.begin(); - + Serial.print("Output modus"); Serial.println(Compass.getOutputModus()); } @@ -63,4 +56,6 @@ void loop() delay(500); } + // -- END OF FILE -- + diff --git a/libraries/hmc6352/hmc6352.cpp b/libraries/hmc6352/hmc6352.cpp index 6ebdb562..7bcad9d6 100644 --- a/libraries/hmc6352/hmc6352.cpp +++ b/libraries/hmc6352/hmc6352.cpp @@ -1,7 +1,7 @@ // // FILE: hmc6352.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.3.0 +// VERSION: 0.3.1 // PURPOSE: Arduino library for HMC6352 digital compass sensor // // HISTORY: @@ -11,8 +11,9 @@ // 0.1.03 2011-04-13 fixed small things; added getHeading() // 0.1.4 2017-09-13 minor refactor // 0.2.0 2020-06-12 remove pre1.0 support, main refactor -// 0.2.1 2020-12-28 arduino-ci + unit test +// 0.2.1 2020-12-28 Arduino-CI + unit test // 0.3.0 2021-06-07 add multi-Wire interface + refactor +// 0.3.1 2021-12-19 update library.json, license, minor edits #include "hmc6352.h" diff --git a/libraries/hmc6352/hmc6352.h b/libraries/hmc6352/hmc6352.h index 777210b6..f905d050 100644 --- a/libraries/hmc6352/hmc6352.h +++ b/libraries/hmc6352/hmc6352.h @@ -2,7 +2,7 @@ // // FILE: hmc6352.h // AUTHOR: Rob Tillaart -// VERSION: 0.3.0 +// VERSION: 0.3.1 // PURPOSE: HMC6352 library for Arduino @@ -10,20 +10,20 @@ #include "Arduino.h" -#define HMC6352_LIB_VERSION (F("0.3.0")) +#define HMC6352_LIB_VERSION (F("0.3.1")) // status function calls -#define HMC6532_OK 0 -#define HMC6352_ERROR_PARAM1 -20 -#define HMC6352_ERROR_PARAM2 -21 +#define HMC6532_OK 0 +#define HMC6352_ERROR_PARAM1 -20 +#define HMC6352_ERROR_PARAM2 -21 // I2C related errors -#define HMC6532_I2C_OK 0 -#define HMC6532_I2C_ERROR_BUFFEROVERFLOW -1 -#define HMC6532_I2C_ERROR_ADDR_NACK -2 -#define HMC6532_I2C_ERROR_DATA_NACK -3 -#define HMC6532_I2C_ERROR_OTHER -4 -#define HMC6352_I2C_ERROR_REQ_FROM -10 +#define HMC6532_I2C_OK 0 +#define HMC6532_I2C_ERROR_BUFFEROVERFLOW -1 +#define HMC6532_I2C_ERROR_ADDR_NACK -2 +#define HMC6532_I2C_ERROR_DATA_NACK -3 +#define HMC6532_I2C_ERROR_OTHER -4 +#define HMC6352_I2C_ERROR_REQ_FROM -10 enum hmcMode @@ -31,6 +31,7 @@ enum hmcMode STANDBY = 0, QUERY = 1, CONT = 2, ERROR }; + enum hmcOutputMode { HEADING = 0, RAWMAGX = 1, RAWMAGY= 2, MAGX = 3, MAGY = 4 @@ -104,4 +105,6 @@ private: TwoWire* _wire; }; -// -- END OF FILE -- + +// -- END OF FILE -- + diff --git a/libraries/hmc6352/keywords.txt b/libraries/hmc6352/keywords.txt index 642bfd7f..9ccac23c 100644 --- a/libraries/hmc6352/keywords.txt +++ b/libraries/hmc6352/keywords.txt @@ -1,8 +1,10 @@ -# Syntax Coloring Map For HMC6352 +# Syntax Colouring Map For HMC6352 -# Datatypes (KEYWORD1) + +# Data types (KEYWORD1) HMC6352 KEYWORD1 + # Methods and Functions (KEYWORD2) begin KEYWORD2 isConnected KEYWORD2 @@ -35,6 +37,7 @@ getMeasurementSumming KEYWORD2 saveOpMode KEYWORD2 updateOffsets KEYWORD2 + # Constants (LITERAL1) HMC6352_LIB_VERSION LITERAL1 diff --git a/libraries/hmc6352/library.json b/libraries/hmc6352/library.json index 346a41c5..8900f417 100644 --- a/libraries/hmc6352/library.json +++ b/libraries/hmc6352/library.json @@ -15,8 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/HMC6352.git" }, - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "frameworks": "arduino", - "platforms": "*" + "platforms": "*", + "headers": "hmc6352.h" } diff --git a/libraries/hmc6352/library.properties b/libraries/hmc6352/library.properties index b51ff3ed..535f6f05 100644 --- a/libraries/hmc6352/library.properties +++ b/libraries/hmc6352/library.properties @@ -1,5 +1,5 @@ name=HMC6352 -version=0.3.0 +version=0.3.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Experimental Arduino library for HMC6352 digital compass sensor diff --git a/libraries/hmc6352/test/unit_test_001.cpp b/libraries/hmc6352/test/unit_test_001.cpp index 16a9af90..94b39f1d 100644 --- a/libraries/hmc6352/test/unit_test_001.cpp +++ b/libraries/hmc6352/test/unit_test_001.cpp @@ -31,6 +31,7 @@ unittest_setup() { + fprintf(stderr, "HMC6352_LIB_VERSION: %s\n", (char *) HMC6352_LIB_VERSION); } unittest_teardown() @@ -53,8 +54,6 @@ unittest(test_new_operator) unittest(test_constructor) { - fprintf(stderr, "VERSION: %s\n", HMC6352_LIB_VERSION); - hmc6352 Compass(0x21); assertTrue(Compass.begin()); assertTrue(Compass.isConnected()); @@ -63,8 +62,6 @@ unittest(test_constructor) unittest(test_constants) { - fprintf(stderr, "VERSION: %s\n", HMC6352_LIB_VERSION); - fprintf(stderr, "\nFunction return values\n"); assertEqual( 0, HMC6532_OK); assertEqual(-20, HMC6352_ERROR_PARAM1);