0.3.1 HMC6352

This commit is contained in:
rob tillaart 2021-12-19 13:57:35 +01:00
parent 945a64e50b
commit 4f56779c5a
17 changed files with 105 additions and 90 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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 <hmc6352.h>
@ -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 --

View File

@ -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.h>
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 --

View File

@ -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 <hmc6352.h>
@ -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 --

View File

@ -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 <Wire.h>
@ -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 --

View File

@ -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 <Wire.h>
@ -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 --

View File

@ -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 <Wire.h>
@ -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 --

View File

@ -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 <hmc6352.h>
@ -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 --

View File

@ -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"

View File

@ -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 --

View File

@ -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

View File

@ -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"
}

View File

@ -1,5 +1,5 @@
name=HMC6352
version=0.3.0
version=0.3.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Experimental Arduino library for HMC6352 digital compass sensor

View File

@ -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);