{"id":13481042,"url":"https://github.com/cagdasc/AndroidThings-HMC5883L","last_synced_at":"2025-03-27T11:31:37.668Z","repository":{"id":72055108,"uuid":"77295258","full_name":"cagdasc/AndroidThings-HMC5883L","owner":"cagdasc","description":"HMC5883L 3-axis magnetometer AndroidThings device driver","archived":false,"fork":false,"pushed_at":"2016-12-28T11:53:07.000Z","size":624,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-01T17:24:32.519Z","etag":null,"topics":["android","android-library","android-things","driver","embedded","i2c","i2c-sensors"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cagdasc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-12-24T18:17:20.000Z","updated_at":"2021-09-29T10:24:13.000Z","dependencies_parsed_at":"2023-05-24T09:30:40.454Z","dependency_job_id":null,"html_url":"https://github.com/cagdasc/AndroidThings-HMC5883L","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cagdasc%2FAndroidThings-HMC5883L","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cagdasc%2FAndroidThings-HMC5883L/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cagdasc%2FAndroidThings-HMC5883L/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cagdasc%2FAndroidThings-HMC5883L/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cagdasc","download_url":"https://codeload.github.com/cagdasc/AndroidThings-HMC5883L/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222239501,"owners_count":16953961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","android-things","driver","embedded","i2c","i2c-sensors"],"created_at":"2024-07-31T17:00:48.038Z","updated_at":"2024-10-30T14:31:14.652Z","avatar_url":"https://github.com/cagdasc.png","language":"Java","funding_links":[],"categories":["Useful links"],"sub_categories":["Drivers"],"readme":"HMC5883L driver for Android Things\n================================\n\nThis driver include 3-axis magnetometer. There is no warranty for this driver. NOT USE IN PRODUCTION!!\n\nHow to use the driver\n---------------------\n\n### Sample usage\nManual usage\n```java\nimport com.cacaosd.android.things.contrib.driver.hmc5883l;\n\n// Access the environmental sensor:\n\nHMC5883L hmcl5883l;\n\ntry {\n    hmcl5883l = new HMC5883L(i2cBusName);\n    hmcl5883l.setSamplesAvarage(SAMPLES_AVARAGE_8);\n    hmcl5883l.setOutputRate(OUTPUT_RATE_4);\n    hmcl5883l.setMeasurementMode(MEASUREMENT_NORMAL);\n    hmcl5883l.setMeasurementGain(GAIN_1090);\n    hmcl5883l.setOperationMode(OPERATION_MODE_CONT);\n} catch (IOException e) {\n    // error.\n}\n\n\ntry {\n    float[] magnitudes = hmcl5883l.getMagnitudes();\n} catch (IOException e) {\n    // error reading\n}\n\ntry {\n    hmcl5883l.close();\n} catch (IOException e) {\n    // error closing sensor\n}\n```\n\nYou can register Android Sensor Service like this.\n```java\nSensorManager mSensorManager = getSystemService(Context.SENSOR_SERVICE);\nSensorEventListener mListener = ...;\nHMC5883LSensorDriver mSensorDriver;\n\nmSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);\n        mSensorManager.registerDynamicSensorCallback(new SensorManager.DynamicSensorCallback() {\n            @Override\n            public void onDynamicSensorConnected(Sensor sensor) {\n                if (sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {\n                    mSensorManager.registerListener(MagnetometerActivity.this,\n                            sensor, SensorManager.SENSOR_DELAY_NORMAL);\n                }\n            }\n        });\n\n        try {\n            mSensorDriver = new HMC5883LSensorDriver(BoardDefaults.getI2CPort());\n            mSensorDriver.registerMagmetormeterSensor();\n\n        } catch (IOException e) {\n            Log.e(TAG, \"Error configuring sensor\", e);\n        }\n    }\n\nif (mSensorDriver != null) {\n    mSensorManager.unregisterListener(this);\n    mSensorDriver.unregisterMagmetormeterSensor();\n    try {\n        mSensorDriver.close();\n    } catch (IOException e) {\n        Log.e(TAG, \"Error closing sensor\", e);\n    } catch (Exception e) {\n        e.printStackTrace();\n    } finally {\n        mSensorDriver = null;\n    }\n}\n```\n![device](device.png)\n\nLicense\n-------\n\n      Copyright 2016 Cagdas Caglak\n\n      Licensed under the Apache License, Version 2.0 (the \"License\");\n      you may not use this file except in compliance with the License.\n      You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n      Unless required by applicable law or agreed to in writing, software\n      distributed under the License is distributed on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n      See the License for the specific language governing permissions and\n      limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcagdasc%2FAndroidThings-HMC5883L","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcagdasc%2FAndroidThings-HMC5883L","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcagdasc%2FAndroidThings-HMC5883L/lists"}