Added missing lib https://github.com/Xinyuan-LilyGO/T-Deck/issues/47
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
*.hpp linguist-language=C++
|
||||
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
name: Build Arduino
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
paths:
|
||||
- "src/**"
|
||||
- "examples/**"
|
||||
- ".github/workflows/arduino_ci.yml"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
board: ["esp32:esp32:esp32s3"]
|
||||
examples:
|
||||
- examples/BAM423_Accelerometer/BAM423_Accelerometer.ino
|
||||
- examples/BAM423_Orientation/BAM423_Orientation.ino
|
||||
- examples/BAM423_Temperature/BAM423_Temperature.ino
|
||||
- examples/BMA423_Feature/BMA423_Feature.ino
|
||||
- examples/CM32181_LightSensor/CM32181_LightSensor.ino
|
||||
- examples/CM32181_LightSensorInterrupt/CM32181_LightSensorInterrupt.ino
|
||||
- examples/DRV2605_Basic/DRV2605_Basic.ino
|
||||
- examples/LTR553ALS_Sensor/LTR553ALS_Sensor.ino
|
||||
- examples/PCF85063_SimpleTime/PCF85063_SimpleTime.ino
|
||||
- examples/PCF8563_AlarmByUnits/PCF8563_AlarmByUnits.ino
|
||||
- examples/PCF8563_SimpleTime/PCF8563_SimpleTime.ino
|
||||
- examples/PCF8563_TimeLib/PCF8563_TimeLib.ino
|
||||
- examples/PCF8563_TimeSynchronization/PCF8563_TimeSynchronization.ino
|
||||
- examples/QMC6310_CalibrateExample/QMC6310_CalibrateExample.ino
|
||||
- examples/QMC6310_CompassExample/QMC6310_CompassExample.ino
|
||||
- examples/QMC6310_GetDataExample/QMC6310_GetDataExample.ino
|
||||
- examples/QMC6310_GetPolarExample/QMC6310_GetPolarExample.ino
|
||||
- examples/QMI8658_BlockExample/QMI8658_BlockExample.ino
|
||||
- examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino
|
||||
- examples/QMI8658_InterruptBlockExample/QMI8658_InterruptBlockExample.ino
|
||||
- examples/QMI8658_InterruptExample/QMI8658_InterruptExample.ino
|
||||
- examples/QMI8658_LockingMechanismExample/QMI8658_LockingMechanismExample.ino
|
||||
- examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino
|
||||
- examples/QMI8658_PedometerExample/QMI8658_PedometerExample.ino
|
||||
- examples/QMI8658_ReadFromFifoExample/QMI8658_ReadFromFifoExample.ino
|
||||
- examples/QMI8658_WakeOnMotion/QMI8658_WakeOnMotion.ino
|
||||
- examples/QMI8658_WakeOnMotionCallBackExample/QMI8658_WakeOnMotionCallBackExample.ino
|
||||
- examples/TouchDrv_CHSC5816_GetPoint/TouchDrv_CHSC5816_GetPoint.ino
|
||||
- examples/TouchDrv_CSTxxx_GetPoint/TouchDrv_CSTxxx_GetPoint.ino
|
||||
- examples/TouchDrv_FT3267_LilyGo_T_RGB/TouchDrv_FT3267_LilyGo_T_RGB.ino
|
||||
- examples/TouchDrv_FT6232_GetPoint/TouchDrv_FT6232_GetPoint.ino
|
||||
- examples/TouchDrv_GT911_GetPoint/TouchDrv_GT911_GetPoint.ino
|
||||
- examples/TouchDrv_GT911_LilyGo_T_RGB/TouchDrv_GT911_LilyGo_T_RGB.ino
|
||||
- examples/XL9555_ExtensionIOInterrupt/XL9555_ExtensionIOInterrupt.ino
|
||||
- examples/XL9555_ExtensionIORead/XL9555_ExtensionIORead.ino
|
||||
- examples/XL9555_ExtensionIOWirte/XL9555_ExtensionIOWirte.ino
|
||||
- examples/BHI260AP_6DoF/BHI260AP_6DoF.ino
|
||||
- examples/BHI260AP_Orientation/BHI260AP_Orientation.ino
|
||||
- examples/BHI260AP_DebugInfo/BHI260AP_DebugInfo.ino
|
||||
- examples/BHI260AP_StepCounter/BHI260AP_StepCounter.ino
|
||||
- examples/BHI260AP_aux_BMM150/BHI260AP_aux_BMM150.ino
|
||||
- examples/BHI260AP_aux_BMM150_euler/BHI260AP_aux_BMM150_euler.ino
|
||||
- examples/BHI260AP_aux_BMM150_quaternion/BHI260AP_aux_BMM150_quaternion.ino
|
||||
- examples/BHI260AP_aux_BMM150_BME280/BHI260AP_aux_BMM150_BME280.ino
|
||||
- examples/BMM150_GetDataExample/BMM150_GetDataExample.ino
|
||||
- examples/TouchDrv_Interface_T_RGB/TouchDrv_Interface_T_RGB.ino
|
||||
- examples/TouchDrv_CST9217_GetPoint/TouchDrv_CST9217_GetPoint.ino
|
||||
|
||||
env:
|
||||
BOARD: ${{ matrix.board }}
|
||||
EXAMPLES: ${{matrix.examples}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Arduino Ci
|
||||
run: |
|
||||
if [[ "$BOARD" =~ "esp32:esp32:" ]]; then
|
||||
wget https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz -O arduino-cli.tar.gz ;
|
||||
sudo tar xf arduino-cli.tar.gz -C /usr/local/bin arduino-cli ;
|
||||
arduino-cli config init ;
|
||||
arduino-cli config add board_manager.additional_urls https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json ;
|
||||
arduino-cli core update-index ;
|
||||
arduino-cli core install esp32:esp32 ;
|
||||
fi
|
||||
|
||||
- name: Build examples
|
||||
run: |
|
||||
mkdir -p $HOME/Arduino/libraries ;
|
||||
cd $HOME/Arduino/libraries ;
|
||||
git clone https://github.com/ThingPulse/esp8266-oled-ssd1306 ;
|
||||
git clone https://github.com/arduino-libraries/MadgwickAHRS ;
|
||||
|
||||
cd $GITHUB_WORKSPACE ;
|
||||
if [[ "$BOARD" =~ "esp32:esp32:" ]]; then
|
||||
arduino-cli compile -besp32:esp32:esp32s3 --library . $PWD/$EXAMPLES ;
|
||||
fi ;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
name: Build esp-idf
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
paths:
|
||||
- "src/**"
|
||||
- "examples/ESP_IDF_TouchDrv_Example/**"
|
||||
- ".github/workflows/esp-idf.yml"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest"]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: "recursive"
|
||||
- name: Build esp-idf examples
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
cd examples/ESP_IDF_TouchDrv_Example
|
||||
idf.py build
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
name: Build PlatformIO
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
paths:
|
||||
- "src/**"
|
||||
- "examples/**"
|
||||
- ".github/workflows/platformio.yml"
|
||||
- "platformio.ini"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
example:
|
||||
- examples/BAM423_Accelerometer
|
||||
- examples/BAM423_Orientation
|
||||
- examples/BAM423_Temperature
|
||||
- examples/BHI260AP_6DoF
|
||||
- examples/BHI260AP_aux_BMM150
|
||||
- examples/BHI260AP_aux_BMM150_euler
|
||||
- examples/BHI260AP_aux_BMM150_quaternion
|
||||
- examples/BHI260AP_aux_BMM150_BME280
|
||||
- examples/BHI260AP_DebugInfo
|
||||
- examples/BHI260AP_Orientation
|
||||
- examples/BHI260AP_StepCounter
|
||||
- examples/BMA423_Feature
|
||||
- examples/BMM150_GetDataExample
|
||||
- examples/CM32181_LightSensor
|
||||
- examples/CM32181_LightSensorInterrupt
|
||||
- examples/DRV2605_Basic
|
||||
- examples/LTR553ALS_Sensor
|
||||
- examples/PCF85063_AlarmByUnits
|
||||
- examples/PCF85063_SimpleTime
|
||||
- examples/PCF8563_AlarmByUnits
|
||||
- examples/PCF8563_SimpleTime
|
||||
- examples/PCF8563_TimeLib
|
||||
- examples/PCF8563_TimeSynchronization
|
||||
- examples/QMC6310_CalibrateExample
|
||||
- examples/QMC6310_CompassExample
|
||||
- examples/QMC6310_GetDataExample
|
||||
- examples/QMC6310_GetPolarExample
|
||||
- examples/QMI8658_BlockExample
|
||||
- examples/QMI8658_GetDataExample
|
||||
- examples/QMI8658_InterruptBlockExample
|
||||
- examples/QMI8658_InterruptExample
|
||||
- examples/QMI8658_LockingMechanismExample
|
||||
- examples/QMI8658_MadgwickAHRS
|
||||
- examples/QMI8658_PedometerExample
|
||||
- examples/QMI8658_ReadFromFifoExample
|
||||
- examples/QMI8658_WakeOnMotion
|
||||
- examples/QMI8658_WakeOnMotionCallBackExample
|
||||
- examples/TouchDrv_CHSC5816_GetPoint
|
||||
- examples/TouchDrv_CST9217_GetPoint
|
||||
- examples/TouchDrv_CSTxxx_GetPoint
|
||||
- examples/TouchDrv_FT3267_LilyGo_T_RGB
|
||||
- examples/TouchDrv_FT6232_GetPoint
|
||||
- examples/TouchDrv_GT911_GetPoint
|
||||
- examples/TouchDrv_GT911_LilyGo_T_RGB
|
||||
- examples/TouchDrv_Interface_T_RGB
|
||||
- examples/XL9555_ExtensionIOInterrupt
|
||||
- examples/XL9555_ExtensionIORead
|
||||
- examples/XL9555_ExtensionIOWirte
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cache/pip
|
||||
~/.platformio/.cache
|
||||
key: ${{ runner.os }}-pio
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.9"
|
||||
- name: Install PlatformIO Core
|
||||
run: pip install --upgrade platformio
|
||||
|
||||
- name: Install MadgwickAHRS library
|
||||
# https://github.com/arduino-libraries/MadgwickAHRS
|
||||
run: pio pkg install --library "arduino-libraries/Madgwick@^1.2.0" -g
|
||||
|
||||
- name: Install esp8266-oled-ssd1306 library
|
||||
# https://github.com/ThingPulse/esp8266-oled-ssd1306
|
||||
run: pio pkg install --library "thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays @ ^4.4.0" -g
|
||||
|
||||
- name: Run PlatformIO
|
||||
run: pio ci --lib="." --board=esp32dev --board=esp32-c3-devkitm-1 --board=esp32-s3-devkitm-1 --board=nrf52840_dk_adafruit
|
||||
env:
|
||||
PLATFORMIO_CI_SRC: ${{ matrix.example }}
|
||||
@@ -0,0 +1,11 @@
|
||||
.pio
|
||||
.vscode
|
||||
test
|
||||
.travis.yml
|
||||
test
|
||||
assets
|
||||
*.bk
|
||||
*.test
|
||||
build
|
||||
*.old
|
||||
sdkconfig
|
||||
@@ -0,0 +1,10 @@
|
||||
set(src_dirs ./src
|
||||
./src/touch
|
||||
./src/platform)
|
||||
set(include_dirs ./src
|
||||
./src/REG
|
||||
./src/touch
|
||||
./src/platform)
|
||||
idf_component_register(SRC_DIRS ${src_dirs}
|
||||
INCLUDE_DIRS ${include_dirs}
|
||||
REQUIRES esp_timer esp_driver_gpio driver)
|
||||
@@ -0,0 +1,16 @@
|
||||
menu "SensorLib Configuration"
|
||||
|
||||
choice SensorLib_ESP_IDF_API
|
||||
prompt "SensorLib library esp-idf api version"
|
||||
default SENSORLIB_ESP_IDF_NEW_API
|
||||
help
|
||||
Define API version
|
||||
|
||||
config SENSORLIB_ESP_IDF_NEW_API
|
||||
bool "Use esp-idf higher version (>= 5.0) API"
|
||||
config SENSORLIB_ESP_IDF_OLD_API
|
||||
bool "Use esp-idf lower version ( < 5.0) API , Compatible with lower versions of esp-idf"
|
||||
endchoice
|
||||
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 lewis he
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,78 @@
|
||||
```
|
||||
_____ _ _ _
|
||||
/ ___| | | (_)| |
|
||||
\ `--. ___ _ __ ___ ___ _ __ | | _ | |__
|
||||
`--. \ / _ \| '_ \ / __| / _ \ | '__|| | | || '_ \
|
||||
/\__/ /| __/| | | |\__ \| (_) || | | |____| || |_) |
|
||||
\____/ \___||_| |_||___/ \___/ |_| \_____/|_||_.__/
|
||||
··· ···
|
||||
> Commonly used I2C , SPI device multi-platform libraries
|
||||
|
||||
```
|
||||
|
||||
[](https://github.com/lewisxhe/SensorLib/actions/workflows/esp-idf.yml)
|
||||
[](https://github.com/lewisxhe/SensorLib/actions/workflows/arduino_ci.yml)
|
||||
[](https://github.com/lewisxhe/SensorLib/actions/workflows/pio.yml)
|
||||
[](https://www.ardu-badge.com/SensorLib)
|
||||
[](https://registry.platformio.org/libraries/lewisxhe/SensorLib)
|
||||
|
||||
|
||||
[](https://github.com/lewisxhe/SensorLib/blob/master/LICENSE)
|
||||
[](https://github.com/lewisxhe/SensorsLib/issues)
|
||||
[](https://github.com/lewisxhe/SensorsLib/graphs/contributors)
|
||||
[](https://github.com/lewisxhe/SensorsLib/stargazers)
|
||||
[](https://github.com/lewisxhe/SensorLib/releases)
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
Support list:
|
||||
|
||||
| Sensor | Description | I2C | SPI |
|
||||
| --------------- | ------------------------ | --- | --- |
|
||||
| PCF8563/HYM8563 | Real-time clock | ✔️ | ❌ |
|
||||
| PCF85063 | Real-time clock | ✔️ | ❌ |
|
||||
| QMI8658 | IMU | ✔️ | ✔️ |
|
||||
| BHI260AP | IMU | ✔️ | ✔️ |
|
||||
| QMC6310 | Magnetic Sensor | ✔️ | ❌ |
|
||||
| BMM150 | Magnetic Sensor | ✔️ | ❌ |
|
||||
| XL9555 | I/O expander | ✔️ | ❌ |
|
||||
| BMA423 | Accelerometer | ✔️ | ❌ |
|
||||
| DRV2605 | Haptic Driver | ✔️ | ❌ |
|
||||
| CM32181 | Ambient Light Sensor | ✔️ | ❌ |
|
||||
| LTR553 | Light & Proximity Sensor | ✔️ | ❌ |
|
||||
| FT3267 | Capacitive touch | ✔️ | ❌ |
|
||||
| FT5206 | Capacitive touch | ✔️ | ❌ |
|
||||
| FT6206 | Capacitive touch | ✔️ | ❌ |
|
||||
| FT6236 | Capacitive touch | ✔️ | ❌ |
|
||||
| CST820 | Capacitive touch | ✔️ | ❌ |
|
||||
| CST816S/T/D | Capacitive touch | ✔️ | ❌ |
|
||||
| CST226SE | Capacitive touch | ✔️ | ❌ |
|
||||
| CHSC5816 | Capacitive touch | ✔️ | ❌ |
|
||||
| GT911 | Capacitive touch | ✔️ | ❌ |
|
||||
| CST9217 | Capacitive touch | ✔️ | ❌ |
|
||||
| CST9220 | Capacitive touch | ✔️ | ❌ |
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BAM423_Accelerometer.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-01
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBMA423.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 21
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 22
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 39
|
||||
#endif
|
||||
|
||||
SensorBMA423 accel;
|
||||
uint32_t lastMillis;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
|
||||
if (!accel.begin(Wire, BMA423_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find BMA423 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Serial.println("Init BAM423 Sensor success!");
|
||||
|
||||
//Default 4G ,200HZ
|
||||
accel.configAccelerometer();
|
||||
|
||||
accel.enableAccelerometer();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int16_t x = 0, y = 0, z = 0;
|
||||
accel.getAccelerometer(x, y, z);
|
||||
Serial.print("X:");
|
||||
Serial.print(x); Serial.print(" ");
|
||||
Serial.print("Y:");
|
||||
Serial.print(y); Serial.print(" ");
|
||||
Serial.print("Z:");
|
||||
Serial.print(z);
|
||||
Serial.println();
|
||||
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BAM423_Orientation.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-03
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBMA423.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 21
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 22
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 39
|
||||
#endif
|
||||
|
||||
SensorBMA423 accel;
|
||||
char report[256];
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
|
||||
if (!accel.begin(Wire, BMA423_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find BMA423 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Serial.println("Init BAM423 Sensor success!");
|
||||
|
||||
//Default 4G ,200HZ
|
||||
accel.configAccelerometer();
|
||||
|
||||
accel.enableAccelerometer();
|
||||
|
||||
Serial.println("Output ...");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t direction = accel.direction();
|
||||
switch (direction) {
|
||||
case SensorBMA423::DIRECTION_BOTTOM_LEFT:
|
||||
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
|
||||
break;
|
||||
case SensorBMA423::DIRECTION_TOP_RIGHT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
case SensorBMA423::DIRECTION_TOP_LEFT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
case SensorBMA423::DIRECTION_BOTTOM_RIGHT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
case SensorBMA423::DIRECTION_BOTTOM:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n |________________| " \
|
||||
"\r\n * \r\n" );
|
||||
break;
|
||||
case SensorBMA423::DIRECTION_TOP:
|
||||
sprintf( report, "\r\n __*_____________ " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
default:
|
||||
sprintf( report, "None of the 3D orientation axes is set in BMA423 - accelerometer.\r\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
Serial.println(direction);
|
||||
Serial.println(report);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BAM423_Temperature.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-01
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBMA423.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 21
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 22
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 39
|
||||
#endif
|
||||
|
||||
SensorBMA423 accel;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
|
||||
if (!accel.begin(Wire, BMA423_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find BMA423 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Serial.println("Init BAM423 Sensor success!");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print("getTemperature:");
|
||||
Serial.print(accel.getTemperature(SensorBMA423::TEMP_DEG));
|
||||
Serial.print("*C ");
|
||||
Serial.print(accel.getTemperature(SensorBMA423::TEMP_FAHREN));
|
||||
Serial.print("*F");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_6DoF.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-06
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 33
|
||||
#define BHI260AP_MISO 34
|
||||
#define BHI260AP_SCK 35
|
||||
#define BHI260AP_CS 36
|
||||
#define BHI260AP_IRQ 37
|
||||
#define BHI260AP_RST 47
|
||||
#endif
|
||||
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
void accel_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
struct bhy2_data_xyz data;
|
||||
float scaling_factor = get_sensor_default_scaling(sensor_id);
|
||||
bhy2_parse_xyz(data_ptr, &data);
|
||||
Serial.print(bhy.getSensorName(sensor_id));
|
||||
Serial.print(":");
|
||||
Serial.printf("x: %f, y: %f, z: %f;\r\n",
|
||||
data.x * scaling_factor,
|
||||
data.y * scaling_factor,
|
||||
data.z * scaling_factor
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void gyro_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
struct bhy2_data_xyz data;
|
||||
float scaling_factor = get_sensor_default_scaling(sensor_id);
|
||||
bhy2_parse_xyz(data_ptr, &data);
|
||||
Serial.print(bhy.getSensorName(sensor_id));
|
||||
Serial.print(":");
|
||||
Serial.printf("x: %f, y: %f, z: %f;\r\n",
|
||||
data.x * scaling_factor,
|
||||
data.y * scaling_factor,
|
||||
data.z * scaling_factor
|
||||
);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* Report immediately */
|
||||
|
||||
// Enable acceleration
|
||||
bhy.configure(SENSOR_ID_ACC_PASS, sample_rate, report_latency_ms);
|
||||
// Enable gyroscope
|
||||
bhy.configure(SENSOR_ID_GYRO_PASS, sample_rate, report_latency_ms);
|
||||
|
||||
// Set the acceleration sensor result callback function
|
||||
bhy.onResultEvent(SENSOR_ID_ACC_PASS, accel_process_callback);
|
||||
|
||||
// Set the gyroscope sensor result callback function
|
||||
bhy.onResultEvent(SENSOR_ID_GYRO_PASS, gyro_process_callback);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_DebugInfo.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-10-08
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 33
|
||||
#define BHI260AP_MISO 34
|
||||
#define BHI260AP_SCK 35
|
||||
#define BHI260AP_CS 36
|
||||
#define BHI260AP_IRQ 37
|
||||
#define BHI260AP_RST 47
|
||||
#endif
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
|
||||
void quaternion_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
Serial.println(bhy.getSensorName(sensor_id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
|
||||
// Output all current sensor information
|
||||
bhy.printInfo(Serial);
|
||||
|
||||
// Output interrupt configuration information to Serial
|
||||
bhy.printInterruptCtrl(Serial);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_Orientation.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-10-07
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 33
|
||||
#define BHI260AP_MISO 34
|
||||
#define BHI260AP_SCK 35
|
||||
#define BHI260AP_CS 36
|
||||
#define BHI260AP_IRQ 37
|
||||
#define BHI260AP_RST 47
|
||||
#endif
|
||||
|
||||
void orientation_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp);
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* Report immediately */
|
||||
|
||||
// Direction detection relies on the accelerometer, and the accelerometer needs to be turned on first.
|
||||
bhy.configure(SENSOR_ID_ACC_PASS, sample_rate, report_latency_ms);
|
||||
// Enable direction detection
|
||||
bhy.configure(SENSOR_ID_DEVICE_ORI, sample_rate, report_latency_ms);
|
||||
// Set the direction detection result output processing function
|
||||
bhy.onResultEvent(SENSOR_ID_DEVICE_ORI, orientation_process_callback);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
void orientation_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
char report[256];
|
||||
uint8_t direction = *data_ptr;
|
||||
switch (direction) {
|
||||
case BHY2_DIRECTION_BOTTOM_LEFT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
|
||||
break;
|
||||
case BHY2_DIRECTION_TOP_RIGHT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
case BHY2_DIRECTION_TOP_LEFT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
case BHY2_DIRECTION_BOTTOM_RIGHT:
|
||||
sprintf( report, "\r\n ________________ " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | | " \
|
||||
"\r\n | * | " \
|
||||
"\r\n |________________| \r\n" );
|
||||
break;
|
||||
default:
|
||||
sprintf( report, "None of the 3D orientation axes is set in BHI260 - accelerometer.\r\n" );
|
||||
break;
|
||||
}
|
||||
Serial.print(bhy.getSensorName(sensor_id));
|
||||
Serial.print(":");
|
||||
Serial.println(direction);
|
||||
Serial.println(report);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_StepCounter.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-10-08
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 33
|
||||
#define BHI260AP_MISO 34
|
||||
#define BHI260AP_SCK 35
|
||||
#define BHI260AP_CS 36
|
||||
#define BHI260AP_IRQ 37
|
||||
#define BHI260AP_RST 47
|
||||
#endif
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
|
||||
void step_detector_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
Serial.print(bhy.getSensorName(sensor_id));
|
||||
Serial.println(" detected.");
|
||||
}
|
||||
|
||||
void step_counter_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
Serial.print(bhy.getSensorName(sensor_id));
|
||||
Serial.print(":");
|
||||
Serial.println(bhy2_parse_step_counter(data_ptr));
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* Report immediately */
|
||||
|
||||
// Direction Step count relies on the accelerometer, and the accelerometer needs to be turned on first.
|
||||
bhy.configure(SENSOR_ID_ACC_PASS, sample_rate, report_latency_ms);
|
||||
// Enable Step detector
|
||||
bhy.configure(SENSOR_ID_STD, sample_rate, report_latency_ms);
|
||||
// Enable Step counter
|
||||
bhy.configure(SENSOR_ID_STC, sample_rate, report_latency_ms);
|
||||
|
||||
// Set the number of steps to detect the callback function
|
||||
bhy.onResultEvent(SENSOR_ID_STD, step_detector_process_callback);
|
||||
bhy.onResultEvent(SENSOR_ID_STC, step_counter_process_callback);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_aux_BMM150.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-07-22
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
/*
|
||||
Write the firmware containing the BMM150 magnetometer function into the flash.
|
||||
This function requires the BHI260AP external SPI Flash.
|
||||
If there is no Flash, it can only be written and run in RAM.
|
||||
Example firmware source: https://github.com/boschsensortec/BHY2_SensorAPI/tree/master/firmware
|
||||
You can also compile custom firmware to write
|
||||
How to build custom firmware see : https://www.bosch-sensortec.com/media/boschsensortec/downloads/application_notes_1/bst-bhi260ab-an000.pdf
|
||||
*/
|
||||
#define WRITE_TO_FLASH 1 //Set 1 write fw to flash ,set 0 write fw to ram
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
#include "BHI260AP_aux_BMM150-flash.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_flash_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_flash_fw);
|
||||
|
||||
#else
|
||||
#include "BHI260AP_aux_BMM150.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_fw);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 27
|
||||
#define BHI260AP_MISO 46
|
||||
#define BHI260AP_SCK 3
|
||||
#define BHI260AP_CS 28
|
||||
#define BHI260AP_IRQ 30
|
||||
#define BHI260AP_RST -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
|
||||
void bhy_process_callback(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
struct bhy2_data_xyz data;
|
||||
float scaling_factor = get_sensor_default_scaling(sensor_id);
|
||||
bhy2_parse_xyz(data_ptr, &data);
|
||||
Serial.print(bhy.getSensorName(sensor_id));
|
||||
Serial.print(":");
|
||||
Serial.printf("x: %f, y: %f, z: %f;\r\n",
|
||||
data.x * scaling_factor,
|
||||
data.y * scaling_factor,
|
||||
data.z * scaling_factor
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
// Set the firmware array address and firmware size
|
||||
bhy.setFirmware(firmware, fw_size, WRITE_TO_FLASH);
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
// Set to load firmware from flash
|
||||
bhy.setBootFormFlash(true);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* 0 = report immediately */
|
||||
|
||||
// Enable acceleration
|
||||
report_latency_ms = 1000; // Report once per second
|
||||
bhy.configure(SENSOR_ID_ACC_PASS, sample_rate, report_latency_ms);
|
||||
|
||||
// Enable gyroscope
|
||||
report_latency_ms = 1000; //Report once per second
|
||||
bhy.configure(SENSOR_ID_GYRO_PASS, sample_rate, report_latency_ms);
|
||||
|
||||
// Enable magnetometer
|
||||
report_latency_ms = 500; //Report every 500 milliseconds
|
||||
bhy.configure(SENSOR_ID_MAG_PASS, sample_rate, report_latency_ms);
|
||||
|
||||
// Set the acceleration sensor result callback function
|
||||
bhy.onResultEvent(SENSOR_ID_ACC_PASS, bhy_process_callback);
|
||||
|
||||
// Set the gyroscope sensor result callback function
|
||||
bhy.onResultEvent(SENSOR_ID_GYRO_PASS, bhy_process_callback);
|
||||
|
||||
// Set the magnetometer sensor result callback function
|
||||
bhy.onResultEvent(SENSOR_ID_MAG_PASS, bhy_process_callback);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_aux_BMM150_BME280.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-07-24
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
/*
|
||||
Write the firmware containing the BMM150 magnetometer function into the flash.
|
||||
This function requires the BHI260AP external SPI Flash.
|
||||
If there is no Flash, it can only be written and run in RAM.
|
||||
Example firmware source: https://github.com/boschsensortec/BHY2_SensorAPI/tree/master/firmware
|
||||
You can also compile custom firmware to write
|
||||
How to build custom firmware see : https://www.bosch-sensortec.com/media/boschsensortec/downloads/application_notes_1/bst-bhi260ab-an000.pdf
|
||||
*/
|
||||
#define WRITE_TO_FLASH 1 //Set 1 write fw to flash ,set 0 write fw to ram
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
#include "BHI260_aux_BMM150_BME280-flash.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_bme280_flash_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_bme280_flash_fw);
|
||||
|
||||
#else
|
||||
#include "BHI260_aux_BMM150_BME280.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_bme280_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_bme280_fw);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 27
|
||||
#define BHI260AP_MISO 46
|
||||
#define BHI260AP_SCK 3
|
||||
#define BHI260AP_CS 28
|
||||
#define BHI260AP_IRQ 30
|
||||
#define BHI260AP_RST -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
|
||||
void parse_bme280_sensor_data(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
float humidity = 0;
|
||||
float temperature = 0;
|
||||
float pressure = 0;
|
||||
switch (sensor_id) {
|
||||
case SENSOR_ID_HUM:
|
||||
bhy2_parse_humidity(data_ptr, &humidity);
|
||||
Serial.print("humidity:"); Serial.print(humidity); Serial.println("%");
|
||||
break;
|
||||
case SENSOR_ID_TEMP:
|
||||
bhy2_parse_temperature_celsius(data_ptr, &temperature);
|
||||
Serial.print("temperature:"); Serial.print(temperature); Serial.println("*C");
|
||||
break;
|
||||
case SENSOR_ID_BARO:
|
||||
bhy2_parse_pressure(data_ptr, &pressure);
|
||||
Serial.print("pressure:"); Serial.print(pressure); Serial.println("hPa");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
// Set the firmware array address and firmware size
|
||||
bhy.setFirmware(firmware, fw_size, WRITE_TO_FLASH);
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
// Set to load firmware from flash
|
||||
bhy.setBootFormFlash(true);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 0.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* Report immediately */
|
||||
|
||||
/*
|
||||
* Enable BME280 function
|
||||
* Function depends on BME280.
|
||||
* If the hardware is not connected to BME280, the function cannot be used.
|
||||
* * */
|
||||
bhy.configure(SENSOR_ID_TEMP, sample_rate, report_latency_ms);
|
||||
bhy.configure(SENSOR_ID_HUM, sample_rate, report_latency_ms);
|
||||
bhy.configure(SENSOR_ID_BARO, sample_rate, report_latency_ms);
|
||||
|
||||
|
||||
// Register BME280 data parse callback function
|
||||
bhy.onResultEvent(SENSOR_ID_TEMP, parse_bme280_sensor_data);
|
||||
bhy.onResultEvent(SENSOR_ID_HUM, parse_bme280_sensor_data);
|
||||
bhy.onResultEvent(SENSOR_ID_BARO, parse_bme280_sensor_data);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10287
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_aux_BMM150_euler.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-07-23
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
/*
|
||||
Write the firmware containing the BMM150 magnetometer function into the flash.
|
||||
This function requires the BHI260AP external SPI Flash.
|
||||
If there is no Flash, it can only be written and run in RAM.
|
||||
Example firmware source: https://github.com/boschsensortec/BHY2_SensorAPI/tree/master/firmware
|
||||
You can also compile custom firmware to write
|
||||
How to build custom firmware see : https://www.bosch-sensortec.com/media/boschsensortec/downloads/application_notes_1/bst-bhi260ab-an000.pdf
|
||||
*/
|
||||
#define WRITE_TO_FLASH 1 //Set 1 write fw to flash ,set 0 write fw to ram
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
#include "BHI260AP_aux_BMM150-flash.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_flash_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_flash_fw);
|
||||
|
||||
#else
|
||||
#include "BHI260AP_aux_BMM150.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_fw);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 27
|
||||
#define BHI260AP_MISO 46
|
||||
#define BHI260AP_SCK 3
|
||||
#define BHI260AP_CS 28
|
||||
#define BHI260AP_IRQ 30
|
||||
#define BHI260AP_RST -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
|
||||
void parse_euler(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
struct bhy2_data_orientation data;
|
||||
uint32_t s, ns;
|
||||
uint64_t tns;
|
||||
|
||||
// Function to parse FIFO frame data into orientation
|
||||
bhy2_parse_orientation(data_ptr, &data);
|
||||
|
||||
uint64_t _timestamp = *timestamp;
|
||||
time_to_s_ns(_timestamp, &s, &ns, &tns);
|
||||
|
||||
uint8_t accuracy = bhy.getAccuracy();
|
||||
if (accuracy) {
|
||||
|
||||
Serial.print("SID:"); Serial.print(sensor_id);
|
||||
Serial.print(" T:"); Serial.print(s);
|
||||
Serial.print("."); Serial.print(ns);
|
||||
Serial.print(" x:"); Serial.print(data.heading * 360.0f / 32768.0f);
|
||||
Serial.print(" y:"); Serial.print(data.pitch * 360.0f / 32768.0f);
|
||||
Serial.print(" x:"); Serial.print(data.roll * 360.0f / 32768.0f);
|
||||
Serial.print(" acc:"); Serial.print(accuracy);
|
||||
/*
|
||||
Serial.printf("SID: %u; T: %u.%09u; h: %f, p: %f, r: %f; acc: %u\r\n",
|
||||
sensor_id,
|
||||
s,
|
||||
ns,
|
||||
data.heading * 360.0f / 32768.0f,
|
||||
data.pitch * 360.0f / 32768.0f,
|
||||
data.roll * 360.0f / 32768.0f,
|
||||
accuracy);
|
||||
*/
|
||||
} else {
|
||||
|
||||
Serial.print("SID:"); Serial.print(sensor_id);
|
||||
Serial.print(" T:"); Serial.print(s);
|
||||
Serial.print("."); Serial.print(ns);
|
||||
Serial.print(" x:"); Serial.print(data.heading * 360.0f / 32768.0f);
|
||||
Serial.print(" y:"); Serial.print(data.pitch * 360.0f / 32768.0f);
|
||||
Serial.print(" x:"); Serial.print(data.roll * 360.0f / 32768.0f);
|
||||
/*
|
||||
Serial.printf("SID: %u; T: %u.%09u; h: %f, p: %f, r: %f\r\n",
|
||||
sensor_id,
|
||||
s,
|
||||
ns,
|
||||
data.heading * 360.0f / 32768.0f,
|
||||
data.pitch * 360.0f / 32768.0f,
|
||||
data.roll * 360.0f / 32768.0f);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
// Set the firmware array address and firmware size
|
||||
bhy.setFirmware(firmware, fw_size, WRITE_TO_FLASH);
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
// Set to load firmware from flash
|
||||
bhy.setBootFormFlash(true);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* Report immediately */
|
||||
|
||||
/*
|
||||
* Enable Euler function
|
||||
* The Euler function depends on BMM150.
|
||||
* If the hardware is not connected to BMM150, the Euler function cannot be used.
|
||||
* * */
|
||||
bhy.configure(SENSOR_EULER_ID, sample_rate, report_latency_ms);
|
||||
|
||||
// Register event callback function
|
||||
bhy.onResultEvent(SENSOR_EULER_ID, parse_euler);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9710
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+179
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BHI260AP_aux_BMM150_quaternion.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-07-23
|
||||
* @note Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
/*
|
||||
Write the firmware containing the BMM150 magnetometer function into the flash.
|
||||
This function requires the BHI260AP external SPI Flash.
|
||||
If there is no Flash, it can only be written and run in RAM.
|
||||
Example firmware source: https://github.com/boschsensortec/BHY2_SensorAPI/tree/master/firmware
|
||||
You can also compile custom firmware to write
|
||||
How to build custom firmware see : https://www.bosch-sensortec.com/media/boschsensortec/downloads/application_notes_1/bst-bhi260ab-an000.pdf
|
||||
*/
|
||||
#define WRITE_TO_FLASH 1 //Set 1 write fw to flash ,set 0 write fw to ram
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
#include "BHI260AP_aux_BMM150-flash.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_flash_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_flash_fw);
|
||||
|
||||
#else
|
||||
#include "BHI260AP_aux_BMM150.fw.h"
|
||||
const uint8_t *firmware = bhi26ap_aux_bmm150_fw;
|
||||
const size_t fw_size = sizeof(bhi26ap_aux_bmm150_fw);
|
||||
#endif
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
#define BHI260AP_SDA 21
|
||||
#define BHI260AP_SCL 22
|
||||
#define BHI260AP_IRQ 39
|
||||
#define BHI260AP_RST -1
|
||||
#else
|
||||
#define BHI260AP_MOSI 27
|
||||
#define BHI260AP_MISO 46
|
||||
#define BHI260AP_SCK 3
|
||||
#define BHI260AP_CS 28
|
||||
#define BHI260AP_IRQ 30
|
||||
#define BHI260AP_RST -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorBHI260AP bhy;
|
||||
|
||||
|
||||
void parse_quaternion(uint8_t sensor_id, uint8_t *data_ptr, uint32_t len, uint64_t *timestamp)
|
||||
{
|
||||
struct bhy2_data_quaternion data;
|
||||
uint32_t s, ns;
|
||||
uint64_t tns;
|
||||
|
||||
// Function to parse FIFO frame data into orientation
|
||||
bhy2_parse_quaternion(data_ptr, &data);
|
||||
|
||||
uint64_t _timestamp = *timestamp;
|
||||
time_to_s_ns(_timestamp, &s, &ns, &tns);
|
||||
|
||||
|
||||
Serial.print("SID:"); Serial.print(sensor_id);
|
||||
Serial.print(" T:"); Serial.print(s);
|
||||
Serial.print("."); Serial.print(ns);
|
||||
Serial.print(" x:"); Serial.print(data.x / 16384.0f);
|
||||
Serial.print(" y:"); Serial.print(data.y / 16384.0f);
|
||||
Serial.print(" x:"); Serial.print(data.z / 16384.0f);
|
||||
Serial.print(" w:"); Serial.print(data.w / 16384.0f);
|
||||
Serial.print(" acc:"); Serial.print(((data.accuracy * 180.0f) / 16384.0f) / 3.141592653589793f);
|
||||
|
||||
/*
|
||||
Serial.printf("SID: %u; T: %u.%09u; x: %f, y: %f, z: %f, w: %f; acc: %.2f\r\n",
|
||||
sensor_id,
|
||||
s,
|
||||
ns,
|
||||
data.x / 16384.0f,
|
||||
data.y / 16384.0f,
|
||||
data.z / 16384.0f,
|
||||
data.w / 16384.0f,
|
||||
((data.accuracy * 180.0f) / 16384.0f) / 3.141592653589793f);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
// Set the reset pin and interrupt pin, if any
|
||||
bhy.setPins(BHI260AP_RST, BHI260AP_IRQ);
|
||||
|
||||
// Set the firmware array address and firmware size
|
||||
bhy.setFirmware(firmware, fw_size, WRITE_TO_FLASH);
|
||||
|
||||
#if WRITE_TO_FLASH
|
||||
// Set to load firmware from flash
|
||||
bhy.setBootFormFlash(true);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BHY2_USE_I2C
|
||||
// Using I2C interface
|
||||
// BHI260AP_SLAVE_ADDRESS_L = 0x28
|
||||
// BHI260AP_SLAVE_ADDRESS_H = 0x29
|
||||
if (!bhy.init(Wire, BHI260AP_SDA, BHI260AP_SCL, BHI260AP_SLAVE_ADDRESS_L)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Using SPI interface
|
||||
if (!bhy.init(SPI, BHI260AP_CS, BHI260AP_MOSI, BHI260AP_MISO, BHI260AP_SCK)) {
|
||||
Serial.print("Failed to init BHI260AP - ");
|
||||
Serial.println(bhy.getError());
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println("Init BHI260AP Sensor success!");
|
||||
|
||||
// Output all available sensors to Serial
|
||||
bhy.printSensors(Serial);
|
||||
|
||||
float sample_rate = 100.0; /* Read out hintr_ctrl measured at 100Hz */
|
||||
uint32_t report_latency_ms = 0; /* Report immediately */
|
||||
|
||||
/*
|
||||
* Enable Euler function
|
||||
* The Euler function depends on BMM150.
|
||||
* If the hardware is not connected to BMM150, the Euler function cannot be used.
|
||||
* * */
|
||||
bhy.configure(QUAT_SENSOR_ID, sample_rate, report_latency_ms);
|
||||
|
||||
// Register event callback function
|
||||
bhy.onResultEvent(QUAT_SENSOR_ID, parse_quaternion);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Update sensor fifo
|
||||
bhy.update();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BMA423_Feature.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-03
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBMA423.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 21
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 22
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 39
|
||||
#endif
|
||||
|
||||
SensorBMA423 accel;
|
||||
uint32_t lastMillis;
|
||||
bool sensorIRQ = false;
|
||||
|
||||
|
||||
void setFlag()
|
||||
{
|
||||
sensorIRQ = true;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
attachInterrupt(SENSOR_IRQ, setFlag, RISING);
|
||||
|
||||
if (!accel.begin(Wire, BMA423_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find BMA423 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init BAM423 Sensor success!");
|
||||
|
||||
//Default 4G ,200HZ
|
||||
accel.configAccelerometer();
|
||||
|
||||
// Enable acceleration sensor
|
||||
accel.enableAccelerometer();
|
||||
|
||||
// Enable pedometer steps
|
||||
accel.enablePedometer();
|
||||
|
||||
// Emptying the pedometer steps
|
||||
accel.resetPedometer();
|
||||
|
||||
// Enable sensor features
|
||||
accel.enableFeature(SensorBMA423::FEATURE_STEP_CNTR |
|
||||
SensorBMA423::FEATURE_ANY_MOTION |
|
||||
SensorBMA423::FEATURE_ACTIVITY |
|
||||
SensorBMA423::FEATURE_TILT |
|
||||
SensorBMA423::FEATURE_WAKEUP,
|
||||
true);
|
||||
|
||||
// Pedometer interrupt enable
|
||||
accel.enablePedometerIRQ();
|
||||
// Tilt interrupt enable
|
||||
accel.enableTiltIRQ();
|
||||
// DoubleTap interrupt enable
|
||||
accel.enableWakeupIRQ();
|
||||
// Any motion / no motion interrupt enable
|
||||
accel.enableAnyNoMotionIRQ();
|
||||
// Activity interruption enable
|
||||
accel.enableActivityIRQ();
|
||||
// Chip interrupt function enable
|
||||
accel.configInterrupt();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (sensorIRQ) {
|
||||
sensorIRQ = false;
|
||||
// The interrupt status must be read after an interrupt is detected
|
||||
uint16_t status = accel.readIrqStatus();
|
||||
Serial.printf("Accelerometer interrupt mask : 0x%x\n", status);
|
||||
|
||||
if (accel.isPedometer()) {
|
||||
uint32_t stepCounter = accel.getPedometerCounter();
|
||||
Serial.print("Step count interrupt,step Counter:");
|
||||
Serial.println(stepCounter);
|
||||
}
|
||||
if (accel.isActivity()) {
|
||||
Serial.println("Activity interrupt");
|
||||
}
|
||||
if (accel.isTilt()) {
|
||||
Serial.println("Tilt interrupt");
|
||||
}
|
||||
if (accel.isDoubleTap()) {
|
||||
Serial.println("DoubleTap interrupt");
|
||||
}
|
||||
if (accel.isAnyNoMotion()) {
|
||||
Serial.println("Any motion / no motion interrupt");
|
||||
}
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file BMM150_GetDataExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-10-10
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorBMM150.hpp"
|
||||
#include "SensorWireHelper.h"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 33
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 35
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorBMM150 bmm;
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
// Using I2C interface
|
||||
if (!bmm.init(Wire, SENSOR_SDA, SENSOR_SCL, BMM150_I2C_ADDRESS_CSB_HIGH_SDO_LOW)) {
|
||||
Serial.print("Failed to init BMM150 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init BMM150 Sensor success!");
|
||||
|
||||
/* Set magnetometer run mode */
|
||||
/**
|
||||
* * POWERMODE_NORMAL,
|
||||
* * POWERMODE_FORCED,
|
||||
* * POWERMODE_SLEEP,
|
||||
* * POWERMODE_SUSPEND,
|
||||
*/
|
||||
bmm.setMode(SensorBMM150::POWERMODE_NORMAL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int16_t x, y, z;
|
||||
/* Read mag data */
|
||||
/* Unit for magnetometer data is microtesla(uT) */
|
||||
if (bmm.getMag(x, y, z)) {
|
||||
Serial.print("X:");
|
||||
Serial.print(x);
|
||||
Serial.print("uT,");
|
||||
Serial.print("Y:");
|
||||
Serial.print(y);
|
||||
Serial.print("uT,");
|
||||
Serial.print("Z:");
|
||||
Serial.print(z);
|
||||
Serial.println("uT");
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file CM32181_LightSensor.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-14
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorCM32181.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 39
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 40
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 1
|
||||
#endif
|
||||
|
||||
SensorCM32181 light;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!light.begin(Wire, CM32181_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find CM32181 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init CM32181 Sensor success!");
|
||||
|
||||
int id = light.getChipID();
|
||||
Serial.print("CM32181 ID = "); Serial.println(id);
|
||||
|
||||
/*
|
||||
Sensitivity mode selection
|
||||
SAMPLING_X1
|
||||
SAMPLING_X2
|
||||
SAMPLING_X1_8
|
||||
SAMPLING_X1_4
|
||||
*/
|
||||
light.setSampling(SensorCM32181::SAMPLING_X2);
|
||||
|
||||
//Power On sensor
|
||||
light.powerOn();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Get raw data
|
||||
uint16_t raw = light.getRaw();
|
||||
|
||||
// Get conversion data , The manual does not provide information on how to obtain the
|
||||
// calibration value, now use the calibration value 0.28 provided by the manual
|
||||
float lux = light.getLux();
|
||||
Serial.printf("RAW:%u Lux:%.2f\n", raw, lux);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file CM32181_LightSensorInterrupt.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-13
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorCM32181.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 39
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 40
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 1
|
||||
#endif
|
||||
|
||||
SensorCM32181 light;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!light.begin(Wire, CM32181_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find CM32181 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init CM32181 Sensor success!");
|
||||
|
||||
int id = light.getChipID();
|
||||
Serial.print("CM32181 ID = "); Serial.println(id);
|
||||
|
||||
/*
|
||||
Sensitivity mode selection
|
||||
SAMPLING_X1
|
||||
SAMPLING_X2
|
||||
SAMPLING_X1_8
|
||||
SAMPLING_X1_4
|
||||
*/
|
||||
light.setSampling(SensorCM32181::SAMPLING_X2,
|
||||
SensorCM32181::INTEGRATION_TIME_400MS
|
||||
);
|
||||
|
||||
// Set high and low thresholds. If the threshold is higher or lower than the set threshold, an interrupt will be triggered.
|
||||
uint16_t lowThresholdRaw = 100;
|
||||
uint16_t highThresholdRaw = 250;
|
||||
light.setIntThreshold(lowThresholdRaw, highThresholdRaw);
|
||||
|
||||
//Power On sensor
|
||||
light.powerOn();
|
||||
|
||||
// Turn on interrupt
|
||||
light.enableINT();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int pinVal = digitalRead(SENSOR_IRQ) ;
|
||||
if (pinVal == LOW) {
|
||||
|
||||
// After triggering the interrupt, the interrupt status must be read
|
||||
SensorCM32181::InterruptEvent event = light.getIrqStatus();
|
||||
|
||||
// Turn off interrupts
|
||||
light.disableINT();
|
||||
|
||||
// Get Status
|
||||
switch (event) {
|
||||
case SensorCM32181::ALS_EVENT_LOW_TRIGGER:
|
||||
Serial.println("Low interrupt event");
|
||||
break;
|
||||
case SensorCM32181::ALS_EVENT_HIGH_TRIGGER:
|
||||
Serial.println("High interrupt event");
|
||||
break;
|
||||
default:
|
||||
Serial.println("This is an impossible place to reach");
|
||||
break;
|
||||
}
|
||||
|
||||
// Get raw data
|
||||
uint16_t raw = light.getRaw();
|
||||
|
||||
// Get conversion data , The manual does not provide information on how to obtain the
|
||||
// calibration value, now use the calibration value 0.28 provided by the manual
|
||||
float lux = light.getLux();
|
||||
Serial.printf("IRQ:%d RAW:%u Lux:%.2f\n", pinVal, raw, lux);
|
||||
|
||||
|
||||
// Turn on interrupts
|
||||
light.enableINT();
|
||||
}
|
||||
|
||||
delay(800);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,468 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file DRV2605_Basic.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-03
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorDRV2605.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 21
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 22
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 39
|
||||
#endif
|
||||
|
||||
SensorDRV2605 drv;
|
||||
|
||||
uint8_t effect = 1;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
|
||||
if (!drv.begin(Wire, DRV2605_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find DRV2605 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Serial.println("Init DRV2605 Sensor success!");
|
||||
|
||||
|
||||
drv.selectLibrary(1);
|
||||
|
||||
// I2C trigger by sending 'run' command
|
||||
// default, internal trigger when sending RUN command
|
||||
drv.setMode(DRV2605_MODE_INTTRIG);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print("Effect #"); Serial.println(effect);
|
||||
|
||||
if (effect == 1) {
|
||||
Serial.println("11.2 Waveform Library Effects List");
|
||||
}
|
||||
|
||||
if (effect == 1) {
|
||||
Serial.println(F("1 - Strong Click - 100%"));
|
||||
}
|
||||
if (effect == 2) {
|
||||
Serial.println(F("2 - Strong Click - 60%"));
|
||||
}
|
||||
if (effect == 3) {
|
||||
Serial.println(F("3 - Strong Click - 30%"));
|
||||
}
|
||||
if (effect == 4) {
|
||||
Serial.println(F("4 - Sharp Click - 100%"));
|
||||
}
|
||||
if (effect == 5) {
|
||||
Serial.println(F("5 - Sharp Click - 60%"));
|
||||
}
|
||||
if (effect == 6) {
|
||||
Serial.println(F("6 - Sharp Click - 30%"));
|
||||
}
|
||||
if (effect == 7) {
|
||||
Serial.println(F("7 - Soft Bump - 100%"));
|
||||
}
|
||||
if (effect == 8) {
|
||||
Serial.println(F("8 - Soft Bump - 60%"));
|
||||
}
|
||||
if (effect == 9) {
|
||||
Serial.println(F("9 - Soft Bump - 30%"));
|
||||
}
|
||||
if (effect == 10) {
|
||||
Serial.println(F("10 - Double Click - 100%"));
|
||||
}
|
||||
if (effect == 11) {
|
||||
Serial.println(F("11 - Double Click - 60%"));
|
||||
}
|
||||
if (effect == 12) {
|
||||
Serial.println(F("12 - Triple Click - 100%"));
|
||||
}
|
||||
if (effect == 13) {
|
||||
Serial.println(F("13 - Soft Fuzz - 60%"));
|
||||
}
|
||||
if (effect == 14) {
|
||||
Serial.println(F("14 - Strong Buzz - 100%"));
|
||||
}
|
||||
if (effect == 15) {
|
||||
Serial.println(F("15 - 750 ms Alert 100%"));
|
||||
}
|
||||
if (effect == 16) {
|
||||
Serial.println(F("16 - 1000 ms Alert 100%"));
|
||||
}
|
||||
if (effect == 17) {
|
||||
Serial.println(F("17 - Strong Click 1 - 100%"));
|
||||
}
|
||||
if (effect == 18) {
|
||||
Serial.println(F("18 - Strong Click 2 - 80%"));
|
||||
}
|
||||
if (effect == 19) {
|
||||
Serial.println(F("19 - Strong Click 3 - 60%"));
|
||||
}
|
||||
if (effect == 20) {
|
||||
Serial.println(F("20 - Strong Click 4 - 30%"));
|
||||
}
|
||||
if (effect == 21) {
|
||||
Serial.println(F("21 - Medium Click 1 - 100%"));
|
||||
}
|
||||
if (effect == 22) {
|
||||
Serial.println(F("22 - Medium Click 2 - 80%"));
|
||||
}
|
||||
if (effect == 23) {
|
||||
Serial.println(F("23 - Medium Click 3 - 60%"));
|
||||
}
|
||||
if (effect == 24) {
|
||||
Serial.println(F("24 - Sharp Tick 1 - 100%"));
|
||||
}
|
||||
if (effect == 25) {
|
||||
Serial.println(F("25 - Sharp Tick 2 - 80%"));
|
||||
}
|
||||
if (effect == 26) {
|
||||
Serial.println(F("26 - Sharp Tick 3 - 60%"));
|
||||
}
|
||||
if (effect == 27) {
|
||||
Serial.println(F("27 - Short Double Click Strong 1 - 100%"));
|
||||
}
|
||||
if (effect == 28) {
|
||||
Serial.println(F("28 - Short Double Click Strong 2 - 80%"));
|
||||
}
|
||||
if (effect == 29) {
|
||||
Serial.println(F("29 - Short Double Click Strong 3 - 60%"));
|
||||
}
|
||||
if (effect == 30) {
|
||||
Serial.println(F("30 - Short Double Click Strong 4 - 30%"));
|
||||
}
|
||||
if (effect == 31) {
|
||||
Serial.println(F("31 - Short Double Click Medium 1 - 100%"));
|
||||
}
|
||||
if (effect == 32) {
|
||||
Serial.println(F("32 - Short Double Click Medium 2 - 80%"));
|
||||
}
|
||||
if (effect == 33) {
|
||||
Serial.println(F("33 - Short Double Click Medium 3 - 60%"));
|
||||
}
|
||||
if (effect == 34) {
|
||||
Serial.println(F("34 - Short Double Sharp Tick 1 - 100%"));
|
||||
}
|
||||
if (effect == 35) {
|
||||
Serial.println(F("35 - Short Double Sharp Tick 2 - 80%"));
|
||||
}
|
||||
if (effect == 36) {
|
||||
Serial.println(F("36 - Short Double Sharp Tick 3 - 60%"));
|
||||
}
|
||||
if (effect == 37) {
|
||||
Serial.println(F("37 - Long Double Sharp Click Strong 1 - 100%"));
|
||||
}
|
||||
if (effect == 38) {
|
||||
Serial.println(F("38 - Long Double Sharp Click Strong 2 - 80%"));
|
||||
}
|
||||
if (effect == 39) {
|
||||
Serial.println(F("39 - Long Double Sharp Click Strong 3 - 60%"));
|
||||
}
|
||||
if (effect == 40) {
|
||||
Serial.println(F("40 - Long Double Sharp Click Strong 4 - 30%"));
|
||||
}
|
||||
if (effect == 41) {
|
||||
Serial.println(F("41 - Long Double Sharp Click Medium 1 - 100%"));
|
||||
}
|
||||
if (effect == 42) {
|
||||
Serial.println(F("42 - Long Double Sharp Click Medium 2 - 80%"));
|
||||
}
|
||||
if (effect == 43) {
|
||||
Serial.println(F("43 - Long Double Sharp Click Medium 3 - 60%"));
|
||||
}
|
||||
if (effect == 44) {
|
||||
Serial.println(F("44 - Long Double Sharp Tick 1 - 100%"));
|
||||
}
|
||||
if (effect == 45) {
|
||||
Serial.println(F("45 - Long Double Sharp Tick 2 - 80%"));
|
||||
}
|
||||
if (effect == 46) {
|
||||
Serial.println(F("46 - Long Double Sharp Tick 3 - 60%"));
|
||||
}
|
||||
if (effect == 47) {
|
||||
Serial.println(F("47 - Buzz 1 - 100%"));
|
||||
}
|
||||
if (effect == 48) {
|
||||
Serial.println(F("48 - Buzz 2 - 80%"));
|
||||
}
|
||||
if (effect == 49) {
|
||||
Serial.println(F("49 - Buzz 3 - 60%"));
|
||||
}
|
||||
if (effect == 50) {
|
||||
Serial.println(F("50 - Buzz 4 - 40%"));
|
||||
}
|
||||
if (effect == 51) {
|
||||
Serial.println(F("51 - Buzz 5 - 20%"));
|
||||
}
|
||||
if (effect == 52) {
|
||||
Serial.println(F("52 - Pulsing Strong 1 - 100%"));
|
||||
}
|
||||
if (effect == 53) {
|
||||
Serial.println(F("53 - Pulsing Strong 2 - 60%"));
|
||||
}
|
||||
if (effect == 54) {
|
||||
Serial.println(F("54 - Pulsing Medium 1 - 100%"));
|
||||
}
|
||||
if (effect == 55) {
|
||||
Serial.println(F("55 - Pulsing Medium 2 - 60%"));
|
||||
}
|
||||
if (effect == 56) {
|
||||
Serial.println(F("56 - Pulsing Sharp 1 - 100%"));
|
||||
}
|
||||
if (effect == 57) {
|
||||
Serial.println(F("57 - Pulsing Sharp 2 - 60%"));
|
||||
}
|
||||
if (effect == 58) {
|
||||
Serial.println(F("58 - Transition Click 1 - 100%"));
|
||||
}
|
||||
if (effect == 59) {
|
||||
Serial.println(F("59 - Transition Click 2 - 80%"));
|
||||
}
|
||||
if (effect == 60) {
|
||||
Serial.println(F("60 - Transition Click 3 - 60%"));
|
||||
}
|
||||
if (effect == 61) {
|
||||
Serial.println(F("61 - Transition Click 4 - 40%"));
|
||||
}
|
||||
if (effect == 62) {
|
||||
Serial.println(F("62 - Transition Click 5 - 20%"));
|
||||
}
|
||||
if (effect == 63) {
|
||||
Serial.println(F("63 - Transition Click 6 - 10%"));
|
||||
}
|
||||
if (effect == 64) {
|
||||
Serial.println(F("64 - Transition Hum 1 - 100%"));
|
||||
}
|
||||
if (effect == 65) {
|
||||
Serial.println(F("65 - Transition Hum 2 - 80%"));
|
||||
}
|
||||
if (effect == 66) {
|
||||
Serial.println(F("66 - Transition Hum 3 - 60%"));
|
||||
}
|
||||
if (effect == 67) {
|
||||
Serial.println(F("67 - Transition Hum 4 - 40%"));
|
||||
}
|
||||
if (effect == 68) {
|
||||
Serial.println(F("68 - Transition Hum 5 - 20%"));
|
||||
}
|
||||
if (effect == 69) {
|
||||
Serial.println(F("69 - Transition Hum 6 - 10%"));
|
||||
}
|
||||
if (effect == 70) {
|
||||
Serial.println(F("70 - Transition Ramp Down Long Smooth 1 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 71) {
|
||||
Serial.println(F("71 - Transition Ramp Down Long Smooth 2 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 72) {
|
||||
Serial.println(F("72 - Transition Ramp Down Medium Smooth 1 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 73) {
|
||||
Serial.println(F("73 - Transition Ramp Down Medium Smooth 2 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 74) {
|
||||
Serial.println(F("74 - Transition Ramp Down Short Smooth 1 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 75) {
|
||||
Serial.println(F("75 - Transition Ramp Down Short Smooth 2 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 76) {
|
||||
Serial.println(F("76 - Transition Ramp Down Long Sharp 1 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 77) {
|
||||
Serial.println(F("77 - Transition Ramp Down Long Sharp 2 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 78) {
|
||||
Serial.println(F("78 - Transition Ramp Down Medium Sharp 1 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 79) {
|
||||
Serial.println(F("79 - Transition Ramp Down Medium Sharp 2 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 80) {
|
||||
Serial.println(F("80 - Transition Ramp Down Short Sharp 1 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 81) {
|
||||
Serial.println(F("81 - Transition Ramp Down Short Sharp 2 - 100 to 0%"));
|
||||
}
|
||||
if (effect == 82) {
|
||||
Serial.println(F("82 - Transition Ramp Up Long Smooth 1 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 83) {
|
||||
Serial.println(F("83 - Transition Ramp Up Long Smooth 2 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 84) {
|
||||
Serial.println(F("84 - Transition Ramp Up Medium Smooth 1 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 85) {
|
||||
Serial.println(F("85 - Transition Ramp Up Medium Smooth 2 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 86) {
|
||||
Serial.println(F("86 - Transition Ramp Up Short Smooth 1 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 87) {
|
||||
Serial.println(F("87 - Transition Ramp Up Short Smooth 2 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 88) {
|
||||
Serial.println(F("88 - Transition Ramp Up Long Sharp 1 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 89) {
|
||||
Serial.println(F("89 - Transition Ramp Up Long Sharp 2 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 90) {
|
||||
Serial.println(F("90 - Transition Ramp Up Medium Sharp 1 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 91) {
|
||||
Serial.println(F("91 - Transition Ramp Up Medium Sharp 2 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 92) {
|
||||
Serial.println(F("92 - Transition Ramp Up Short Sharp 1 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 93) {
|
||||
Serial.println(F("93 - Transition Ramp Up Short Sharp 2 - 0 to 100%"));
|
||||
}
|
||||
if (effect == 94) {
|
||||
Serial.println(F("94 - Transition Ramp Down Long Smooth 1 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 95) {
|
||||
Serial.println(F("95 - Transition Ramp Down Long Smooth 2 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 96) {
|
||||
Serial.println(F("96 - Transition Ramp Down Medium Smooth 1 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 97) {
|
||||
Serial.println(F("97 - Transition Ramp Down Medium Smooth 2 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 98) {
|
||||
Serial.println(F("98 - Transition Ramp Down Short Smooth 1 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 99) {
|
||||
Serial.println(F("99 - Transition Ramp Down Short Smooth 2 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 100) {
|
||||
Serial.println(F("100 - Transition Ramp Down Long Sharp 1 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 101) {
|
||||
Serial.println(F("101 - Transition Ramp Down Long Sharp 2 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 102) {
|
||||
Serial.println(F("102 - Transition Ramp Down Medium Sharp 1 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 103) {
|
||||
Serial.println(F("103 - Transition Ramp Down Medium Sharp 2 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 104) {
|
||||
Serial.println(F("104 - Transition Ramp Down Short Sharp 1 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 105) {
|
||||
Serial.println(F("105 - Transition Ramp Down Short Sharp 2 - 50 to 0%"));
|
||||
}
|
||||
if (effect == 106) {
|
||||
Serial.println(F("106 - Transition Ramp Up Long Smooth 1 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 107) {
|
||||
Serial.println(F("107 - Transition Ramp Up Long Smooth 2 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 108) {
|
||||
Serial.println(F("108 - Transition Ramp Up Medium Smooth 1 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 109) {
|
||||
Serial.println(F("109 - Transition Ramp Up Medium Smooth 2 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 110) {
|
||||
Serial.println(F("110 - Transition Ramp Up Short Smooth 1 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 111) {
|
||||
Serial.println(F("111 - Transition Ramp Up Short Smooth 2 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 112) {
|
||||
Serial.println(F("112 - Transition Ramp Up Long Sharp 1 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 113) {
|
||||
Serial.println(F("113 - Transition Ramp Up Long Sharp 2 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 114) {
|
||||
Serial.println(F("114 - Transition Ramp Up Medium Sharp 1 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 115) {
|
||||
Serial.println(F("115 - Transition Ramp Up Medium Sharp 2 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 116) {
|
||||
Serial.println(F("116 - Transition Ramp Up Short Sharp 1 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 117) {
|
||||
Serial.println(F("117 - Transition Ramp Up Short Sharp 2 - 0 to 50%"));
|
||||
}
|
||||
if (effect == 118) {
|
||||
Serial.println(F("118 - Long buzz for programmatic stopping - 100%"));
|
||||
}
|
||||
if (effect == 119) {
|
||||
Serial.println(F("119 - Smooth Hum 1 (No kick or brake pulse) - 50%"));
|
||||
}
|
||||
if (effect == 120) {
|
||||
Serial.println(F("120 - Smooth Hum 2 (No kick or brake pulse) - 40%"));
|
||||
}
|
||||
if (effect == 121) {
|
||||
Serial.println(F("121 - Smooth Hum 3 (No kick or brake pulse) - 30%"));
|
||||
}
|
||||
if (effect == 122) {
|
||||
Serial.println(F("122 - Smooth Hum 4 (No kick or brake pulse) - 20%"));
|
||||
}
|
||||
if (effect == 123) {
|
||||
Serial.println(F("123 - Smooth Hum 5 (No kick or brake pulse) - 10%"));
|
||||
}
|
||||
|
||||
// set the effect to play
|
||||
drv.setWaveform(0, effect); // play effect
|
||||
drv.setWaveform(1, 0); // end waveform
|
||||
|
||||
// play the effect!
|
||||
drv.run();
|
||||
|
||||
// wait a bit
|
||||
delay(500);
|
||||
|
||||
effect++;
|
||||
if (effect > 117) effect = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS ../../../SensorLib)
|
||||
|
||||
project(ESP_IDF_TouchDrv_Example)
|
||||
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
|
||||
# project subdirectory.
|
||||
#
|
||||
|
||||
PROJECT_NAME := ESP_IDF_TouchDrv_Example
|
||||
|
||||
EXTRA_COMPONENT_DIRS = ../../../SensorLib
|
||||
|
||||
include $(IDF_PATH)/make/project.mk
|
||||
@@ -0,0 +1,181 @@
|
||||
# ESP_IDF_TouchDrv_Example
|
||||
|
||||
```
|
||||
The current example only writes the CSTxxx series touch application.
|
||||
The other sensors have not been added, but the methods are the same.
|
||||
```
|
||||
|
||||
|
||||
### Configure the Project
|
||||
|
||||
Open the project configuration menu (`idf.py menuconfig`).
|
||||
|
||||
|
||||
In the `SensorLib Example Configuration` menu:
|
||||
|
||||
* Select the PMU Type in the `SensorLib read and write methods` option,Choose according to the situation
|
||||
1. Implemented using built-in read and write methods (Read and write methods are provided internally by SensorLib, supporting high version esp-idf >= 5.0, and low version methods (< 5.0))
|
||||
2. Implemented using read and write callback methods (Implemented using externally provided methods, suitable for multiple platforms)
|
||||
* In `Sensor SCL GPIO Num` select the clock pin to connect to the PMU,the default is 17
|
||||
* In `Sensor SDA GPIO Num` select the data pin connected to the PMU,the default is 18
|
||||
* Select the interrupt pin connected to the PMU in `Sensor Interrupt Pin`, the default is 16
|
||||
* Select `Sensor reset Pin` , the default is 21
|
||||
* `Master Frequency` The maximum communication frequency defaults to 100000HZ, and you can decide whether to change it according to the situation.
|
||||
|
||||
## How to Use Example
|
||||
|
||||
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`. default use **esp32s3**
|
||||
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
## Example Output
|
||||
|
||||
The output information is to configure the output voltage and enable status of the PMU
|
||||
|
||||
```
|
||||
ESP-ROM:esp32s3-20210327
|
||||
Build:Mar 27 2021
|
||||
rst:0x15 (USB_UART_CHIP_RESET),boot:0xa (SPI_FAST_FLASH_BOOT)
|
||||
Saved PC:0x403788f6
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:1
|
||||
load:0x3fce3810,len:0x178c
|
||||
load:0x403c9700,len:0x4
|
||||
load:0x403c9704,len:0xbfc
|
||||
load:0x403cc700,len:0x2d64
|
||||
entry 0x403c9900
|
||||
I (26) boot: ESP-IDF v5.3-dev-1288-g5524b692ee 2nd stage bootloader
|
||||
I (27) boot: compile time Jan 10 2024 22:49:17
|
||||
I (27) boot: Multicore bootloader
|
||||
I (31) boot: chip revision: v0.2
|
||||
I (35) boot.esp32s3: Boot SPI Speed : 80MHz
|
||||
I (40) boot.esp32s3: SPI Mode : DIO
|
||||
I (45) boot.esp32s3: SPI Flash Size : 2MB
|
||||
I (49) boot: Enabling RNG early entropy source...
|
||||
I (55) boot: Partition Table:
|
||||
I (58) boot: ## Label Usage Type ST Offset Length
|
||||
I (66) boot: 0 nvs WiFi data 01 02 00009000 00006000
|
||||
I (73) boot: 1 phy_init RF data 01 01 0000f000 00001000
|
||||
I (81) boot: 2 factory factory app 00 00 00010000 00100000
|
||||
I (88) boot: End of partition table
|
||||
I (92) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0e0dch ( 57564) map
|
||||
I (111) esp_image: segment 1: paddr=0001e104 vaddr=3fc93100 size=01f14h ( 7956) load
|
||||
I (113) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=1acb0h (109744) map
|
||||
I (137) esp_image: segment 3: paddr=0003acd8 vaddr=3fc95014 size=00994h ( 2452) load
|
||||
I (138) esp_image: segment 4: paddr=0003b674 vaddr=40374000 size=0f0e0h ( 61664) load
|
||||
I (163) boot: Loaded app from partition at offset 0x10000
|
||||
I (163) boot: Disabling RNG early entropy source...
|
||||
I (163) cpu_start: Multicore app
|
||||
I (176) cpu_start: Pro cpu start user code
|
||||
I (176) cpu_start: cpu freq: 240000000 Hz
|
||||
I (177) cpu_start: Application information:
|
||||
I (177) cpu_start: Project name: ESP_IDF_TouchDrv_Example
|
||||
I (177) cpu_start: App version: v0.1.4-6-gfeaf675-dirty
|
||||
I (177) cpu_start: Compile time: Jan 11 2024 14:01:31
|
||||
I (177) cpu_start: ELF file SHA256: 3ce1527fc...
|
||||
I (178) cpu_start: ESP-IDF: v5.3-dev-1288-g5524b692ee
|
||||
I (178) cpu_start: Min chip rev: v0.0
|
||||
I (178) cpu_start: Max chip rev: v0.99
|
||||
I (178) cpu_start: Chip rev: v0.2
|
||||
I (178) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (179) heap_init: At 3FC96290 len 00053480 (333 KiB): RAM
|
||||
I (179) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
|
||||
I (179) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
|
||||
I (180) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
|
||||
I (181) spi_flash: detected chip: winbond
|
||||
I (181) spi_flash: flash io: dio
|
||||
W (181) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||
W (181) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`
|
||||
I (182) sleep: Configure to isolate all GPIO pins in sleep state
|
||||
I (182) sleep: Enable automatic switching of GPIO sleep configuration
|
||||
I (183) main_task: Started on CPU0
|
||||
I (193) main_task: Calling app_main()
|
||||
I (193) gpio: GPIO[16]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
|
||||
I (193) I2C: Implemented using read and write callback methods (Use lower version < 5.0 API)
|
||||
I (193) mian: I2C initialized successfully
|
||||
I (193) TOUCH: ----touch_drv_init----
|
||||
0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
10: -- -- -- -- -- 15 -- -- -- -- -- -- -- -- -- --
|
||||
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
I (303) TOUCH: Find touch address 0x15
|
||||
I (303) TOUCH: Find touch address 0x15
|
||||
I (303) TOUCH: Implemented using built-in read and write methods (Use lower version < 5.0 API)
|
||||
Using ESP-IDF Driver interface.
|
||||
E (303) i2c: i2c driver install error
|
||||
I (303) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
|
||||
I (303) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
|
||||
Chip ID:0xb5
|
||||
Version :0x2
|
||||
Touch type:CST816T
|
||||
I (383) TOUCH: Init touch SUCCESS!
|
||||
I (383) TOUCH: Some CST816 will automatically enter sleep,can use the touch.disableAutoSleep() to turn off
|
||||
I (383) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
|
||||
I (513) mian: Run...
|
||||
I (513) main_task: Returned from app_main()
|
||||
X[0]:143 Y[0]:127
|
||||
X[0]:143 Y[0]:127
|
||||
X[0]:142 Y[0]:127
|
||||
X[0]:141 Y[0]:126
|
||||
X[0]:138 Y[0]:125
|
||||
X[0]:135 Y[0]:123
|
||||
X[0]:131 Y[0]:121
|
||||
X[0]:126 Y[0]:119
|
||||
X[0]:121 Y[0]:117
|
||||
X[0]:84 Y[0]:146
|
||||
X[0]:85 Y[0]:146
|
||||
X[0]:86 Y[0]:145
|
||||
X[0]:87 Y[0]:143
|
||||
X[0]:88 Y[0]:140
|
||||
X[0]:89 Y[0]:136
|
||||
X[0]:90 Y[0]:132
|
||||
X[0]:91 Y[0]:127
|
||||
X[0]:92 Y[0]:123
|
||||
X[0]:93 Y[0]:119
|
||||
X[0]:94 Y[0]:115
|
||||
X[0]:95 Y[0]:111
|
||||
I (513563) TOUCH: Touch Home button pressed!
|
||||
I (513573) TOUCH: Touch Home button pressed!
|
||||
I (513583) TOUCH: Touch Home button pressed!
|
||||
I (513603) TOUCH: Touch Home button pressed!
|
||||
I (513613) TOUCH: Touch Home button pressed!
|
||||
I (513633) TOUCH: Touch Home button pressed!
|
||||
I (513643) TOUCH: Touch Home button pressed!
|
||||
```
|
||||
|
||||
## Build process example
|
||||
|
||||
Assuming you don't have esp-idf yet
|
||||
|
||||
```
|
||||
mkdir -p ~/esp
|
||||
cd ~/esp
|
||||
git clone --recursive https://github.com/espressif/esp-idf.git
|
||||
git clone https://github.com/lewisxhe/XPowersLib.git
|
||||
cd esp-idf
|
||||
./install.sh
|
||||
. ./export.sh
|
||||
cd ..
|
||||
cd SensorLib/examples/ESP_IDF_Example
|
||||
|
||||
Configure SDA,SCL,INT,RST,Pin
|
||||
...
|
||||
|
||||
idf.py menuconfig
|
||||
idf.py build
|
||||
idf.py -b 921600 flash
|
||||
idf.py monitor
|
||||
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(SRCS
|
||||
"touch_drv.cpp"
|
||||
"i2c_driver.cpp"
|
||||
"main.cpp"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,52 @@
|
||||
menu "SensorLib Example Configuration"
|
||||
|
||||
choice I2C_COMMUNICATION_METHOD
|
||||
prompt "SensorLib read and write methods"
|
||||
default I2C_COMMUNICATION_METHOD_BUILTIN_RW
|
||||
help
|
||||
Define SensorLib read and write methods
|
||||
|
||||
config I2C_COMMUNICATION_METHOD_BUILTIN_RW
|
||||
bool "Implemented using built-in read and write methods"
|
||||
config I2C_COMMUNICATION_METHOD_CALLBACK_RW
|
||||
bool "Implemented using read and write callback methods"
|
||||
endchoice
|
||||
|
||||
config I2C_MASTER_PORT_NUM
|
||||
int "Sensor I2C Port Number"
|
||||
default 1
|
||||
help
|
||||
Port number for I2C Master device.
|
||||
|
||||
config I2C_MASTER_FREQUENCY
|
||||
int "Master Frequency"
|
||||
default 100000
|
||||
help
|
||||
I2C Speed of Master device.
|
||||
|
||||
config SENSOR_SCL
|
||||
int "Sensor SCL GPIO Num"
|
||||
default 17
|
||||
help
|
||||
GPIO number for I2C clock line.
|
||||
|
||||
config SENSOR_SDA
|
||||
int "Sensor SDA GPIO Num"
|
||||
default 18
|
||||
help
|
||||
GPIO number for I2C data line.
|
||||
|
||||
config SENSOR_IRQ
|
||||
int "Sensor Interrupt Pin"
|
||||
default 16
|
||||
help
|
||||
Sensor interrupt pin.
|
||||
|
||||
config SENSOR_RST
|
||||
int "Sensor reset Pin"
|
||||
default 21
|
||||
help
|
||||
Sensor reset pin.
|
||||
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# "main" pseudo-component makefile.
|
||||
#
|
||||
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
* @file port_i2c.cpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @license MIT
|
||||
* @copyright Copyright (c) 2024 Shenzhen Xinyuan Electronic Technology Co., Ltd
|
||||
* @date 2024-01-10
|
||||
*
|
||||
*/
|
||||
#include <cstring>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "i2c_driver.h"
|
||||
|
||||
static const char *TAG = "I2C";
|
||||
|
||||
#define I2C_MASTER_NUM (i2c_port_t)CONFIG_I2C_MASTER_PORT_NUM
|
||||
#define I2C_MASTER_SDA_IO (gpio_num_t)CONFIG_SENSOR_SDA
|
||||
#define I2C_MASTER_SCL_IO (gpio_num_t)CONFIG_SENSOR_SCL
|
||||
#define I2C_MASTER_FREQ_HZ CONFIG_I2C_MASTER_FREQUENCY /*!< I2C master clock frequency */
|
||||
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
|
||||
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
|
||||
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
#include "soc/clk_tree_defs.h"
|
||||
|
||||
i2c_master_dev_handle_t i2c_device;
|
||||
|
||||
// * Using the new API of esp-idf 5.x, you need to pass the I2C BUS handle,
|
||||
// * which is useful when the bus shares multiple devices.
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_I2C_COMMUNICATION_METHOD_CALLBACK_RW
|
||||
|
||||
/**
|
||||
* @brief Read a sequence of bytes from a pmu registers
|
||||
*/
|
||||
int i2c_read_callback(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint8_t len)
|
||||
{
|
||||
esp_err_t ret;
|
||||
if (len == 0) {
|
||||
return ESP_OK;
|
||||
}
|
||||
if (data == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
|
||||
ret = i2c_master_transmit_receive(
|
||||
i2c_device,
|
||||
(const uint8_t *)®Addr,
|
||||
1,
|
||||
data,
|
||||
len,
|
||||
-1);
|
||||
#else
|
||||
|
||||
i2c_cmd_handle_t cmd;
|
||||
|
||||
cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (devAddr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(cmd, regAddr, true);
|
||||
i2c_master_stop(cmd);
|
||||
ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, pdTICKS_TO_MS(1000));
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "PMU i2c_master_cmd_begin FAILED! > ");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (devAddr << 1) | I2C_MASTER_READ, true);
|
||||
if (len > 1) {
|
||||
i2c_master_read(cmd, data, len - 1, I2C_MASTER_ACK);
|
||||
}
|
||||
i2c_master_read_byte(cmd, &data[len - 1], I2C_MASTER_NACK);
|
||||
i2c_master_stop(cmd);
|
||||
ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, pdTICKS_TO_MS(1000));
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "i2c_read_error.");
|
||||
}
|
||||
#endif
|
||||
return ret == ESP_OK ? 0 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a byte to a pmu register
|
||||
*/
|
||||
int i2c_write_callback(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint8_t len)
|
||||
{
|
||||
esp_err_t ret;
|
||||
if (data == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
uint8_t *write_buffer = (uint8_t *)malloc(sizeof(uint8_t) * (len + 1));
|
||||
if (!write_buffer) {
|
||||
return -1;
|
||||
}
|
||||
write_buffer[0] = regAddr;
|
||||
memcpy(write_buffer + 1, data, len);
|
||||
|
||||
ret = i2c_master_transmit(
|
||||
i2c_device,
|
||||
write_buffer,
|
||||
len + 1,
|
||||
-1);
|
||||
free(write_buffer);
|
||||
#else
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (devAddr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(cmd, regAddr, true);
|
||||
i2c_master_write(cmd, data, len, true);
|
||||
i2c_master_stop(cmd);
|
||||
ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, pdTICKS_TO_MS(1000));
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "i2c_write_error.");
|
||||
}
|
||||
#endif
|
||||
return ret == ESP_OK ? 0 : -1;
|
||||
}
|
||||
|
||||
esp_err_t i2c_drv_device_init(uint8_t address)
|
||||
{
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
i2c_device_config_t i2c_dev_conf = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = address,
|
||||
.scl_speed_hz = I2C_MASTER_FREQ_HZ,
|
||||
};
|
||||
return i2c_master_bus_add_device(bus_handle, &i2c_dev_conf, &i2c_device);
|
||||
#else
|
||||
return ESP_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //CONFIG_I2C_COMMUNICATION_METHOD_CALLBACK_RW
|
||||
|
||||
|
||||
/**
|
||||
* @brief i2c master initialization
|
||||
*/
|
||||
esp_err_t i2c_drv_init(void)
|
||||
{
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
|
||||
ESP_LOGI(TAG, "Implemented using read and write callback methods (Use higher version >= 5.0 API)");
|
||||
|
||||
i2c_master_bus_config_t i2c_bus_config;
|
||||
memset(&i2c_bus_config, 0, sizeof(i2c_bus_config));
|
||||
i2c_bus_config.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||
i2c_bus_config.i2c_port = I2C_MASTER_NUM;
|
||||
i2c_bus_config.scl_io_num = (gpio_num_t)I2C_MASTER_SCL_IO;
|
||||
i2c_bus_config.sda_io_num = (gpio_num_t)I2C_MASTER_SDA_IO;
|
||||
i2c_bus_config.glitch_ignore_cnt = 7;
|
||||
|
||||
ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_config, &bus_handle));
|
||||
|
||||
return ESP_OK;
|
||||
#else
|
||||
|
||||
ESP_LOGI(TAG, "Implemented using read and write callback methods (Use lower version < 5.0 API)");
|
||||
|
||||
i2c_config_t i2c_conf ;
|
||||
memset(&i2c_conf, 0, sizeof(i2c_conf));
|
||||
i2c_conf.mode = I2C_MODE_MASTER;
|
||||
i2c_conf.sda_io_num = I2C_MASTER_SDA_IO;
|
||||
i2c_conf.scl_io_num = I2C_MASTER_SCL_IO;
|
||||
i2c_conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
i2c_conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
i2c_conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
|
||||
i2c_param_config(I2C_MASTER_NUM, &i2c_conf);
|
||||
return i2c_driver_install(I2C_MASTER_NUM, i2c_conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void i2c_drv_scan()
|
||||
{
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
|
||||
esp_err_t err = ESP_OK;
|
||||
uint8_t address = 0x00;
|
||||
printf("Scand I2C Devices:\n");
|
||||
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
for (int i = 0; i < 128; i += 16) {
|
||||
printf("%02x: ", i);
|
||||
for (int j = 0; j < 16; j++) {
|
||||
fflush(stdout);
|
||||
address = i + j;
|
||||
err = i2c_master_probe(bus_handle, address, 1000);
|
||||
if (err == ESP_OK) {
|
||||
printf("%02x ", address);
|
||||
} else if (err == ESP_ERR_TIMEOUT) {
|
||||
printf("UU ");
|
||||
} else {
|
||||
printf("-- ");
|
||||
}
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
printf("\n\n\n");
|
||||
#else
|
||||
uint8_t address;
|
||||
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
for (int i = 0; i < 128; i += 16) {
|
||||
printf("%02x: ", i);
|
||||
for (int j = 0; j < 16; j++) {
|
||||
fflush(stdout);
|
||||
address = i + j;
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (address << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 50 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret == ESP_OK) {
|
||||
printf("%02x ", address);
|
||||
} else if (ret == ESP_ERR_TIMEOUT) {
|
||||
printf("UU ");
|
||||
} else {
|
||||
printf("-- ");
|
||||
}
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool i2c_drv_probe(uint8_t devAddr)
|
||||
{
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
return ESP_OK == i2c_master_probe(bus_handle, devAddr, 1000);
|
||||
#else
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (devAddr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 50 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
return (ret == ESP_OK);
|
||||
#endif //ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @file i2c_driver.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @license MIT
|
||||
* @copyright Copyright (c) 2024 Shenzhen Xinyuan Electronic Technology Co., Ltd
|
||||
* @date 2024-01-10
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_idf_version.h"
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
#include "driver/i2c_master.h"
|
||||
#else
|
||||
#include "driver/i2c.h"
|
||||
#endif //ESP_IDF_VERSION
|
||||
|
||||
|
||||
esp_err_t i2c_drv_init(void);
|
||||
void i2c_drv_scan();
|
||||
bool i2c_drv_probe(uint8_t devAddr);
|
||||
int i2c_read_callback(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint8_t len);
|
||||
int i2c_write_callback(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint8_t len);
|
||||
|
||||
#if CONFIG_I2C_COMMUNICATION_METHOD_CALLBACK_RW
|
||||
esp_err_t i2c_drv_device_init(uint8_t address);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file main.cpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @license MIT
|
||||
* @copyright Copyright (c) 2024 Shenzhen Xinyuan Electronic Technology Co., Ltd
|
||||
* @date 2024-01-10
|
||||
*
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "i2c_driver.h"
|
||||
|
||||
#define SENSOR_INPUT_PIN (gpio_num_t)CONFIG_SENSOR_IRQ /*!< axp power chip interrupt Pin*/
|
||||
#define SENSOR_INPUT_PIN_SEL (1ULL<<SENSOR_INPUT_PIN)
|
||||
|
||||
static const char *TAG = "mian";
|
||||
|
||||
extern esp_err_t sensor_drv_init();
|
||||
extern esp_err_t touch_drv_init();
|
||||
|
||||
extern void touch_drv_isr_handler();
|
||||
|
||||
static void sensor_hander_task(void *);
|
||||
static QueueHandle_t gpio_evt_queue = NULL;
|
||||
|
||||
static void IRAM_ATTR sensor_irq_handler(void *arg)
|
||||
{
|
||||
uint32_t gpio_num = (uint32_t) arg;
|
||||
xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
|
||||
}
|
||||
|
||||
static void irq_init()
|
||||
{
|
||||
gpio_config_t io_conf;
|
||||
io_conf.intr_type = GPIO_INTR_NEGEDGE;
|
||||
io_conf.mode = GPIO_MODE_INPUT;
|
||||
io_conf.pin_bit_mask = SENSOR_INPUT_PIN_SEL;
|
||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||
gpio_config(&io_conf);
|
||||
gpio_set_intr_type(SENSOR_INPUT_PIN, GPIO_INTR_NEGEDGE);
|
||||
//install gpio isr service
|
||||
gpio_install_isr_service(0);
|
||||
//hook isr handler for specific gpio pin
|
||||
gpio_isr_handler_add(SENSOR_INPUT_PIN, sensor_irq_handler, (void *) SENSOR_INPUT_PIN);
|
||||
|
||||
}
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
//create a queue to handle gpio event from isr
|
||||
gpio_evt_queue = xQueueCreate(5, sizeof(uint32_t));
|
||||
|
||||
// Register Sensor interrupt pins
|
||||
irq_init();
|
||||
|
||||
ESP_ERROR_CHECK(i2c_drv_init());
|
||||
ESP_LOGI(TAG, "I2C initialized successfully");
|
||||
|
||||
ESP_ERROR_CHECK(touch_drv_init());
|
||||
|
||||
xTaskCreate(sensor_hander_task, "App/sen", 4 * 1024, NULL, 10, NULL);
|
||||
|
||||
ESP_LOGI(TAG, "Run...");
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void sensor_hander_task(void *args)
|
||||
{
|
||||
uint32_t io_num;
|
||||
while (1) {
|
||||
if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
|
||||
touch_drv_isr_handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @file touch_drv.cpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @license MIT
|
||||
* @copyright Copyright (c) 2024 Shenzhen Xinyuan Electronic Technology Co., Ltd
|
||||
* @date 2024-01-10
|
||||
*
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "i2c_driver.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "TouchDrvCSTXXX.hpp"
|
||||
|
||||
static const char *TAG = "TOUCH";
|
||||
|
||||
TouchDrvCSTXXX touch;
|
||||
|
||||
static void touch_home_button_callback(void *user_data);
|
||||
|
||||
esp_err_t touch_drv_init()
|
||||
{
|
||||
uint8_t address = 0xFF;
|
||||
|
||||
ESP_LOGI(TAG, "----touch_drv_init----");
|
||||
|
||||
/*
|
||||
* CST816, CST328 Some chips have automatic sleep function.
|
||||
* If you want to scan the device address,
|
||||
* must reset the chip first. If the reset pin is not connected,
|
||||
* you may not be able to obtain the device address by scanning the bus.
|
||||
*/
|
||||
gpio_num_t gpio_num = (gpio_num_t)CONFIG_SENSOR_RST;
|
||||
ESP_ERROR_CHECK(gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT));
|
||||
|
||||
gpio_set_level(gpio_num, 0);
|
||||
vTaskDelay(pdMS_TO_TICKS(15));
|
||||
gpio_set_level(gpio_num, 1);
|
||||
vTaskDelay(pdMS_TO_TICKS(80));
|
||||
|
||||
// Run bus scan
|
||||
i2c_drv_scan();
|
||||
|
||||
// Get known address
|
||||
if (i2c_drv_probe(CST816_SLAVE_ADDRESS)) {
|
||||
address = CST816_SLAVE_ADDRESS;
|
||||
ESP_LOGI(TAG, "Find touch address 0x%X", address);
|
||||
}
|
||||
if (i2c_drv_probe(CST226SE_SLAVE_ADDRESS)) {
|
||||
address = CST226SE_SLAVE_ADDRESS;
|
||||
ESP_LOGI(TAG, "Find touch address 0x%X", address);
|
||||
}
|
||||
if (i2c_drv_probe(CST328_SLAVE_ADDRESS)) {
|
||||
address = CST328_SLAVE_ADDRESS;
|
||||
ESP_LOGI(TAG, "Find touch address 0x%X", address);
|
||||
}
|
||||
if (address == 0xFF) {
|
||||
ESP_LOGE(TAG, "Could't find touch chip!"); return ESP_FAIL;
|
||||
}
|
||||
ESP_LOGI(TAG, "Find touch address 0x%X", address);
|
||||
|
||||
// Set reset and interrupt pin
|
||||
touch.setPins(CONFIG_SENSOR_RST, CONFIG_SENSOR_IRQ);
|
||||
|
||||
//* Implemented using read and write callback methods, applicable to other platforms
|
||||
#if CONFIG_I2C_COMMUNICATION_METHOD_CALLBACK_RW
|
||||
|
||||
// * Provide the device address to the callback function
|
||||
i2c_drv_device_init(address);
|
||||
|
||||
ESP_LOGI(TAG, "Implemented using read and write callback methods");
|
||||
if (touch.begin(address, i2c_read_callback, i2c_write_callback)) {
|
||||
ESP_LOGI(TAG, "Init touch SUCCESS!");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Init touch FAILED!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
//* Use the built-in esp-idf communication method
|
||||
#if CONFIG_I2C_COMMUNICATION_METHOD_BUILTIN_RW
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
|
||||
|
||||
ESP_LOGI(TAG, "Implemented using built-in read and write methods (Use higher version >= 5.0 API)");
|
||||
|
||||
// * Using the new API of esp-idf 5.x, you need to pass the I2C BUS handle,
|
||||
// * which is useful when the bus shares multiple devices.
|
||||
extern i2c_master_bus_handle_t bus_handle;
|
||||
|
||||
if (touch.begin(bus_handle, address)) {
|
||||
ESP_LOGI(TAG, "Init touch SUCCESS!");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Init touch FAILED!");
|
||||
return false;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
ESP_LOGI(TAG, "Implemented using built-in read and write methods (Use lower version < 5.0 API)");
|
||||
if (touch.begin((i2c_port_t)CONFIG_I2C_MASTER_PORT_NUM, address, CONFIG_SENSOR_SDA, CONFIG_SENSOR_SCL)) {
|
||||
ESP_LOGI(TAG, "Init touch SUCCESS!");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Init touch FAILED!");
|
||||
return false;
|
||||
}
|
||||
#endif //ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)
|
||||
#endif //CONFIG_I2C_COMMUNICATION_METHOD_BUILTIN_RW
|
||||
|
||||
const char *model = touch.getModelName();
|
||||
if (strncmp(model, "CST8", 3) == 0) {
|
||||
ESP_LOGI(TAG, "Some CST816 will automatically enter sleep,can use the touch.disableAutoSleep() to turn off");
|
||||
// Some CST816 will automatically enter sleep,
|
||||
// can use the touch.disableAutoSleep() to turn off
|
||||
touch.disableAutoSleep();
|
||||
|
||||
/**
|
||||
* Some touch screens have touch buttons,
|
||||
* and the touch coordinates need to be given
|
||||
* before the touch button callback function can be used.
|
||||
*/
|
||||
// Example touch coordinates using T-Display-S3 touch
|
||||
touch.setCenterButtonCoordinate(85, 360);
|
||||
|
||||
touch.setHomeButtonCallback(touch_home_button_callback);
|
||||
}
|
||||
|
||||
// Set the maximum valid coordinates
|
||||
// touch.setMaxCoordinates(320, 170);
|
||||
|
||||
// Swap XY coordinates
|
||||
// touch.setSwapXY(true);
|
||||
|
||||
// Mirror XY coordinates
|
||||
// touch.setMirrorXY(false, true);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void touch_home_button_callback(void *user_data)
|
||||
{
|
||||
ESP_LOGI(TAG, "Touch Home button pressed!");
|
||||
}
|
||||
|
||||
void touch_drv_isr_handler()
|
||||
{
|
||||
int16_t x[5], y[5];
|
||||
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
|
||||
if (touched) {
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
printf("X[");
|
||||
printf("%d", i);
|
||||
printf("]:");
|
||||
printf("%d", x[i]);
|
||||
printf(" ");
|
||||
printf(" Y[");
|
||||
printf("%d", i);
|
||||
printf("]:");
|
||||
printf("%d", y[i]);
|
||||
printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
CONFIG_IDF_TARGET="esp32s3"
|
||||
CONFIG_IDF_TARGET_ESP32S3=y
|
||||
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
|
||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
|
||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=240
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file LTR553ALS_Sensor.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-09
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorLTR553.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 5
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 6
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 21
|
||||
#endif
|
||||
|
||||
SensorLTR553 als;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!als.begin(Wire, LTR553_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find LTR553 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init LTR553 Sensor success!");
|
||||
|
||||
// Set the ambient light high and low thresholds.
|
||||
// If the value exceeds or falls below the set value, an interrupt will be triggered.
|
||||
als.setLightSensorThreshold(10, 200);
|
||||
|
||||
// Set the high and low thresholds of the proximity sensor.
|
||||
// If the value exceeds or falls below the set value, an interrupt will be triggered.
|
||||
als.setProximityThreshold(10, 30);
|
||||
|
||||
// Controls the Light Sensor N number of times the measurement data is outside the range
|
||||
// defined by the upper and lower threshold limits before asserting the interrupt.
|
||||
als.setLightSensorPersists(5);
|
||||
|
||||
// Controls the Proximity N number of times the measurement data is outside the range
|
||||
// defined by the upper and lower threshold limits before asserting the interrupt.
|
||||
als.setProximityPersists(5);
|
||||
|
||||
/*
|
||||
* ALS_IRQ_ACTIVE_LOW, // INT pin is considered active when it is a logic 0 (default)
|
||||
* ALS_IRQ_ACTIVE_HIGH // INT pin is considered active when it is a logic 1
|
||||
* * */
|
||||
als.setIRQLevel(SensorLTR553::ALS_IRQ_ACTIVE_LOW);
|
||||
|
||||
/*
|
||||
* ALS_IRQ_ONLY_PS, // Only PS measurement can trigger interrupt
|
||||
* ALS_IRQ_ONLY_ALS, // Only ALS measurement can trigger interrupt
|
||||
* ALS_IRQ_BOTH, // Both ALS and PS measurement can trigger interrupt
|
||||
* * * */
|
||||
als.enableIRQ(SensorLTR553::ALS_IRQ_BOTH);
|
||||
|
||||
/*
|
||||
* ALS_GAIN_1X , -> 1 lux to 64k lux (default)
|
||||
* ALS_GAIN_2X , -> 0.5 lux to 32k lux
|
||||
* ALS_GAIN_4X , -> 0.25 lux to 16k lux
|
||||
* ALS_GAIN_8X , -> 0.125 lux to 8k lux
|
||||
* ALS_GAIN_48X , -> 0.02 lux to 1.3k lux
|
||||
* ALS_GAIN_96X , -> 0.01 lux to 600 lux
|
||||
* */
|
||||
als.setLightSensorGain(SensorLTR553::ALS_GAIN_8X);
|
||||
|
||||
/*
|
||||
* PS_LED_PLUSE_30KHZ,
|
||||
* PS_LED_PLUSE_40KHZ,
|
||||
* PS_LED_PLUSE_50KHZ,
|
||||
* PS_LED_PLUSE_60KHZ,
|
||||
* PS_LED_PLUSE_70KHZ,
|
||||
* PS_LED_PLUSE_80KHZ,
|
||||
* PS_LED_PLUSE_90KHZ,
|
||||
* PS_LED_PLUSE_100KHZ,
|
||||
* * * * * * * * * * */
|
||||
als.setPsLedPulsePeriod(SensorLTR553::PS_LED_PLUSE_100KHZ);
|
||||
|
||||
|
||||
/*
|
||||
* PS_LED_DUTY_25,
|
||||
* PS_LED_DUTY_50,
|
||||
* PS_LED_DUTY_75,
|
||||
* PS_LED_DUTY_100,
|
||||
* * * */
|
||||
als.setPsLedDutyCycle(SensorLTR553::PS_LED_DUTY_100);
|
||||
|
||||
|
||||
/*
|
||||
* PS_LED_CUR_5MA,
|
||||
* PS_LED_CUR_10MA,
|
||||
* PS_LED_CUR_20MA,
|
||||
* PS_LED_CUR_50MA,
|
||||
* PS_LED_CUR_100MA,
|
||||
* * * * * * * */
|
||||
als.setPsLedCurrnet(SensorLTR553::PS_LED_CUR_50MA);
|
||||
|
||||
/*
|
||||
* PS_MEAS_RATE_50MS,
|
||||
* PS_MEAS_RATE_70MS,
|
||||
* PS_MEAS_RATE_100MS,
|
||||
* PS_MEAS_RATE_200MS,
|
||||
* PS_MEAS_RATE_500MS,
|
||||
* PS_MEAS_RATE_1000MS,
|
||||
* PS_MEAS_RATE_2000MS,
|
||||
* PS_MEAS_RATE_10MS
|
||||
* * * * * * * */
|
||||
als.setProximityRate(SensorLTR553::PS_MEAS_RATE_200MS);
|
||||
|
||||
// Number of pulses
|
||||
als.setPsLedPulses(1);
|
||||
|
||||
// Enable proximity sensor saturation indication
|
||||
als.enablePsIndicator();
|
||||
|
||||
// Enable ambient light sensor
|
||||
als.enableLightSensor();
|
||||
|
||||
// Enable proximity sensor
|
||||
als.enableProximity();
|
||||
|
||||
}
|
||||
|
||||
bool canRead()
|
||||
{
|
||||
#if SENSOR_IRQ != -1
|
||||
return digitalRead(SENSOR_IRQ) == LOW;
|
||||
#else
|
||||
static uint32_t lastReadMillis;
|
||||
if (millis() > lastReadMillis) {
|
||||
lastReadMillis = millis() + 500;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
/*
|
||||
* PS Saturation Flag is used for monitoring the internal IC saturation.
|
||||
* It will be flagged when the IC has reached saturation
|
||||
* and not able to perform any further PS measurement
|
||||
* */
|
||||
bool saturated = false;
|
||||
if (canRead()) {
|
||||
Serial.print(" ALS: CH1:"); Serial.print(als.getLightSensor(1));
|
||||
Serial.print(" - CH0:"); Serial.print(als.getLightSensor(0));
|
||||
Serial.print(" - PS:"); Serial.print(als.getProximity(&saturated));
|
||||
Serial.print(" - "); Serial.println(saturated ? "PS saturated" : "PS not saturated");
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF85063_AlarmByUnits.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-12-11
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include <time.h>
|
||||
#include "SensorPCF85063.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 4
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 5
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 14
|
||||
#endif
|
||||
|
||||
|
||||
SensorPCF85063 rtc;
|
||||
|
||||
|
||||
uint32_t lastMillis = 0;
|
||||
uint8_t nextHour = 22;
|
||||
uint8_t nextMonth = 1;
|
||||
uint8_t nextDay = 1;
|
||||
uint8_t nextMinute = 59;
|
||||
uint8_t nextSecond = 20;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
if (!rtc.begin(Wire, PCF85063_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
|
||||
nextSecond = 55;
|
||||
|
||||
// First test alarm seconds
|
||||
rtc.setAlarmBySecond(30);
|
||||
|
||||
rtc.enableAlarm();
|
||||
|
||||
}
|
||||
|
||||
void printDateTime()
|
||||
{
|
||||
if (millis() - lastMillis > 1000) {
|
||||
/**
|
||||
/// Format output time*
|
||||
Option:
|
||||
DATETIME_FORMAT_HM
|
||||
DATETIME_FORMAT_HMS
|
||||
DATETIME_FORMAT_YYYY_MM_DD
|
||||
DATETIME_FORMAT_MM_DD_YYYY
|
||||
DATETIME_FORMAT_DD_MM_YYYY
|
||||
DATETIME_FORMAT_YYYY_MM_DD_H_M_S
|
||||
default: DATETIME_FORMAT_YYYY_MM_DD_H_M_S_WEEK
|
||||
*/
|
||||
Serial.println(rtc.strftime());
|
||||
|
||||
lastMillis = millis();
|
||||
}
|
||||
}
|
||||
|
||||
// Test seconds timing
|
||||
void testAlarmSeconds()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmSeconds Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
rtc.setAlarmByMinutes(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Test minute timing
|
||||
void testAlarmMinute()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmMinute Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
nextHour++;
|
||||
if (nextHour >= 24) {
|
||||
nextHour = 23;
|
||||
nextDay = 25;
|
||||
rtc.setAlarmByHours(0);
|
||||
Serial.println("setAlarmByHours");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
// Test hour timing
|
||||
void testAlarmHour()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmHour Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
nextDay++;
|
||||
if (nextDay >= 30) {
|
||||
nextMonth = 1;
|
||||
nextHour = 23;
|
||||
nextMinute = 59;
|
||||
nextSecond = 55;
|
||||
nextDay = rtc.getDaysInMonth(nextMonth, 2022);
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
rtc.setAlarmByDays(1);
|
||||
Serial.println("setAlarmByDays");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
// Test day timing
|
||||
void testAlarmDay()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmDay Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
nextDay = rtc.getDaysInMonth(nextMonth, 2022);
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
nextMonth++;
|
||||
if (nextMonth >= 12) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
testAlarmSeconds();
|
||||
testAlarmMinute();
|
||||
testAlarmHour();
|
||||
testAlarmDay();
|
||||
|
||||
Serial.println("Test done ...");
|
||||
while (1) {
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF85063_ClockOutput.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-07-24
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorPCF85063.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 7
|
||||
#endif
|
||||
|
||||
|
||||
SensorPCF85063::ClockHz clock_array[] = {
|
||||
SensorPCF85063::CLK_32768HZ,
|
||||
SensorPCF85063::CLK_16384HZ,
|
||||
SensorPCF85063::CLK_8192HZ,
|
||||
SensorPCF85063::CLK_4096HZ,
|
||||
SensorPCF85063::CLK_2048HZ,
|
||||
SensorPCF85063::CLK_1024HZ,
|
||||
SensorPCF85063::CLK_1HZ,
|
||||
SensorPCF85063::CLK_LOW,
|
||||
};
|
||||
|
||||
String freq_hz_str[] = {
|
||||
"32.768KHZ",
|
||||
"16.384KHZ",
|
||||
"8.192KHZ",
|
||||
"4.096KHZ",
|
||||
"2.048KHZ",
|
||||
"1.024KHZ",
|
||||
"1HZ",
|
||||
"LOW"
|
||||
};
|
||||
|
||||
|
||||
SensorPCF85063 rtc;
|
||||
uint32_t lastMillis;
|
||||
uint8_t i = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
if (!rtc.begin(Wire, PCF85063_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastMillis > 5000) {
|
||||
lastMillis = millis();
|
||||
Serial.print("Set freq : ");
|
||||
Serial.println(freq_hz_str[i]);
|
||||
rtc.setClockOutput(clock_array[i]);
|
||||
i++;
|
||||
i %= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF85063_SimpleTime.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-07
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorPCF85063.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 7
|
||||
#endif
|
||||
|
||||
SensorPCF85063 rtc;
|
||||
uint32_t lastMillis;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!rtc.begin(Wire, PCF85063_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t year = 2023;
|
||||
uint8_t month = 9;
|
||||
uint8_t day = 7;
|
||||
uint8_t hour = 11;
|
||||
uint8_t minute = 24;
|
||||
uint8_t second = 30;
|
||||
|
||||
rtc.setDateTime(year, month, day, hour, minute, second);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastMillis > 1000) {
|
||||
lastMillis = millis();
|
||||
RTC_DateTime datetime = rtc.getDateTime();
|
||||
Serial.printf(" Year :"); Serial.print(datetime.year);
|
||||
Serial.printf(" Month:"); Serial.print(datetime.month);
|
||||
Serial.printf(" Day :"); Serial.print(datetime.day);
|
||||
Serial.printf(" Hour:"); Serial.print(datetime.hour);
|
||||
Serial.printf(" Minute:"); Serial.print(datetime.minute);
|
||||
Serial.printf(" Sec :"); Serial.println(datetime.second);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF8563_AlarmByUnits.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-12-11
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include <time.h>
|
||||
#include "SensorPCF8563.hpp"
|
||||
|
||||
#ifdef ESP32
|
||||
#define SENSOR_SDA 42
|
||||
#define SENSOR_SCL 41
|
||||
#define SENSOR_IRQ 14
|
||||
#else
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
#define SENSOR_SDA _PINNUM(0,26)
|
||||
#define SENSOR_SCL _PINNUM(0,27)
|
||||
#define SENSOR_IRQ _PINNUM(0,16)
|
||||
#endif
|
||||
|
||||
|
||||
SensorPCF8563 rtc;
|
||||
|
||||
|
||||
uint32_t lastMillis = 0;
|
||||
uint8_t nextHour = 22;
|
||||
uint8_t nextMonth = 1;
|
||||
uint8_t nextDay = 1;
|
||||
uint8_t nextMinute = 59;
|
||||
uint8_t nextSecond = 55;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
if (!rtc.begin(Wire, PCF8563_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
|
||||
// From minute timer
|
||||
rtc.setAlarmByMinutes(0);
|
||||
|
||||
rtc.enableAlarm();
|
||||
|
||||
}
|
||||
|
||||
void printDateTime()
|
||||
{
|
||||
if (millis() - lastMillis > 1000) {
|
||||
/**
|
||||
/// Format output time*
|
||||
Option:
|
||||
DATETIME_FORMAT_HM
|
||||
DATETIME_FORMAT_HMS
|
||||
DATETIME_FORMAT_YYYY_MM_DD
|
||||
DATETIME_FORMAT_MM_DD_YYYY
|
||||
DATETIME_FORMAT_DD_MM_YYYY
|
||||
DATETIME_FORMAT_YYYY_MM_DD_H_M_S
|
||||
default: DATETIME_FORMAT_YYYY_MM_DD_H_M_S_WEEK
|
||||
*/
|
||||
Serial.println(rtc.strftime());
|
||||
|
||||
lastMillis = millis();
|
||||
}
|
||||
}
|
||||
|
||||
// Test minute timing
|
||||
void testAlarmMinute()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmMinute Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
nextHour++;
|
||||
if (nextHour >= 24) {
|
||||
nextHour = 23;
|
||||
nextDay = 25;
|
||||
rtc.setAlarmByHours(0);
|
||||
Serial.println("setAlarmByHours");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
// Test hour timing
|
||||
void testAlarmHour()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmHour Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
nextDay++;
|
||||
if (nextDay >= 30) {
|
||||
nextMonth = 1;
|
||||
nextHour = 23;
|
||||
nextMinute = 59;
|
||||
nextSecond = 55;
|
||||
nextDay = rtc.getDaysInMonth(nextMonth, 2022);
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
rtc.setAlarmByDays(1);
|
||||
Serial.println("setAlarmByDays");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
// Test day timing
|
||||
void testAlarmDay()
|
||||
{
|
||||
while (1) {
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.println("testAlarmDay Interrupt .... ");
|
||||
if (rtc.isAlarmActive()) {
|
||||
Serial.println("Alarm active");
|
||||
rtc.resetAlarm();
|
||||
nextDay = rtc.getDaysInMonth(nextMonth, 2022);
|
||||
rtc.setDateTime(2022, nextMonth, nextDay, nextHour, nextMinute, nextSecond);
|
||||
nextMonth++;
|
||||
if (nextMonth >= 12) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
testAlarmMinute();
|
||||
testAlarmHour();
|
||||
testAlarmDay();
|
||||
|
||||
Serial.println("Test done ...");
|
||||
while (1) {
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF8563_SimpleTime.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-12-12
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorPCF8563.hpp"
|
||||
|
||||
// lilygo t-beam-s3-core pin
|
||||
#define SENSOR_SDA 42
|
||||
#define SENSOR_SCL 41
|
||||
#define SENSOR_IRQ 14
|
||||
|
||||
SensorPCF8563 rtc;
|
||||
uint32_t lastMillis;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!rtc.begin(Wire, PCF8563_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t year = 2022;
|
||||
uint8_t month = 12;
|
||||
uint8_t day = 12;
|
||||
uint8_t hour = 21;
|
||||
uint8_t minute = 00;
|
||||
uint8_t second = 30;
|
||||
|
||||
rtc.setDateTime(year, month, day, hour, minute, second);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastMillis > 1000) {
|
||||
lastMillis = millis();
|
||||
RTC_DateTime datetime = rtc.getDateTime();
|
||||
Serial.printf(" Year :"); Serial.print(datetime.year);
|
||||
Serial.printf(" Month:"); Serial.print(datetime.month);
|
||||
Serial.printf(" Day :"); Serial.print(datetime.day);
|
||||
Serial.printf(" Hour:"); Serial.print(datetime.hour);
|
||||
Serial.printf(" Minute:"); Serial.print(datetime.minute);
|
||||
Serial.printf(" Sec :"); Serial.println(datetime.second);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF8563_TimeLib.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-12-12
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorPCF8563.hpp"
|
||||
#include <time.h>
|
||||
|
||||
// lilygo t-beam-s3-core pin
|
||||
#define SENSOR_SDA 42
|
||||
#define SENSOR_SCL 41
|
||||
#define SENSOR_IRQ 14
|
||||
|
||||
SensorPCF8563 rtc;
|
||||
uint32_t lastMillis;
|
||||
char buf[64];
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!rtc.begin(Wire, PCF8563_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastMillis > 1000) {
|
||||
|
||||
lastMillis = millis();
|
||||
|
||||
struct tm timeinfo;
|
||||
// Get the time C library structure
|
||||
rtc.getDateTime(&timeinfo);
|
||||
|
||||
// Format the output using the strftime function
|
||||
// For more formats, please refer to :
|
||||
// https://man7.org/linux/man-pages/man3/strftime.3.html
|
||||
|
||||
size_t written = strftime(buf, 64, "%A, %B %d %Y %H:%M:%S", &timeinfo);
|
||||
|
||||
if (written != 0) {
|
||||
Serial.println(buf);
|
||||
}
|
||||
|
||||
written = strftime(buf, 64, "%b %d %Y %H:%M:%S", &timeinfo);
|
||||
if (written != 0) {
|
||||
Serial.println(buf);
|
||||
}
|
||||
|
||||
|
||||
written = strftime(buf, 64, "%A, %d. %B %Y %I:%M%p", &timeinfo);
|
||||
if (written != 0) {
|
||||
Serial.println(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF8563_TimeSynchronization.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-12-12
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <time.h>
|
||||
#include <WiFi.h>
|
||||
#include <sntp.h>
|
||||
#include "SensorPCF8563.hpp"
|
||||
|
||||
// lilygo t-beam-s3-core pin
|
||||
#define SENSOR_SDA 42
|
||||
#define SENSOR_SCL 41
|
||||
#define SENSOR_IRQ 14
|
||||
|
||||
const char *ssid = "YOUR_SSID";
|
||||
const char *password = "YOUR_PASS";
|
||||
|
||||
const char *ntpServer1 = "pool.ntp.org";
|
||||
const char *ntpServer2 = "time.nist.gov";
|
||||
const long gmtOffset_sec = 3600;
|
||||
const int daylightOffset_sec = 3600;
|
||||
|
||||
const char *time_zone = "CST-8"; // TimeZone rule for Europe/Rome including daylight adjustment rules (optional)
|
||||
|
||||
SensorPCF8563 rtc;
|
||||
uint32_t lastMillis;
|
||||
|
||||
|
||||
// Callback function (get's called when time adjusts via NTP)
|
||||
void timeavailable(struct timeval *t)
|
||||
{
|
||||
Serial.println("Got time adjustment from NTP, Write the hardware clock");
|
||||
|
||||
// Write synchronization time to hardware
|
||||
rtc.hwClockWrite();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
|
||||
if (!rtc.begin(Wire, PCF8563_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find PCF8563 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// set notification call-back function
|
||||
sntp_set_time_sync_notification_cb( timeavailable );
|
||||
|
||||
/**
|
||||
* NTP server address could be aquired via DHCP,
|
||||
*
|
||||
* NOTE: This call should be made BEFORE esp32 aquires IP address via DHCP,
|
||||
* otherwise SNTP option 42 would be rejected by default.
|
||||
* NOTE: configTime() function call if made AFTER DHCP-client run
|
||||
* will OVERRIDE aquired NTP server address
|
||||
*/
|
||||
sntp_servermode_dhcp(1); // (optional)
|
||||
|
||||
/**
|
||||
* This will set configured ntp servers and constant TimeZone/daylightOffset
|
||||
* should be OK if your time zone does not need to adjust daylightOffset twice a year,
|
||||
* in such a case time adjustment won't be handled automagicaly.
|
||||
*/
|
||||
// configTime(gmtOffset_sec, daylightOffset_sec, ntpServer1, ntpServer2);
|
||||
|
||||
/**
|
||||
* A more convenient approach to handle TimeZones with daylightOffset
|
||||
* would be to specify a environmnet variable with TimeZone definition including daylight adjustmnet rules.
|
||||
* A list of rules for your zone could be obtained from https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
|
||||
*/
|
||||
configTzTime(time_zone, ntpServer1, ntpServer2);
|
||||
|
||||
//connect to WiFi
|
||||
Serial.printf("Connecting to %s ", ssid);
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println(" CONNECTED");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastMillis > 1000) {
|
||||
|
||||
lastMillis = millis();
|
||||
|
||||
// hardware clock
|
||||
struct tm hwTimeinfo;
|
||||
rtc.getDateTime(&hwTimeinfo);
|
||||
Serial.print("Hardware clock :");
|
||||
Serial.println(&hwTimeinfo, "%A, %B %d %Y %H:%M:%S");
|
||||
|
||||
// system clock
|
||||
struct tm timeinfo;
|
||||
if (!getLocalTime(&timeinfo)) {
|
||||
Serial.println("No time available (yet)");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print("System clock :");
|
||||
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("Examples only ESP32"); delay(1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMC6310_CalibrateExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorQMC6310.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorQMC6310 qmc;
|
||||
|
||||
|
||||
void calibrate()
|
||||
{
|
||||
qmc.setDataOutputRate(SensorQMC6310::DATARATE_200HZ);
|
||||
|
||||
int32_t x_min = 65535;
|
||||
int32_t x_max = -65535;
|
||||
int32_t y_min = 65535;
|
||||
int32_t y_max = -65535;
|
||||
int32_t z_min = 65535;
|
||||
int32_t z_max = -65535;
|
||||
Serial.println("Place the sensor on the plane and slowly rotate the sensor...");
|
||||
|
||||
int32_t range = 1000;
|
||||
int32_t i = 0;
|
||||
int32_t x = 0, y = 0, z = 0;;
|
||||
float a = 0.5 ;
|
||||
float x_offset = 0;
|
||||
float y_offset = 0;
|
||||
float z_offset = 0;
|
||||
|
||||
while (i < range) {
|
||||
i += 1;
|
||||
|
||||
if (qmc.isDataReady()) {
|
||||
|
||||
qmc.readData();
|
||||
|
||||
x = a * qmc.getRawX() + (1 - a) * x;
|
||||
y = a * qmc.getRawY() + (1 - a) * y;
|
||||
z = a * qmc.getRawZ() + (1 - a) * z;
|
||||
if (x < x_min) {
|
||||
x_min = x;
|
||||
i = 0;
|
||||
}
|
||||
if (x > x_max) {
|
||||
x_max = x;
|
||||
i = 0;
|
||||
}
|
||||
if (y < y_min) {
|
||||
y_min = y;
|
||||
i = 0;
|
||||
}
|
||||
if (y > y_max) {
|
||||
y_max = y;
|
||||
i = 0;
|
||||
}
|
||||
if (z < z_min) {
|
||||
z_min = z;
|
||||
i = 0;
|
||||
}
|
||||
if (z > z_max) {
|
||||
z_max = z;
|
||||
i = 0;
|
||||
}
|
||||
int j = round(10 * i / range);
|
||||
|
||||
Serial.print("[");
|
||||
for (int k = 0; k < j; ++k) {
|
||||
Serial.print("*");
|
||||
}
|
||||
Serial.println("]");
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
|
||||
x_offset = (x_max + x_min) / 2;
|
||||
y_offset = (y_max + y_min) / 2;
|
||||
z_offset = (z_max + z_min) / 2;
|
||||
|
||||
Serial.print("x_min:");
|
||||
Serial.print(x_min);
|
||||
|
||||
Serial.print("x_max:");
|
||||
Serial.print(x_max);
|
||||
|
||||
Serial.print("y_min:");
|
||||
Serial.print(y_min);
|
||||
|
||||
Serial.print("y_max:");
|
||||
Serial.print(y_max);
|
||||
|
||||
Serial.print("z_min:");
|
||||
Serial.print(z_min);
|
||||
|
||||
Serial.print("z_max:");
|
||||
Serial.println(z_max);
|
||||
|
||||
|
||||
|
||||
Serial.print("x_offset:");
|
||||
Serial.print(x_offset);
|
||||
|
||||
Serial.print("y_offset:");
|
||||
Serial.print(y_offset);
|
||||
|
||||
Serial.print("z_offset:");
|
||||
Serial.print(z_offset);
|
||||
|
||||
|
||||
// Serial.printf("x_min:%d x_max:%d y_min:%d y_max:%d z_min:%d z_max:%d\n", x_min, x_max, y_min, y_max, z_min, z_max);
|
||||
// Serial.printf("x_offset:%.2f y_offset:%.2f z_offset:%.2f \n", x_offset, y_offset, z_offset);
|
||||
|
||||
// Set the calibration value and the user calculates the deviation
|
||||
qmc.setOffset(x_offset, y_offset, z_offset);
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
if (!qmc.begin(Wire, QMC6310_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMC6310 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get Magnetometer chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmc.getChipID(), HEX);
|
||||
|
||||
/* Config Magnetometer */
|
||||
qmc.configMagnetometer(
|
||||
/*
|
||||
* Run Mode
|
||||
* MODE_SUSPEND
|
||||
* MODE_NORMAL
|
||||
* MODE_SINGLE
|
||||
* MODE_CONTINUOUS
|
||||
* * */
|
||||
SensorQMC6310::MODE_CONTINUOUS,
|
||||
/*
|
||||
* Full Range
|
||||
* RANGE_30G
|
||||
* RANGE_12G
|
||||
* RANGE_8G
|
||||
* RANGE_2G
|
||||
* * */
|
||||
SensorQMC6310::RANGE_8G,
|
||||
/*
|
||||
* Output data rate
|
||||
* DATARATE_10HZ
|
||||
* DATARATE_50HZ
|
||||
* DATARATE_100HZ
|
||||
* DATARATE_200HZ
|
||||
* * */
|
||||
SensorQMC6310::DATARATE_200HZ,
|
||||
/*
|
||||
* Over sample Ratio1
|
||||
* OSR_8
|
||||
* OSR_4
|
||||
* OSR_2
|
||||
* OSR_1
|
||||
* * * */
|
||||
SensorQMC6310::OSR_1,
|
||||
|
||||
/*
|
||||
* Down sample Ratio1
|
||||
* DSR_8
|
||||
* DSR_4
|
||||
* DSR_2
|
||||
* DSR_1
|
||||
* * */
|
||||
SensorQMC6310::DSR_1);
|
||||
|
||||
|
||||
|
||||
|
||||
// Calibration algorithm reference from
|
||||
// https://github.com/CoreElectronics/CE-PiicoDev-QMC6310-MicroPython-Module
|
||||
calibrate();
|
||||
|
||||
Serial.println("Calibration done .");
|
||||
delay(5000);
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
//Wait data ready
|
||||
if (qmc.isDataReady()) {
|
||||
|
||||
qmc.readData();
|
||||
|
||||
Serial.print("GYR: ");
|
||||
Serial.print("X:");
|
||||
Serial.print(qmc.getX());
|
||||
Serial.print(" Y:");
|
||||
Serial.print(qmc.getY());
|
||||
Serial.print(" Z:");
|
||||
Serial.print(qmc.getZ());
|
||||
Serial.println(" uT");
|
||||
Serial.print("RAW: ");
|
||||
Serial.print("X:");
|
||||
Serial.print(qmc.getRawX());
|
||||
Serial.print(" Y:");
|
||||
Serial.print(qmc.getRawY());
|
||||
Serial.print(" Z:");
|
||||
Serial.println(qmc.getRawZ());
|
||||
|
||||
/*
|
||||
float x, y, z;
|
||||
qmc.getMag(x, y, z);
|
||||
Serial.print("X:");
|
||||
Serial.print(x);
|
||||
Serial.print(" Y:");
|
||||
Serial.print(y);
|
||||
Serial.print(" Z:");
|
||||
Serial.println(x);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMC6310_GetDataExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
|
||||
#include "SensorQMC6310.hpp"
|
||||
#include "SH1106Wire.h" //Oled display from https://github.com/ThingPulse/esp8266-oled-ssd1306
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
|
||||
#define I2C1_SDA 22 //Display Wire SDA Pin
|
||||
#define I2C1_SCL 21 //Display Wire SCL Pin
|
||||
|
||||
SH1106Wire display(0x3c, I2C1_SDA, I2C1_SCL);
|
||||
SensorQMC6310 qmc;
|
||||
|
||||
int last_dx, last_dy, dx, dy, angle;
|
||||
|
||||
const int centreX = 32;
|
||||
const int centreY = 30;
|
||||
const int radius = 22;
|
||||
|
||||
//Compass application from https://github.com/G6EJD/ESP8266_micro_compass_HMC5883_OLED
|
||||
void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, OLEDDISPLAY_COLOR color)
|
||||
{
|
||||
display.setColor(color);
|
||||
float distance;
|
||||
int dx, dy, x2o, y2o, x3, y3, x4, y4, k;
|
||||
distance = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
|
||||
dx = x2 + (x1 - x2) * alength / distance;
|
||||
dy = y2 + (y1 - y2) * alength / distance;
|
||||
k = awidth / alength;
|
||||
x2o = x2 - dx;
|
||||
y2o = dy - y2;
|
||||
x3 = y2o * k + dx;
|
||||
y3 = x2o * k + dy;
|
||||
x4 = dx - y2o * k;
|
||||
y4 = dy - x2o * k;
|
||||
display.drawLine(x1, y1, x2, y2);
|
||||
display.drawLine(x1, y1, dx, dy);
|
||||
display.drawLine(x3, y3, x4, y4);
|
||||
display.drawLine(x3, y3, x2, y2);
|
||||
display.drawLine(x2, y2, x4, y4);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
if (!qmc.begin(Wire, QMC6310_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMC6310 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
display.init();
|
||||
|
||||
last_dx = centreX;
|
||||
last_dy = centreY;
|
||||
|
||||
/* Get Magnetometer chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmc.getChipID(), HEX);
|
||||
|
||||
/* Config Magnetometer */
|
||||
int r = qmc.configMagnetometer(
|
||||
/*
|
||||
* Run Mode
|
||||
* MODE_SUSPEND
|
||||
* MODE_NORMAL
|
||||
* MODE_SINGLE
|
||||
* MODE_CONTINUOUS
|
||||
* * */
|
||||
SensorQMC6310::MODE_NORMAL,
|
||||
/*
|
||||
* Full Range
|
||||
* RANGE_30G
|
||||
* RANGE_12G
|
||||
* RANGE_8G
|
||||
* RANGE_2G
|
||||
* * */
|
||||
SensorQMC6310::RANGE_2G,
|
||||
/*
|
||||
* Output data rate
|
||||
* DATARATE_10HZ
|
||||
* DATARATE_50HZ
|
||||
* DATARATE_100HZ
|
||||
* DATARATE_200HZ
|
||||
* * */
|
||||
SensorQMC6310::DATARATE_100HZ,
|
||||
/*
|
||||
* Over sample Ratio1
|
||||
* OSR_8
|
||||
* OSR_4
|
||||
* OSR_2
|
||||
* OSR_1
|
||||
* * * */
|
||||
SensorQMC6310::OSR_1,
|
||||
|
||||
/*
|
||||
* Down sample Ratio1
|
||||
* DSR_8
|
||||
* DSR_4
|
||||
* DSR_2
|
||||
* DSR_1
|
||||
* * */
|
||||
SensorQMC6310::DSR_1);
|
||||
|
||||
if (r != DEV_WIRE_NONE) {
|
||||
Serial.println("Device config failed!");
|
||||
while (1)delay(1000);
|
||||
}
|
||||
|
||||
// Print register configuration information
|
||||
qmc.dumpCtrlRegister();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
//Wiat data ready
|
||||
if (qmc.isDataReady()) {
|
||||
|
||||
qmc.readData();
|
||||
|
||||
|
||||
display.drawString(29, 0, "N");
|
||||
display.drawString( 0, 28, "W");
|
||||
display.drawString(60, 28, "E");
|
||||
display.drawString(29, 53, "S");
|
||||
|
||||
display.drawLine(1, 1, 7, 7);
|
||||
display.drawLine(62, 1, 56, 7);
|
||||
display.drawLine(1, 62, 7, 56);
|
||||
display.drawLine(56, 56, 62, 62);
|
||||
|
||||
//Compass application from https://github.com/G6EJD/ESP8266_micro_compass_HMC5883_OLED
|
||||
float heading = atan2(qmc.getY(), qmc.getX()); // Result is in radians
|
||||
// Now add the 'Declination Angle' for you location. Declination is the variation in magnetic field at your location.
|
||||
// Find your declination here: http://www.magnetic-declination.com/
|
||||
// At my location it is : -2° 20' W, or -2.33 Degrees, which needs to be in radians so = -2.33 / 180 * PI = -0.041 West is + E is -
|
||||
// Make declination = 0 if you can't find your Declination value, the error is negible for nearly all locations
|
||||
float declination = -0.041;
|
||||
heading = heading + declination;
|
||||
|
||||
if (heading < 0) heading += 2 * PI; // Correct for when signs are reversed.
|
||||
if (heading > 2 * PI) heading -= 2 * PI; // Correct for when heading exceeds 360-degree, especially when declination is included
|
||||
angle = int(heading * 180 / M_PI); // Convert radians to degrees for more a more usual result
|
||||
// For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions
|
||||
dx = (0.7 * radius * cos((angle - 90) * 3.14 / 180)) + centreX; // calculate X position for the screen coordinates - can be confusing!
|
||||
dy = (0.7 * radius * sin((angle - 90) * 3.14 / 180)) + centreY; // calculate Y position for the screen coordinates - can be confusing!
|
||||
arrow(last_dx, last_dy, centreX, centreY, 2, 2, BLACK); // Erase last arrow
|
||||
arrow(dx, dy, centreX, centreY, 2, 2, WHITE); // Draw arrow in new position
|
||||
|
||||
display.setColor(BLACK);
|
||||
display.fillRect(80, 50, 25, 48);
|
||||
display.setColor(WHITE);
|
||||
display.drawString(80, 50, String(angle) + "°");
|
||||
display.display();
|
||||
|
||||
last_dx = dx;
|
||||
last_dy = dy;
|
||||
|
||||
// for debug.
|
||||
Serial.print("GYR: ");
|
||||
Serial.print("X:");
|
||||
Serial.print(qmc.getX());
|
||||
Serial.print(" Y:");
|
||||
Serial.print(qmc.getY());
|
||||
Serial.print(" Z:");
|
||||
Serial.print(qmc.getZ());
|
||||
Serial.println(" uT");
|
||||
}
|
||||
|
||||
|
||||
delay(100);
|
||||
}
|
||||
#else
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("The graphics library may not be supported on the current platform"); delay(1000);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMC6310_GetDataExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorQMC6310.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
SensorQMC6310 qmc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
if (!qmc.begin(Wire, QMC6310_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMC6310 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get Magnetometer chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmc.getChipID(), HEX);
|
||||
|
||||
/* Config Magnetometer */
|
||||
qmc.configMagnetometer(
|
||||
/*
|
||||
* Run Mode
|
||||
* MODE_SUSPEND
|
||||
* MODE_NORMAL
|
||||
* MODE_SINGLE
|
||||
* MODE_CONTINUOUS
|
||||
* * */
|
||||
SensorQMC6310::MODE_CONTINUOUS,
|
||||
/*
|
||||
* Full Range
|
||||
* RANGE_30G
|
||||
* RANGE_12G
|
||||
* RANGE_8G
|
||||
* RANGE_2G
|
||||
* * */
|
||||
SensorQMC6310::RANGE_8G,
|
||||
/*
|
||||
* Output data rate
|
||||
* DATARATE_10HZ
|
||||
* DATARATE_50HZ
|
||||
* DATARATE_100HZ
|
||||
* DATARATE_200HZ
|
||||
* * */
|
||||
SensorQMC6310::DATARATE_200HZ,
|
||||
/*
|
||||
* Over sample Ratio1
|
||||
* OSR_8
|
||||
* OSR_4
|
||||
* OSR_2
|
||||
* OSR_1
|
||||
* * * */
|
||||
SensorQMC6310::OSR_1,
|
||||
|
||||
/*
|
||||
* Down sample Ratio1
|
||||
* DSR_8
|
||||
* DSR_4
|
||||
* DSR_2
|
||||
* DSR_1
|
||||
* * */
|
||||
SensorQMC6310::DSR_1);
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
//Wiat data ready
|
||||
if (qmc.isDataReady()) {
|
||||
|
||||
qmc.readData();
|
||||
|
||||
Serial.print("GYR: ");
|
||||
Serial.print("X:");
|
||||
Serial.print(qmc.getX());
|
||||
Serial.print(" Y:");
|
||||
Serial.print(qmc.getY());
|
||||
Serial.print(" Z:");
|
||||
Serial.print(qmc.getZ());
|
||||
Serial.println(" uT");
|
||||
Serial.print("RAW: ");
|
||||
Serial.print("X:");
|
||||
Serial.print(qmc.getRawX());
|
||||
Serial.print(" Y:");
|
||||
Serial.print(qmc.getRawY());
|
||||
Serial.print(" Z:");
|
||||
Serial.println(qmc.getRawZ());
|
||||
|
||||
/*
|
||||
float x, y, z;
|
||||
qmc.getMag(x, y, z);
|
||||
Serial.print("X:");
|
||||
Serial.print(x);
|
||||
Serial.print(" Y:");
|
||||
Serial.print(y);
|
||||
Serial.print(" Z:");
|
||||
Serial.println(x);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMC6310_GetPolarExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "SensorQMC6310.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
SensorQMC6310 qmc;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
if (!qmc.begin(Wire, QMC6310_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMC6310 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get Magnetometer chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmc.getChipID(), HEX);
|
||||
|
||||
/* Config Magnetometer */
|
||||
qmc.configMagnetometer(
|
||||
/*
|
||||
* Run Mode
|
||||
* MODE_SUSPEND
|
||||
* MODE_NORMAL
|
||||
* MODE_SINGLE
|
||||
* MODE_CONTINUOUS
|
||||
* * */
|
||||
SensorQMC6310::MODE_NORMAL,
|
||||
/*
|
||||
* Full Range
|
||||
* RANGE_30G
|
||||
* RANGE_12G
|
||||
* RANGE_8G
|
||||
* RANGE_2G
|
||||
* * */
|
||||
SensorQMC6310::RANGE_8G,
|
||||
/*
|
||||
* Output data rate
|
||||
* DATARATE_10HZ
|
||||
* DATARATE_50HZ
|
||||
* DATARATE_100HZ
|
||||
* DATARATE_200HZ
|
||||
* * */
|
||||
SensorQMC6310::DATARATE_200HZ,
|
||||
/*
|
||||
* Over sample Ratio1
|
||||
* OSR_8
|
||||
* OSR_4
|
||||
* OSR_2
|
||||
* OSR_1
|
||||
* * * */
|
||||
SensorQMC6310::OSR_8,
|
||||
|
||||
/*
|
||||
* Down sample Ratio1
|
||||
* DSR_8
|
||||
* DSR_4
|
||||
* DSR_2
|
||||
* DSR_1
|
||||
* * */
|
||||
SensorQMC6310::DSR_1);
|
||||
|
||||
qmc.dumpCtrlRegister();
|
||||
|
||||
// Declination is the difference between magnetic-north and true-north ("heading") and depends on location
|
||||
qmc.setDeclination(-2.77); // Found with: https://www.magnetic-declination.com/CHINA/SHENZHEN/475119.html
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Polar data;
|
||||
// Wait for data ready
|
||||
if (qmc.readPolar(data)) {
|
||||
Serial.print(" polar:"); Serial.print(data.polar); Serial.print("°");
|
||||
Serial.print(" Gauss:"); Serial.print(data.Gauss);
|
||||
Serial.print(" uT:"); Serial.println(data.uT);
|
||||
}
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_BlockExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include "SensorQMI8658.hpp"
|
||||
#include <MadgwickAHRS.h> //MadgwickAHRS from https://github.com/arduino-libraries/MadgwickAHRS
|
||||
#include "SH1106Wire.h" //Oled display from https://github.com/ThingPulse/esp8266-oled-ssd1306
|
||||
|
||||
// #define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
#define I2C1_SDA 22 //Display Wire SDA Pin
|
||||
#define I2C1_SCL 21 //Display Wire SCL Pin
|
||||
|
||||
SH1106Wire display(0x3c, I2C1_SDA, I2C1_SCL);
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
Madgwick filter;
|
||||
unsigned long microsPerReading, microsPrevious;
|
||||
|
||||
float posX = 64;
|
||||
float posY = 32;
|
||||
float lastPosX = posX;
|
||||
float lastPosY = posY;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
display.init();
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
//Use tbeams3 defalut spi pin
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT1 (33) //INTERRUPT PIN1 & PIN2 ,Use or logic to form a pin
|
||||
|
||||
pinMode(SPI_CS, OUTPUT); //sdcard pin set high
|
||||
digitalWrite(SPI_CS, HIGH);
|
||||
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
|
||||
|
||||
#else
|
||||
//Use esp32dev module defalut spi pin
|
||||
#define IMU_CS (5)
|
||||
#define IMU_INT1 (15)
|
||||
#define IMU_INT2 (22)
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
#endif
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
display.flipScreenVertically();
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_2G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_256DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
// start filter
|
||||
filter.begin(25);
|
||||
|
||||
// initialize variables to pace updates to correct rate
|
||||
microsPerReading = 1000000 / 25;
|
||||
microsPrevious = micros();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
const uint8_t rectWidth = 10;
|
||||
|
||||
void loop()
|
||||
{
|
||||
float roll, pitch, heading;
|
||||
|
||||
// check if it's time to read data and update the filter
|
||||
if (micros() - microsPrevious >= microsPerReading) {
|
||||
|
||||
// read raw data from IMU
|
||||
if (qmi.getDataReady()) {
|
||||
|
||||
qmi.getAccelerometer(acc.x, acc.y, acc.z);
|
||||
qmi.getGyroscope(gyr.x, gyr.y, gyr.z);
|
||||
|
||||
// update the filter, which computes orientation
|
||||
filter.updateIMU(gyr.x, gyr.y, gyr.z, acc.x, acc.y, acc.z);
|
||||
|
||||
// print the heading, pitch and roll
|
||||
roll = filter.getRoll();
|
||||
pitch = filter.getPitch();
|
||||
heading = filter.getYaw();
|
||||
|
||||
posX -= roll * 2;
|
||||
posY += pitch;
|
||||
|
||||
Serial.printf("x:%.2f y:%.2f \n", posX, posY);
|
||||
posX = constrain(posX, 0, display.width() - rectWidth);
|
||||
posY = constrain(posY, 0, display.height() - rectWidth);
|
||||
|
||||
display.setColor(BLACK);
|
||||
display.fillRect(lastPosX, lastPosY, 10, 10);
|
||||
display.setColor(WHITE);
|
||||
display.fillRect(posX, posY, 10, 10);
|
||||
display.display();
|
||||
|
||||
lastPosX = posX;
|
||||
lastPosY = posY;
|
||||
}
|
||||
// increment previous time, so we keep proper pace
|
||||
microsPrevious = microsPrevious + microsPerReading;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("The graphics library may not be supported on the current platform"); delay(1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_GetDataExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
#define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
|
||||
#define IMU_CS 5
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_4G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_64DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if (qmi.getDataReady()) {
|
||||
|
||||
if (qmi.getAccelerometer(acc.x, acc.y, acc.z)) {
|
||||
Serial.print("{ACCEL: ");
|
||||
Serial.print(acc.x);
|
||||
Serial.print(",");
|
||||
Serial.print(acc.y);
|
||||
Serial.print(",");
|
||||
Serial.print(acc.z);
|
||||
Serial.println("}");
|
||||
}
|
||||
|
||||
if (qmi.getGyroscope(gyr.x, gyr.y, gyr.z)) {
|
||||
Serial.print("{GYRO: ");
|
||||
Serial.print(gyr.x);
|
||||
Serial.print(",");
|
||||
Serial.print(gyr.y );
|
||||
Serial.print(",");
|
||||
Serial.print(gyr.z);
|
||||
Serial.println("}");
|
||||
}
|
||||
Serial.print("\t\t\t\t > ");
|
||||
Serial.print(qmi.getTimestamp());
|
||||
Serial.print(" ");
|
||||
Serial.print(qmi.getTemperature_C());
|
||||
Serial.println("*C");
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_InterruptBlockExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include "SensorQMI8658.hpp"
|
||||
#include <MadgwickAHRS.h> //MadgwickAHRS from https://github.com/arduino-libraries/MadgwickAHRS
|
||||
#include "SH1106Wire.h" //Oled display from https://github.com/ThingPulse/esp8266-oled-ssd1306
|
||||
|
||||
// #define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
|
||||
#define I2C1_SDA 22 //Display Wire SDA Pin
|
||||
#define I2C1_SCL 21 //Display Wire SCL Pin
|
||||
|
||||
SH1106Wire display(0x3c, I2C1_SDA, I2C1_SCL);
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
Madgwick filter;
|
||||
unsigned long microsPerReading, microsPrevious;
|
||||
|
||||
float posX = 64;
|
||||
float posY = 32;
|
||||
float lastPosX = posX;
|
||||
float lastPosY = posY;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
display.init();
|
||||
display.flipScreenVertically();
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
//Use tbeams3 defalut spi pin
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT1 (33) //INTERRUPT PIN1 & PIN2 ,Use or logic to form a pin
|
||||
|
||||
pinMode(SPI_CS, OUTPUT); //sdcard pin set high
|
||||
digitalWrite(SPI_CS, HIGH);
|
||||
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
|
||||
|
||||
#else
|
||||
//Use esp32dev module defalut spi pin
|
||||
#define IMU_CS (5)
|
||||
#define IMU_INT1 (15)
|
||||
#define IMU_INT2 (22)
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
#endif
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_2G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_256DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
pinMode(IMU_INT1, INPUT);
|
||||
#ifdef IMU_INT2
|
||||
pinMode(IMU_INT2, INPUT);
|
||||
#endif
|
||||
|
||||
// qmi.enableINT(SensorQMI8658::IntPin1); //no use
|
||||
// Enable data ready to interrupt pin2
|
||||
qmi.enableINT(SensorQMI8658::IntPin2);
|
||||
qmi.enableDataReadyINT();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
// start filter
|
||||
filter.begin(25);
|
||||
|
||||
// initialize variables to pace updates to correct rate
|
||||
microsPerReading = 1000000 / 25;
|
||||
microsPrevious = micros();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
const uint8_t rectWidth = 10;
|
||||
|
||||
void loop()
|
||||
{
|
||||
float roll, pitch, heading;
|
||||
|
||||
// check if it's time to read data and update the filter
|
||||
if (micros() - microsPrevious >= microsPerReading) {
|
||||
|
||||
// read raw data from IMU
|
||||
if (digitalRead(IMU_INT1) == HIGH) {
|
||||
|
||||
qmi.getAccelerometer(acc.x, acc.y, acc.z);
|
||||
qmi.getGyroscope(gyr.x, gyr.y, gyr.z);
|
||||
|
||||
// update the filter, which computes orientation
|
||||
filter.updateIMU(gyr.x, gyr.y, gyr.z, acc.x, acc.y, acc.z);
|
||||
|
||||
// print the heading, pitch and roll
|
||||
roll = filter.getRoll();
|
||||
pitch = filter.getPitch();
|
||||
heading = filter.getYaw();
|
||||
|
||||
posX -= roll * 2;
|
||||
posY += pitch;
|
||||
|
||||
Serial.printf("x:%.2f y:%.2f \n", posX, posY);
|
||||
posX = constrain(posX, 0, display.width() - rectWidth);
|
||||
posY = constrain(posY, 0, display.height() - rectWidth);
|
||||
|
||||
display.setColor(BLACK);
|
||||
display.fillRect(lastPosX, lastPosY, 10, 10);
|
||||
display.setColor(WHITE);
|
||||
display.fillRect(posX, posY, 10, 10);
|
||||
display.display();
|
||||
|
||||
lastPosX = posX;
|
||||
lastPosY = posY;
|
||||
}
|
||||
// increment previous time, so we keep proper pace
|
||||
microsPrevious = microsPrevious + microsPerReading;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("The graphics library may not support your current platform"); delay(1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_InterruptExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-11-03
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
// #define USE_WIRE
|
||||
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
//Use tbeams3 defalut spi pin
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT1 (33)
|
||||
|
||||
pinMode(SPI_CS, OUTPUT); //sdcard pin set high
|
||||
digitalWrite(SPI_CS, HIGH);
|
||||
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
|
||||
|
||||
#else
|
||||
//Use esp32dev module defalut spi pin
|
||||
#define IMU_CS (5)
|
||||
#define IMU_INT1 (15)
|
||||
#define IMU_INT2 (22)
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
#endif
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_4G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_64DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
|
||||
pinMode(IMU_INT1, INPUT);
|
||||
#ifdef IMU_INT2
|
||||
pinMode(IMU_INT2, INPUT);
|
||||
#endif
|
||||
|
||||
// qmi.enableINT(SensorQMI8658::IntPin1); //no use
|
||||
// Enable data ready to interrupt pin2
|
||||
qmi.enableINT(SensorQMI8658::IntPin2);
|
||||
qmi.enableDataReadyINT();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
void readSensorData(const char *name)
|
||||
{
|
||||
uint8_t status = qmi.getIrqStatus();
|
||||
// status == 0x01
|
||||
// If syncSmpl (CTRL7.bit7) = 1:
|
||||
// 0: Sensor Data is not available
|
||||
// 1: Sensor Data is available for reading
|
||||
// If syncSmpl = 0, this bit shows the same value of INT2 level
|
||||
Serial.print(name);
|
||||
Serial.print(" -> [");
|
||||
Serial.print(millis());
|
||||
Serial.print("]: -<HEX> ");
|
||||
Serial.print(status);
|
||||
Serial.print(" -<BIN> ");
|
||||
Serial.println(status, BIN);
|
||||
if (status & 0x01) {
|
||||
if (qmi.getAccelerometer(acc.x, acc.y, acc.z)) {
|
||||
Serial.print("{ACCEL: ");
|
||||
Serial.print(acc.x);
|
||||
Serial.print(",");
|
||||
Serial.print(acc.y);
|
||||
Serial.print(",");
|
||||
Serial.print(acc.z);
|
||||
Serial.println("}");
|
||||
}
|
||||
|
||||
if (qmi.getGyroscope(gyr.x, gyr.y, gyr.z)) {
|
||||
Serial.print("{GYRO: ");
|
||||
Serial.print(gyr.x);
|
||||
Serial.print(",");
|
||||
Serial.print(gyr.y );
|
||||
Serial.print(",");
|
||||
Serial.print(gyr.z);
|
||||
Serial.println("}");
|
||||
}
|
||||
Serial.print("\t\t\t\t > ");
|
||||
Serial.print(qmi.getTimestamp());
|
||||
Serial.print(" ");
|
||||
Serial.print(qmi.getTemperature_C());
|
||||
Serial.println("*C");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (digitalRead(IMU_INT1) == HIGH) {
|
||||
readSensorData("INT1");
|
||||
}
|
||||
|
||||
#ifdef IMU_INT2
|
||||
if (digitalRead(IMU_INT2) == HIGH) {
|
||||
readSensorData("INT2");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_LockingMechanismExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-11-07
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
// #define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
bool interruptFlag = false;
|
||||
|
||||
void setFlag(void)
|
||||
{
|
||||
interruptFlag = true;
|
||||
}
|
||||
|
||||
// Callback when data is locked
|
||||
void lockingMechanismHandler()
|
||||
{
|
||||
if (qmi.getAccelerometer(acc.x, acc.y, acc.z)) {
|
||||
Serial.print("{ACCEL: ");
|
||||
Serial.print(acc.x);
|
||||
Serial.print(",");
|
||||
Serial.print(acc.y);
|
||||
Serial.print(",");
|
||||
Serial.print(acc.z);
|
||||
Serial.println("}");
|
||||
}
|
||||
|
||||
if (qmi.getGyroscope(gyr.x, gyr.y, gyr.z)) {
|
||||
Serial.print("{GYRO: ");
|
||||
Serial.print(gyr.x);
|
||||
Serial.print(",");
|
||||
Serial.print(gyr.y );
|
||||
Serial.print(",");
|
||||
Serial.print(gyr.z);
|
||||
Serial.println("}");
|
||||
}
|
||||
Serial.print("\t\t\t\t > ");
|
||||
Serial.print(qmi.getTimestamp());
|
||||
Serial.print(" ");
|
||||
Serial.print(qmi.getTemperature_C());
|
||||
Serial.println("*C");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
//Use tbeams3 default spi pin
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT1 (33)
|
||||
|
||||
pinMode(SPI_CS, OUTPUT); //sdcard pin set high
|
||||
digitalWrite(SPI_CS, HIGH);
|
||||
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
|
||||
|
||||
#else
|
||||
//Use esp32dev module defalut spi pin
|
||||
#define IMU_CS (5)
|
||||
#define IMU_INT1 (15)
|
||||
#define IMU_INT2 (22)
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
#endif
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_4G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_64DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
//Enable Locking Mechanism
|
||||
qmi.enableLockingMechanism();
|
||||
|
||||
// Set locking data event callback
|
||||
qmi.setDataLockingEvevntCallBack(lockingMechanismHandler);
|
||||
|
||||
|
||||
// Use interrupt .
|
||||
// QMI8658 interrupt always outputs low level by default,
|
||||
// and the interrupt is triggered when the rising edge
|
||||
pinMode(IMU_INT1, INPUT_PULLUP);
|
||||
#ifdef IMU_INT2
|
||||
pinMode(IMU_INT2, INPUT_PULLUP);
|
||||
attachInterrupt(IMU_INT2, setFlag, RISING);
|
||||
#else
|
||||
attachInterrupt(IMU_INT1, setFlag, RISING);
|
||||
#endif
|
||||
|
||||
// qmi.enableINT(SensorQMI8658::IntPin1); //no use
|
||||
// Enable data ready to interrupt pin2
|
||||
qmi.enableINT(SensorQMI8658::IntPin2);
|
||||
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (interruptFlag) {
|
||||
interruptFlag = false;
|
||||
qmi.readSensorStatus();
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_MadgwickAHRS.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
#include <MadgwickAHRS.h> //MadgwickAHRS from https://github.com/arduino-libraries/MadgwickAHRS
|
||||
|
||||
#define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
#define IMU_CS 5
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
Madgwick filter;
|
||||
unsigned long microsPerReading, microsPrevious;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_2G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_256DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
// start filter
|
||||
filter.begin(25);
|
||||
|
||||
// initialize variables to pace updates to correct rate
|
||||
microsPerReading = 1000000 / 25;
|
||||
microsPrevious = micros();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
float roll, pitch, heading;
|
||||
|
||||
// check if it's time to read data and update the filter
|
||||
if (micros() - microsPrevious >= microsPerReading) {
|
||||
|
||||
// read raw data from IMU
|
||||
if (qmi.getDataReady()) {
|
||||
qmi.getAccelerometer(acc.x, acc.y, acc.z);
|
||||
qmi.getGyroscope(gyr.x, gyr.y, gyr.z);
|
||||
// update the filter, which computes orientation
|
||||
filter.updateIMU(gyr.x, gyr.y, gyr.z, acc.x, acc.y, acc.z);
|
||||
|
||||
// print the heading, pitch and roll
|
||||
roll = filter.getRoll();
|
||||
pitch = filter.getPitch();
|
||||
heading = filter.getYaw();
|
||||
Serial.print("Orientation: ");
|
||||
Serial.print(heading);
|
||||
Serial.print(" ");
|
||||
Serial.print(pitch);
|
||||
Serial.print(" ");
|
||||
Serial.println(roll);
|
||||
}
|
||||
// increment previous time, so we keep proper pace
|
||||
microsPrevious = microsPrevious + microsPerReading;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_GetDataExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
#define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
#define IMU_CS 5
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_4G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_125Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_64DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_112_1Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
|
||||
qmi.configPedometer(0x007D, 0x00CC, 0x0066, 0x00C8, 0x14, 0x0A, 0, 0x04);
|
||||
|
||||
qmi.enablePedometer();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Get IMU status
|
||||
uint8_t status = qmi.getStatusRegister();
|
||||
Serial.printf("STATUS:0x%x BIN:", status);
|
||||
Serial.println(status, BIN);
|
||||
|
||||
if (status & SensorQMI8658::EVENT_TAP_MOTION) {
|
||||
Serial.println("Detected TAP event");
|
||||
qmi.getTapStatus();
|
||||
}
|
||||
if (status & SensorQMI8658::EVENT_WOM_MOTION) {
|
||||
Serial.println("Detected Wom event");
|
||||
}
|
||||
if (status & SensorQMI8658::EVENT_PEDOMETER_MOTION) {
|
||||
Serial.println("Detected Pedometer event");
|
||||
uint32_t val = qmi.getPedometerCounter();
|
||||
Serial.println(val);
|
||||
}
|
||||
if (status & SensorQMI8658::EVENT_ANY_MOTION) {
|
||||
Serial.println("Detected Any Motion event");
|
||||
}
|
||||
if (status & SensorQMI8658::EVENT_NO_MOTION) {
|
||||
Serial.println("Detected No Motion event");
|
||||
}
|
||||
if (status & SensorQMI8658::EVENT_SIGNIFICANT_MOTION) {
|
||||
Serial.println("Detected Significant Motion event");
|
||||
}
|
||||
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_ReadFromFifoExample.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
#define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
#define IMU_CS 5
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
|
||||
IMUdata acc[128];
|
||||
IMUdata gyr[128];
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
//Using SPI !!
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
|
||||
qmi.configAccelerometer(
|
||||
/*
|
||||
* ACC_RANGE_2G
|
||||
* ACC_RANGE_4G
|
||||
* ACC_RANGE_8G
|
||||
* ACC_RANGE_16G
|
||||
* */
|
||||
SensorQMI8658::ACC_RANGE_4G,
|
||||
/*
|
||||
* ACC_ODR_1000H
|
||||
* ACC_ODR_500Hz
|
||||
* ACC_ODR_250Hz
|
||||
* ACC_ODR_125Hz
|
||||
* ACC_ODR_62_5Hz
|
||||
* ACC_ODR_31_25Hz
|
||||
* ACC_ODR_LOWPOWER_128Hz
|
||||
* ACC_ODR_LOWPOWER_21Hz
|
||||
* ACC_ODR_LOWPOWER_11Hz
|
||||
* ACC_ODR_LOWPOWER_3H
|
||||
* */
|
||||
SensorQMI8658::ACC_ODR_1000Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_0,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
|
||||
qmi.configGyroscope(
|
||||
/*
|
||||
* GYR_RANGE_16DPS
|
||||
* GYR_RANGE_32DPS
|
||||
* GYR_RANGE_64DPS
|
||||
* GYR_RANGE_128DPS
|
||||
* GYR_RANGE_256DPS
|
||||
* GYR_RANGE_512DPS
|
||||
* GYR_RANGE_1024DPS
|
||||
* */
|
||||
SensorQMI8658::GYR_RANGE_64DPS,
|
||||
/*
|
||||
* GYR_ODR_7174_4Hz
|
||||
* GYR_ODR_3587_2Hz
|
||||
* GYR_ODR_1793_6Hz
|
||||
* GYR_ODR_896_8Hz
|
||||
* GYR_ODR_448_4Hz
|
||||
* GYR_ODR_224_2Hz
|
||||
* GYR_ODR_112_1Hz
|
||||
* GYR_ODR_56_05Hz
|
||||
* GYR_ODR_28_025H
|
||||
* */
|
||||
SensorQMI8658::GYR_ODR_896_8Hz,
|
||||
/*
|
||||
* LPF_MODE_0 //2.66% of ODR
|
||||
* LPF_MODE_1 //3.63% of ODR
|
||||
* LPF_MODE_2 //5.39% of ODR
|
||||
* LPF_MODE_3 //13.37% of ODR
|
||||
* */
|
||||
SensorQMI8658::LPF_MODE_3,
|
||||
// selfTest enable
|
||||
true);
|
||||
|
||||
qmi.configFIFO(
|
||||
/**
|
||||
* FIFO_MODE_BYPASS -- Disable fifo
|
||||
* FIFO_MODE_FIFO -- Will not overwrite
|
||||
* FIFO_MODE_STREAM -- Cover
|
||||
*/
|
||||
SensorQMI8658::FIFO_MODE_FIFO,
|
||||
/*
|
||||
* FIFO_SAMPLES_16
|
||||
* FIFO_SAMPLES_32
|
||||
* FIFO_SAMPLES_64
|
||||
* FIFO_SAMPLES_128
|
||||
* */
|
||||
SensorQMI8658::FIFO_SAMPLES_16,
|
||||
|
||||
//FiFo mapped interrupt IO port
|
||||
SensorQMI8658::IntPin1,
|
||||
// watermark level
|
||||
8);
|
||||
|
||||
// In 6DOF mode (accelerometer and gyroscope are both enabled),
|
||||
// the output data rate is derived from the nature frequency of gyroscope
|
||||
qmi.enableGyroscope();
|
||||
qmi.enableAccelerometer();
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
|
||||
Serial.println("Read data now...");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// If the reading is successful, true will be returned
|
||||
if (!qmi.readFromFifo(acc, 128, gyr, 128)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
Serial.print("ACCEL: ");
|
||||
Serial.print("X:");
|
||||
Serial.print(acc[i].x);
|
||||
Serial.print(" Y:");
|
||||
Serial.print(acc[i].y);
|
||||
Serial.print(" Z:");
|
||||
Serial.println(acc[i].z);
|
||||
Serial.print("GYRO: ");
|
||||
Serial.print(" X:");
|
||||
Serial.print(gyr[i].x);
|
||||
Serial.print(" Y:");
|
||||
Serial.print(gyr[i].y );
|
||||
Serial.print(" Z:");
|
||||
Serial.println(gyr[i].z);
|
||||
}
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_WakeOnMotion.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-11-05
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
// #define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
|
||||
bool interruptFlag = false;
|
||||
|
||||
void setFlag(void)
|
||||
{
|
||||
interruptFlag = true;
|
||||
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
//Use tbeams3 defalut spi pinz
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT1 (33) //INTERRUPT PIN1 & PIN2 ,Use or logic to form a pin
|
||||
|
||||
pinMode(SPI_CS, OUTPUT); //sdcard pin set high
|
||||
digitalWrite(SPI_CS, HIGH);
|
||||
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
|
||||
|
||||
#else
|
||||
//Use esp32dev module defalut spi pin
|
||||
#define IMU_CS (5)
|
||||
#define IMU_INT1 (15)
|
||||
#define IMU_INT2 (22)
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
#endif
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
// enabling wake on motion low power mode with a threshold of 120 mg and
|
||||
// an accelerometer data rate of 128 Hz.
|
||||
qmi.configWakeOnMotion();
|
||||
|
||||
/*
|
||||
* When the QMI8658 is configured as Wom, the interrupt level is arbitrary,
|
||||
* not absolute high or low, and it is in the jump transition state
|
||||
*/
|
||||
pinMode(IMU_INT1, INPUT_PULLUP);
|
||||
#ifdef IMU_INT2
|
||||
pinMode(IMU_INT2, INPUT_PULLUP);
|
||||
attachInterrupt(IMU_INT2, setFlag, CHANGE);
|
||||
#else
|
||||
attachInterrupt(IMU_INT1, setFlag, CHANGE);
|
||||
#endif
|
||||
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if (interruptFlag) {
|
||||
interruptFlag = false;
|
||||
uint8_t status = qmi.getStatusRegister();
|
||||
Serial.printf("status:0x%X BIN:", status);
|
||||
Serial.println(status, BIN);
|
||||
|
||||
if (status & SensorQMI8658::EVENT_SIGNIFICANT_MOTION) {
|
||||
Serial.println("EVENT_SIGNIFICANT_MOTION");
|
||||
} else if (status & SensorQMI8658::EVENT_NO_MOTION) {
|
||||
Serial.println("EVENT_NO_MOITON");
|
||||
} else if (status & SensorQMI8658::EVENT_ANY_MOTION) {
|
||||
Serial.println("EVENT_ANY_MOTION");
|
||||
} else if (status & SensorQMI8658::EVENT_PEDOMETER_MOTION) {
|
||||
Serial.println("EVENT_PEDOMETER_MOTION");
|
||||
} else if (status & SensorQMI8658::EVENT_WOM_MOTION) {
|
||||
Serial.println("EVENT_WOM_MOTION");
|
||||
} else if (status & SensorQMI8658::EVENT_TAP_MOTION) {
|
||||
Serial.println("EVENT_TAP_MOTION");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658_WakeOnMotionCallBack.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-11-07
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "SensorQMI8658.hpp"
|
||||
|
||||
// #define USE_WIRE
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
|
||||
SensorQMI8658 qmi;
|
||||
|
||||
IMUdata acc;
|
||||
IMUdata gyr;
|
||||
|
||||
|
||||
bool interruptFlag = false;
|
||||
|
||||
void setFlag(void)
|
||||
{
|
||||
interruptFlag = true;
|
||||
}
|
||||
|
||||
void wakeUp()
|
||||
{
|
||||
Serial.println("Awake!");
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WIRE
|
||||
//Using WIRE !!
|
||||
if (!qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
//Use tbeams3 defalut spi pinz
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT1 (33) //INTERRUPT PIN1 & PIN2 ,Use or logic to form a pin
|
||||
|
||||
pinMode(SPI_CS, OUTPUT); //sdcard pin set high
|
||||
digitalWrite(SPI_CS, HIGH);
|
||||
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
|
||||
|
||||
#else
|
||||
//Use esp32dev module defalut spi pin
|
||||
#define IMU_CS (5)
|
||||
#define IMU_INT1 (15)
|
||||
#define IMU_INT2 (22)
|
||||
if (!qmi.begin(IMU_CS)) {
|
||||
#endif
|
||||
Serial.println("Failed to find QMI8658 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get chip id*/
|
||||
Serial.print("Device ID:");
|
||||
Serial.println(qmi.getChipID(), HEX);
|
||||
|
||||
// enabling wake on motion low power mode with a threshold of 200 mg and
|
||||
// an accelerometer data rate of 128 Hz.
|
||||
qmi.configWakeOnMotion();
|
||||
|
||||
|
||||
qmi.setWakeupMotionEventCallBack(wakeUp);
|
||||
|
||||
/*
|
||||
* When the QMI8658 is configured as Wom, the interrupt level is arbitrary,
|
||||
* not absolute high or low, and it is in the jump transition state
|
||||
*/
|
||||
pinMode(IMU_INT1, INPUT_PULLUP);
|
||||
#ifdef IMU_INT2
|
||||
pinMode(IMU_INT2, INPUT_PULLUP);
|
||||
attachInterrupt(IMU_INT2, setFlag, CHANGE);
|
||||
#else
|
||||
attachInterrupt(IMU_INT1, setFlag, CHANGE);
|
||||
#endif
|
||||
|
||||
|
||||
// Print register configuration information
|
||||
qmi.dumpCtrlRegister();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if (interruptFlag) {
|
||||
interruptFlag = false;
|
||||
qmi.readSensorStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_CHSC5816_GetPoint.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-17
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvCHSC5816.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 39
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 40
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 13
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST 14
|
||||
#endif
|
||||
|
||||
TouchDrvCHSC5816 touch;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
touch.setPins(SENSOR_RST, SENSOR_IRQ);
|
||||
if (!touch.begin(Wire, CHSC5816_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find CHSC5816 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init CHSC5816 Touch device success!");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int16_t x[2], y[2];
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
uint8_t touched = touch.getPoint(x, y);
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_CST9217_GetPoint.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-07-27
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvCST92xx.h"
|
||||
#include "SensorWireHelper.h"
|
||||
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 8
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 10
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 5
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST -1
|
||||
#endif
|
||||
|
||||
TouchDrvCST92xx touch;
|
||||
int16_t x[5], y[5];
|
||||
bool isPressed = false;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
#if SENSOR_RST != -1
|
||||
pinMode(SENSOR_RST, OUTPUT);
|
||||
digitalWrite(SENSOR_RST, LOW);
|
||||
delay(30);
|
||||
digitalWrite(SENSOR_RST, HIGH);
|
||||
delay(50);
|
||||
delay(1000);
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
Wire.setSCL(SENSOR_SCL);
|
||||
Wire.setSDA(SENSOR_SDA);
|
||||
Wire.begin();
|
||||
#elif defined(NRF52840_XXAA) || defined(NRF52832_XXAA)
|
||||
Wire.setPins(SENSOR_SDA, SENSOR_SCL);
|
||||
Wire.begin();
|
||||
#else
|
||||
Wire.begin(SENSOR_SDA, SENSOR_SCL);
|
||||
#endif
|
||||
|
||||
// Scan I2C devices
|
||||
SensorWireHelper::dumpDevices(Wire);
|
||||
|
||||
|
||||
// uint8_t touchAddress = 0x1A; // Other device addresses are determined by the touch firmware and are generally 0X5A by default.
|
||||
uint8_t touchAddress = 0x5A; // The device address is determined according to the actual situation. Not all device addresses are 0X5A. There can also be other customized device addresses.
|
||||
|
||||
|
||||
// Set to skip register check, used when the touch device address conflicts with other I2C device addresses [0x5A]
|
||||
touch.jumpCheck();
|
||||
|
||||
|
||||
touch.setPins(SENSOR_RST, SENSOR_IRQ);
|
||||
bool result = touch.begin(Wire, touchAddress, SENSOR_SDA, SENSOR_SCL);
|
||||
if (result == false) {
|
||||
Serial.println("touch is not online..."); while (1)delay(1000);
|
||||
}
|
||||
Serial.print("Model :"); Serial.println(touch.getModelName());
|
||||
|
||||
touch.setCoverScreenCallback([](void *ptr) {
|
||||
Serial.print(millis());
|
||||
Serial.println(" : The screen is covered");
|
||||
}, NULL);
|
||||
|
||||
|
||||
Serial.println("Enter touch sleep mode.");
|
||||
// Unable to obtain coordinates after turning on sleep
|
||||
// CST9217 Work current ~= 1.3mA
|
||||
// CST9217 sleep current = 3.4 uA
|
||||
touch.sleep();
|
||||
|
||||
int i = 10;
|
||||
while (i--) {
|
||||
Serial.printf("Wake up after %d seconds\n", i);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// Wakeup touch
|
||||
touch.reset();
|
||||
|
||||
// Set touch max xy
|
||||
// touch.setMaxCoordinates(240, 296);
|
||||
|
||||
// Set swap xy
|
||||
// touch.setSwapXY(true);
|
||||
|
||||
// Set mirror xy
|
||||
// touch.setMirrorXY(true, true);
|
||||
|
||||
//Register touch plane interrupt pin
|
||||
attachInterrupt(SENSOR_IRQ, []() {
|
||||
isPressed = true;
|
||||
}, FALLING);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (isPressed) {
|
||||
isPressed = false;
|
||||
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
|
||||
if (touched) {
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
delay(30);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_CSTxxx_GetPoint.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-24
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvCSTXXX.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 8
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 10
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 5
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST -1
|
||||
#endif
|
||||
|
||||
TouchDrvCSTXXX touch;
|
||||
int16_t x[5], y[5];
|
||||
|
||||
void scanDevices(void)
|
||||
{
|
||||
byte error, address;
|
||||
int nDevices = 0;
|
||||
Serial.println("Scanning for I2C devices ...");
|
||||
for (address = 0x01; address < 0x7f; address++) {
|
||||
Wire.beginTransmission(address);
|
||||
error = Wire.endTransmission();
|
||||
if (error == 0) {
|
||||
Serial.printf("I2C device found at address 0x%02X\n", address);
|
||||
nDevices++;
|
||||
} else if (error != 2) {
|
||||
Serial.printf("Error %d at address 0x%02X\n", error, address);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0) {
|
||||
Serial.println("No I2C devices found");
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
#if SENSOR_RST != -1
|
||||
pinMode(SENSOR_RST, OUTPUT);
|
||||
digitalWrite(SENSOR_RST, LOW);
|
||||
delay(30);
|
||||
digitalWrite(SENSOR_RST, HIGH);
|
||||
delay(50);
|
||||
// delay(1000);
|
||||
#endif
|
||||
|
||||
// Search for known CSTxxx device addresses
|
||||
uint8_t address = 0xFF;
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
Wire.setSCL(SENSOR_SCL);
|
||||
Wire.setSDA(SENSOR_SDA);
|
||||
Wire.begin();
|
||||
#elif defined(NRF52840_XXAA) || defined(NRF52832_XXAA)
|
||||
Wire.setPins(SENSOR_SDA, SENSOR_SCL);
|
||||
Wire.begin();
|
||||
#else
|
||||
Wire.begin(SENSOR_SDA, SENSOR_SCL);
|
||||
#endif
|
||||
|
||||
// Scan I2C devices
|
||||
scanDevices();
|
||||
|
||||
Wire.beginTransmission(CST816_SLAVE_ADDRESS);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
address = CST816_SLAVE_ADDRESS;
|
||||
}
|
||||
Wire.beginTransmission(CST226SE_SLAVE_ADDRESS);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
address = CST226SE_SLAVE_ADDRESS;
|
||||
}
|
||||
Wire.beginTransmission(CST328_SLAVE_ADDRESS);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
address = CST328_SLAVE_ADDRESS;
|
||||
}
|
||||
while (address == 0xFF) {
|
||||
Serial.println("Could't find touch chip!"); delay(1000);
|
||||
}
|
||||
|
||||
touch.setPins(SENSOR_RST, SENSOR_IRQ);
|
||||
touch.begin(Wire, address, SENSOR_SDA, SENSOR_SCL);
|
||||
|
||||
|
||||
Serial.print("Model :"); Serial.println(touch.getModelName());
|
||||
|
||||
// T-Display-S3 CST816 touch panel, touch button coordinates are is 85 , 160
|
||||
touch.setCenterButtonCoordinate(85, 360);
|
||||
|
||||
// T-Display-AMOLED 1.91 Inch CST816T touch panel, touch button coordinates is 600, 120.
|
||||
// touch.setCenterButtonCoordinate(600, 120); // Only suitable for AMOLED 1.91 inch
|
||||
|
||||
|
||||
// Depending on the touch panel, not all touch panels have touch buttons.
|
||||
touch.setHomeButtonCallback([](void *user_data) {
|
||||
Serial.println("Home key pressed!");
|
||||
}, NULL);
|
||||
|
||||
|
||||
// Unable to obtain coordinates after turning on sleep
|
||||
// CST816T sleep current = 1.1 uA
|
||||
// CST226SE sleep current = 60 uA
|
||||
// touch.sleep();
|
||||
|
||||
// Set touch max xy
|
||||
// touch.setMaxCoordinates(536, 240);
|
||||
|
||||
// Set swap xy
|
||||
// touch.setSwapXY(true);
|
||||
|
||||
// Set mirror xy
|
||||
// touch.setMirrorXY(true, true);
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
|
||||
if (touched) {
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_FT3267_LilyGo_T_RGB.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-17
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvFT6X36.hpp"
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 8
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 48
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 1
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST 1
|
||||
#endif
|
||||
|
||||
TouchDrvFT6X36 touch;
|
||||
ExtensionIOXL9555 extIO;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
|
||||
// T-RGB Use 0x20 device address
|
||||
if (!extIO.begin(Wire, XL9555_SLAVE_ADDRESS0, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find XL9555 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Set PORT0 as output
|
||||
extIO.configPort(ExtensionIOXL9555::PORT0, OUTPUT);
|
||||
extIO.writePort(ExtensionIOXL9555::PORT0, 0xFF);
|
||||
|
||||
extIO.digitalWrite(SENSOR_RST, LOW);
|
||||
delay(300);
|
||||
extIO.digitalWrite(SENSOR_RST, HIGH);
|
||||
delay(300);
|
||||
|
||||
|
||||
if (!touch.begin(Wire, FT3267_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find FT3267 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
touch.interruptTrigger();
|
||||
|
||||
Serial.println("Init FT3267 Sensor success!");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int16_t x[2], y[2];
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
uint8_t touched = touch.getPoint(x, y, 2);
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_FT6232_GetPoint.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-02
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvFT6X36.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 21
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 22
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 39
|
||||
#endif
|
||||
|
||||
TouchDrvFT6X36 touch;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT);
|
||||
|
||||
if (!touch.begin(Wire, FT6X36_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find FT6X36 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
touch.interruptTrigger();
|
||||
|
||||
Serial.println("Init FT6X36 Sensor success!");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
int16_t x[2], y[2];
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
uint8_t touched = touch.getPoint(x, y, 2);
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file GT911_GetPoint.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-12
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvGT911.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 2
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 3
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 1
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST 10
|
||||
#endif
|
||||
|
||||
TouchDrvGT911 touch;
|
||||
int16_t x[5], y[5];
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
// If the reset pin and interrupt pin can be controlled by GPIO, the device address can be set arbitrarily
|
||||
// If the interrupt and reset pins are not connected, you can pass in the -1 parameter and the library will automatically determine the address.
|
||||
touch.setPins(SENSOR_RST, SENSOR_IRQ);
|
||||
if (!touch.begin(Wire, GT911_SLAVE_ADDRESS_L, SENSOR_SDA, SENSOR_SCL)) {
|
||||
while (1) {
|
||||
Serial.println("Failed to find GT911 - check your wiring!");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Init GT911 Sensor success!");
|
||||
|
||||
// Set the center button to trigger the callback , Only for specific devices, e.g LilyGo-EPD47 S3 GT911
|
||||
touch.setHomeButtonCallback([](void *user_data) {
|
||||
Serial.println("Home button pressed!");
|
||||
}, NULL);
|
||||
|
||||
|
||||
/*
|
||||
* GT911 Interrupt mode
|
||||
* * */
|
||||
// Low level when idle, converts to high level when touched
|
||||
// touch.setInterruptMode(HIGH_LEVEL_QUERY);
|
||||
|
||||
// Keep low level when idle, and trigger on the falling edge after touching, trigger once at a frequency of 100HZ, and keep high level for 10ms
|
||||
// touch.setInterruptMode(RISING);
|
||||
|
||||
// Keep high level when idle, and switch to low level when touched
|
||||
// touch.setInterruptMode(LOW_LEVEL_QUERY);
|
||||
|
||||
// Maintains high level when idle, and is triggered by the falling edge after being touched. The frequency is 100HZ and is triggered once. Maintains 10ms in the low level interval
|
||||
// touch.setInterruptMode(FALLING);
|
||||
|
||||
|
||||
/*
|
||||
* GT911 Max touch point ,range: 1 ~ 5
|
||||
* */
|
||||
// touch.setMaxTouchPoint(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (touch.isPressed()) {
|
||||
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
|
||||
if (touched > 0) {
|
||||
Serial.print(millis());
|
||||
Serial.print("ms ");
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_GT911_LilyGo_T_RGB.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-12
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "TouchDrvGT911.hpp"
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 8
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 48
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 1
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST 1
|
||||
#endif
|
||||
|
||||
TouchDrvGT911 touch;
|
||||
ExtensionIOXL9555 extIO;
|
||||
int16_t x[5], y[5];
|
||||
|
||||
void scanDevices(void)
|
||||
{
|
||||
byte error, address;
|
||||
int nDevices = 0;
|
||||
Serial.println("Scanning for I2C devices ...");
|
||||
for (address = 0x01; address < 0x7f; address++) {
|
||||
Wire.beginTransmission(address);
|
||||
error = Wire.endTransmission();
|
||||
if (error == 0) {
|
||||
Serial.printf("I2C device found at address 0x%02X\n", address);
|
||||
nDevices++;
|
||||
} else if (error != 2) {
|
||||
Serial.printf("Error %d at address 0x%02X\n", error, address);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0) {
|
||||
Serial.println("No I2C devices found");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void digitalWrite_CB(uint32_t pin, uint8_t value)
|
||||
{
|
||||
extIO.digitalWrite(pin, value);
|
||||
}
|
||||
|
||||
void pinMode_CB(uint32_t pin, uint8_t mode)
|
||||
{
|
||||
extIO.pinMode(pin, mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
Serial.println("Start!");
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
Wire.setSCL(SENSOR_SCL);
|
||||
Wire.setSDA(SENSOR_SDA);
|
||||
Wire.begin();
|
||||
#elif defined(NRF52840_XXAA) || defined(NRF52832_XXAA)
|
||||
Wire.setPins(SENSOR_SDA, SENSOR_SCL);
|
||||
Wire.begin();
|
||||
#else
|
||||
Wire.begin(SENSOR_SDA, SENSOR_SCL);
|
||||
#endif
|
||||
|
||||
scanDevices();
|
||||
|
||||
// T-RGB Use 0x20 device address
|
||||
if (!extIO.begin(Wire, XL9555_SLAVE_ADDRESS0, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find XL9555 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
// Set PORT0 as output
|
||||
extIO.configPort(ExtensionIOXL9555::PORT0, OUTPUT);
|
||||
extIO.writePort(ExtensionIOXL9555::PORT0, 0xFF);
|
||||
|
||||
|
||||
touch.setPins(SENSOR_RST, SENSOR_IRQ);
|
||||
touch.setGpioWriteCallback(digitalWrite_CB);
|
||||
touch.setGpioModeCallback(pinMode_CB);
|
||||
|
||||
if (!touch.begin(Wire, GT911_SLAVE_ADDRESS_L, SENSOR_SDA, SENSOR_SCL )) {
|
||||
scanDevices();
|
||||
|
||||
while (1) {
|
||||
Serial.println("Failed to find GT911 - check your wiring!");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
//Set to trigger on falling edge
|
||||
touch.setInterruptMode(FALLING);
|
||||
|
||||
Serial.println("Init GT911 Sensor success!");
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (touch.isPressed()) {
|
||||
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
|
||||
if (touched) {
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file TouchDrv_LilyGo_T_RGB.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-01-21
|
||||
* @note T-RGB has three types of screens, each of which uses different touch driver chips.
|
||||
* The example demonstrates using the touch interface class and one sketch is suitable for three types of touch chips.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
#include "TouchDrvGT911.hpp"
|
||||
#include "TouchDrvFT6X36.hpp"
|
||||
#include "TouchDrvCSTXXX.hpp"
|
||||
|
||||
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 8
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 48
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ 1 //ESP32S3 GPIO1
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_RST
|
||||
#define SENSOR_RST 1 //XL9555 GPIO1
|
||||
#endif
|
||||
|
||||
TouchDrvInterface *touchDrv = NULL;
|
||||
ExtensionIOXL9555 extension;
|
||||
|
||||
ExtensionIOXL9555::ExtensionGPIO tp_reset = ExtensionIOXL9555::IO1;
|
||||
ExtensionIOXL9555::ExtensionGPIO power_enable = ExtensionIOXL9555::IO2;
|
||||
|
||||
int16_t x[5], y[5];
|
||||
|
||||
|
||||
//GPIO callback function
|
||||
void TouchDrvDigitalWrite(uint32_t gpio, uint8_t level)
|
||||
{
|
||||
if (gpio & 0x80) {
|
||||
extension.digitalWrite(gpio & 0x7F, level);
|
||||
} else {
|
||||
digitalWrite(gpio, level);
|
||||
}
|
||||
}
|
||||
|
||||
//GPIO callback function
|
||||
int TouchDrvDigitalRead(uint32_t gpio)
|
||||
{
|
||||
if (gpio & 0x80) {
|
||||
return extension.digitalRead(gpio & 0x7F);
|
||||
} else {
|
||||
return digitalRead(gpio);
|
||||
}
|
||||
}
|
||||
|
||||
//GPIO callback function
|
||||
void TouchDrvPinMode(uint32_t gpio, uint8_t mode)
|
||||
{
|
||||
if (gpio & 0x80) {
|
||||
extension.pinMode(gpio & 0x7F, mode);
|
||||
} else {
|
||||
pinMode(gpio, mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool setupTouchDrv()
|
||||
{
|
||||
//Touch interrupt uses ESP32S3 GPIO1, touch reset uses XL9555 extended IO chip GPIO1, and needs to add a mask to distinguish
|
||||
const uint8_t touch_reset_pin = 1 | 0x80;
|
||||
const uint8_t touch_irq_pin = 1;
|
||||
bool result = false;
|
||||
|
||||
touchDrv = new TouchDrvCSTXXX();
|
||||
// T-RGB reset GPIO is connected through the expansion chip, and the GPIO callback function needs to be set.
|
||||
touchDrv->setGpioCallback(TouchDrvPinMode, TouchDrvDigitalWrite, TouchDrvDigitalRead);
|
||||
touchDrv->setPins(touch_reset_pin, touch_irq_pin);
|
||||
result = touchDrv->begin(Wire, CST816_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL);
|
||||
if (result) {
|
||||
const char *model = touchDrv->getModelName();
|
||||
Serial.printf("Successfully initialized %s, using %s Driver!", model, model);
|
||||
return true;
|
||||
}
|
||||
|
||||
delete touchDrv;
|
||||
|
||||
touchDrv = new TouchDrvGT911();
|
||||
// T-RGB reset GPIO is connected through the expansion chip, and the GPIO callback function needs to be set.
|
||||
touchDrv->setGpioCallback(TouchDrvPinMode, TouchDrvDigitalWrite, TouchDrvDigitalRead);
|
||||
touchDrv->setPins(touch_reset_pin, touch_irq_pin);
|
||||
result = touchDrv->begin(Wire, GT911_SLAVE_ADDRESS_H, SENSOR_SDA, SENSOR_SCL);
|
||||
if (result) {
|
||||
Serial.println("Successfully initialized GT911, using GT911 Driver!");
|
||||
return true;
|
||||
}
|
||||
delete touchDrv;
|
||||
|
||||
touchDrv = new TouchDrvFT6X36();
|
||||
// T-RGB reset GPIO is connected through the expansion chip, and the GPIO callback function needs to be set.
|
||||
touchDrv->setGpioCallback(TouchDrvPinMode, TouchDrvDigitalWrite, TouchDrvDigitalRead);
|
||||
touchDrv->setPins(touch_reset_pin, touch_irq_pin);
|
||||
result = touchDrv->begin(Wire, FT3267_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL);
|
||||
if (result) {
|
||||
const char *model = touchDrv->getModelName();
|
||||
Serial.printf("Successfully initialized %s, using %s Driver!", model, model);
|
||||
return true;
|
||||
}
|
||||
delete touchDrv;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
Serial.println("Start!");
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
Wire.setSCL(SENSOR_SCL);
|
||||
Wire.setSDA(SENSOR_SDA);
|
||||
Wire.begin();
|
||||
#elif defined(NRF52840_XXAA) || defined(NRF52832_XXAA)
|
||||
Wire.setPins(SENSOR_SDA, SENSOR_SCL);
|
||||
Wire.begin();
|
||||
#else
|
||||
Wire.begin(SENSOR_SDA, SENSOR_SCL);
|
||||
#endif
|
||||
|
||||
// T-RGB XL9555 Use 0x20 device address
|
||||
if (!extension.begin(Wire, XL9555_SLAVE_ADDRESS0, SENSOR_SDA, SENSOR_SCL)) {
|
||||
while (1) {
|
||||
Serial.println("Failed to find XL9555 - check your wiring!");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// T-RGB power enable GPIO connected to XL9555 expansion chip GPIO
|
||||
extension.pinMode(power_enable, OUTPUT);
|
||||
extension.digitalWrite(power_enable, HIGH);
|
||||
|
||||
// Initialize touch using touch driver interface class
|
||||
if (!setupTouchDrv()) {
|
||||
while (1) {
|
||||
Serial.println("Failed to find touch - check your wiring!");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (touchDrv) {
|
||||
if (touchDrv->isPressed()) {
|
||||
uint8_t touched = touchDrv->getPoint(x, y, touchDrv->getSupportTouchPoint());
|
||||
if (touched) {
|
||||
for (int i = 0; i < touched; ++i) {
|
||||
Serial.print("X[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(x[i]);
|
||||
Serial.print(" ");
|
||||
Serial.print(" Y[");
|
||||
Serial.print(i);
|
||||
Serial.print("]:");
|
||||
Serial.print(y[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file XL9555_ExtensionIOInterrupt.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-01-03
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include <time.h>
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
ExtensionIOXL9555 extIO;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
// Device address 0x20~0x27
|
||||
if (!extIO.begin(Wire, XL9555_SLAVE_ADDRESS4, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find XL9555 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
// Set PORT0 as input,mask = 0xFF = all pin input
|
||||
extIO.configPort(ExtensionIOXL9555::PORT0, 0xFF);
|
||||
// Set PORT1 as input,mask = 0xFF = all pin input
|
||||
extIO.configPort(ExtensionIOXL9555::PORT1, 0xFF);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// When the interrupt occurs, we read the mask value of PORT
|
||||
if (digitalRead(SENSOR_IRQ) == LOW) {
|
||||
Serial.print("PORT0:0b");
|
||||
Serial.print(extIO.readPort(ExtensionIOXL9555::PORT0), BIN);
|
||||
Serial.print("\tPORT1:0b");
|
||||
Serial.println(extIO.readPort(ExtensionIOXL9555::PORT1), BIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file XL9555_ExtensionIORead.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-01-03
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include <time.h>
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
ExtensionIOXL9555 extIO;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
// Device address 0x20~0x27
|
||||
if (!extIO.begin(Wire, XL9555_SLAVE_ADDRESS4, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find XL9555 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
pinMode(SENSOR_IRQ, INPUT_PULLUP);
|
||||
// Set PORT0 as input,mask = 0xFF = all pin input
|
||||
extIO.configPort(ExtensionIOXL9555::PORT0, 0xFF);
|
||||
// Set PORT1 as input,mask = 0xFF = all pin input
|
||||
extIO.configPort(ExtensionIOXL9555::PORT1, 0xFF);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print("PORT0:0b");
|
||||
Serial.print(extIO.readPort(ExtensionIOXL9555::PORT0), BIN);
|
||||
Serial.print("\tPORT1:0b");
|
||||
Serial.println(extIO.readPort(ExtensionIOXL9555::PORT1), BIN);
|
||||
|
||||
//Allowable range of parameter input: IO0 ~ IO15
|
||||
Serial.println("IO0:\tIO1:\tIO2:\tIO3:\tIO4:\tIO5:\tIO6:\tIO7:\tIO8:\tIO9:\tIO10:\tIO11:\tIO12:\tIO13:\tIO14:\tIO15:\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO0));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO1));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO2));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO3));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO4));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO5));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO6));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO7));
|
||||
Serial.print("\t");
|
||||
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO8));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO9));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO10));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO11));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO12));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO13));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO14));
|
||||
Serial.print("\t");
|
||||
Serial.print(extIO.digitalRead(ExtensionIOXL9555::IO15));
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file XL9555_ExtensionIOWirte.ino
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-01-03
|
||||
*
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Arduino.h>
|
||||
#include <time.h>
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
|
||||
#ifndef SENSOR_SDA
|
||||
#define SENSOR_SDA 17
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_SCL
|
||||
#define SENSOR_SCL 18
|
||||
#endif
|
||||
|
||||
#ifndef SENSOR_IRQ
|
||||
#define SENSOR_IRQ -1
|
||||
#endif
|
||||
|
||||
ExtensionIOXL9555 extIO;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
|
||||
|
||||
// Device address 0x20~0x27
|
||||
if (!extIO.begin(Wire, XL9555_SLAVE_ADDRESS4, SENSOR_SDA, SENSOR_SCL)) {
|
||||
Serial.println("Failed to find XL9555 - check your wiring!");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
// Set PORT0 as output ,mask = 0x00 = all pin output
|
||||
extIO.configPort(ExtensionIOXL9555::PORT0, 0x00);
|
||||
// Set PORT1 as output ,mask = 0x00 = all pin output
|
||||
extIO.configPort(ExtensionIOXL9555::PORT1, 0x00);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Set all PORTs to 1, and the parameters here are mask values, corresponding to the 0~7 bits
|
||||
Serial.println("Set port HIGH");
|
||||
extIO.writePort(ExtensionIOXL9555::PORT0, 0xFF);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("Set port LOW");
|
||||
// Set all PORTs to 0, and the parameters here are mask values, corresponding to the 0~7 bits
|
||||
extIO.writePort(ExtensionIOXL9555::PORT1, 0x00);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("digitalWrite");
|
||||
extIO.digitalWrite(ExtensionIOXL9555::IO0, HIGH);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("digitalToggle");
|
||||
extIO.digitalToggle(ExtensionIOXL9555::IO0);
|
||||
delay(1000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For SensorLib By lewis He
|
||||
# github:https://github.com/lewisxhe
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
ExtensionIOXL9555 KEYWORD1
|
||||
RTC_DateTime KEYWORD1
|
||||
RTC_Alarm KEYWORD1
|
||||
SensorPCF8563 KEYWORD1
|
||||
SensorQMC6310 KEYWORD1
|
||||
MagRange KEYWORD1
|
||||
OutputRate KEYWORD1
|
||||
CtrlReg KEYWORD1
|
||||
OverSampleRatio KEYWORD1
|
||||
DownSampleRatio KEYWORD1
|
||||
|
||||
SensorQMI8658 KEYWORD1
|
||||
AccelRange KEYWORD1
|
||||
GyroRange KEYWORD1
|
||||
AccelODR KEYWORD1
|
||||
GyroODR KEYWORD1
|
||||
LpfMode KEYWORD1
|
||||
MotionEvent KEYWORD1
|
||||
IntPin KEYWORD1
|
||||
Fifo_Samples KEYWORD1
|
||||
FIFO_Mode KEYWORD1
|
||||
SampleMode KEYWORD1
|
||||
CommandTable KEYWORD1
|
||||
StatusReg KEYWORD1
|
||||
TagPriority KEYWORD1
|
||||
SensorStatus KEYWORD1
|
||||
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
# XL9555 Coloring Map
|
||||
|
||||
init KEYWORD2
|
||||
deinit KEYWORD2
|
||||
pinMode KEYWORD2
|
||||
digitalRead KEYWORD2
|
||||
digitalWrite KEYWORD2
|
||||
digitalToggle KEYWORD2
|
||||
readPort KEYWORD2
|
||||
writePort KEYWORD2
|
||||
readConfig KEYWORD2
|
||||
configPort KEYWORD2
|
||||
|
||||
|
||||
# PCF8563 Coloring Map
|
||||
setDateTime KEYWORD2
|
||||
getDateTime KEYWORD2
|
||||
getAlarm KEYWORD2
|
||||
enableAlarm KEYWORD2
|
||||
disableAlarm KEYWORD2
|
||||
resetAlarm KEYWORD2
|
||||
isAlarmActive KEYWORD2
|
||||
setAlarm KEYWORD2
|
||||
setAlarmByMinutes KEYWORD2
|
||||
setAlarmByDays KEYWORD2
|
||||
setAlarmByHours KEYWORD2
|
||||
setAlarmByWeekDay KEYWORD2
|
||||
isCountdownTimerEnable KEYWORD2
|
||||
isCountdownTimerActive KEYWORD2
|
||||
enableCountdownTimer KEYWORD2
|
||||
disableCountdownTimer KEYWORD2
|
||||
setCountdownTimer KEYWORD2
|
||||
clearCountdownTimer KEYWORD2
|
||||
enableCLK KEYWORD2
|
||||
strftime KEYWORD2
|
||||
conversionUnixTime KEYWORD2
|
||||
hwClockRead KEYWORD2
|
||||
hwClockWrite KEYWORD2
|
||||
getDayOfWeek KEYWORD2
|
||||
getNextMonth KEYWORD2
|
||||
getNextYear KEYWORD2
|
||||
getLeapYear KEYWORD2
|
||||
getDaysInMonth KEYWORD2
|
||||
|
||||
# SensorQMC6310 Coloring Map
|
||||
reset KEYWORD2
|
||||
getChipID KEYWORD2
|
||||
getStatus KEYWORD2
|
||||
isDataReady KEYWORD2
|
||||
isDataOverflow KEYWORD2
|
||||
setSelfTest KEYWORD2
|
||||
setMode KEYWORD2
|
||||
setCtrlRegister KEYWORD2
|
||||
setDataOutputRate KEYWORD2
|
||||
setOverSampleRate KEYWORD2
|
||||
setDownSampleRate KEYWORD2
|
||||
setSign KEYWORD2
|
||||
configMagnetometer KEYWORD2
|
||||
setMagRange KEYWORD2
|
||||
setOffset KEYWORD2
|
||||
readData KEYWORD2
|
||||
setDeclination KEYWORD2
|
||||
readPolar KEYWORD2
|
||||
getRawX KEYWORD2
|
||||
getRawY KEYWORD2
|
||||
getRawZ KEYWORD2
|
||||
getX KEYWORD2
|
||||
getY KEYWORD2
|
||||
getZ KEYWORD2
|
||||
getMag KEYWORD2
|
||||
dumpCtrlRegister KEYWORD2
|
||||
|
||||
# SensorQMI8658 Coloring Map
|
||||
whoAmI KEYWORD2
|
||||
getTimestamp KEYWORD2
|
||||
getTemperature_C KEYWORD2
|
||||
enableINT KEYWORD2
|
||||
getIrqStatus KEYWORD2
|
||||
enableDataReadyINT KEYWORD2
|
||||
configAccelerometer KEYWORD2
|
||||
configGyroscope KEYWORD2
|
||||
configFIFO KEYWORD2
|
||||
getFifoNeedBytes KEYWORD2
|
||||
readFromFifo KEYWORD2
|
||||
enableAccelerometer KEYWORD2
|
||||
disableAccelerometer KEYWORD2
|
||||
isEnableAccelerometer KEYWORD2
|
||||
isEnableGyroscope KEYWORD2
|
||||
enableGyroscope KEYWORD2
|
||||
disableGyroscope KEYWORD2
|
||||
getAccelRaw KEYWORD2
|
||||
getAccelerometer KEYWORD2
|
||||
getAccelerometerScales KEYWORD2
|
||||
getGyroscopeScales KEYWORD2
|
||||
getGyroRaw KEYWORD2
|
||||
getGyroscope KEYWORD2
|
||||
getDataReady KEYWORD2
|
||||
enableSyncSampleMode KEYWORD2
|
||||
disableSyncSampleMode KEYWORD2
|
||||
enableLockingMechanism KEYWORD2
|
||||
disableLockingMechanism KEYWORD2
|
||||
powerDown KEYWORD2
|
||||
powerOn KEYWORD2
|
||||
getStatusRegister KEYWORD2
|
||||
configActivityInterruptMap KEYWORD2
|
||||
configPedometer KEYWORD2
|
||||
getPedometerCounter KEYWORD2
|
||||
clearPedometerCounter KEYWORD2
|
||||
enablePedometer KEYWORD2
|
||||
disablePedometer KEYWORD2
|
||||
configTap KEYWORD2
|
||||
enableTap KEYWORD2
|
||||
disableTap KEYWORD2
|
||||
getTapStatus KEYWORD2
|
||||
configMotion KEYWORD2
|
||||
enableMotionDetect KEYWORD2
|
||||
disableMotionDetect KEYWORD2
|
||||
configWakeOnMotion KEYWORD2
|
||||
getChipUsid KEYWORD2
|
||||
getChipFirmwareVersion KEYWORD2
|
||||
readSensorStatus KEYWORD2
|
||||
setWakeupMotionEventCallBack KEYWORD2
|
||||
setTapEventCallBack KEYWORD2
|
||||
setPedometerEventCallBack KEYWORD2
|
||||
setNoMotionEventCallBack KEYWORD2
|
||||
setAnyMotionEventCallBack KEYWORD2
|
||||
setSignificantMotionEventCallBack KEYWORD2
|
||||
setGyroDataReadyCallBack KEYWORD2
|
||||
setAccelDataReadyEventCallBack KEYWORD2
|
||||
setDataLockingEvevntCallBack KEYWORD2
|
||||
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "SensorLib",
|
||||
"version": "0.2.0",
|
||||
"description": "Commonly used I2C , SPI device multi-platform libraries",
|
||||
"keywords": "QMC6310, QMI8658, PCF8563, PCF85063, XL9555, BMA423, BHI260AP, DRV2605, CM32181, LTR553, FT5206, FT3267, FT6236, FT6336, CST816S,CST816T,CST816D, CST820, CST226, CHSC5816, GT911",
|
||||
"authors": [
|
||||
{
|
||||
"name": "LewisHe",
|
||||
"url": "https://github.com/lewisxhe",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lewisxhe/SensorsLib.git"
|
||||
},
|
||||
"homepage": "https://github.com/lewisxhe/SensorsLib",
|
||||
"export": {
|
||||
"include": [
|
||||
"LICENSE",
|
||||
"library.json",
|
||||
"library.properties",
|
||||
"README.md",
|
||||
"keywords.txt",
|
||||
"src/*",
|
||||
"examples/*"
|
||||
]
|
||||
},
|
||||
"frameworks": ["arduino", "espidf"],
|
||||
"platforms": "esp32,raspberrypi,ststm32,espressif32",
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
name=SensorLib
|
||||
version=0.2.0
|
||||
author=Lewis He
|
||||
maintainer=Lewis He <lewishe@outlook.com>
|
||||
sentence=Commonly used I2C , SPI device multi-platform libraries
|
||||
paragraph=Support QMC6310,QMI8658,PCF8563,PCF85063,XL9555,BMA423,BHI260AP,DRV2605,CM32181,LTR553,FT5206,FT3267,FT6236,FT6336,CST816S/T/D,CST820,CST226,CHSC5816,GT911
|
||||
category=Communication
|
||||
url=https://github.com/lewisxhe/SensorsLib
|
||||
architectures=esp32
|
||||
@@ -0,0 +1,191 @@
|
||||
;PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
; src_dir = examples/BAM423_Accelerometer
|
||||
; src_dir = examples/BAM423_Temperature
|
||||
; src_dir = examples/BMA423_Feature
|
||||
; src_dir = examples/BAM423_Orientation
|
||||
; src_dir = examples/PCF8563_AlarmByUnits
|
||||
; src_dir = examples/PCF8563_SimpleTime
|
||||
; src_dir = examples/PCF8563_TimeLib
|
||||
; src_dir = examples/PCF8563_TimeSynchronization
|
||||
; src_dir = examples/PCF85063_SimpleTime
|
||||
; src_dir = examples/PCF85063_AlarmByUnits
|
||||
; src_dir = examples/PCF85063_ClockOutput
|
||||
; src_dir = examples/QMC6310_CalibrateExample
|
||||
; src_dir = examples/QMC6310_CompassExample
|
||||
; src_dir = examples/QMC6310_GetDataExample
|
||||
; src_dir = examples/QMC6310_GetPolarExample
|
||||
; src_dir = examples/QMI8658_BlockExample
|
||||
; src_dir = examples/QMI8658_GetDataExample
|
||||
; src_dir = examples/QMI8658_InterruptBlockExample
|
||||
; src_dir = examples/QMI8658_InterruptExample
|
||||
; src_dir = examples/QMI8658_LockingMechanismExample
|
||||
; src_dir = examples/QMI8658_MadgwickAHRS
|
||||
; src_dir = examples/QMI8658_PedometerExample
|
||||
; src_dir = examples/QMI8658_ReadFromFifoExample
|
||||
; src_dir = examples/QMI8658_WakeOnMotion
|
||||
; src_dir = examples/QMI8658_WakeOnMotionCallBackExample
|
||||
; src_dir = examples/XL9555_ExtensionIOInterrupt
|
||||
; src_dir = examples/XL9555_ExtensionIORead
|
||||
; src_dir = examples/XL9555_ExtensionIOWirte
|
||||
; src_dir = examples/DRV2605_Basic
|
||||
; src_dir = examples/CM32181_LightSensor
|
||||
; src_dir = examples/CM32181_LightSensorInterrupt
|
||||
; src_dir = examples/LTR553ALS_Sensor
|
||||
; src_dir = examples/BHI260AP_6DoF
|
||||
; src_dir = examples/BHI260AP_Orientation
|
||||
; src_dir = examples/BHI260AP_StepCounter
|
||||
; src_dir = examples/BHI260AP_DebugInfo
|
||||
; src_dir = examples/BHI260AP_aux_BMM150
|
||||
; src_dir = examples/BHI260AP_aux_BMM150_euler
|
||||
; src_dir = examples/BHI260AP_aux_BMM150_quaternion
|
||||
; src_dir = examples/BHI260AP_aux_BMM150_BME280
|
||||
; src_dir = examples/BMM150_GetDataExample
|
||||
|
||||
|
||||
; Touch devices support list
|
||||
; src_dir = examples/TouchDrv_FT3267_LilyGo_T_RGB
|
||||
; src_dir = examples/TouchDrv_GT911_LilyGo_T_RGB
|
||||
; src_dir = examples/TouchDrv_Interface_T_RGB
|
||||
; src_dir = examples/TouchDrv_FT6232_GetPoint
|
||||
; src_dir = examples/TouchDrv_GT911_GetPoint
|
||||
; src_dir = examples/TouchDrv_CHSC5816_GetPoint
|
||||
; src_dir = examples/TouchDrv_CSTxxx_GetPoint
|
||||
src_dir = examples/TouchDrv_CST9217_GetPoint
|
||||
|
||||
; default_envs = esp32dev
|
||||
default_envs = esp32s3
|
||||
; default_envs = esp32c3
|
||||
; default_envs = rp2040
|
||||
; default_envs = nrf52840
|
||||
|
||||
; Custom board variant
|
||||
boards_dir = ./board
|
||||
|
||||
[env]
|
||||
lib_extra_dirs = .
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
build_flags =
|
||||
; -DLOG_PORT=Serial
|
||||
; -DSENSOR_SDA=21
|
||||
; -DSENSOR_SCL=22
|
||||
; -DSENSOR_IRQ=35
|
||||
|
||||
; T-Display-AMOLED 1.91 Inch CST816T✅
|
||||
; -DSENSOR_SDA=3
|
||||
; -DSENSOR_SCL=2
|
||||
; -DSENSOR_IRQ=21
|
||||
; -DSENSOR_RST=-1
|
||||
|
||||
; T-Display-Lite 1.47 Inch CHSC5816 ✅
|
||||
; -DSENSOR_SDA=1
|
||||
; -DSENSOR_SCL=2
|
||||
; -DSENSOR_IRQ=13
|
||||
; -DSENSOR_RST=14
|
||||
|
||||
; T-Deck GT911
|
||||
; -DSENSOR_SDA=18
|
||||
; -DSENSOR_SCL=8
|
||||
; -DSENSOR_IRQ=16
|
||||
; -DSENSOR_RST=-1
|
||||
|
||||
; T-Display-S3-Pro CST226SE✅
|
||||
; -DSENSOR_SDA=5
|
||||
; -DSENSOR_SCL=6
|
||||
; -DSENSOR_IRQ=7
|
||||
; -DSENSOR_RST=13
|
||||
|
||||
; T-Display-S3 CST816T✅
|
||||
; -DSENSOR_SDA=18
|
||||
; -DSENSOR_SCL=17
|
||||
; -DSENSOR_IRQ=16
|
||||
; -DSENSOR_RST=21
|
||||
|
||||
; T-Display-S3-Pro CST226SE✅
|
||||
; -DSENSOR_SDA=5
|
||||
; -DSENSOR_SCL=6
|
||||
; -DSENSOR_IRQ=7
|
||||
; -DSENSOR_RST=13
|
||||
|
||||
; T4-S3 CST226SE ✅
|
||||
; -DSENSOR_SDA=6
|
||||
; -DSENSOR_SCL=7
|
||||
; -DSENSOR_IRQ=8
|
||||
; -DSENSOR_RST=17
|
||||
|
||||
; T-EPD47 S3 GT911 2 Point touch✅
|
||||
; -DSENSOR_SDA=6
|
||||
; -DSENSOR_SCL=5
|
||||
; -DSENSOR_IRQ=15
|
||||
; -DSENSOR_RST=41
|
||||
|
||||
; -DSENSOR_SDA=33
|
||||
; -DSENSOR_SCL=35
|
||||
; -DSENSOR_IRQ=34
|
||||
; -DSENSOR_RST=-1
|
||||
|
||||
; T-Watch-S3-U
|
||||
-DSENSOR_SDA=2
|
||||
-DSENSOR_SCL=3
|
||||
-DSENSOR_IRQ=12
|
||||
-DSENSOR_RST=46
|
||||
|
||||
-DCORE_DEBUG_LEVEL=0
|
||||
-Wnarrowing
|
||||
-Wtype-limits
|
||||
; -Werror
|
||||
-Wall
|
||||
-Wunused-variable
|
||||
-Werror=format
|
||||
-Wmissing-field-initializers
|
||||
|
||||
[env:esp32dev]
|
||||
extends = env
|
||||
platform = espressif32@6.7.0
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
|
||||
[env:esp32c3]
|
||||
extends = env
|
||||
platform = espressif32@6.7.0
|
||||
framework = arduino
|
||||
board = esp32-c3-devkitm-1
|
||||
|
||||
[env:esp32s3]
|
||||
extends = env
|
||||
platform = espressif32@6.7.0
|
||||
framework = arduino
|
||||
board = esp32-s3-devkitm-1
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
; -UARDUINO_USB_CDC_ON_BOOT
|
||||
|
||||
[env:rp2040]
|
||||
extends = env
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
board = pico
|
||||
framework = arduino
|
||||
board_build.core = earlephilhower
|
||||
|
||||
[env:nrf52840]
|
||||
platform = nordicnrf52
|
||||
board = nrf52840_dk_adafruit
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
upload_protocol = nrfutil
|
||||
; upload_protocol = nrfjprog
|
||||
; upload_protocol = jlink
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file ExtensionIOXL9555.hpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-12-27
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "REG/XL9555Constants.h"
|
||||
#include "SensorCommon.tpp"
|
||||
#include "ExtensionSPI.tpp"
|
||||
|
||||
class ExtensionIOXL9555 :
|
||||
public SensorCommon<ExtensionIOXL9555>,
|
||||
public ExtensionSPI<ExtensionIOXL9555>
|
||||
{
|
||||
friend class SensorCommon<ExtensionIOXL9555>;
|
||||
friend class ExtensionSPI<ExtensionIOXL9555>;
|
||||
public:
|
||||
|
||||
enum {
|
||||
PORT0,
|
||||
PORT1,
|
||||
};
|
||||
|
||||
enum ExtensionGPIO {
|
||||
IO0,
|
||||
IO1,
|
||||
IO2,
|
||||
IO3,
|
||||
IO4,
|
||||
IO5,
|
||||
IO6,
|
||||
IO7,
|
||||
IO8,
|
||||
IO9,
|
||||
IO10,
|
||||
IO11,
|
||||
IO12,
|
||||
IO13,
|
||||
IO14,
|
||||
IO15,
|
||||
};
|
||||
|
||||
|
||||
#if defined(ARDUINO)
|
||||
ExtensionIOXL9555(PLATFORM_WIRE_TYPE &w, int sda = DEFAULT_SDA, int scl = DEFAULT_SCL, uint8_t addr = XL9555_SLAVE_ADDRESS0)
|
||||
{
|
||||
__wire = &w;
|
||||
__sda = sda;
|
||||
__scl = scl;
|
||||
__addr = addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
ExtensionIOXL9555()
|
||||
{
|
||||
#if defined(ARDUINO)
|
||||
__wire = &Wire;
|
||||
__sda = DEFAULT_SDA;
|
||||
__scl = DEFAULT_SCL;
|
||||
#endif
|
||||
__addr = XL9555_SLAVE_ADDRESS0;
|
||||
}
|
||||
|
||||
~ExtensionIOXL9555()
|
||||
{
|
||||
deinit();
|
||||
}
|
||||
|
||||
#if defined(ARDUINO)
|
||||
bool init(PLATFORM_WIRE_TYPE &w, int sda = DEFAULT_SDA, int scl = DEFAULT_SCL, uint8_t addr = XL9555_SLAVE_ADDRESS0)
|
||||
{
|
||||
return SensorCommon::begin(w, addr, sda, scl);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void deinit()
|
||||
{
|
||||
// end();
|
||||
}
|
||||
|
||||
|
||||
void pinMode(uint8_t pin, uint8_t mode)
|
||||
{
|
||||
uint8_t registers = 0;
|
||||
if (pin >= IO8) {
|
||||
pin -= IO8;
|
||||
registers = XL9555_CTRL_CFG1;
|
||||
} else {
|
||||
registers = XL9555_CTRL_CFG0;
|
||||
}
|
||||
switch (mode) {
|
||||
case INPUT:
|
||||
setRegisterBit(registers, pin);
|
||||
break;
|
||||
case OUTPUT:
|
||||
clrRegisterBit(registers, pin);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int digitalRead(uint8_t pin)
|
||||
{
|
||||
uint8_t registers = 0;
|
||||
if (pin >= IO8) {
|
||||
pin -= IO8;
|
||||
registers = XL9555_CTRL_INP1;
|
||||
} else {
|
||||
registers = XL9555_CTRL_INP0;
|
||||
}
|
||||
return getRegisterBit(registers, pin);
|
||||
}
|
||||
|
||||
void digitalWrite(uint8_t pin, uint8_t val)
|
||||
{
|
||||
uint8_t registers = 0;
|
||||
if (pin >= IO8) {
|
||||
pin -= IO8;
|
||||
registers = XL9555_CTRL_OUTP1;
|
||||
} else {
|
||||
registers = XL9555_CTRL_OUTP0;
|
||||
}
|
||||
val ? setRegisterBit(registers, pin) : clrRegisterBit(registers, pin);
|
||||
}
|
||||
|
||||
void digitalToggle(uint8_t pin)
|
||||
{
|
||||
int state = 1 - digitalRead(pin);
|
||||
digitalWrite(pin, state);
|
||||
}
|
||||
|
||||
int readPort(uint8_t port)
|
||||
{
|
||||
return readRegister(port == PORT0 ? XL9555_CTRL_INP0 : XL9555_CTRL_INP1);
|
||||
}
|
||||
|
||||
int writePort(uint8_t port, uint8_t mask)
|
||||
{
|
||||
return writeRegister(port == PORT0 ? XL9555_CTRL_OUTP0 : XL9555_CTRL_OUTP1, mask);
|
||||
}
|
||||
|
||||
int readConfig(uint8_t port)
|
||||
{
|
||||
return readRegister(port == PORT0 ? XL9555_CTRL_CFG0 : XL9555_CTRL_CFG1);
|
||||
}
|
||||
|
||||
int configPort(uint8_t port, uint8_t mask)
|
||||
{
|
||||
return writeRegister(port == PORT0 ? XL9555_CTRL_CFG0 : XL9555_CTRL_CFG1, mask);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool initImpl()
|
||||
{
|
||||
int cfg1 = readConfig(PORT0);
|
||||
if (cfg1 == DEV_WIRE_ERR)return false;
|
||||
configPort(PORT0, 0x03);
|
||||
uint8_t val = readConfig(PORT0);
|
||||
if (val != 0x03) {
|
||||
return false;
|
||||
}
|
||||
writePort(PORT0, cfg1);
|
||||
return true;
|
||||
}
|
||||
|
||||
int getReadMaskImpl()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file ExtensionSPI.hpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-01-19
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "SensorLib.h"
|
||||
|
||||
template <class chipType>
|
||||
class ExtensionSPI
|
||||
{
|
||||
public:
|
||||
void beginSPI(int mosi,
|
||||
int miso,
|
||||
int sck,
|
||||
int cs
|
||||
)
|
||||
{
|
||||
_mosi = mosi;
|
||||
_miso = miso;
|
||||
_sck = sck;
|
||||
_cs = cs;
|
||||
|
||||
thisChip().pinMode(_mosi, OUTPUT);
|
||||
thisChip().pinMode(_sck, OUTPUT);
|
||||
|
||||
if (_cs != SENSOR_PIN_NONE) {
|
||||
thisChip().pinMode(_cs, OUTPUT);
|
||||
thisChip().digitalWrite(_cs, HIGH);
|
||||
}
|
||||
|
||||
if (_miso != SENSOR_PIN_NONE) {
|
||||
thisChip().pinMode(_miso, INPUT);
|
||||
}
|
||||
thisChip().digitalWrite(_mosi, HIGH);
|
||||
thisChip().digitalWrite(_sck, HIGH);
|
||||
|
||||
}
|
||||
|
||||
void setBitOrder(uint8_t order)
|
||||
{
|
||||
_order = order & 1;
|
||||
}
|
||||
|
||||
uint8_t transfer8(uint8_t val)
|
||||
{
|
||||
return transferDataBits(val, 8);
|
||||
}
|
||||
|
||||
uint16_t transfer9(uint16_t val)
|
||||
{
|
||||
return transferDataBits(val, 9);
|
||||
}
|
||||
|
||||
uint32_t transferDataBits(uint32_t val, uint32_t bits)
|
||||
{
|
||||
uint32_t mask = _BV(bits - 1);
|
||||
uint8_t out = 0;
|
||||
if (_cs != SENSOR_PIN_NONE) {
|
||||
thisChip().digitalWrite(_cs, LOW);
|
||||
}
|
||||
for (int i = 0; i < bits ; i++) {
|
||||
thisChip().digitalWrite(_sck, LOW);
|
||||
out <<= 1;
|
||||
if (_miso != SENSOR_PIN_NONE) {
|
||||
if (thisChip().digitalRead(_miso)) {
|
||||
out |= 0x01;
|
||||
}
|
||||
}
|
||||
thisChip().digitalWrite(_mosi, val & mask ? HIGH : LOW);
|
||||
val <<= 1;
|
||||
thisChip().digitalWrite(_sck, HIGH);
|
||||
}
|
||||
if (_cs != SENSOR_PIN_NONE) {
|
||||
thisChip().digitalWrite(_cs, HIGH);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
inline const chipType &thisChip() const
|
||||
{
|
||||
return static_cast<const chipType &>(*this);
|
||||
}
|
||||
|
||||
inline chipType &thisChip()
|
||||
{
|
||||
return static_cast<chipType &>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
int _mosi;
|
||||
int _sck;
|
||||
int _miso;
|
||||
int _order;
|
||||
int _cs;
|
||||
};
|
||||
@@ -0,0 +1,726 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#define BMA423_SLAVE_ADDRESS (0x19)
|
||||
|
||||
|
||||
#define BAM423_SENSOR_RESOLUTION (12)
|
||||
|
||||
#define BMA423_RESET_REG (0x7E)
|
||||
|
||||
/**\name CHIP ID ADDRESS*/
|
||||
#define BMA4_CHIP_ID_ADDR (0x00)
|
||||
|
||||
/**\name Chip ID of BMA423 sensor */
|
||||
#define BMA423_CHIP_ID (0x13)
|
||||
|
||||
/**\name POWER_CTRL REGISTER*/
|
||||
#define BMA4_POWER_CONF_ADDR (0x7C)
|
||||
#define BMA4_POWER_CTRL_ADDR (0x7D)
|
||||
|
||||
|
||||
/**\name ADVANCE POWER SAVE POSITION AND MASK*/
|
||||
#define BMA4_ADVANCE_POWER_SAVE_MSK (0x01)
|
||||
|
||||
/**\name MAP INTERRUPT 1 and 2 REGISTERS*/
|
||||
#define BMA4_INT_MAP_1_ADDR (0X56)
|
||||
#define BMA4_INT_MAP_2_ADDR (0X57)
|
||||
#define BMA4_INT_MAP_DATA_ADDR (0x58)
|
||||
#define BMA4_INIT_CTRL_ADDR (0x59)
|
||||
|
||||
|
||||
/**\name FEATURE CONFIG RELATED */
|
||||
#define BMA4_RESERVED_REG_5B_ADDR (0x5B)
|
||||
#define BMA4_RESERVED_REG_5C_ADDR (0x5C)
|
||||
#define BMA4_FEATURE_CONFIG_ADDR (0x5E)
|
||||
#define BMA4_INTERNAL_ERROR (0x5F)
|
||||
|
||||
/**\name GPIO REGISTERS*/
|
||||
#define BMA4_STEP_CNT_OUT_0_ADDR (0x1E)
|
||||
#define BMA4_HIGH_G_OUT_ADDR (0x1F)
|
||||
#define BMA4_ACTIVITY_OUT_ADDR (0x27)
|
||||
#define BMA4_ORIENTATION_OUT_ADDR (0x28)
|
||||
#define BMA4_INTERNAL_STAT (0x2A)
|
||||
|
||||
|
||||
|
||||
|
||||
/**\name SENSOR TIME REGISTERS*/
|
||||
#define BMA4_SENSORTIME_0_ADDR (0X18)
|
||||
|
||||
/**\name INTERRUPT/FEATURE STATUS REGISTERS*/
|
||||
#define BMA4_INT_STAT_0_ADDR (0X1C)
|
||||
|
||||
/**\name INTERRUPT/FEATURE STATUS REGISTERS*/
|
||||
#define BMA4_INT_STAT_1_ADDR (0X1D)
|
||||
|
||||
/**\name BUS READ AND WRITE LENGTH FOR MAG & ACCEL*/
|
||||
#define BMA4_MAG_TRIM_DATA_SIZE (16)
|
||||
#define BMA4_MAG_XYZ_DATA_LENGTH (6)
|
||||
#define BMA4_MAG_XYZR_DATA_LENGTH (8)
|
||||
#define BMA4_ACCEL_DATA_LENGTH (6)
|
||||
#define BMA4_FIFO_DATA_LENGTH (2)
|
||||
#define BMA4_TEMP_DATA_SIZE (1)
|
||||
|
||||
/**\name AUX/ACCEL DATA BASE ADDRESS REGISTERS*/
|
||||
#define BMA4_DATA_0_ADDR (0X0A)
|
||||
#define BMA4_DATA_8_ADDR (0X12)
|
||||
|
||||
|
||||
/**\name Feature offset address */
|
||||
#define BMA423_ANY_NO_MOTION_OFFSET (0x00)
|
||||
#define BMA423_STEP_CNTR_OFFSET (0x36)
|
||||
#define BMA423_STEP_CNTR_PARAM_OFFSET (0x04)
|
||||
#define BMA423_WAKEUP_OFFSET (0x38)
|
||||
#define BMA423_TILT_OFFSET (0x3A)
|
||||
#define BMA423_CONFIG_ID_OFFSET (0x3C)
|
||||
#define BMA423_AXES_REMAP_OFFSET (0x3E)
|
||||
|
||||
/**\name Sensor feature size */
|
||||
#define BMA423_FEATURE_SIZE (64)
|
||||
#define BMA423_ANYMOTION_EN_LEN (2)
|
||||
#define BMA423_RD_WR_MIN_LEN (2)
|
||||
|
||||
/**************************************************************/
|
||||
/**\name Remap Axes */
|
||||
/**************************************************************/
|
||||
#define BMA423_X_AXIS_MASK (0x03)
|
||||
#define BMA423_X_AXIS_SIGN_MASK (0x04)
|
||||
#define BMA423_Y_AXIS_MASK (0x18)
|
||||
#define BMA423_Y_AXIS_SIGN_MASK (0x20)
|
||||
#define BMA423_Z_AXIS_MASK (0xC0)
|
||||
#define BMA423_Z_AXIS_SIGN_MASK (0x01)
|
||||
|
||||
|
||||
|
||||
/**\name ACCELEROMETER ENABLE POSITION AND MASK*/
|
||||
#define BMA4_ACCEL_ENABLE_MSK (0x04)
|
||||
#define BMA4_ASIC_INITIALIZED (0x01)
|
||||
|
||||
#define BMA4_CONFIG_STREAM_SIZE (6144)
|
||||
|
||||
|
||||
/**\name Feature configuration file */
|
||||
static const unsigned char bma423_config_file[] = {
|
||||
0x80, 0x2e, 0xfc, 0x00, 0x80, 0x2e, 0xfe, 0x00, 0xc8, 0x2e, 0x00, 0x2e,
|
||||
0x80, 0x2e, 0xfa, 0x00, 0x80, 0x2e, 0x23, 0xb1, 0x80, 0x2e, 0xfd, 0x00,
|
||||
0x80, 0x2e, 0xfb, 0x00, 0x80, 0x2e, 0x5a, 0xb1, 0x50, 0x39, 0x21, 0x2e,
|
||||
0xb0, 0xf0, 0x10, 0x30, 0x21, 0x2e, 0x16, 0xf0, 0x80, 0x2e, 0xfc, 0x01,
|
||||
0x5d, 0x50, 0x45, 0x52, 0x01, 0x42, 0x3b, 0x80, 0x41, 0x30, 0x01, 0x42,
|
||||
0x3c, 0x80, 0x00, 0x2e, 0x01, 0x40, 0x01, 0x42, 0x21, 0x2e, 0xff, 0xaf,
|
||||
0xb8, 0x2e, 0xb6, 0xd6, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0xfd, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x24, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x2e,
|
||||
0x99, 0x01, 0x20, 0x26, 0x98, 0x2e, 0xf6, 0x00, 0x98, 0x2e, 0xe9, 0x01,
|
||||
0x10, 0x30, 0x21, 0x2e, 0x59, 0xf0, 0x98, 0x2e, 0xd8, 0x00, 0x00, 0x2e,
|
||||
0x00, 0x2e, 0xd0, 0x2e, 0x98, 0x2e, 0xdd, 0x00, 0x01, 0x2e, 0x56, 0x00,
|
||||
0x00, 0xb2, 0x11, 0x2f, 0x00, 0x30, 0x21, 0x2e, 0x56, 0x00, 0x41, 0x50,
|
||||
0x98, 0x2e, 0xcc, 0xb0, 0x41, 0x50, 0x98, 0x2e, 0x8f, 0xb4, 0x01, 0x2e,
|
||||
0x03, 0xf0, 0x0d, 0xbc, 0x0f, 0xb8, 0x00, 0x90, 0x02, 0x2f, 0x45, 0x50,
|
||||
0x21, 0x2e, 0xbc, 0xf0, 0x01, 0x2e, 0x55, 0x00, 0x00, 0xb2, 0x1a, 0x2f,
|
||||
0x00, 0x30, 0x21, 0x2e, 0x55, 0x00, 0x43, 0x50, 0x98, 0x2e, 0xcc, 0xb0,
|
||||
0x43, 0x50, 0x98, 0x2e, 0xdc, 0xb1, 0x43, 0x50, 0x98, 0x2e, 0x92, 0xb5,
|
||||
0x43, 0x50, 0x98, 0x2e, 0x00, 0xb0, 0x01, 0x2e, 0x1c, 0x01, 0x0f, 0xbc,
|
||||
0x0f, 0xb8, 0x00, 0x90, 0x45, 0x50, 0x02, 0x2f, 0x21, 0x2e, 0xbc, 0xf0,
|
||||
0x02, 0x2d, 0x21, 0x2e, 0xba, 0xf0, 0x98, 0x2e, 0xd8, 0x00, 0xc3, 0x2d,
|
||||
0x01, 0x2e, 0x55, 0xf0, 0xc0, 0x2e, 0x21, 0x2e, 0x55, 0xf0, 0x03, 0x2e,
|
||||
0x00, 0xf0, 0x45, 0x54, 0x01, 0x2e, 0x59, 0xf0, 0x4a, 0x0e, 0x02, 0x2f,
|
||||
0xf1, 0x33, 0x0d, 0x2c, 0x01, 0x08, 0xf2, 0x30, 0x4a, 0x08, 0x79, 0x84,
|
||||
0x82, 0xa2, 0x04, 0x2f, 0x02, 0x34, 0x82, 0x0a, 0x47, 0xa2, 0x03, 0x2c,
|
||||
0x10, 0x22, 0x45, 0x52, 0x01, 0x0a, 0xc0, 0x2e, 0x21, 0x2e, 0x59, 0xf0,
|
||||
0x00, 0x31, 0xc0, 0x2e, 0x21, 0x2e, 0xba, 0xf0, 0xc8, 0x2e, 0xc8, 0x2e,
|
||||
0xc8, 0x2e, 0xc8, 0x2e, 0xc8, 0x2e, 0x44, 0x47, 0xaa, 0x00, 0x05, 0x00,
|
||||
0x2d, 0x01, 0xd4, 0x7b, 0x3b, 0x01, 0xdb, 0x7a, 0x04, 0x00, 0x3f, 0x7b,
|
||||
0xcd, 0x6c, 0xc3, 0x04, 0x85, 0x09, 0xc3, 0x04, 0xec, 0xe6, 0x0c, 0x46,
|
||||
0x01, 0x00, 0x27, 0x00, 0x19, 0x00, 0x96, 0x00, 0xa0, 0x00, 0x01, 0x00,
|
||||
0x0c, 0x00, 0xf0, 0x3c, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00,
|
||||
0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x43, 0x28, 0x88, 0x00,
|
||||
0x52, 0x00, 0x4f, 0x00, 0x80, 0x00, 0x5b, 0x00, 0x00, 0x40, 0xaf, 0x00,
|
||||
0xff, 0x00, 0xff, 0xb7, 0x00, 0x02, 0x00, 0xb0, 0x05, 0x80, 0xb1, 0xf0,
|
||||
0xc0, 0x00, 0x00, 0x01, 0x5e, 0xf0, 0x39, 0xf0, 0x89, 0xf0, 0x00, 0x20,
|
||||
0xff, 0x7f, 0x7d, 0x00, 0x5e, 0x00, 0x62, 0x00, 0x7c, 0x00, 0xff, 0xfb,
|
||||
0x52, 0xf0, 0x56, 0xf0, 0x33, 0x09, 0x33, 0x07, 0x00, 0x08, 0x90, 0x01,
|
||||
0x00, 0xf8, 0x67, 0x00, 0x4c, 0x04, 0xa0, 0x00, 0xe8, 0x03, 0x81, 0x00,
|
||||
0x82, 0x00, 0x6a, 0x00, 0x6d, 0x00, 0x6c, 0x00, 0xeb, 0x07, 0xae, 0x07,
|
||||
0x72, 0x00, 0x6f, 0x00, 0xa1, 0x01, 0x1e, 0x05, 0x47, 0xfd, 0x73, 0x00,
|
||||
0x77, 0x00, 0x79, 0x00, 0x76, 0x00, 0xcc, 0x00, 0x30, 0x50, 0x50, 0x40,
|
||||
0x00, 0x18, 0x50, 0x40, 0x56, 0x25, 0x47, 0x25, 0x00, 0x18, 0x2e, 0x00,
|
||||
0x41, 0x40, 0xa7, 0x02, 0x09, 0x18, 0xc6, 0x00, 0xfb, 0x7f, 0x00, 0x30,
|
||||
0x49, 0x52, 0x05, 0x30, 0x05, 0x2c, 0x17, 0x03, 0x1e, 0xbd, 0xd2, 0xba,
|
||||
0x92, 0xb8, 0x6a, 0x0b, 0x61, 0x0e, 0xf9, 0x2f, 0x61, 0x1a, 0x01, 0x2f,
|
||||
0x5d, 0x0e, 0xf5, 0x2f, 0xd4, 0x7f, 0x02, 0x30, 0x1f, 0x2c, 0xe3, 0x7f,
|
||||
0x85, 0x01, 0xd1, 0x03, 0x7c, 0x0e, 0x03, 0x2f, 0x7c, 0x1a, 0x0f, 0x2f,
|
||||
0x73, 0x0f, 0x0d, 0x2f, 0xe3, 0x6f, 0xde, 0x04, 0x5f, 0xba, 0x11, 0xbf,
|
||||
0xb4, 0x0b, 0xd4, 0x6f, 0x27, 0x07, 0xb3, 0x25, 0xd1, 0xbf, 0xeb, 0x7f,
|
||||
0x07, 0x00, 0xb4, 0x25, 0x96, 0x02, 0xdb, 0x7f, 0x2f, 0xbf, 0x9e, 0xbf,
|
||||
0x01, 0xb8, 0xd2, 0xba, 0x21, 0xb9, 0x92, 0xb8, 0x06, 0x0a, 0x6f, 0x0b,
|
||||
0x40, 0x90, 0xdf, 0x2f, 0x40, 0x91, 0xdd, 0x2f, 0xfb, 0x6f, 0xd0, 0x5f,
|
||||
0xb8, 0x2e, 0x57, 0x50, 0x41, 0x30, 0x02, 0x40, 0x51, 0x0a, 0x01, 0x42,
|
||||
0x18, 0x82, 0x4b, 0x50, 0x60, 0x42, 0x70, 0x3c, 0x4d, 0x54, 0x42, 0x42,
|
||||
0x69, 0x82, 0x82, 0x32, 0x43, 0x40, 0x18, 0x08, 0x02, 0x0a, 0x40, 0x42,
|
||||
0x42, 0x80, 0x02, 0x3f, 0x01, 0x40, 0x10, 0x50, 0x4a, 0x08, 0xfb, 0x7f,
|
||||
0x11, 0x42, 0x0b, 0x31, 0x0b, 0x42, 0x3e, 0x80, 0x01, 0x32, 0x01, 0x42,
|
||||
0x00, 0x2e, 0x01, 0x2e, 0x40, 0xf0, 0x13, 0x90, 0x20, 0x2f, 0x03, 0x30,
|
||||
0x51, 0x50, 0x4f, 0x54, 0xf4, 0x34, 0x06, 0x30, 0x55, 0x52, 0x55, 0x32,
|
||||
0x1d, 0x1a, 0xe3, 0x22, 0x18, 0x1a, 0x53, 0x58, 0xe3, 0x22, 0x04, 0x30,
|
||||
0xd5, 0x40, 0xb5, 0x0d, 0xe1, 0xbe, 0x6f, 0xbb, 0x80, 0x91, 0xa9, 0x0d,
|
||||
0x01, 0x89, 0xb5, 0x23, 0x10, 0xa1, 0xf7, 0x2f, 0xda, 0x0e, 0xf4, 0x34,
|
||||
0xeb, 0x2f, 0x01, 0x2e, 0x25, 0x00, 0x70, 0x1a, 0x00, 0x30, 0x21, 0x30,
|
||||
0x02, 0x2c, 0x08, 0x22, 0x30, 0x30, 0x00, 0xb2, 0x06, 0x2f, 0x21, 0x2e,
|
||||
0x59, 0xf0, 0x98, 0x2e, 0xd8, 0x00, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e,
|
||||
0xfb, 0x6f, 0xf0, 0x5f, 0xb8, 0x2e, 0x01, 0x2e, 0xb1, 0xf0, 0x59, 0x52,
|
||||
0x01, 0x0a, 0x21, 0x2e, 0xb1, 0xf0, 0x01, 0x2e, 0x1c, 0x01, 0x0f, 0xbc,
|
||||
0x0f, 0xb8, 0x00, 0x90, 0x45, 0x50, 0x02, 0x2f, 0xc0, 0x2e, 0x21, 0x2e,
|
||||
0xbc, 0xf0, 0xc0, 0x2e, 0x21, 0x2e, 0xba, 0xf0, 0x1a, 0x24, 0x26, 0x00,
|
||||
0x80, 0x2e, 0x8f, 0x00, 0x03, 0x2e, 0x01, 0x01, 0x05, 0x2e, 0x01, 0x01,
|
||||
0x92, 0xbd, 0x20, 0x50, 0x03, 0x2e, 0x01, 0x01, 0xbf, 0xba, 0x21, 0xbd,
|
||||
0x2f, 0xbb, 0x1f, 0xba, 0x40, 0x91, 0xf0, 0x7f, 0x04, 0x2f, 0x80, 0x91,
|
||||
0x02, 0x2f, 0x00, 0xb3, 0x90, 0x2e, 0xc7, 0xb0, 0x03, 0x2e, 0x7b, 0x00,
|
||||
0x01, 0x80, 0x40, 0x90, 0x14, 0x2f, 0x41, 0x84, 0xf1, 0x6f, 0x25, 0x2e,
|
||||
0x7b, 0x00, 0x41, 0x40, 0x23, 0x2e, 0x5a, 0x00, 0x47, 0x52, 0x12, 0x40,
|
||||
0x52, 0x42, 0x02, 0x30, 0x00, 0x40, 0x40, 0x42, 0xe0, 0x5f, 0x25, 0x2e,
|
||||
0x57, 0x00, 0x25, 0x2e, 0x58, 0x00, 0x25, 0x2e, 0x5d, 0x00, 0xb8, 0x2e,
|
||||
0x07, 0x2e, 0x00, 0x01, 0x03, 0x2e, 0x01, 0x01, 0x05, 0x2e, 0x00, 0x01,
|
||||
0x24, 0xbd, 0x0f, 0x2e, 0x59, 0x00, 0xb5, 0xbd, 0x93, 0xbc, 0x2f, 0xb9,
|
||||
0xb5, 0xb9, 0x93, 0xb8, 0x3a, 0x1a, 0x06, 0x2f, 0x07, 0x30, 0x25, 0x2e,
|
||||
0x59, 0x00, 0x2f, 0x2e, 0x57, 0x00, 0x2f, 0x2e, 0x58, 0x00, 0x40, 0xb3,
|
||||
0x05, 0x30, 0x07, 0x30, 0x0a, 0x2f, 0xf7, 0x6f, 0xe6, 0x7f, 0x00, 0x2e,
|
||||
0xc6, 0x41, 0x0f, 0x2e, 0x5a, 0x00, 0xb7, 0x05, 0x80, 0xa9, 0xee, 0x05,
|
||||
0xf7, 0x23, 0xe6, 0x6f, 0x80, 0xb3, 0x06, 0x30, 0x09, 0x2f, 0xe7, 0x7f,
|
||||
0x00, 0x2e, 0x06, 0x40, 0x0f, 0x2e, 0x5b, 0x00, 0xb7, 0x05, 0x80, 0xa9,
|
||||
0xee, 0x05, 0xb7, 0x23, 0xe7, 0x6f, 0x00, 0xb3, 0x04, 0x30, 0x0b, 0x2f,
|
||||
0xf4, 0x6f, 0x02, 0x89, 0xe7, 0x7f, 0x00, 0x2e, 0x04, 0x41, 0x0f, 0x2e,
|
||||
0x5c, 0x00, 0x27, 0x05, 0x00, 0xa9, 0xec, 0x05, 0x27, 0x23, 0xe7, 0x6f,
|
||||
0x7b, 0x0f, 0x17, 0x30, 0x0b, 0x2f, 0x73, 0x0f, 0x05, 0x30, 0x17, 0x30,
|
||||
0x07, 0x2f, 0x63, 0x0f, 0x15, 0x30, 0x17, 0x30, 0x00, 0x2f, 0x07, 0x30,
|
||||
0xe3, 0x0e, 0x00, 0x2f, 0x05, 0x30, 0x80, 0x90, 0x05, 0x2e, 0x57, 0x00,
|
||||
0x13, 0x30, 0x13, 0x29, 0xf2, 0x6f, 0x47, 0x5c, 0x17, 0x2f, 0xc0, 0x91,
|
||||
0x05, 0x30, 0x0b, 0x2f, 0x07, 0x2e, 0x58, 0x00, 0xc1, 0x86, 0x2b, 0x2e,
|
||||
0x57, 0x00, 0x59, 0x0e, 0x27, 0x2e, 0x58, 0x00, 0x24, 0x2f, 0x2b, 0x2e,
|
||||
0x5d, 0x00, 0x22, 0x2d, 0x61, 0x0e, 0x29, 0x2e, 0x57, 0x00, 0x2b, 0x2e,
|
||||
0x58, 0x00, 0x1b, 0x2f, 0x27, 0x2e, 0x5d, 0x00, 0x19, 0x2d, 0x40, 0x91,
|
||||
0x05, 0x2f, 0x01, 0x30, 0x23, 0x2e, 0x57, 0x00, 0x23, 0x2e, 0x5d, 0x00,
|
||||
0x06, 0x2d, 0x29, 0x2e, 0x57, 0x00, 0x61, 0x0e, 0x01, 0x2f, 0x27, 0x2e,
|
||||
0x5d, 0x00, 0x81, 0x40, 0x23, 0x2e, 0x5a, 0x00, 0x30, 0x25, 0x47, 0x52,
|
||||
0xd4, 0x40, 0x54, 0x42, 0x00, 0x2e, 0xc3, 0x40, 0x43, 0x42, 0x00, 0x2e,
|
||||
0x03, 0x2e, 0x5d, 0x00, 0x40, 0xb2, 0x0d, 0x2f, 0x81, 0x40, 0x23, 0x2e,
|
||||
0x5a, 0x00, 0x11, 0x40, 0x91, 0x43, 0x01, 0x34, 0x00, 0x40, 0x80, 0x43,
|
||||
0x23, 0x2e, 0x5e, 0xf0, 0x03, 0x2d, 0x00, 0x30, 0x21, 0x2e, 0x7b, 0x00,
|
||||
0xe0, 0x5f, 0xb8, 0x2e, 0x50, 0x50, 0xf0, 0x7f, 0x1a, 0x25, 0x13, 0x40,
|
||||
0x7b, 0x84, 0xe0, 0x7f, 0x83, 0x42, 0x35, 0x30, 0x11, 0x40, 0x04, 0x40,
|
||||
0xc1, 0x7f, 0xd4, 0x7f, 0x86, 0x31, 0x07, 0x2e, 0x59, 0xf0, 0x03, 0x2e,
|
||||
0x1f, 0x01, 0x0d, 0x09, 0x02, 0xab, 0x05, 0x30, 0x8e, 0x09, 0x2c, 0x23,
|
||||
0xe3, 0xba, 0x42, 0xab, 0x16, 0x30, 0x75, 0x23, 0x59, 0x5c, 0x8e, 0x09,
|
||||
0x66, 0xbb, 0x82, 0xab, 0x27, 0x30, 0xbe, 0x23, 0x3e, 0x80, 0x25, 0x1a,
|
||||
0x06, 0x2f, 0x2e, 0x1a, 0x04, 0x2f, 0x26, 0x1a, 0x02, 0x2f, 0xf7, 0x3d,
|
||||
0x03, 0x2c, 0xdf, 0x08, 0x07, 0x32, 0xdf, 0x0a, 0x14, 0x01, 0x55, 0x01,
|
||||
0x04, 0x41, 0x14, 0x42, 0x16, 0x01, 0x42, 0x41, 0x45, 0x30, 0x4d, 0x09,
|
||||
0x04, 0x41, 0x12, 0x42, 0x04, 0x42, 0x40, 0xb3, 0x04, 0x2f, 0xf0, 0x6f,
|
||||
0x02, 0x30, 0x04, 0x40, 0x94, 0x04, 0x02, 0x42, 0x00, 0x32, 0x08, 0x08,
|
||||
0x00, 0xb2, 0x00, 0x30, 0x05, 0x2f, 0xe2, 0x6f, 0x00, 0x2e, 0x84, 0x40,
|
||||
0x04, 0x05, 0x84, 0x42, 0x00, 0x2e, 0x5b, 0x54, 0x4a, 0x08, 0x40, 0xb2,
|
||||
0xf1, 0x6f, 0x04, 0x2f, 0x42, 0x82, 0x00, 0x2e, 0x42, 0x40, 0x02, 0x04,
|
||||
0x40, 0x42, 0xb0, 0x5f, 0x27, 0x2e, 0x59, 0xf0, 0xb8, 0x2e, 0x50, 0x50,
|
||||
0xf7, 0x7f, 0x00, 0x2e, 0x0f, 0x2e, 0xb8, 0xf0, 0xf8, 0xbf, 0xff, 0xbb,
|
||||
0xc0, 0xb3, 0x2a, 0x2f, 0x0f, 0x2e, 0x01, 0xf0, 0xfe, 0xbf, 0xe6, 0x7f,
|
||||
0x7e, 0xbb, 0xd5, 0x7f, 0x37, 0x30, 0x5f, 0x5a, 0xbe, 0x05, 0x67, 0x41,
|
||||
0xc4, 0x7f, 0x78, 0xbe, 0x47, 0x41, 0x27, 0x0b, 0xb3, 0x7f, 0xe6, 0x11,
|
||||
0x41, 0x56, 0x43, 0x89, 0xd7, 0x42, 0x00, 0x2e, 0x27, 0x41, 0x05, 0x41,
|
||||
0xf8, 0xbf, 0x7d, 0x0b, 0x6e, 0x11, 0x03, 0x8f, 0xd5, 0x42, 0x14, 0x30,
|
||||
0xe5, 0x41, 0xc7, 0x41, 0xd8, 0xbe, 0x6f, 0x0b, 0x6e, 0x11, 0xc5, 0x42,
|
||||
0x29, 0x2e, 0x56, 0x00, 0x45, 0x56, 0x27, 0x2e, 0xb8, 0xf0, 0xe6, 0x6f,
|
||||
0xd5, 0x6f, 0xc4, 0x6f, 0xb3, 0x6f, 0xf7, 0x6f, 0xb0, 0x5f, 0xc8, 0x2e,
|
||||
0x50, 0x50, 0xe5, 0x7f, 0xd7, 0x7f, 0xf6, 0x7f, 0x36, 0x30, 0x0b, 0x2e,
|
||||
0x01, 0xf0, 0xde, 0xbe, 0xde, 0xbb, 0x61, 0x5a, 0xb7, 0x05, 0x67, 0x41,
|
||||
0xc4, 0x7f, 0x78, 0xbe, 0x47, 0x41, 0x27, 0x0b, 0xb3, 0x7f, 0xe6, 0x11,
|
||||
0x43, 0x56, 0x43, 0x89, 0xd7, 0x42, 0x00, 0x2e, 0x27, 0x41, 0x05, 0x41,
|
||||
0xf8, 0xbf, 0x7d, 0x0b, 0x6e, 0x11, 0x03, 0x8f, 0xd5, 0x42, 0x14, 0x30,
|
||||
0xe5, 0x41, 0xc7, 0x41, 0xd8, 0xbe, 0x6f, 0x0b, 0x6e, 0x11, 0xc5, 0x42,
|
||||
0x29, 0x2e, 0x55, 0x00, 0x03, 0x31, 0x27, 0x2e, 0xb8, 0xf0, 0xf6, 0x6f,
|
||||
0xe5, 0x6f, 0xd7, 0x6f, 0xc4, 0x6f, 0xb3, 0x6f, 0xb0, 0x5f, 0xc8, 0x2e,
|
||||
0x40, 0x50, 0xf6, 0x7f, 0x1a, 0x18, 0x63, 0x56, 0x33, 0x00, 0x06, 0x30,
|
||||
0xfe, 0x03, 0x0e, 0xb8, 0xf2, 0xbf, 0x07, 0x0a, 0x2a, 0x18, 0x63, 0x5a,
|
||||
0xb5, 0x01, 0x03, 0x30, 0xfb, 0x03, 0x6e, 0xbb, 0xf2, 0xbf, 0xe1, 0x7f,
|
||||
0xf7, 0x0b, 0x56, 0x40, 0x36, 0x25, 0x46, 0x40, 0x06, 0x28, 0xc7, 0x7f,
|
||||
0x22, 0x18, 0xd1, 0x7f, 0xb5, 0x00, 0x01, 0x30, 0x39, 0x03, 0x2e, 0xb9,
|
||||
0x42, 0xbe, 0x14, 0x0b, 0xf2, 0x6f, 0x10, 0x18, 0xb5, 0x00, 0xb9, 0x03,
|
||||
0x2e, 0xb9, 0x62, 0xbf, 0x96, 0x0a, 0xb6, 0x6f, 0x30, 0x18, 0x75, 0x01,
|
||||
0xb9, 0x03, 0x5c, 0x28, 0xe2, 0xbf, 0xde, 0xb9, 0xd6, 0x6f, 0xdf, 0x0a,
|
||||
0x8a, 0x28, 0xc4, 0x6f, 0x82, 0x43, 0x23, 0x29, 0xe5, 0x6f, 0xc0, 0x2e,
|
||||
0x44, 0x43, 0xc0, 0x5f, 0x40, 0x50, 0xd0, 0x7f, 0x4a, 0x17, 0x00, 0x40,
|
||||
0x01, 0x18, 0x46, 0x25, 0x07, 0x25, 0x65, 0x56, 0xd9, 0x04, 0x53, 0x18,
|
||||
0xeb, 0x18, 0x05, 0x30, 0x49, 0x16, 0x69, 0x06, 0xca, 0x18, 0xa6, 0x00,
|
||||
0xc7, 0x02, 0x65, 0x58, 0xcb, 0x7f, 0x98, 0x2e, 0x7f, 0xb6, 0xcb, 0x6f,
|
||||
0xd2, 0x6f, 0xc0, 0x2e, 0x80, 0x42, 0xc0, 0x5f, 0x09, 0x2e, 0x1b, 0x01,
|
||||
0x05, 0x2e, 0x1b, 0x01, 0xa3, 0xbc, 0x44, 0xbe, 0x90, 0x50, 0x4f, 0xb9,
|
||||
0x07, 0x2e, 0x1b, 0x01, 0x4a, 0x25, 0x9f, 0xb8, 0x39, 0x8f, 0xb2, 0xbd,
|
||||
0xf2, 0x7f, 0xbf, 0xb9, 0xeb, 0x7f, 0x8a, 0x0a, 0x37, 0x89, 0x0b, 0x30,
|
||||
0x93, 0x0a, 0x8b, 0x7f, 0xcb, 0x43, 0x0b, 0x43, 0x80, 0xb2, 0xd3, 0x7f,
|
||||
0xc1, 0x7f, 0x90, 0x2e, 0x87, 0xb2, 0x20, 0x25, 0x01, 0x2e, 0x64, 0x00,
|
||||
0x01, 0x90, 0x0e, 0x2f, 0x67, 0x52, 0x01, 0x2e, 0x61, 0x00, 0xb4, 0x7f,
|
||||
0xa2, 0x7f, 0x98, 0x2e, 0x8d, 0xb2, 0x00, 0x30, 0x21, 0x2e, 0x64, 0x00,
|
||||
0xc1, 0x6f, 0xd3, 0x6f, 0xa2, 0x6f, 0xb4, 0x6f, 0x0b, 0x30, 0x01, 0x2e,
|
||||
0x1b, 0x01, 0x06, 0xbc, 0x06, 0xbb, 0x57, 0x25, 0x01, 0x2e, 0x1b, 0x01,
|
||||
0x94, 0xb1, 0x05, 0xbc, 0xb6, 0x7f, 0x0f, 0xbb, 0x6b, 0x50, 0x80, 0xb3,
|
||||
0x0f, 0x2f, 0x0d, 0x2e, 0x1b, 0x01, 0x6f, 0x5e, 0xb7, 0x09, 0x2d, 0x2e,
|
||||
0x1b, 0x01, 0x71, 0x5c, 0x69, 0x5e, 0x9b, 0x43, 0x9b, 0x43, 0xdb, 0x43,
|
||||
0x9b, 0x43, 0x1b, 0x42, 0xcb, 0x43, 0x0b, 0x42, 0x8b, 0x43, 0x40, 0xb2,
|
||||
0x05, 0x2f, 0x69, 0x50, 0x00, 0x2e, 0x16, 0x40, 0x0b, 0x40, 0x76, 0x7f,
|
||||
0x8b, 0x7f, 0xcb, 0x0a, 0x01, 0x2e, 0x61, 0x00, 0x67, 0x52, 0x6d, 0x5c,
|
||||
0x98, 0x2e, 0xd3, 0xb2, 0x90, 0x6f, 0x00, 0xb2, 0x0b, 0x2f, 0xf0, 0x6f,
|
||||
0x00, 0xb2, 0x08, 0x2f, 0x69, 0x58, 0x6b, 0x50, 0x12, 0x41, 0x12, 0x42,
|
||||
0x21, 0x30, 0x04, 0x41, 0x04, 0x42, 0x23, 0x2e, 0x5e, 0xf0, 0xc0, 0x6f,
|
||||
0x00, 0xb2, 0x26, 0x2f, 0x74, 0x6f, 0x80, 0x6f, 0x71, 0x54, 0x88, 0xbd,
|
||||
0xc8, 0xb8, 0x4b, 0x0a, 0x94, 0x42, 0x91, 0x42, 0x90, 0x42, 0x88, 0xba,
|
||||
0x69, 0x52, 0xf3, 0x6f, 0x54, 0x42, 0x85, 0x42, 0xc0, 0x90, 0x40, 0x42,
|
||||
0x15, 0x2f, 0x6b, 0x52, 0x00, 0x2e, 0x52, 0x40, 0x41, 0x40, 0xa2, 0x04,
|
||||
0x41, 0x06, 0x40, 0xaa, 0x04, 0x2f, 0x40, 0x90, 0x0b, 0x2f, 0xb1, 0x6f,
|
||||
0x4a, 0x0f, 0x08, 0x2f, 0xb2, 0x6f, 0x80, 0xb2, 0x05, 0x2f, 0x6b, 0x54,
|
||||
0x21, 0x30, 0x94, 0x42, 0x80, 0x42, 0x23, 0x2e, 0x5e, 0xf0, 0xd0, 0x6f,
|
||||
0x00, 0xb2, 0x13, 0x2f, 0x01, 0x2e, 0x60, 0x00, 0x09, 0x2e, 0x7c, 0x00,
|
||||
0x04, 0x1a, 0x0d, 0x2f, 0x73, 0x50, 0x29, 0x2e, 0x60, 0x00, 0x24, 0x42,
|
||||
0x44, 0x30, 0x02, 0x40, 0x02, 0x42, 0x09, 0x80, 0x00, 0x2e, 0x04, 0x42,
|
||||
0x03, 0x2d, 0x10, 0x30, 0x21, 0x2e, 0x64, 0x00, 0xeb, 0x6f, 0x70, 0x5f,
|
||||
0xb8, 0x2e, 0x09, 0x86, 0x49, 0x54, 0xe4, 0x40, 0xc3, 0x80, 0x94, 0x04,
|
||||
0xc3, 0x40, 0x13, 0x05, 0x05, 0x40, 0x25, 0x05, 0x8a, 0x17, 0x73, 0x30,
|
||||
0x73, 0x09, 0x8c, 0x17, 0xf3, 0x08, 0xe3, 0x00, 0x4c, 0x82, 0x95, 0x00,
|
||||
0xb3, 0xb5, 0x23, 0xb5, 0x53, 0x42, 0x52, 0x42, 0x53, 0x42, 0x42, 0x42,
|
||||
0x71, 0x82, 0x75, 0x54, 0x52, 0x42, 0x10, 0x50, 0x77, 0x54, 0x52, 0x42,
|
||||
0xfb, 0x7f, 0x22, 0x30, 0x79, 0x56, 0x43, 0x42, 0x44, 0x82, 0x0b, 0x30,
|
||||
0x52, 0x42, 0x5b, 0x42, 0x7c, 0x84, 0x4b, 0x42, 0x35, 0x82, 0x8c, 0x80,
|
||||
0x8b, 0x42, 0x0b, 0x42, 0x39, 0x80, 0x04, 0x30, 0x0b, 0x42, 0x37, 0x80,
|
||||
0x15, 0x30, 0x60, 0x25, 0x98, 0x2e, 0xc6, 0xb2, 0x8b, 0x83, 0xfb, 0x6f,
|
||||
0x65, 0x42, 0xc0, 0x2e, 0x44, 0x42, 0xf0, 0x5f, 0x05, 0x80, 0x02, 0x30,
|
||||
0x51, 0x82, 0x02, 0x42, 0x13, 0x30, 0x41, 0x40, 0x4b, 0x08, 0x7b, 0x54,
|
||||
0x3e, 0x80, 0x51, 0x14, 0xc0, 0x2e, 0x01, 0x42, 0x00, 0x2e, 0x40, 0x51,
|
||||
0xd1, 0x7f, 0x12, 0x25, 0x02, 0x30, 0x42, 0x43, 0x32, 0x30, 0x82, 0x43,
|
||||
0xc6, 0x7f, 0xe5, 0x7f, 0xb4, 0x7f, 0xa3, 0x7f, 0x90, 0x7f, 0x8b, 0x7f,
|
||||
0x98, 0x2e, 0x54, 0x01, 0xc0, 0x7e, 0x00, 0xac, 0x01, 0x2f, 0x65, 0x50,
|
||||
0xc0, 0x7e, 0x00, 0x2e, 0x90, 0x6f, 0x09, 0x8a, 0xd1, 0x6f, 0x75, 0x7f,
|
||||
0x4c, 0x82, 0x63, 0x41, 0x65, 0x7f, 0x11, 0x7f, 0x00, 0x2e, 0x64, 0x41,
|
||||
0x44, 0x85, 0x52, 0x7f, 0x45, 0x7f, 0x00, 0x2e, 0xa6, 0x40, 0x80, 0x40,
|
||||
0x32, 0x7f, 0x82, 0x8e, 0xc2, 0x6e, 0x45, 0x41, 0xf0, 0x7f, 0x27, 0x7f,
|
||||
0x02, 0x7f, 0x98, 0x2e, 0x8a, 0xb1, 0x23, 0x6f, 0xd1, 0x6f, 0xc2, 0x40,
|
||||
0xf9, 0x86, 0x23, 0x7f, 0x80, 0xb2, 0xe0, 0x7e, 0x0f, 0x2f, 0x32, 0x6f,
|
||||
0x64, 0x6f, 0x82, 0x40, 0xf2, 0x7f, 0x4e, 0x82, 0x42, 0x6f, 0x50, 0x6f,
|
||||
0x73, 0x6f, 0x85, 0x40, 0xc3, 0x40, 0x04, 0x41, 0x06, 0x40, 0xe2, 0x6e,
|
||||
0x98, 0x2e, 0x8a, 0xb1, 0xe0, 0x7e, 0xf3, 0x31, 0x10, 0x6f, 0x36, 0x80,
|
||||
0xe1, 0x6e, 0x02, 0x40, 0x71, 0x7f, 0x51, 0x04, 0x02, 0x30, 0x40, 0xa8,
|
||||
0x91, 0x04, 0x4a, 0x22, 0x89, 0x16, 0x93, 0x08, 0x4a, 0x00, 0x95, 0xb4,
|
||||
0x09, 0x18, 0x8e, 0x16, 0x13, 0x30, 0x93, 0x08, 0x21, 0x6f, 0x60, 0x7f,
|
||||
0x4d, 0x86, 0x02, 0x80, 0xb2, 0x00, 0x41, 0x40, 0x21, 0xb5, 0x50, 0x7f,
|
||||
0x43, 0x7f, 0x98, 0x2e, 0xc2, 0xb1, 0x40, 0x6f, 0x62, 0x6f, 0x55, 0x6f,
|
||||
0x13, 0x40, 0x84, 0x40, 0x01, 0x40, 0x45, 0x41, 0x42, 0xbe, 0x1d, 0x18,
|
||||
0x4c, 0x04, 0x31, 0x0f, 0x04, 0x8a, 0xc0, 0x6f, 0x11, 0x30, 0x02, 0x2f,
|
||||
0x00, 0x2e, 0x03, 0x2c, 0x01, 0x42, 0x23, 0x30, 0x03, 0x42, 0x00, 0x2e,
|
||||
0xd6, 0x6f, 0x44, 0x41, 0x8a, 0x87, 0x76, 0x8b, 0x00, 0xb3, 0x53, 0x7f,
|
||||
0x15, 0x2f, 0x04, 0x6f, 0x7d, 0x5e, 0x8b, 0x8d, 0xe7, 0x01, 0xc0, 0xa5,
|
||||
0x84, 0x41, 0x01, 0x2f, 0x00, 0xa1, 0x03, 0x2f, 0xc0, 0xad, 0x08, 0x2f,
|
||||
0x00, 0xa5, 0x06, 0x2f, 0xc6, 0x40, 0x81, 0x8d, 0x07, 0x30, 0x3c, 0x05,
|
||||
0xd6, 0x42, 0x04, 0x2c, 0xc4, 0x42, 0x02, 0x2c, 0x07, 0x30, 0x07, 0x30,
|
||||
0x86, 0x86, 0x94, 0x6f, 0xd7, 0x7e, 0x0e, 0x8d, 0x00, 0x40, 0x74, 0x89,
|
||||
0xc7, 0x40, 0x02, 0xb2, 0xf9, 0x29, 0x45, 0x41, 0x86, 0x41, 0xbe, 0x80,
|
||||
0x21, 0x41, 0x75, 0x23, 0x82, 0x40, 0xc7, 0x42, 0x45, 0x7f, 0x34, 0x7f,
|
||||
0x20, 0x7f, 0x98, 0x2e, 0xc2, 0xb1, 0x31, 0x6f, 0x60, 0x6f, 0x24, 0x6f,
|
||||
0x22, 0x40, 0x05, 0x41, 0x43, 0x40, 0x13, 0x01, 0x43, 0x86, 0xac, 0x0f,
|
||||
0xd1, 0x6f, 0x30, 0x7f, 0x00, 0x2f, 0x44, 0x42, 0x48, 0x8a, 0x41, 0x88,
|
||||
0xe1, 0x40, 0x13, 0x7f, 0x04, 0x7f, 0xf5, 0x7e, 0x98, 0x2e, 0xc2, 0xb1,
|
||||
0x11, 0x6f, 0x60, 0x6f, 0x34, 0x6f, 0x42, 0x40, 0x03, 0x40, 0x9a, 0x04,
|
||||
0x04, 0x41, 0x43, 0x82, 0xa2, 0x0e, 0x03, 0x6f, 0x00, 0x2f, 0xc2, 0x42,
|
||||
0x00, 0x2e, 0x41, 0x40, 0x72, 0x6f, 0x98, 0x2e, 0xc2, 0xb1, 0x25, 0x6f,
|
||||
0x72, 0x6f, 0x53, 0x41, 0x93, 0x0e, 0xd1, 0x6f, 0x46, 0x80, 0x1b, 0x30,
|
||||
0x03, 0x30, 0x0c, 0x2f, 0x04, 0x40, 0x00, 0x91, 0x42, 0x42, 0x08, 0x2f,
|
||||
0xf6, 0x6e, 0x44, 0x6f, 0x86, 0x41, 0xb4, 0x0e, 0x03, 0x2f, 0x02, 0x88,
|
||||
0xdb, 0x7e, 0x03, 0x43, 0x0b, 0x42, 0x46, 0x8d, 0x44, 0x41, 0x47, 0x80,
|
||||
0x05, 0x6f, 0x94, 0x0f, 0x76, 0x7f, 0x60, 0x7f, 0x02, 0x2f, 0x45, 0x89,
|
||||
0x42, 0x43, 0x03, 0x43, 0x49, 0x88, 0xa5, 0x6f, 0x40, 0x91, 0xa4, 0x7f,
|
||||
0x15, 0x30, 0xe2, 0x6f, 0xd3, 0x6e, 0x03, 0x2f, 0x04, 0x30, 0x83, 0x42,
|
||||
0x80, 0x2e, 0x77, 0xb4, 0x04, 0x40, 0x25, 0x29, 0x04, 0x42, 0x83, 0x42,
|
||||
0x45, 0x82, 0x94, 0x6f, 0x04, 0x85, 0xc0, 0xb2, 0x90, 0x2e, 0x63, 0xb4,
|
||||
0x15, 0x87, 0x3c, 0x8c, 0xc4, 0x40, 0x46, 0x7f, 0xc2, 0x86, 0x07, 0x40,
|
||||
0x86, 0x41, 0xf4, 0xbf, 0x00, 0xb3, 0x0c, 0x2f, 0x90, 0x6f, 0x16, 0x80,
|
||||
0x46, 0x25, 0x00, 0x40, 0x57, 0x25, 0x04, 0x18, 0xae, 0x0e, 0x10, 0x30,
|
||||
0x06, 0x30, 0x75, 0x25, 0x46, 0x23, 0x60, 0x6f, 0x64, 0x25, 0xc4, 0x40,
|
||||
0xfa, 0x86, 0x00, 0xb3, 0x33, 0x7f, 0x09, 0x2f, 0x93, 0x6f, 0xd8, 0x88,
|
||||
0x53, 0x6f, 0x04, 0x41, 0xc3, 0x40, 0xdc, 0x0e, 0x13, 0x30, 0x04, 0x30,
|
||||
0xdc, 0x22, 0xb3, 0x25, 0x40, 0xb3, 0x02, 0x2f, 0x3b, 0x25, 0xc0, 0x90,
|
||||
0x05, 0x2f, 0x91, 0x6f, 0xd0, 0x6f, 0x98, 0x2e, 0xc6, 0xb2, 0x4d, 0x2c,
|
||||
0x04, 0x30, 0x8d, 0x88, 0x43, 0x40, 0x82, 0x40, 0x54, 0x7f, 0xda, 0x0f,
|
||||
0x04, 0x30, 0x08, 0x2f, 0xc1, 0x80, 0x40, 0x42, 0xc2, 0x0f, 0x02, 0x2f,
|
||||
0x00, 0x30, 0xc0, 0x7e, 0x1b, 0x2d, 0xc0, 0x7e, 0x19, 0x2d, 0xe1, 0xbc,
|
||||
0x92, 0x6f, 0x4f, 0x04, 0x90, 0x84, 0x40, 0xa8, 0x21, 0x05, 0x83, 0x40,
|
||||
0x4c, 0x22, 0x4b, 0x0e, 0xb6, 0x84, 0x21, 0x30, 0x02, 0x2f, 0x11, 0x30,
|
||||
0x04, 0x2c, 0xc1, 0x7e, 0xe3, 0x6f, 0xc1, 0x7e, 0xc1, 0x42, 0x00, 0x2e,
|
||||
0x00, 0x40, 0x81, 0x40, 0x04, 0xbd, 0x40, 0x6f, 0x98, 0x2e, 0xc2, 0xb1,
|
||||
0x50, 0x6f, 0x11, 0x30, 0x02, 0x40, 0x51, 0x08, 0xc3, 0x6e, 0x03, 0x80,
|
||||
0x99, 0x15, 0x0b, 0x40, 0xb1, 0x6f, 0xd0, 0x6f, 0xb6, 0x7f, 0x5b, 0x7f,
|
||||
0x04, 0x30, 0x4d, 0x54, 0x03, 0x30, 0x11, 0x2c, 0x10, 0x80, 0x55, 0x6f,
|
||||
0x06, 0x40, 0x75, 0x01, 0x58, 0xbb, 0x6a, 0x09, 0x05, 0x42, 0xc1, 0x86,
|
||||
0x47, 0x40, 0x51, 0x25, 0xbe, 0x01, 0x56, 0x43, 0x00, 0x2e, 0x46, 0x41,
|
||||
0xf4, 0x03, 0xb6, 0x6f, 0x47, 0x43, 0x5e, 0x0e, 0xed, 0x2f, 0x31, 0x6f,
|
||||
0x60, 0x6f, 0x42, 0x40, 0x15, 0x30, 0x02, 0x82, 0x95, 0x08, 0x04, 0x42,
|
||||
0x52, 0x42, 0x02, 0x2c, 0x44, 0x42, 0x04, 0x30, 0x3e, 0x8e, 0x91, 0x6f,
|
||||
0x4f, 0x8c, 0x02, 0x40, 0x83, 0x41, 0xb5, 0x8d, 0x93, 0x0e, 0xd0, 0x6f,
|
||||
0x01, 0x2f, 0x98, 0x2e, 0xc6, 0xb2, 0x00, 0x2e, 0xc0, 0x41, 0x81, 0x41,
|
||||
0xc1, 0x0f, 0xc0, 0x6f, 0x01, 0x2f, 0x04, 0x42, 0x00, 0x2e, 0x70, 0x6f,
|
||||
0x3c, 0x82, 0x00, 0x40, 0x41, 0x40, 0x89, 0x16, 0x95, 0x08, 0x4a, 0x00,
|
||||
0x04, 0xbc, 0x91, 0xb4, 0x01, 0x0e, 0xe0, 0x6f, 0x07, 0x2f, 0xa1, 0x6f,
|
||||
0x00, 0x2e, 0x41, 0x40, 0x40, 0xb2, 0x02, 0x2f, 0xa1, 0x6f, 0x05, 0x42,
|
||||
0x44, 0x42, 0x00, 0x2e, 0x8b, 0x6f, 0xc0, 0x5e, 0xb8, 0x2e, 0x03, 0x2e,
|
||||
0x1c, 0x01, 0x9c, 0xbc, 0x1d, 0xb9, 0x02, 0x82, 0x25, 0x2e, 0x8e, 0x00,
|
||||
0x83, 0x56, 0x13, 0x18, 0x01, 0x2e, 0x66, 0x00, 0x43, 0x40, 0xd8, 0x04,
|
||||
0x05, 0x2e, 0x65, 0x00, 0x40, 0x50, 0x27, 0x2e, 0x65, 0x00, 0xfb, 0x7f,
|
||||
0xda, 0x05, 0x8b, 0x50, 0x4b, 0x40, 0x02, 0x40, 0x81, 0x82, 0x01, 0x42,
|
||||
0x03, 0x80, 0x81, 0x52, 0xb1, 0x00, 0x03, 0x40, 0x3b, 0x82, 0x85, 0x58,
|
||||
0x14, 0x01, 0xc0, 0xb2, 0x37, 0x2e, 0x66, 0x00, 0xd1, 0x7f, 0xe2, 0x7f,
|
||||
0x04, 0x2f, 0x05, 0x2e, 0x6b, 0x00, 0x81, 0x84, 0x25, 0x2e, 0x6b, 0x00,
|
||||
0x62, 0x40, 0x3a, 0x0f, 0x45, 0x40, 0xc1, 0x7f, 0x21, 0x30, 0x12, 0x30,
|
||||
0x42, 0x2f, 0x0d, 0x2e, 0x69, 0x00, 0x3e, 0x0e, 0x33, 0x2f, 0x05, 0x2e,
|
||||
0x6a, 0x00, 0x01, 0x35, 0x91, 0x0e, 0x01, 0x30, 0x03, 0x2f, 0x09, 0x2e,
|
||||
0x6e, 0x00, 0x00, 0xb3, 0x24, 0x2f, 0xc0, 0x35, 0x90, 0x0e, 0x39, 0x2f,
|
||||
0x8f, 0x50, 0x02, 0x30, 0x01, 0x40, 0x7f, 0x82, 0x43, 0xa2, 0x02, 0x2f,
|
||||
0x00, 0x2e, 0x0c, 0x2c, 0x01, 0x30, 0xc0, 0xb2, 0x11, 0x30, 0x02, 0x2f,
|
||||
0x25, 0x2e, 0x6d, 0x00, 0x03, 0x2d, 0x23, 0x2e, 0x6d, 0x00, 0x21, 0x30,
|
||||
0x25, 0x2e, 0x6b, 0x00, 0x42, 0xb2, 0x04, 0x2f, 0x41, 0xb2, 0x02, 0x2f,
|
||||
0x25, 0x2e, 0x6d, 0x00, 0x31, 0x30, 0x3e, 0x80, 0x04, 0x86, 0x25, 0x2e,
|
||||
0x6c, 0x00, 0x02, 0x42, 0xc2, 0x42, 0x18, 0x2d, 0x02, 0x35, 0x01, 0x42,
|
||||
0x25, 0x2e, 0x6a, 0x00, 0x13, 0x2d, 0x2c, 0x04, 0x38, 0x1e, 0x21, 0x2e,
|
||||
0x69, 0x00, 0x7f, 0x50, 0x11, 0x30, 0x22, 0x30, 0x98, 0x2e, 0x66, 0xb5,
|
||||
0x09, 0x2c, 0x01, 0x30, 0x2c, 0x00, 0x38, 0x1c, 0x21, 0x2e, 0x68, 0x00,
|
||||
0x7f, 0x50, 0x98, 0x2e, 0x66, 0xb5, 0x01, 0x30, 0xc0, 0x6f, 0xd4, 0xb1,
|
||||
0xf5, 0xbd, 0x6b, 0xba, 0x91, 0x5a, 0x02, 0x40, 0x15, 0x18, 0xf5, 0xbe,
|
||||
0xeb, 0xbb, 0xe3, 0x0a, 0x3d, 0x0b, 0xd2, 0x6f, 0xe3, 0x00, 0x84, 0x40,
|
||||
0x63, 0x05, 0x93, 0x58, 0x2c, 0x18, 0xf5, 0xbe, 0x03, 0x42, 0xeb, 0xbb,
|
||||
0xfd, 0x0b, 0xe0, 0x6f, 0x58, 0x01, 0xdf, 0x01, 0x7d, 0x1f, 0x95, 0x42,
|
||||
0x18, 0x04, 0x85, 0x40, 0x5d, 0x05, 0x2c, 0x18, 0x75, 0xbe, 0xeb, 0xba,
|
||||
0x2c, 0x0b, 0xdc, 0x04, 0x18, 0x1c, 0x80, 0x42, 0x84, 0x80, 0x02, 0x30,
|
||||
0x00, 0x40, 0x00, 0xb2, 0x0c, 0x2f, 0x01, 0x2e, 0x6b, 0x00, 0x03, 0x35,
|
||||
0x83, 0x0e, 0x07, 0x2f, 0x8d, 0x50, 0x3e, 0x80, 0x25, 0x2e, 0x6d, 0x00,
|
||||
0x02, 0x42, 0x03, 0x80, 0x00, 0x2e, 0x02, 0x42, 0x40, 0xb2, 0x04, 0x2f,
|
||||
0x8b, 0x50, 0x04, 0x80, 0x25, 0x2e, 0x6a, 0x00, 0x02, 0x42, 0x42, 0xb2,
|
||||
0x89, 0x56, 0x9a, 0x22, 0x41, 0xb2, 0x01, 0x2e, 0x1c, 0x01, 0x87, 0x52,
|
||||
0x0b, 0xbc, 0x8a, 0x22, 0x0f, 0xb8, 0x00, 0x90, 0x01, 0x32, 0x06, 0x2f,
|
||||
0x10, 0x30, 0x90, 0x08, 0x80, 0xb2, 0x08, 0x2f, 0x23, 0x2e, 0x5e, 0xf0,
|
||||
0x06, 0x2d, 0x20, 0x30, 0x90, 0x08, 0x80, 0xb2, 0x01, 0x2f, 0x23, 0x2e,
|
||||
0x5e, 0xf0, 0xfb, 0x6f, 0xc0, 0x5f, 0xb8, 0x2e, 0x07, 0x86, 0xfc, 0x88,
|
||||
0xc6, 0x40, 0x05, 0x41, 0x31, 0x1a, 0x12, 0x2f, 0x80, 0x91, 0x22, 0x2f,
|
||||
0x01, 0x35, 0x29, 0x0f, 0x0a, 0x2f, 0x06, 0x80, 0x00, 0x2e, 0x00, 0x40,
|
||||
0x00, 0xb2, 0x01, 0x2f, 0x44, 0xa9, 0x03, 0x2f, 0x00, 0x30, 0xc0, 0x42,
|
||||
0x00, 0x43, 0xb8, 0x2e, 0xc2, 0x42, 0x01, 0x43, 0xb8, 0x2e, 0x01, 0x35,
|
||||
0xa9, 0x0e, 0x0e, 0x2f, 0x03, 0x3b, 0xeb, 0x00, 0xcc, 0xa8, 0x0a, 0x2f,
|
||||
0x05, 0x86, 0xc2, 0x80, 0xc3, 0x40, 0x02, 0x42, 0x3c, 0x84, 0xc1, 0x80,
|
||||
0x81, 0x42, 0x82, 0x84, 0xc0, 0x2e, 0x80, 0x42, 0x00, 0x2e, 0xb8, 0x2e,
|
||||
0x03, 0x2e, 0x1d, 0x01, 0x9f, 0xbc, 0x9f, 0xb8, 0x90, 0x50, 0x40, 0xb2,
|
||||
0x90, 0x2e, 0x71, 0xb6, 0x12, 0x40, 0x03, 0x30, 0x11, 0x40, 0x80, 0xa8,
|
||||
0x5a, 0x05, 0x9f, 0x58, 0x55, 0x23, 0x00, 0x40, 0x75, 0x7f, 0x40, 0xa8,
|
||||
0x16, 0x41, 0xd9, 0x05, 0xcf, 0x23, 0x56, 0x05, 0x40, 0xa9, 0x9d, 0x05,
|
||||
0x87, 0x7f, 0x6e, 0x23, 0x17, 0x41, 0xa5, 0x7f, 0x3e, 0x8b, 0x04, 0x41,
|
||||
0x52, 0x43, 0x00, 0xa8, 0x98, 0x05, 0xf2, 0x7f, 0x86, 0x22, 0xcf, 0x05,
|
||||
0xc0, 0xa9, 0x9f, 0x05, 0xbe, 0x23, 0x04, 0x05, 0x92, 0x7f, 0x00, 0xa9,
|
||||
0xdc, 0x05, 0x51, 0x43, 0xb6, 0x7f, 0x27, 0x23, 0xa7, 0x54, 0xe1, 0x7f,
|
||||
0x02, 0x18, 0x7d, 0x83, 0x40, 0x43, 0xeb, 0xba, 0x75, 0xbd, 0xaa, 0x0a,
|
||||
0x0b, 0x2e, 0x71, 0x00, 0x77, 0x5c, 0x2e, 0x18, 0xf5, 0xbe, 0x6b, 0xbb,
|
||||
0x75, 0x0b, 0xaa, 0x00, 0xc4, 0x7f, 0x25, 0x2e, 0x71, 0x00, 0xb2, 0x6f,
|
||||
0xa5, 0x6f, 0xaa, 0x00, 0x54, 0x01, 0x84, 0x6f, 0x72, 0x6f, 0x94, 0x05,
|
||||
0x80, 0xa9, 0xde, 0x05, 0xb7, 0x23, 0x99, 0x5e, 0x77, 0x0e, 0x41, 0x40,
|
||||
0x97, 0x5c, 0xb1, 0x01, 0xd5, 0x7f, 0x00, 0x2e, 0x85, 0x41, 0x0e, 0x2f,
|
||||
0x00, 0xa0, 0x0c, 0x2f, 0x14, 0x0f, 0x04, 0x2f, 0xe0, 0x6f, 0x00, 0xac,
|
||||
0x10, 0x30, 0x08, 0x2c, 0x18, 0x22, 0xf0, 0x6f, 0x00, 0xac, 0x30, 0x30,
|
||||
0x24, 0x30, 0x02, 0x2c, 0x20, 0x22, 0x40, 0x30, 0x0d, 0x2e, 0x71, 0x00,
|
||||
0x80, 0xa1, 0x1e, 0x23, 0x79, 0x5e, 0x37, 0x0f, 0xbc, 0x23, 0x00, 0x90,
|
||||
0x14, 0x30, 0x10, 0x30, 0x18, 0x2f, 0x9d, 0x50, 0x30, 0x00, 0x9b, 0x56,
|
||||
0x43, 0x0e, 0x02, 0x2f, 0x10, 0x30, 0x0a, 0x2c, 0x03, 0x30, 0x99, 0x50,
|
||||
0x10, 0x0e, 0x13, 0x30, 0x00, 0x2f, 0x03, 0x30, 0x90, 0x0f, 0x10, 0x30,
|
||||
0x00, 0x2f, 0x00, 0x30, 0x00, 0x90, 0x10, 0x30, 0x00, 0x2f, 0x00, 0x30,
|
||||
0xc0, 0x90, 0x13, 0x30, 0x00, 0x2f, 0x03, 0x30, 0x40, 0xb2, 0x87, 0x5c,
|
||||
0x22, 0x2f, 0x41, 0x90, 0x4a, 0x2f, 0xa5, 0x50, 0x00, 0x2e, 0x01, 0x40,
|
||||
0x41, 0x82, 0x01, 0x42, 0x02, 0x80, 0x4a, 0xa8, 0x01, 0x40, 0x06, 0x2f,
|
||||
0xd0, 0x6f, 0x85, 0x0e, 0x3e, 0x2f, 0x41, 0x80, 0x21, 0x2e, 0x78, 0x00,
|
||||
0x3b, 0x2d, 0x95, 0x50, 0xfb, 0x7f, 0x4a, 0xa8, 0x06, 0x2f, 0x98, 0x2e,
|
||||
0x73, 0xb6, 0xc0, 0x90, 0xfb, 0x6f, 0x32, 0x2f, 0x00, 0x2e, 0x30, 0x2d,
|
||||
0x98, 0x2e, 0x73, 0xb6, 0x29, 0x2e, 0x7a, 0x00, 0x2b, 0x2c, 0xfb, 0x6f,
|
||||
0xa1, 0x52, 0xd2, 0x6f, 0x95, 0x0e, 0x41, 0x40, 0x05, 0x2f, 0x00, 0x90,
|
||||
0x17, 0x2f, 0x05, 0x2e, 0x7a, 0x00, 0x80, 0x90, 0x13, 0x2f, 0x7f, 0x82,
|
||||
0x40, 0xac, 0x23, 0x2e, 0x77, 0x00, 0x01, 0x30, 0x18, 0x2f, 0xa1, 0x54,
|
||||
0x82, 0x84, 0x23, 0x2e, 0x77, 0x00, 0x82, 0x40, 0x80, 0xb2, 0x11, 0x2f,
|
||||
0x00, 0x90, 0x23, 0x2e, 0x79, 0x00, 0x0d, 0x2f, 0x29, 0x2e, 0x72, 0x00,
|
||||
0x0b, 0x2d, 0x41, 0x80, 0x21, 0x2e, 0x77, 0x00, 0x0f, 0xa4, 0x05, 0x2f,
|
||||
0xa3, 0x50, 0x3e, 0x80, 0xf1, 0x30, 0x29, 0x2e, 0x79, 0x00, 0x01, 0x42,
|
||||
0x06, 0x30, 0x34, 0x08, 0x00, 0xb2, 0x02, 0x2f, 0x80, 0x30, 0x21, 0x2e,
|
||||
0x5e, 0xf0, 0x70, 0x5f, 0xb8, 0x2e, 0x04, 0x84, 0x01, 0x30, 0x81, 0x42,
|
||||
0x82, 0x84, 0x01, 0x42, 0xa1, 0x42, 0x81, 0x42, 0x82, 0x84, 0x00, 0x2e,
|
||||
0x91, 0x42, 0x81, 0x42, 0xb8, 0x2e, 0x30, 0x50, 0xf3, 0x7f, 0xc0, 0xac,
|
||||
0xe4, 0x7f, 0xd5, 0x7f, 0x03, 0x2f, 0x00, 0x30, 0x82, 0x04, 0xf3, 0x6f,
|
||||
0xc3, 0x06, 0x40, 0xad, 0x05, 0x2f, 0xe0, 0x6f, 0x05, 0x30, 0x28, 0x04,
|
||||
0xd1, 0x6f, 0x69, 0x07, 0xe0, 0x7f, 0x40, 0xa1, 0x01, 0x30, 0x20, 0x2f,
|
||||
0x13, 0x25, 0x02, 0x25, 0x04, 0x32, 0x06, 0x30, 0x02, 0x30, 0x03, 0x30,
|
||||
0xaf, 0xbb, 0xb1, 0xbd, 0xdf, 0x0a, 0x9f, 0xbb, 0x21, 0xbd, 0x97, 0x0a,
|
||||
0x8f, 0xbb, 0x91, 0xbc, 0x01, 0xbc, 0x4f, 0x0a, 0x6b, 0x0e, 0x04, 0x2f,
|
||||
0x6b, 0x1a, 0x07, 0x2f, 0xe7, 0x6f, 0x7a, 0x0f, 0x04, 0x2f, 0xe7, 0x6f,
|
||||
0x97, 0x04, 0x17, 0x30, 0x07, 0x0a, 0xdd, 0x06, 0x81, 0x8d, 0x34, 0x0e,
|
||||
0xe6, 0x2f, 0x00, 0x2e, 0x0d, 0x2d, 0x6b, 0x0e, 0x00, 0x30, 0x05, 0x2f,
|
||||
0x6b, 0x1a, 0x07, 0x2f, 0xe0, 0x6f, 0x42, 0x0f, 0x00, 0x30, 0x03, 0x2f,
|
||||
0xe0, 0x6f, 0x90, 0x04, 0xdd, 0x06, 0x10, 0x30, 0xf5, 0x6f, 0xc3, 0x7f,
|
||||
0xb2, 0x7f, 0x40, 0xad, 0x06, 0x2f, 0x03, 0x30, 0xb2, 0x6f, 0x9a, 0x04,
|
||||
0xc4, 0x6f, 0xdc, 0x06, 0xb2, 0x7f, 0xc3, 0x7f, 0x00, 0x2e, 0xd2, 0x6f,
|
||||
0xaa, 0x0c, 0x80, 0xac, 0x02, 0x30, 0x01, 0x2f, 0x10, 0x04, 0x51, 0x06,
|
||||
0xd0, 0x5f, 0xb8, 0x2e, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00,
|
||||
0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00, 0x80, 0x2e, 0x18, 0x00
|
||||
};
|
||||
|
||||
#define BMA4_ACCEL_CONFIG_ADDR (0X40)
|
||||
#define BMA4_TEMPERATURE_ADDR (0X22)
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
/**\name Step Counter & Detector */
|
||||
/**************************************************************/
|
||||
/**\name Step counter enable macros */
|
||||
#define BMA423_STEP_CNTR_EN_POS (4)
|
||||
#define BMA423_STEP_CNTR_EN_MSK (0x10)
|
||||
#define BMA423_ACTIVITY_EN_MSK (0x20)
|
||||
|
||||
/**\name Step counter watermark macros */
|
||||
#define BMA423_STEP_CNTR_WM_MSK (0x03FF)
|
||||
|
||||
/**\name Step counter reset macros */
|
||||
#define BMA423_STEP_CNTR_RST_POS (2)
|
||||
#define BMA423_STEP_CNTR_RST_MSK (0x04)
|
||||
|
||||
/**\name Step detector enable macros */
|
||||
#define BMA423_STEP_DETECTOR_EN_POS (3)
|
||||
#define BMA423_STEP_DETECTOR_EN_MSK (0x08)
|
||||
|
||||
/**\name Tilt enable macros */
|
||||
#define BMA423_TILT_EN_MSK (0x01)
|
||||
|
||||
/**\name Step count output length*/
|
||||
#define BMA423_STEP_CNTR_DATA_SIZE (4)
|
||||
|
||||
/**\name Wakeup enable macros */
|
||||
#define BMA423_WAKEUP_EN_MSK (0x01)
|
||||
|
||||
/**\name Wake up sensitivity macros */
|
||||
#define BMA423_WAKEUP_SENS_POS (1)
|
||||
#define BMA423_WAKEUP_SENS_MSK (0x0E)
|
||||
|
||||
/**\name Tap selection macro */
|
||||
#define BMA423_TAP_SEL_POS (4)
|
||||
#define BMA423_TAP_SEL_MSK (0x10)
|
||||
|
||||
/**************************************************************/
|
||||
/**\name Any Motion */
|
||||
/**************************************************************/
|
||||
/**\name Any motion threshold macros */
|
||||
#define BMA423_ANY_NO_MOTION_THRES_POS (0)
|
||||
#define BMA423_ANY_NO_MOTION_THRES_MSK (0x07FF)
|
||||
|
||||
/**\name Any motion selection macros */
|
||||
#define BMA423_ANY_NO_MOTION_SEL_POS (3)
|
||||
#define BMA423_ANY_NO_MOTION_SEL_MSK (0x08)
|
||||
|
||||
/**\name Any motion enable macros */
|
||||
#define BMA423_ANY_NO_MOTION_AXIS_EN_POS (5)
|
||||
#define BMA423_ANY_NO_MOTION_AXIS_EN_MSK (0xE0)
|
||||
|
||||
/**\name Any motion duration macros */
|
||||
#define BMA423_ANY_NO_MOTION_DUR_MSK (0x1FFF)
|
||||
|
||||
/**\name INTERRUPT MAPS */
|
||||
#define BMA4_INTR1_MAP (0)
|
||||
#define BMA4_INTR2_MAP (1)
|
||||
|
||||
/**\name INTERRUPT ENABLE REGISTERS*/
|
||||
#define BMA4_INT1_IO_CTRL_ADDR (0X53)
|
||||
#define BMA4_INT2_IO_CTRL_ADDR (0X54)
|
||||
|
||||
/**\name LATCH DURATION REGISTERS*/
|
||||
#define BMA4_INTR_LATCH_ADDR (0X55)
|
||||
|
||||
/**\name CONSTANTS */
|
||||
#define BMA4_FIFO_CONFIG_LENGTH (2)
|
||||
#define BMA4_ACCEL_CONFIG_LENGTH (2)
|
||||
#define BMA4_FIFO_WM_LENGTH (2)
|
||||
#define BMA4_CONFIG_STREAM_SIZE (6144)
|
||||
#define BMA4_NON_LATCH_MODE (0)
|
||||
#define BMA4_LATCH_MODE (1)
|
||||
#define BMA4_OPEN_DRAIN (1)
|
||||
#define BMA4_PUSH_PULL (0)
|
||||
#define BMA4_ACTIVE_HIGH (1)
|
||||
#define BMA4_ACTIVE_LOW (0)
|
||||
#define BMA4_EDGE_TRIGGER (1)
|
||||
#define BMA4_LEVEL_TRIGGER (0)
|
||||
#define BMA4_OUTPUT_ENABLE (1)
|
||||
#define BMA4_OUTPUT_DISABLE (0)
|
||||
#define BMA4_INPUT_ENABLE (1)
|
||||
#define BMA4_INPUT_DISABLE (0)
|
||||
|
||||
|
||||
/**\name OUTPUT TYPE ENABLE POSITION AND MASK*/
|
||||
#define BMA4_INT_EDGE_CTRL_MASK (0x01)
|
||||
#define BMA4_INT_EDGE_CTRL_POS (0x00)
|
||||
#define BMA4_INT_LEVEL_MASK (0x02)
|
||||
#define BMA4_INT_LEVEL_POS (0x01)
|
||||
#define BMA4_INT_OPEN_DRAIN_MASK (0x04)
|
||||
#define BMA4_INT_OPEN_DRAIN_POS (0x02)
|
||||
#define BMA4_INT_OUTPUT_EN_MASK (0x08)
|
||||
#define BMA4_INT_OUTPUT_EN_POS (0x03)
|
||||
#define BMA4_INT_INPUT_EN_MASK (0x10)
|
||||
#define BMA4_INT_INPUT_EN_POS (0x04)
|
||||
|
||||
|
||||
/**\name Interrupt status macros */
|
||||
#define BMA423_STEP_CNTR_INT (0x02)
|
||||
#define BMA423_ACTIVITY_INT (0x04)
|
||||
#define BMA423_TILT_INT (0x08)
|
||||
#define BMA423_WAKEUP_INT (0x20)
|
||||
#define BMA423_ANY_NO_MOTION_INT (0x40)
|
||||
#define BMA423_ERROR_INT (0x80)
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file CHSC5816Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-17
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CHSC5816_SLAVE_ADDRESS (0x2E)
|
||||
|
||||
#define CHSC5816_REG_CMD_BUFF (0x20000000U)
|
||||
#define CHSC5816_REG_RSP_BUFF (0x20000000U)
|
||||
#define CHSC5816_REG_IMG_HEAD (0x20000014U)
|
||||
#define CHSC5816_REG_POINT (0x2000002CU)
|
||||
#define CHSC5816_REG_WR_BUFF (0x20002000U)
|
||||
#define CHSC5816_REG_RD_BUFF (0x20002400U)
|
||||
#define CHSC5816_REG_HOLD_MCU (0x40007000U)
|
||||
#define CHSC5816_REG_AUTO_FEED (0x40007010U)
|
||||
#define CHSC5816_REG_REMAP_MCU (0x40007000U)
|
||||
#define CHSC5816_REG_RELEASE_MCU (0x40007000U)
|
||||
#define CHSC5816_REG_BOOT_STATE (0x20000018U)
|
||||
|
||||
|
||||
|
||||
#define CHSC5816_HOLD_MCU_VAL (0x12044000U)
|
||||
#define CHSC5816_AUTO_FEED_VAL (0x0000925aU)
|
||||
#define CHSC5816_REMAP_MCU_VAL (0x12044002U)
|
||||
#define CHSC5816_RELEASE_MCU_VAL (0x12044003U)
|
||||
|
||||
#define CHSC5816_REG_VID_PID_BACKUP (40 * 1024 + 0x10U)
|
||||
|
||||
#define CHSC5816_SIG_VALUE (0x43534843U)
|
||||
/*ctp work staus*/
|
||||
#define CHSC5816_POINTING_WORK (0x00000000U)
|
||||
#define CHSC5816_READY_UPGRADE (1 << 1)
|
||||
#define CHSC5816_UPGRAD_RUNING (1 << 2)
|
||||
#define CHSC5816_SLFTEST_RUNING (1 << 3)
|
||||
#define CHSC5816_SUSPEND_GATE (1 << 16)
|
||||
#define CHSC5816_GUESTURE_GATE (1 << 17)
|
||||
#define CHSC5816_PROXIMITY_GATE (1 << 18)
|
||||
#define CHSC5816_GLOVE_GATE (1 << 19)
|
||||
#define CHSC5816_ORIENTATION_GATE (1 << 20)
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file CM32181Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-14
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM32181_SLAVE_ADDRESS (0x10)
|
||||
|
||||
|
||||
|
||||
// CM32181 slave address can be 0x10 or 0x48, determined by pin ADDR configuration
|
||||
#define CM32181_ADDR_ALS (0x10) // 7-bit
|
||||
#define CM32181_ADDR_ALS1 (0x48) // 7-bit
|
||||
|
||||
// CM32181 registers
|
||||
#define CM32181_REG_ALS_CONF (uint8_t)(0x00)
|
||||
#define CM32181_REG_ALS_THDH (uint8_t)(0x01)
|
||||
#define CM32181_REG_ALS_THDL (uint8_t)(0x02)
|
||||
#define CM32181_REG_ALS_PSM (uint8_t)(0x03)
|
||||
#define CM32181_REG_ALS_DATA (uint8_t)(0x04)
|
||||
#define CM32181_REG_ALS_STATUS (uint8_t)(0x06)
|
||||
#define CM32181_REG_ID (uint8_t)(0x07)
|
||||
|
||||
#define CM32181_CHIP_ID (0x81)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file CSTxxxConstants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-24
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CSTXXX_SLAVE_ADDRESS (0x15)
|
||||
#define CST816_SLAVE_ADDRESS (0x15)
|
||||
#define CST328_SLAVE_ADDRESS (0x1A)
|
||||
#define CST226SE_SLAVE_ADDRESS (0x5A)
|
||||
|
||||
#define CST816S_CHIP_ID (0xB4)
|
||||
#define CST816T_CHIP_ID (0xB5)
|
||||
#define CST716_CHIP_ID (0x20)
|
||||
#define CST226SE_CHIP_ID (0xA8)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file DRV2605Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-03
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define DRV2605_SLAVE_ADDRESS (0x5A)
|
||||
|
||||
#define DRV2604_CHIP_ID (0x04) //* DRV2604 (contains RAM, does not contain licensed ROM library)
|
||||
#define DRV2605_CHIP_ID (0x03) //* DRV2605 (contains licensed ROM library, does not contain RAM)
|
||||
#define DRV2604L_CHIP_ID (0x06) //* DRV2604L (low-voltage version of the DRV2604 device)
|
||||
#define DRV2605L_CHIP_ID (0x07) //* DRV2605L (low-voltage version of the DRV2605 device)
|
||||
|
||||
#define DRV2605_REG_STATUS (0x00) //* Status register
|
||||
#define DRV2605_REG_MODE (0x01) //* Mode register
|
||||
#define DRV2605_MODE_INTTRIG (0x00) //* Internal trigger mode
|
||||
#define DRV2605_MODE_EXTTRIGEDGE (0x01) //* External edge trigger mode
|
||||
#define DRV2605_MODE_EXTTRIGLVL (0x02) //* External level trigger mode
|
||||
#define DRV2605_MODE_PWMANALOG (0x03) //* PWM/Analog input mode
|
||||
#define DRV2605_MODE_AUDIOVIBE (0x04) //* Audio-to-vibe mode
|
||||
#define DRV2605_MODE_REALTIME (0x05) //* Real-time playback (RTP) mode
|
||||
#define DRV2605_MODE_DIAGNOS (0x06) //* Diagnostics mode
|
||||
#define DRV2605_MODE_AUTOCAL (0x07) //* Auto calibration mode
|
||||
#define DRV2605_REG_RTPIN (0x02) //* Real-time playback input register
|
||||
#define DRV2605_REG_LIBRARY (0x03) //* Waveform library selection register
|
||||
#define DRV2605_REG_WAVESEQ1 (0x04) //* Waveform sequence register 1
|
||||
#define DRV2605_REG_WAVESEQ2 (0x05) //* Waveform sequence register 2
|
||||
#define DRV2605_REG_WAVESEQ3 (0x06) //* Waveform sequence register 3
|
||||
#define DRV2605_REG_WAVESEQ4 (0x07) //* Waveform sequence register 4
|
||||
#define DRV2605_REG_WAVESEQ5 (0x08) //* Waveform sequence register 5
|
||||
#define DRV2605_REG_WAVESEQ6 (0x09) //* Waveform sequence register 6
|
||||
#define DRV2605_REG_WAVESEQ7 (0x0A) //* Waveform sequence register 7
|
||||
#define DRV2605_REG_WAVESEQ8 (0x0B) //* Waveform sequence register 8
|
||||
#define DRV2605_REG_GO (0x0C) //* Go register
|
||||
#define DRV2605_REG_OVERDRIVE (0x0D) //* Overdrive time offset register
|
||||
#define DRV2605_REG_SUSTAINPOS (0x0E) //* Sustain time offset, positive register
|
||||
#define DRV2605_REG_SUSTAINNEG (0x0F) //* Sustain time offset, negative register
|
||||
#define DRV2605_REG_BREAK (0x10) //* Brake time offset register
|
||||
#define DRV2605_REG_AUDIOCTRL (0x11) //* Audio-to-vibe control register
|
||||
#define DRV2605_REG_AUDIOLVL (0x12) //* Audio-to-vibe minimum input level register
|
||||
#define DRV2605_REG_AUDIOMAX (0x13) //* Audio-to-vibe maximum input level register
|
||||
#define DRV2605_REG_AUDIOOUTMIN (0x14) //* Audio-to-vibe minimum output drive register
|
||||
#define DRV2605_REG_AUDIOOUTMAX (0x15) //* Audio-to-vibe maximum output drive register
|
||||
#define DRV2605_REG_RATEDV (0x16) //* Rated voltage register
|
||||
#define DRV2605_REG_CLAMPV (0x17) //* Overdrive clamp voltage register
|
||||
#define DRV2605_REG_AUTOCALCOMP (0x18) //* Auto-calibration compensation result register
|
||||
#define DRV2605_REG_AUTOCALEMP (0x19) //* Auto-calibration back-EMF result register
|
||||
#define DRV2605_REG_FEEDBACK (0x1A) //* Feedback control register
|
||||
#define DRV2605_REG_CONTROL1 (0x1B) //* Control1 Register
|
||||
#define DRV2605_REG_CONTROL2 (0x1C) //* Control2 Register
|
||||
#define DRV2605_REG_CONTROL3 (0x1D) //* Control3 Register
|
||||
#define DRV2605_REG_CONTROL4 (0x1E) //* Control4 Register
|
||||
#define DRV2605_REG_VBAT (0x21) //* Vbat voltage-monitor register
|
||||
#define DRV2605_REG_LRARESON (0x22) //* LRA resonance-period register
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file FT6X36Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-01
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FT3267_SLAVE_ADDRESS (0x38)
|
||||
#define FT5206_SLAVE_ADDRESS (0x38)
|
||||
#define FT6X36_SLAVE_ADDRESS (0x38)
|
||||
|
||||
#define FT6X36_VEND_ID (0x11)
|
||||
#define FT3267_CHIP_ID (0x33)
|
||||
#define FT6206_CHIP_ID (0x06)
|
||||
#define FT6236_CHIP_ID (0x36)
|
||||
#define FT6236U_CHIP_ID (0x64)
|
||||
#define FT5206U_CHIP_ID (0x64)
|
||||
|
||||
#define FT6X36_REG_MODE (0x00)
|
||||
#define FT6X36_REG_GEST (0x01)
|
||||
#define FT6X36_REG_STATUS (0x02)
|
||||
#define FT6X36_REG_TOUCH1_XH (0x03)
|
||||
#define FT6X36_REG_TOUCH1_XL (0x04)
|
||||
#define FT6X36_REG_TOUCH1_YH (0x05)
|
||||
#define FT6X36_REG_TOUCH1_YL (0x06)
|
||||
#define FT6X36_REG_THRESHOLD (0x80)
|
||||
#define FT6X36_REG_MONITOR_TIME (0x87)
|
||||
#define FT6X36_REG_PERIOD_ACTIVE (0x88)
|
||||
#define FT6X36_REG_PERIOD_MONITOR (0x89)
|
||||
|
||||
|
||||
#define FT6X36_REG_AUTO_CLB_MODE (0xA0)
|
||||
#define FT6X36_REG_LIB_VERSION_H (0xA1)
|
||||
#define FT6X36_REG_LIB_VERSION_L (0xA2)
|
||||
#define FT6X36_REG_INT_STATUS (0xA4)
|
||||
#define FT6X36_REG_POWER_MODE (0xA5)
|
||||
#define FT6X36_REG_FIRM_VERS (0xA6)
|
||||
#define FT6X36_REG_CHIP_ID (0xA3)
|
||||
#define FT6X36_REG_VENDOR1_ID (0xA8)
|
||||
#define FT6X36_REG_ERROR_STATUS (0xA9)
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file GT911Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-04-12
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GT911_SLAVE_ADDRESS_H (0x14)
|
||||
#define GT911_SLAVE_ADDRESS_L (0x5D)
|
||||
#define GT911_DEV_ID (911)
|
||||
#define GT911_BASE_REF_RATE (5)
|
||||
#define GT911_REG_LENGTH (186)
|
||||
|
||||
// Real-time command (Write only)
|
||||
#define GT911_COMMAND (0x8040)
|
||||
#define GT911_ESD_CHECK (0x8041)
|
||||
#define GT911_COMMAND_CHECK (0x8046)
|
||||
|
||||
// Configuration information (R/W)
|
||||
#define GT911_CONFIG_START (0x8047)
|
||||
#define GT911_CONFIG_VERSION (0x8047)
|
||||
#define GT911_X_OUTPUT_MAX_LOW (0x8048)
|
||||
#define GT911_X_OUTPUT_MAX_HIGH (0x8049)
|
||||
#define GT911_Y_OUTPUT_MAX_LOW (0x804A)
|
||||
#define GT911_Y_OUTPUT_MAX_HIGH (0x804B)
|
||||
#define GT911_TOUCH_NUMBER (0x804C)
|
||||
#define GT911_MODULE_SWITCH_1 (0x804D)
|
||||
#define GT911_MODULE_SWITCH_2 (0x804E)
|
||||
#define GT911_SHAKE_COUNT (0x804F)
|
||||
#define GT911_FILTER (0x8050)
|
||||
#define GT911_LARGE_TOUCH (0x8051)
|
||||
#define GT911_NOISE_REDUCTION (0x8052)
|
||||
#define GT911_SCREEN_TOUCH_LEVEL (0x8053)
|
||||
#define GT911_SCREEN_RELEASE_LEVEL (0x8054)
|
||||
#define GT911_LOW_POWER_CONTROL (0x8055)
|
||||
#define GT911_REFRESH_RATE (0x8056)
|
||||
#define GT911_X_THRESHOLD (0x8057)
|
||||
#define GT911_Y_THRESHOLD (0x8058)
|
||||
#define GT911_X_SPEED_LIMIT (0x8059) // Reserve
|
||||
#define GT911_Y_SPEED_LIMIT (0x805A) // Reserve
|
||||
#define GT911_SPACE_TOP_BOTTOM (0x805B)
|
||||
#define GT911_SPACE_LEFT_RIGHT (0x805C)
|
||||
#define GT911_MINI_FILTER (0x805D)
|
||||
#define GT911_STRETCH_R0 (0x805E)
|
||||
#define GT911_STRETCH_R1 (0x805F)
|
||||
#define GT911_STRETCH_R2 (0x8060)
|
||||
#define GT911_STRETCH_RM (0x8061)
|
||||
#define GT911_DRV_GROUPA_NUM (0x8062)
|
||||
#define GT911_DRV_GROUPB_NUM (0x8063)
|
||||
#define GT911_SENSOR_NUM (0x8064)
|
||||
#define GT911_FREQ_A_FACTOR (0x8065)
|
||||
#define GT911_FREQ_B_FACTOR (0x8066)
|
||||
#define GT911_PANEL_BIT_FREQ_L (0x8067)
|
||||
#define GT911_PANEL_BIT_FREQ_H (0x8068)
|
||||
#define GT911_PANEL_SENSOR_TIME_L (0x8069) // Reserve
|
||||
#define GT911_PANEL_SENSOR_TIME_H (0x806A)
|
||||
#define GT911_PANEL_TX_GAIN (0x806B)
|
||||
#define GT911_PANEL_RX_GAIN (0x806C)
|
||||
#define GT911_PANEL_DUMP_SHIFT (0x806D)
|
||||
#define GT911_DRV_FRAME_CONTROL (0x806E)
|
||||
#define GT911_CHARGING_LEVEL_UP (0x806F)
|
||||
#define GT911_MODULE_SWITCH3 (0x8070)
|
||||
#define GT911_GESTURE_DIS (0X8071)
|
||||
#define GT911_GESTURE_LONG_PRESS_TIME (0x8072)
|
||||
#define GT911_X_Y_SLOPE_ADJUST (0X8073)
|
||||
#define GT911_GESTURE_CONTROL (0X8074)
|
||||
#define GT911_GESTURE_SWITCH1 (0X8075)
|
||||
#define GT911_GESTURE_SWITCH2 (0X8076)
|
||||
#define GT911_GESTURE_REFRESH_RATE (0x8077)
|
||||
#define GT911_GESTURE_TOUCH_LEVEL (0x8078)
|
||||
#define GT911_NEWGREENWAKEUPLEVEL (0x8079)
|
||||
#define GT911_FREQ_HOPPING_START (0x807A)
|
||||
#define GT911_FREQ_HOPPING_END (0X807B)
|
||||
#define GT911_NOISE_DETECT_TIMES (0x807C)
|
||||
#define GT911_HOPPING_FLAG (0X807D)
|
||||
#define GT911_HOPPING_THRESHOLD (0X807E)
|
||||
#define GT911_NOISE_THRESHOLD (0X807F) // Reserve
|
||||
#define GT911_NOISE_MIN_THRESHOLD (0X8080)
|
||||
#define GT911_HOPPING_SENSOR_GROUP (0X8082)
|
||||
#define GT911_HOPPING_SEG1_NORMALIZE (0X8083)
|
||||
#define GT911_HOPPING_SEG1_FACTOR (0X8084)
|
||||
#define GT911_MAIN_CLOCK_AJDUST (0X8085)
|
||||
#define GT911_HOPPING_SEG2_NORMALIZE (0X8086)
|
||||
#define GT911_HOPPING_SEG2_FACTOR (0X8087)
|
||||
#define GT911_HOPPING_SEG3_NORMALIZE (0X8089)
|
||||
#define GT911_HOPPING_SEG3_FACTOR (0X808A)
|
||||
#define GT911_HOPPING_SEG4_NORMALIZE (0X808C)
|
||||
#define GT911_HOPPING_SEG4_FACTOR (0X808D)
|
||||
#define GT911_HOPPING_SEG5_NORMALIZE (0X808F)
|
||||
#define GT911_HOPPING_SEG5_FACTOR (0X8090)
|
||||
#define GT911_HOPPING_SEG6_NORMALIZE (0X8092)
|
||||
#define GT911_KEY_1 (0X8093)
|
||||
#define GT911_KEY_2 (0X8094)
|
||||
#define GT911_KEY_3 (0X8095)
|
||||
#define GT911_KEY_4 (0X8096)
|
||||
#define GT911_KEY_AREA (0X8097)
|
||||
#define GT911_KEY_TOUCH_LEVEL (0X8098)
|
||||
#define GT911_KEY_LEAVE_LEVEL (0X8099)
|
||||
#define GT911_KEY_SENS_1_2 (0X809A)
|
||||
#define GT911_KEY_SENS_3_4 (0X809B)
|
||||
#define GT911_KEY_RESTRAIN (0X809C)
|
||||
#define GT911_KEY_RESTRAIN_TIME (0X809D)
|
||||
#define GT911_GESTURE_LARGE_TOUCH (0X809E)
|
||||
#define GT911_HOTKNOT_NOISE_MAP (0X80A1)
|
||||
#define GT911_LINK_THRESHOLD (0X80A2)
|
||||
#define GT911_PXY_THRESHOLD (0X80A3)
|
||||
#define GT911_GHOT_DUMP_SHIFT (0X80A4)
|
||||
#define GT911_GHOT_RX_GAIN (0X80A5)
|
||||
#define GT911_FREQ_GAIN0 (0X80A6)
|
||||
#define GT911_FREQ_GAIN1 (0X80A7)
|
||||
#define GT911_FREQ_GAIN2 (0X80A8)
|
||||
#define GT911_FREQ_GAIN3 (0X80A9)
|
||||
#define GT911_COMBINE_DIS (0X80B3)
|
||||
#define GT911_SPLIT_SET (0X80B4)
|
||||
#define GT911_SENSOR_CH0 (0X80B7)
|
||||
#define GT911_DRIVER_CH0 (0X80D5)
|
||||
#define GT911_CONFIG_CHKSUM (0X80FF)
|
||||
#define GT911_CONFIG_FRESH (0X8100)
|
||||
#define GT911_CONFIG_SIZE (0xFF - 0x46)
|
||||
|
||||
// Coordinate information
|
||||
#define GT911_PRODUCT_ID (0x8140)
|
||||
#define GT911_FIRMWARE_VERSION (0x8144)
|
||||
#define GT911_X_RESOLUTION (0x8146)
|
||||
#define GT911_Y_RESOLUTION (0x8148)
|
||||
|
||||
#define GT911_VENDOR_ID (0X8140)
|
||||
#define GT911_IMFORMATION (0X8140)
|
||||
#define GT911_POINT_INFO (0X814E)
|
||||
#define GT911_POINT_1 (0X814F)
|
||||
#define GT911_POINT_2 (0X8157)
|
||||
#define GT911_POINT_3 (0X815F)
|
||||
#define GT911_POINT_4 (0X8167)
|
||||
#define GT911_POINT_5 (0X816F)
|
||||
|
||||
|
||||
#define GT911_GET_POINT(x) (x & 0x0F)
|
||||
#define GT911_GET_BUFFER_STATUS(x) (x & 0x80)
|
||||
#define GT911_GET_HAVE_KEY(x) (x & 0x10)
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2023 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file LTR533Constants.tpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-09
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define LTR553_SLAVE_ADDRESS (0x23)
|
||||
|
||||
#define LTR553_REG_ALS_CONTR (0x80)
|
||||
#define LTR553_REG_PS_CONTR (0x81)
|
||||
#define LTR553_REG_PS_LED (0x82)
|
||||
#define LTR553_REG_PS_N_PULSES (0x83)
|
||||
#define LTR553_REG_PS_MEAS_RATE (0x84)
|
||||
#define LTR553_REG_ALS_MEAS_RATE (0x85)
|
||||
#define LTR553_REG_PART_ID (0x86)
|
||||
#define LTR553_REG_MANUFAC_ID (0x87)
|
||||
#define LTR553_REG_ALS_DATA_CH1_0 (0x88)
|
||||
#define LTR553_REG_ALS_DATA_CH1_1 (0x89)
|
||||
#define LTR553_REG_ALS_DATA_CH0_0 (0x8A)
|
||||
#define LTR553_REG_ALS_DATA_CH0_1 (0x8B)
|
||||
#define LTR553_REG_ALS_PS_STATUS (0x8C)
|
||||
#define LTR553_REG_PS_DATA_0 (0x8D)
|
||||
#define LTR553_REG_PS_DATA_1 (0x8E)
|
||||
#define LTR553_REG_INTERRUPT (0x8F)
|
||||
#define LTR553_REG_PS_THRES_UP_0 (0x90)
|
||||
#define LTR553_REG_PS_THRES_UP_1 (0x91)
|
||||
#define LTR553_REG_PS_THRES_LOW_0 (0x92)
|
||||
#define LTR553_REG_PS_THRES_LOW_1 (0x93)
|
||||
#define LTR553_REG_PS_OFFSET_1 (0x94)
|
||||
#define LTR553_REG_PS_OFFSET_0 (0x95)
|
||||
#define LTR553_REG_ALS_THRES_UP_0 (0x97)
|
||||
#define LTR553_REG_ALS_THRES_UP_1 (0x98)
|
||||
#define LTR553_REG_ALS_THRES_LOW_0 (0x99)
|
||||
#define LTR553_REG_ALS_THRES_LOW_1 (0x9A)
|
||||
#define LTR553_REG_INTERRUPT_PERSIST (0x9E)
|
||||
|
||||
|
||||
|
||||
#define LTR553_DEFAULT_MAN_ID (0x05)
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file MPU6886Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define MPU6886_SLAVE_ADDRESS (0x68)
|
||||
|
||||
#define MPU6886_REG_XG_OFFS_TC_H (0x04)
|
||||
#define MPU6886_REG_XG_OFFS_TC_L (0x05)
|
||||
#define MPU6886_REG_YG_OFFS_TC_H (0x07)
|
||||
#define MPU6886_REG_YG_OFFS_TC_L (0x08)
|
||||
#define MPU6886_REG_ZG_OFFS_TC_H (0x0A)
|
||||
#define MPU6886_REG_ZG_OFFS_TC_L (0x0B)
|
||||
#define MPU6886_REG_SELF_TEST_X_ACCEL (0x0D)
|
||||
#define MPU6886_REG_SELF_TEST_Y_ACCEL (0x0E)
|
||||
#define MPU6886_REG_SELF_TEST_Z_ACCEL (0x0F)
|
||||
#define MPU6886_REG_XG_OFFS_USRH (0x13)
|
||||
#define MPU6886_REG_XG_OFFS_USRL (0x14)
|
||||
#define MPU6886_REG_YG_OFFS_USRH (0x15)
|
||||
#define MPU6886_REG_YG_OFFS_USRL (0x16)
|
||||
#define MPU6886_REG_ZG_OFFS_USRH (0x17)
|
||||
#define MPU6886_REG_ZG_OFFS_USRL (0x18)
|
||||
#define MPU6886_REG_SMPLRT_DIV (0x19)
|
||||
#define MPU6886_REG_CONFIG (0x1A)
|
||||
#define MPU6886_REG_GYRO_CONFIG (0x1B)
|
||||
#define MPU6886_REG_ACCEL_CONFIG (0x1C)
|
||||
#define MPU6886_REG_ACCEL_CONFIG_2 (0x1D)
|
||||
#define MPU6886_REG_LP_MODE_CFG (0x1E)
|
||||
#define MPU6886_REG_ACCEL_WOM_X_THR (0x20)
|
||||
#define MPU6886_REG_ACCEL_WOM_Y_THR (0x21)
|
||||
#define MPU6886_REG_ACCEL_WOM_Z_THR (0x22)
|
||||
#define MPU6886_REG_FIFO_EN (0x23)
|
||||
#define MPU6886_REG_FSYNC_INT (0x36)
|
||||
#define MPU6886_REG_INT_PIN_CFG (0x37)
|
||||
#define MPU6886_REG_INT_ENABLE (0x38)
|
||||
#define MPU6886_REG_FIFO_WM_INT_STATUS (0x39)
|
||||
#define MPU6886_REG_INT_STATUS (0x3A)
|
||||
#define MPU6886_REG_ACCEL_XOUT_H (0x3B)
|
||||
#define MPU6886_REG_ACCEL_XOUT_L (0x3C)
|
||||
#define MPU6886_REG_ACCEL_YOUT_H (0x3D)
|
||||
#define MPU6886_REG_ACCEL_YOUT_L (0x3E)
|
||||
#define MPU6886_REG_ACCEL_ZOUT_H (0x3F)
|
||||
#define MPU6886_REG_ACCEL_ZOUT_L (0x40)
|
||||
#define MPU6886_REG_TEMP_OUT_H (0x41)
|
||||
#define MPU6886_REG_TEMP_OUT_L (0x42)
|
||||
#define MPU6886_REG_GYRO_XOUT_H (0x43)
|
||||
#define MPU6886_REG_GYRO_XOUT_L (0x44)
|
||||
#define MPU6886_REG_GYRO_YOUT_H (0x45)
|
||||
#define MPU6886_REG_GYRO_YOUT_L (0x46)
|
||||
#define MPU6886_REG_GYRO_ZOUT_H (0x47)
|
||||
#define MPU6886_REG_GYRO_ZOUT_L (0x48)
|
||||
#define MPU6886_REG_SELF_TEST_X_GYRO (0x50)
|
||||
#define MPU6886_REG_SELF_TEST_Y_GYRO (0x51)
|
||||
#define MPU6886_REG_SELF_TEST_Z_GYRO (0x52)
|
||||
#define MPU6886_REG_E_ID0 (0x53)
|
||||
#define MPU6886_REG_E_ID1 (0x54)
|
||||
#define MPU6886_REG_E_ID2 (0x55)
|
||||
#define MPU6886_REG_E_ID3 (0x56)
|
||||
#define MPU6886_REG_E_ID4 (0x57)
|
||||
#define MPU6886_REG_E_ID5 (0x58)
|
||||
#define MPU6886_REG_E_ID6 (0x59)
|
||||
#define MPU6886_REG_FIFO_WM_TH1 (0x60)
|
||||
#define MPU6886_REG_FIFO_WM_TH2 (0x61)
|
||||
#define MPU6886_REG_SIGNAL_PATH_RESET (0x68)
|
||||
#define MPU6886_REG_ACCEL_INTEL_CTRL (0x69)
|
||||
#define MPU6886_REG_USER_CTRL (0x6A)
|
||||
#define MPU6886_REG_PWR_MGMT_1 (0x6B)
|
||||
#define MPU6886_REG_PWR_MGMT_2 (0x6C)
|
||||
#define MPU6886_REG_I2C_IF (0x70)
|
||||
#define MPU6886_REG_FIFO_COUNTH (0x72)
|
||||
#define MPU6886_REG_FIFO_COUNTL (0x73)
|
||||
#define MPU6886_REG_FIFO_R_W (0x74)
|
||||
#define MPU6886_REG_WHO_AM_I (0x75)
|
||||
#define MPU6886_REG_XA_OFFSET_H (0x77)
|
||||
#define MPU6886_REG_XA_OFFSET_L (0x78)
|
||||
#define MPU6886_REG_YA_OFFSET_H (0x7A)
|
||||
#define MPU6886_REG_YA_OFFSET_L (0x7B)
|
||||
#define MPU6886_REG_ZA_OFFSET_H (0x7D)
|
||||
#define MPU6886_REG_ZA_OFFSET_L (0x7E)
|
||||
|
||||
|
||||
#define MPU6886_WHO_AM_I_RES (0x19)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF85063Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-07
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define PCF85063_SLAVE_ADDRESS (0x51)
|
||||
|
||||
#define PCF85063_CTRL1_REG (0x00)
|
||||
#define PCF85063_CTRL2_REG (0x01)
|
||||
#define PCF85063_OFFSET_REG (0x02)
|
||||
#define PCF85063_RAM_REG (0x03)
|
||||
#define PCF85063_SEC_REG (0x04)
|
||||
#define PCF85063_MIN_REG (0x05)
|
||||
#define PCF85063_HR_REG (0x06)
|
||||
#define PCF85063_DAY_REG (0x07)
|
||||
#define PCF85063_WEEKDAY_REG (0x08)
|
||||
#define PCF85063_MONTH_REG (0x09)
|
||||
#define PCF85063_YEAR_REG (0x0A)
|
||||
#define PCF85063_ALRM_SEC_REG (0x0B)
|
||||
#define PCF85063_ALRM_MIN_REG (0x0C)
|
||||
#define PCF85063_ALRM_HR_REG (0x0D)
|
||||
#define PCF85063_ALRM_DAY_REG (0x0E)
|
||||
#define PCF85063_ALRM_WEEK_REG (0x0F)
|
||||
#define PCF85063_TIMER_VAL_REG (0x10)
|
||||
#define PCF85063_TIMER_MD_REG (0x11)
|
||||
|
||||
#define PCF85063_CTRL1_TEST_EN_MASK (1<<7u)
|
||||
#define PCF85063_CTRL1_CLOCK_EN_MASK (1<<5u)
|
||||
#define PCF85063_CTRL1_SOFTRST_EN_MASK (1<<4u)
|
||||
#define PCF85063_CTRL1_CIE_EN_MASK (1<<2u)
|
||||
#define PCF85063_CTRL1_HOUR_FORMAT_12H_MASK (1<<1u)
|
||||
|
||||
|
||||
#define PCF85063_NO_ALARM (0xFF)
|
||||
#define PCF85063_ALARM_ENABLE (0x80)
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file PCF8563Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-12-09
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define PCF8563_SLAVE_ADDRESS (0x51)
|
||||
|
||||
#define PCF8563_STAT1_REG (0x00)
|
||||
#define PCF8563_STAT2_REG (0x01)
|
||||
#define PCF8563_SEC_REG (0x02)
|
||||
#define PCF8563_MIN_REG (0x03)
|
||||
#define PCF8563_HR_REG (0x04)
|
||||
#define PCF8563_DAY_REG (0x05)
|
||||
#define PCF8563_WEEKDAY_REG (0x06)
|
||||
#define PCF8563_MONTH_REG (0x07)
|
||||
#define PCF8563_YEAR_REG (0x08)
|
||||
#define PCF8563_ALRM_MIN_REG (0x09)
|
||||
#define PCF8563_SQW_REG (0x0D)
|
||||
#define PCF8563_TIMER1_REG (0x0E)
|
||||
#define PCF8563_TIMER2_REG (0x0F)
|
||||
|
||||
#define PCF8563_VOL_LOW_MASK (0x80)
|
||||
#define PCF8563_MINUTES_MASK (0x7F)
|
||||
#define PCF8563_HOUR_MASK (0x3F)
|
||||
#define PCF8563_WEEKDAY_MASK (0x07)
|
||||
#define PCF8563_CENTURY_MASK (0x80)
|
||||
#define PCF8563_DAY_MASK (0x3F)
|
||||
#define PCF8563_MONTH_MASK (0x1F)
|
||||
#define PCF8563_TIMER_CTL_MASK (0x03)
|
||||
|
||||
|
||||
#define PCF8563_ALARM_AF (0x08)
|
||||
#define PCF8563_TIMER_TF (0x04)
|
||||
#define PCF8563_ALARM_AIE (0x02)
|
||||
#define PCF8563_TIMER_TIE (0x01)
|
||||
#define PCF8563_TIMER_TE (0x80)
|
||||
#define PCF8563_TIMER_TD10 (0x03)
|
||||
|
||||
#define PCF8563_NO_ALARM (0xFF)
|
||||
#define PCF8563_ALARM_ENABLE (0x80)
|
||||
#define PCF8563_CLK_ENABLE (0x80)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMC6310Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// @brief device address
|
||||
#define QMC6310_SLAVE_ADDRESS (0x1C)
|
||||
#define QMC6310_DEFAULT_ID (0x80)
|
||||
|
||||
|
||||
#define QMC6310_REG_CHIP_ID (0x00)
|
||||
#define QMC6310_REG_LSB_DX (0X01)
|
||||
#define QMC6310_REG_MSB_DX (0X02)
|
||||
#define QMC6310_REG_LSB_DY (0X03)
|
||||
#define QMC6310_REG_MSB_DY (0X04)
|
||||
#define QMC6310_REG_LSB_DZ (0X05)
|
||||
#define QMC6310_REG_MSB_DZ (0X06)
|
||||
#define QMC6310_REG_STAT (0X09)
|
||||
#define QMC6310_REG_CMD1 (0x0A)
|
||||
#define QMC6310_REG_CMD2 (0x0B)
|
||||
|
||||
|
||||
#define QMC6310_REG_SIGN (0x29)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file QMI8658Constants.h
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2022-10-16
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// @brief device address
|
||||
#define QMI8658_L_SLAVE_ADDRESS (0x6B)
|
||||
#define QMI8658_H_SLAVE_ADDRESS (0x6A)
|
||||
|
||||
|
||||
// @brief registers default value
|
||||
#define QMI8658_REG_WHOAMI_DEFAULT (0x05)
|
||||
#define QMI8658_REG_STATUS_DEFAULT (0x03)
|
||||
#define QMI8658_REG_RESET_DEFAULT (0xB0)
|
||||
|
||||
|
||||
// @brief registers list
|
||||
#define QMI8658_REG_WHOAMI (0x00)
|
||||
#define QMI8658_REG_REVISION (0x01)
|
||||
#define QMI8658_REG_CTRL1 (0x02)
|
||||
#define QMI8658_REG_CTRL2 (0x03)
|
||||
#define QMI8658_REG_CTRL3 (0x04)
|
||||
// #define QMI8658_REG_CTRL4 (0x05)
|
||||
#define QMI8658_REG_CTRL5 (0x06)
|
||||
// #define QMI8658_REG_CTRL6 (0x07)
|
||||
#define QMI8658_REG_CTRL7 (0x08)
|
||||
#define QMI8658_REG_CTRL8 (0x09)
|
||||
#define QMI8658_REG_CTRL9 (0x0A)
|
||||
|
||||
#define QMI8658_REG_CAL1_L (0x0B)
|
||||
#define QMI8658_REG_CAL1_H (0x0C)
|
||||
#define QMI8658_REG_CAL2_L (0x0D)
|
||||
#define QMI8658_REG_CAL2_H (0x0E)
|
||||
#define QMI8658_REG_CAL3_L (0x0F)
|
||||
#define QMI8658_REG_CAL3_H (0x10)
|
||||
#define QMI8658_REG_CAL4_L (0x11)
|
||||
#define QMI8658_REG_CAL4_H (0x12)
|
||||
|
||||
#define QMI8658_REG_FIFOWMKTH (0x13)
|
||||
#define QMI8658_REG_FIFOCTRL (0x14)
|
||||
#define QMI8658_REG_FIFOCOUNT (0x15)
|
||||
#define QMI8658_REG_FIFOSTATUS (0x16)
|
||||
#define QMI8658_REG_FIFODATA (0x17)
|
||||
// #define QMI8658_REG_STATUSI2CM (0x2C)
|
||||
#define QMI8658_REG_STATUSINT (0x2D)
|
||||
#define QMI8658_REG_STATUS0 (0x2E)
|
||||
#define QMI8658_REG_STATUS1 (0x2F)
|
||||
#define QMI8658_REG_TIMESTAMP_L (0x30)
|
||||
#define QMI8658_REG_TIMESTAMP_M (0x31)
|
||||
#define QMI8658_REG_TIMESTAMP_H (0x32)
|
||||
#define QMI8658_REG_TEMPEARTURE_L (0x33)
|
||||
#define QMI8658_REG_TEMPEARTURE_H (0x34)
|
||||
#define QMI8658_REG_AX_L (0x35)
|
||||
#define QMI8658_REG_AX_H (0x36)
|
||||
#define QMI8658_REG_AY_L (0x37)
|
||||
#define QMI8658_REG_AY_H (0x38)
|
||||
#define QMI8658_REG_AZ_L (0x39)
|
||||
#define QMI8658_REG_AZ_H (0x3A)
|
||||
#define QMI8658_REG_GX_L (0x3B)
|
||||
#define QMI8658_REG_GX_H (0x3C)
|
||||
#define QMI8658_REG_GY_L (0x3D)
|
||||
#define QMI8658_REG_GY_H (0x3E)
|
||||
#define QMI8658_REG_GZ_L (0x3F)
|
||||
#define QMI8658_REG_GZ_H (0x40)
|
||||
|
||||
#define QMI8658_REG_COD_STATUS (0x46)
|
||||
|
||||
#define QMI8658_REG_DQW_L (0x49)
|
||||
#define QMI8658_REG_DQW_H (0x4A)
|
||||
#define QMI8658_REG_DQX_L (0x4B)
|
||||
#define QMI8658_REG_DQX_H (0x4C)
|
||||
#define QMI8658_REG_DQY_L (0x4D)
|
||||
#define QMI8658_REG_DQY_H (0x4E)
|
||||
#define QMI8658_REG_DQZ_L (0x4F)
|
||||
#define QMI8658_REG_DQZ_H (0x50)
|
||||
|
||||
#define QMI8658_REG_DVX_L (0x51)
|
||||
#define QMI8658_REG_DVX_H (0x52)
|
||||
#define QMI8658_REG_DVY_L (0x53)
|
||||
#define QMI8658_REG_DVY_H (0x54)
|
||||
#define QMI8658_REG_DVZ_L (0x55)
|
||||
#define QMI8658_REG_DVZ_H (0x56)
|
||||
|
||||
#define QMI8658_REG_TAP_STATUS (0x59)
|
||||
#define QMI8658_REG_PEDO_L (0x5A)
|
||||
#define QMI8658_REG_PEDO_M (0x5B)
|
||||
#define QMI8658_REG_PEDO_H (0x5C)
|
||||
#define QMI8658_REG_RESET (0x60)
|
||||
|
||||
#define QMI8658_REG_RST_RESULT (0x4D)
|
||||
#define QMI8658_REG_RST_RESULT_VAL (0x80)
|
||||
|
||||
#define STATUS0_ACCE_AVAIL (0x01)
|
||||
#define STATUS0_GYRO_AVAIL (0x02)
|
||||
#define QMI8658_ACCEL_LPF_MASK (0xF9)
|
||||
#define QMI8658_GYRO_LPF_MASK (0x9F)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define QMI8658_ACCEL_EN_MASK (0x01)
|
||||
#define QMI8658_GYRO_EN_MASK (0x02)
|
||||
#define QMI8658_ACCEL_GYRO_EN_MASK (0x03)
|
||||
|
||||
|
||||
#define QMI8658_FIFO_MAP_INT1 0x04 // ctrl1
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
// A0, A1, A2 connect to GND
|
||||
#define XL9555_SLAVE_ADDRESS0 (0x20)
|
||||
#define XL9555_SLAVE_ADDRESS1 (0x21)
|
||||
#define XL9555_SLAVE_ADDRESS2 (0x22)
|
||||
#define XL9555_SLAVE_ADDRESS3 (0x23)
|
||||
#define XL9555_SLAVE_ADDRESS4 (0x24)
|
||||
#define XL9555_SLAVE_ADDRESS5 (0x25)
|
||||
#define XL9555_SLAVE_ADDRESS6 (0x26)
|
||||
#define XL9555_SLAVE_ADDRESS7 (0x27)
|
||||
|
||||
// Input Port 0 /R
|
||||
#define XL9555_CTRL_INP0 (0x00)
|
||||
// Input Port 1 /R
|
||||
#define XL9555_CTRL_INP1 (0x01)
|
||||
// Output Port 0 /RW
|
||||
#define XL9555_CTRL_OUTP0 (0x02)
|
||||
// Output Port 1 /RW
|
||||
#define XL9555_CTRL_OUTP1 (0x03)
|
||||
// Polarity Inversion Port 0 /RW
|
||||
#define XL9555_CTRL_PIP0 (0x04)
|
||||
// Polarity Inversion Port 1 /RW
|
||||
#define XL9555_CTRL_PIP1 (0x05)
|
||||
// Configuration Port 0 /RW
|
||||
#define XL9555_CTRL_CFG0 (0x06)
|
||||
// Configuration Port 1 /RW
|
||||
#define XL9555_CTRL_CFG1 (0x07)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2024 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file SensorBHI260AP.cpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2024-05-27
|
||||
*
|
||||
*/
|
||||
#include "SensorBHI260AP.hpp"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
volatile bool SensorBHI260AP::__data_available;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,820 @@
|
||||
/**
|
||||
*
|
||||
* @license MIT License
|
||||
*
|
||||
* Copyright (c) 2022 lewis he
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @file SensorBHI260AP.hpp
|
||||
* @author Lewis He (lewishe@outlook.com)
|
||||
* @date 2023-09-06
|
||||
* @note Most source code references come from the https://github.com/boschsensortec/BHY2-Sensor-API
|
||||
* Simplification for Arduino
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#include "bosch/BoschParse.h"
|
||||
#include "bosch/SensorBhy2Define.h"
|
||||
#include "bosch/firmware/BHI260AP.fw.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class SensorBHI260AP
|
||||
{
|
||||
friend class BoschParse;
|
||||
public:
|
||||
SensorBHI260AP(PLATFORM_WIRE_TYPE &w, int sda = DEFAULT_SDA, int scl = DEFAULT_SCL, uint8_t addr = BHI260AP_SLAVE_ADDRESS_L)
|
||||
{
|
||||
__handler.u.i2c_dev.scl = scl;
|
||||
__handler.u.i2c_dev.sda = sda;
|
||||
__handler.u.i2c_dev.addr = addr;
|
||||
__handler.u.i2c_dev.wire = &w;
|
||||
__handler.intf = SENSORLIB_I2C_INTERFACE;
|
||||
}
|
||||
|
||||
SensorBHI260AP(int cs, int mosi = -1, int miso = -1, int sck = -1,
|
||||
PLATFORM_SPI_TYPE &spi = SPI
|
||||
)
|
||||
{
|
||||
__handler.u.spi_dev.cs = cs;
|
||||
__handler.u.spi_dev.miso = miso;
|
||||
__handler.u.spi_dev.mosi = mosi;
|
||||
__handler.u.spi_dev.sck = sck;
|
||||
__handler.u.spi_dev.spi = &spi;
|
||||
__handler.intf = SENSORLIB_SPI_INTERFACE;
|
||||
}
|
||||
|
||||
~SensorBHI260AP()
|
||||
{
|
||||
deinit();
|
||||
}
|
||||
|
||||
SensorBHI260AP()
|
||||
{
|
||||
memset(&__handler, 0, sizeof(__handler));
|
||||
}
|
||||
|
||||
void setPins(int rst, int irq)
|
||||
{
|
||||
__handler.irq = irq;
|
||||
__handler.rst = rst;
|
||||
|
||||
}
|
||||
|
||||
bool init(PLATFORM_WIRE_TYPE &w, int sda = DEFAULT_SDA, int scl = DEFAULT_SCL, uint8_t addr = BHI260AP_SLAVE_ADDRESS_L)
|
||||
{
|
||||
__handler.u.i2c_dev.scl = scl;
|
||||
__handler.u.i2c_dev.sda = sda;
|
||||
__handler.u.i2c_dev.addr = addr;
|
||||
__handler.u.i2c_dev.wire = &w;
|
||||
__handler.intf = SENSORLIB_I2C_INTERFACE;
|
||||
return initImpl();
|
||||
}
|
||||
|
||||
bool init(
|
||||
PLATFORM_SPI_TYPE &spi,
|
||||
int cs, int mosi = MOSI, int miso = MISO, int sck = SCK)
|
||||
{
|
||||
__handler.u.spi_dev.cs = cs;
|
||||
__handler.u.spi_dev.miso = miso;
|
||||
__handler.u.spi_dev.mosi = mosi;
|
||||
__handler.u.spi_dev.sck = sck;
|
||||
__handler.u.spi_dev.spi = &spi;
|
||||
__handler.intf = SENSORLIB_SPI_INTERFACE;
|
||||
return initImpl();
|
||||
}
|
||||
|
||||
bool init()
|
||||
{
|
||||
return initImpl();
|
||||
}
|
||||
|
||||
void deinit()
|
||||
{
|
||||
if (__pro_buf) {
|
||||
free(__pro_buf);
|
||||
}
|
||||
__pro_buf = NULL;
|
||||
|
||||
if (bhy2) {
|
||||
free(bhy2);
|
||||
bhy2 = NULL;
|
||||
}
|
||||
|
||||
if (__handler.irq != SENSOR_PIN_NONE) {
|
||||
detachInterrupt(__handler.irq);
|
||||
}
|
||||
// end();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
if (__handler.rst != SENSOR_PIN_NONE) {
|
||||
digitalWrite(__handler.rst, HIGH);
|
||||
delay(5);
|
||||
digitalWrite(__handler.rst, LOW);
|
||||
delay(10);
|
||||
digitalWrite(__handler.rst, HIGH);
|
||||
delay(5);
|
||||
}
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
if (!__pro_buf) {
|
||||
return;
|
||||
}
|
||||
if (__handler.irq != SENSOR_PIN_NONE) {
|
||||
if (__data_available) {
|
||||
bhy2_get_and_process_fifo(__pro_buf, __pro_buf_size, bhy2);
|
||||
}
|
||||
} else {
|
||||
bhy2_get_and_process_fifo(__pro_buf, __pro_buf_size, bhy2);
|
||||
}
|
||||
}
|
||||
|
||||
void setBootFormFlash(bool boot_from_flash)
|
||||
{
|
||||
__boot_from_flash = boot_from_flash;
|
||||
}
|
||||
|
||||
bool enablePowerSave()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool disablePowerSave()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void disableInterruptCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
void enableInterruptCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
bhy2_dev *getHandler()
|
||||
{
|
||||
return bhy2;
|
||||
}
|
||||
|
||||
void printSensors(Stream &port)
|
||||
{
|
||||
uint8_t cnt = 0;
|
||||
bool presentBuff[256];
|
||||
|
||||
for (uint16_t i = 0; i < sizeof(bhy2->present_buff); i++) {
|
||||
for (uint8_t j = 0; j < 8; j++) {
|
||||
presentBuff[i * 8 + j] = ((bhy2->present_buff[i] >> j) & 0x01);
|
||||
}
|
||||
}
|
||||
|
||||
port.println("Present sensors: ");
|
||||
for (int i = 0; i < (int)sizeof(presentBuff); i++) {
|
||||
if (presentBuff[i]) {
|
||||
cnt++;
|
||||
port.print(i);
|
||||
port.print(" - ");
|
||||
port.print(get_sensor_name(i));
|
||||
port.println();
|
||||
}
|
||||
}
|
||||
port.printf("Total %u Sensor online .\n", cnt);
|
||||
}
|
||||
|
||||
|
||||
bool printInfo(Stream &stream)
|
||||
{
|
||||
uint16_t kernel_version = 0, user_version = 0;
|
||||
uint16_t rom_version = 0;
|
||||
uint8_t product_id = 0;
|
||||
uint8_t host_status = 0, feat_status = 0;
|
||||
uint8_t boot_status = 0;
|
||||
uint8_t sensor_error;
|
||||
struct bhy2_sensor_info info;
|
||||
|
||||
/* Get product_id */
|
||||
__error_code = (bhy2_get_product_id(&product_id, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_product_id failed!", false);
|
||||
|
||||
/* Get Kernel version */
|
||||
__error_code = (bhy2_get_kernel_version(&kernel_version, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_kernel_version failed!", false);
|
||||
|
||||
/* Get User version */
|
||||
__error_code = (bhy2_get_user_version(&user_version, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_user_version failed!", false);
|
||||
|
||||
/* Get ROM version */
|
||||
__error_code = (bhy2_get_rom_version(&rom_version, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_rom_version failed!", false);
|
||||
|
||||
__error_code = (bhy2_get_host_status(&host_status, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_host_status failed!", false);
|
||||
|
||||
__error_code = (bhy2_get_feature_status(&feat_status, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_feature_status failed!", false);
|
||||
|
||||
stream.printf("Product ID : %02x\n", product_id);
|
||||
stream.printf("Kernel version : %04u\n", kernel_version);
|
||||
stream.printf("User version : %04u\n", user_version);
|
||||
stream.printf("ROM version : %04u\n", rom_version);
|
||||
stream.printf("Power state : %s\n", (host_status & BHY2_HST_POWER_STATE) ? "sleeping" : "active");
|
||||
stream.printf("Host interface : %s\n", (host_status & BHY2_HST_HOST_PROTOCOL) ? "SPI" : "I2C");
|
||||
stream.printf("Feature status : 0x%02x\n", feat_status);
|
||||
|
||||
/* Read boot status */
|
||||
__error_code = (bhy2_get_boot_status(&boot_status, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_boot_status failed!", false);
|
||||
|
||||
stream.printf("Boot Status : 0x%02x: ", boot_status);
|
||||
|
||||
if (boot_status & BHY2_BST_FLASH_DETECTED) {
|
||||
stream.println("\tFlash detected. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_FLASH_VERIFY_DONE) {
|
||||
stream.println("\tFlash verify done. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_FLASH_VERIFY_ERROR) {
|
||||
stream.println("Flash verification failed. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_NO_FLASH) {
|
||||
stream.println("\tNo flash installed. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_INTERFACE_READY) {
|
||||
stream.println("\tHost interface ready. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_FW_VERIFY_DONE) {
|
||||
stream.println("\tFirmware verification done. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_FW_VERIFY_ERROR) {
|
||||
stream.println("\tFirmware verification error. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_FW_IDLE) {
|
||||
stream.println("\tFirmware halted. ");
|
||||
}
|
||||
|
||||
/* Read error value */
|
||||
__error_code = (bhy2_get_error_value(&sensor_error, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_error_value failed!", false);
|
||||
if (sensor_error) {
|
||||
log_e("%s", get_sensor_error_text(sensor_error));
|
||||
}
|
||||
|
||||
|
||||
if (feat_status & BHY2_FEAT_STATUS_OPEN_RTOS_MSK) {
|
||||
|
||||
bhy2_update_virtual_sensor_list(bhy2);
|
||||
|
||||
/* Get present virtual sensor */
|
||||
bhy2_get_virt_sensor_list(bhy2);
|
||||
|
||||
stream.printf("Virtual sensor list.\r\n");
|
||||
stream.printf("Sensor ID | Sensor Name | ID | Ver | Min rate | Max rate |\r\n");
|
||||
stream.printf("----------+--------------------------------------+-----+-----+-----------+-----------|\r\n");
|
||||
for (uint8_t i = 0; i < BHY2_SENSOR_ID_MAX; i++) {
|
||||
if (bhy2_is_sensor_available(i, bhy2)) {
|
||||
if (i < BHY2_SENSOR_ID_CUSTOM_START) {
|
||||
stream.printf(" %8u | %36s ", i, get_sensor_name(i));
|
||||
}
|
||||
__error_code = (bhy2_get_sensor_info(i, &info, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_sensor_info failed!", false);
|
||||
stream.printf("| %3u | %3u | %9.4f | %9.4f |\r\n",
|
||||
info.driver_id,
|
||||
info.driver_version,
|
||||
info.min_rate.f_val,
|
||||
info.max_rate.f_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool setInterruptCtrl(uint8_t data)
|
||||
{
|
||||
__error_code = bhy2_set_host_interrupt_ctrl(data, bhy2);
|
||||
if (__error_code != BHY2_OK) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t getInterruptCtrl()
|
||||
{
|
||||
uint8_t data;
|
||||
__error_code = bhy2_get_host_interrupt_ctrl(&data, bhy2);
|
||||
if (__error_code != BHY2_OK) {
|
||||
return 0;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void printInterruptCtrl(Stream &stream)
|
||||
{
|
||||
uint8_t data;
|
||||
__error_code = bhy2_get_host_interrupt_ctrl(&data, bhy2);
|
||||
if (__error_code != BHY2_OK) {
|
||||
return ;
|
||||
}
|
||||
stream.printf("Host interrupt control\r\n");
|
||||
stream.printf("-- Wake up FIFO %s.\r\n", (data & BHY2_ICTL_DISABLE_FIFO_W) ? "disabled" : "enabled");
|
||||
stream.printf("-- Non wake up FIFO %s.\r\n", (data & BHY2_ICTL_DISABLE_FIFO_NW) ? "disabled" : "enabled");
|
||||
stream.printf("-- Status FIFO %s.\r\n", (data & BHY2_ICTL_DISABLE_STATUS_FIFO) ? "disabled" : "enabled");
|
||||
stream.printf("-- Debugging %s.\r\n", (data & BHY2_ICTL_DISABLE_DEBUG) ? "disabled" : "enabled");
|
||||
stream.printf("-- Fault %s.\r\n", (data & BHY2_ICTL_DISABLE_FAULT) ? "disabled" : "enabled");
|
||||
stream.printf("-- Interrupt is %s.\r\n", (data & BHY2_ICTL_ACTIVE_LOW) ? "active low" : "active high");
|
||||
stream.printf("-- Interrupt is %s triggered.\r\n", (data & BHY2_ICTL_EDGE) ? "pulse" : "level");
|
||||
stream.printf("-- Interrupt pin drive is %s.\r\n", (data & BHY2_ICTL_OPEN_DRAIN) ? "open drain" : "push-pull");
|
||||
}
|
||||
|
||||
bool isReady()
|
||||
{
|
||||
uint8_t boot_status = 0;
|
||||
__error_code = bhy2_get_boot_status(&boot_status, bhy2);
|
||||
log_i("boot_status:0x%x", boot_status);
|
||||
if (__error_code != BHY2_OK) {
|
||||
return false;
|
||||
}
|
||||
return (boot_status & BHY2_BST_HOST_INTERFACE_READY);
|
||||
}
|
||||
|
||||
uint16_t getKernelVersion()
|
||||
{
|
||||
uint16_t version = 0;
|
||||
__error_code = bhy2_get_kernel_version(&version, bhy2);
|
||||
if ((__error_code != BHY2_OK) && (version == 0)) {
|
||||
return 0;
|
||||
}
|
||||
log_d("Boot successful. Kernel version %u.", version);
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void onEvent(BhySensorEvent event_id, BhyEventCb callback)
|
||||
{
|
||||
SensorEventCbList_t newEventHandler;
|
||||
newEventHandler.cb = callback;
|
||||
newEventHandler.event = event_id;
|
||||
BoschParse::bhyEventVector.push_back(newEventHandler);
|
||||
}
|
||||
|
||||
void removeEvent(BhySensorEvent event_id, BhyEventCb callback)
|
||||
{
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
for (uint32_t i = 0; i < BoschParse::bhyEventVector.size(); i++) {
|
||||
SensorEventCbList_t entry = BoschParse::bhyEventVector[i];
|
||||
if (entry.cb == callback && entry.event == event_id) {
|
||||
BoschParse::bhyEventVector.erase(BoschParse::bhyEventVector.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onResultEvent(BhySensorID sensor_id, BhyParseDataCallback callback)
|
||||
{
|
||||
ParseCallBackList_t newEventHandler;
|
||||
newEventHandler.cb = callback;
|
||||
newEventHandler.id = sensor_id;
|
||||
BoschParse::bhyParseEventVector.push_back(newEventHandler);
|
||||
}
|
||||
|
||||
void removeResultEvent(BhySensorID sensor_id, BhyParseDataCallback callback)
|
||||
{
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
for (uint32_t i = 0; i < BoschParse::bhyParseEventVector.size(); i++) {
|
||||
ParseCallBackList_t entry = BoschParse::bhyParseEventVector[i];
|
||||
if (entry.cb == callback && entry.id == sensor_id) {
|
||||
BoschParse::bhyParseEventVector.erase(BoschParse::bhyParseEventVector.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setProcessBufferSize(uint32_t size)
|
||||
{
|
||||
__pro_buf_size = size;
|
||||
}
|
||||
|
||||
|
||||
bool uploadFirmware(const uint8_t *firmware, uint32_t length, bool write2Flash = false)
|
||||
{
|
||||
uint8_t sensor_error;
|
||||
uint8_t boot_status;
|
||||
|
||||
log_i("Upload Firmware ...");
|
||||
|
||||
__error_code = bhy2_get_boot_status(&boot_status, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_boot_status failed!", false);
|
||||
|
||||
if (write2Flash) {
|
||||
if (boot_status & BHY2_BST_FLASH_DETECTED) {
|
||||
uint32_t start_addr = BHY2_FLASH_SECTOR_START_ADDR;
|
||||
uint32_t end_addr = start_addr + length;
|
||||
log_i("Flash detected. Erasing flash to upload firmware");
|
||||
__error_code = bhy2_erase_flash(start_addr, end_addr, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_erase_flash failed!", false);
|
||||
} else {
|
||||
log_e("Flash not detected");
|
||||
return false;
|
||||
}
|
||||
printf("Loading firmware into FLASH.");
|
||||
__error_code = bhy2_upload_firmware_to_flash(firmware, length, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_upload_firmware_to_flash failed!", false);
|
||||
} else {
|
||||
log_i("Loading firmware into RAM.");
|
||||
log_i("upload size = %lu", length);
|
||||
__error_code = bhy2_upload_firmware_to_ram(firmware, length, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_upload_firmware_to_ram failed!", false);
|
||||
}
|
||||
|
||||
log_i("Loading firmware into RAM Done");
|
||||
__error_code = bhy2_get_error_value(&sensor_error, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_error_value failed!", false);
|
||||
if (sensor_error != BHY2_OK) {
|
||||
__error_code = bhy2_get_error_value(&sensor_error, bhy2);
|
||||
log_e("%s", get_sensor_error_text(sensor_error));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (write2Flash) {
|
||||
log_i("Booting from FLASH.");
|
||||
__error_code = bhy2_boot_from_flash(bhy2);
|
||||
} else {
|
||||
log_i("Booting from RAM.");
|
||||
__error_code = bhy2_boot_from_ram(bhy2);
|
||||
}
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2 boot failed!", false);
|
||||
|
||||
__error_code = bhy2_get_error_value(&sensor_error, bhy2);
|
||||
if (sensor_error) {
|
||||
log_e("%s", get_sensor_error_text(sensor_error));
|
||||
return false;
|
||||
}
|
||||
return sensor_error == BHY2_OK;
|
||||
}
|
||||
|
||||
String getError()
|
||||
{
|
||||
String err = get_api_error(__error_code);
|
||||
err += " Code:" + String(__error_code);
|
||||
return err;
|
||||
}
|
||||
|
||||
bool configure(uint8_t sensor_id, float sample_rate, uint32_t report_latency_ms)
|
||||
{
|
||||
if (!bhy2_is_sensor_available(sensor_id, bhy2)) {
|
||||
log_e("Sensor not present"); return false;
|
||||
}
|
||||
__error_code = bhy2_set_virt_sensor_cfg(sensor_id, sample_rate, report_latency_ms, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_set_virt_sensor_cfg failed!", false);
|
||||
log_i("Enable %s at %.2fHz.", get_sensor_name(sensor_id), sample_rate);
|
||||
return true;
|
||||
}
|
||||
|
||||
struct bhy2_virt_sensor_conf getConfigure(uint8_t sensor_id)
|
||||
{
|
||||
bhy2_virt_sensor_conf conf;
|
||||
bhy2_get_virt_sensor_cfg(sensor_id, &conf, bhy2);
|
||||
log_i("range:%u sample_rate:%f latency:%lu sensitivity:%u\n", conf.range, conf.sample_rate, conf.latency, conf.sensitivity);
|
||||
return conf;
|
||||
}
|
||||
|
||||
float getScaling(uint8_t sensor_id)
|
||||
{
|
||||
return get_sensor_default_scaling(sensor_id);
|
||||
}
|
||||
|
||||
void setFirmware(const uint8_t *image, size_t image_len, bool write_flash)
|
||||
{
|
||||
__firmware = image;
|
||||
__firmware_size = image_len;
|
||||
__write_flash = write_flash;
|
||||
}
|
||||
|
||||
static const char *getSensorName(uint8_t sensor_id)
|
||||
{
|
||||
return get_sensor_name(sensor_id);
|
||||
}
|
||||
|
||||
// Get an accuracy report
|
||||
uint8_t getAccuracy()
|
||||
{
|
||||
return __accuracy;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool bootFromFlash()
|
||||
{
|
||||
int8_t rslt;
|
||||
uint8_t boot_status, feat_status;
|
||||
uint8_t error_val = 0;
|
||||
uint16_t tries = 300; /* Wait for up to little over 3s */
|
||||
|
||||
log_d("Waiting for firmware verification to complete");
|
||||
do {
|
||||
__error_code = bhy2_get_boot_status(&boot_status, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_boot_status failed!", false);
|
||||
if (boot_status & BHY2_BST_FLASH_VERIFY_DONE) {
|
||||
break;
|
||||
}
|
||||
delay(10);
|
||||
} while (tries--);
|
||||
|
||||
__error_code = bhy2_get_boot_status(&boot_status, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_boot_status failed!", false);
|
||||
print_boot_status(boot_status);
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_INTERFACE_READY) {
|
||||
|
||||
if (boot_status & BHY2_BST_FLASH_DETECTED) {
|
||||
|
||||
/* If no firmware is running, boot from Flash */
|
||||
log_d("Booting from flash");
|
||||
rslt = bhy2_boot_from_flash(bhy2);
|
||||
if (rslt != BHY2_OK) {
|
||||
log_e("%s. Booting from flash failed.\r\n", get_api_error(rslt));
|
||||
__error_code = bhy2_get_regs(BHY2_REG_ERROR_VALUE, &error_val, 1, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_regs failed!", false);
|
||||
if (error_val) {
|
||||
log_e("%s\r\n", get_sensor_error_text(error_val));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
__error_code = bhy2_get_boot_status(&boot_status, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_boot_status failed!", false);
|
||||
print_boot_status(boot_status);
|
||||
|
||||
if (!(boot_status & BHY2_BST_HOST_INTERFACE_READY)) {
|
||||
/* hub is not ready, need reset hub */
|
||||
log_d("Host interface is not ready, triggering a reset");
|
||||
__error_code = bhy2_soft_reset(bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_soft_reset failed!", false);
|
||||
}
|
||||
|
||||
__error_code = (bhy2_get_feature_status(&feat_status, bhy2));
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "Reading Feature status failed, booting from flash failed!", false);
|
||||
|
||||
} else {
|
||||
log_e("Can't detect external flash");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
log_e("Host interface is not ready");
|
||||
return false;
|
||||
}
|
||||
|
||||
log_d("Booting from flash successful");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void print_boot_status(uint8_t boot_status)
|
||||
{
|
||||
log_d("Boot Status : 0x%02x: ", boot_status);
|
||||
if (boot_status & BHY2_BST_FLASH_DETECTED) {
|
||||
log_d("Flash detected. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_FLASH_VERIFY_DONE) {
|
||||
log_d("Flash verify done. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_FLASH_VERIFY_ERROR) {
|
||||
log_d("Flash verification failed. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_NO_FLASH) {
|
||||
log_d("No flash installed. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_INTERFACE_READY) {
|
||||
log_d("Host interface ready. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_FW_VERIFY_DONE) {
|
||||
log_d("Firmware verification done. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_FW_VERIFY_ERROR) {
|
||||
log_d("Firmware verification error. ");
|
||||
}
|
||||
|
||||
if (boot_status & BHY2_BST_HOST_FW_IDLE) {
|
||||
log_d("Firmware halted. ");
|
||||
}
|
||||
}
|
||||
|
||||
static void handleISR()
|
||||
{
|
||||
__data_available = true;
|
||||
}
|
||||
|
||||
|
||||
bool initImpl()
|
||||
{
|
||||
uint8_t product_id = 0;
|
||||
|
||||
if (__handler.rst != SENSOR_PIN_NONE) {
|
||||
pinMode(__handler.rst, OUTPUT);
|
||||
}
|
||||
|
||||
reset();
|
||||
|
||||
bhy2 = (struct bhy2_dev *)malloc(sizeof(struct bhy2_dev ));
|
||||
BHY2_RLST_CHECK(!bhy2, " Device handler malloc failed!", false);
|
||||
|
||||
switch (__handler.intf) {
|
||||
case BHY2_I2C_INTERFACE:
|
||||
// esp32s3 test I2C maximum read and write is 64 bytes
|
||||
__max_rw_length = 64;
|
||||
BHY2_RLST_CHECK(!__handler.u.i2c_dev.wire, "Wire ptr NULL", false);
|
||||
if (!SensorInterfaces::setup_interfaces(__handler)) {
|
||||
log_e("setup_interfaces failed");
|
||||
return false;
|
||||
}
|
||||
__error_code = bhy2_init(BHY2_I2C_INTERFACE,
|
||||
SensorInterfaces::bhy2_i2c_read,
|
||||
SensorInterfaces::bhy2_i2c_write,
|
||||
SensorInterfaces::bhy2_delay_us,
|
||||
__max_rw_length, &__handler, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_init failed!", false);
|
||||
// __error_code = bhy2_set_host_intf_ctrl(BHY2_I2C_INTERFACE, bhy2);
|
||||
// BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_set_host_intf_ctrl failed!", false);
|
||||
break;
|
||||
|
||||
case BHY2_SPI_INTERFACE:
|
||||
// esp32s3 test SPI maximum read and write is 256 bytes
|
||||
__max_rw_length = 256;
|
||||
BHY2_RLST_CHECK(!__handler.u.spi_dev.spi, "SPI ptr NULL", false);
|
||||
if (!SensorInterfaces::setup_interfaces(__handler)) {
|
||||
log_e("setup_interfaces failed");
|
||||
return false;
|
||||
}
|
||||
__error_code = bhy2_init(BHY2_SPI_INTERFACE,
|
||||
SensorInterfaces::bhy2_spi_read,
|
||||
SensorInterfaces::bhy2_spi_write,
|
||||
SensorInterfaces::bhy2_delay_us,
|
||||
__max_rw_length,
|
||||
&__handler,
|
||||
bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_init failed!", false);
|
||||
// __error_code = bhy2_set_host_intf_ctrl(BHY2_SPI_INTERFACE, bhy2);
|
||||
// BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_set_host_intf_ctrl failed!", false);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
__error_code = bhy2_soft_reset(bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "reset bhy2 failed!", false);
|
||||
|
||||
__error_code = bhy2_get_product_id(&product_id, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_get_product_id failed!", false);
|
||||
|
||||
|
||||
/* Check for a valid product ID */
|
||||
if (product_id != BHY2_PRODUCT_ID) {
|
||||
log_e("Product ID read %X. Expected %X", product_id, BHY2_PRODUCT_ID);
|
||||
return false;
|
||||
} else {
|
||||
log_i("BHI260/BHA260 found. Product ID read %X", product_id);
|
||||
}
|
||||
|
||||
if (!__firmware) {
|
||||
// Default write to ram
|
||||
setFirmware(bhy2_firmware_image, sizeof(bhy2_firmware_image), false);
|
||||
}
|
||||
|
||||
if (__boot_from_flash) {
|
||||
if (!bootFromFlash()) {
|
||||
//** If the boot from flash fails, re-upload the firmware to flash
|
||||
__error_code = bhy2_soft_reset(bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "reset bhy2 failed!", false);
|
||||
|
||||
if (!uploadFirmware(__firmware, __firmware_size, __write_flash)) {
|
||||
log_e("uploadFirmware failed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// ** Upload firmware to RAM
|
||||
if (!uploadFirmware(__firmware, __firmware_size, __write_flash)) {
|
||||
log_e("uploadFirmware failed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t version = getKernelVersion();
|
||||
BHY2_RLST_CHECK(!version, "getKernelVersion failed!", false);
|
||||
log_i("Boot successful. Kernel version %u.", version);
|
||||
|
||||
//Set event callback
|
||||
__error_code = bhy2_register_fifo_parse_callback(BHY2_SYS_ID_META_EVENT, BoschParse::parseMetaEvent, (void *)&__accuracy, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_register_fifo_parse_callback failed!", false);
|
||||
|
||||
__error_code = bhy2_register_fifo_parse_callback(BHY2_SYS_ID_META_EVENT_WU, BoschParse::parseMetaEvent, (void *)&__accuracy, bhy2);
|
||||
BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_register_fifo_parse_callback failed!", false);
|
||||
|
||||
// __error_code = bhy2_register_fifo_parse_callback(BHY2_SYS_ID_DEBUG_MSG, BoschParse::parseDebugMessage, NULL, bhy2);
|
||||
// BHY2_RLST_CHECK(__error_code != BHY2_OK, "bhy2_register_fifo_parse_callback parseDebugMessage failed!", false);
|
||||
|
||||
//Set process buffer
|
||||
#if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32)) && defined(BOARD_HAS_PSRAM)
|
||||
__pro_buf = (uint8_t *)ps_malloc(__pro_buf_size);
|
||||
#else
|
||||
__pro_buf = (uint8_t *)malloc(__pro_buf_size);
|
||||
#endif
|
||||
BHY2_RLST_CHECK(!__pro_buf, "process buffer malloc failed!", false);
|
||||
|
||||
__error_code = bhy2_get_and_process_fifo(__pro_buf, __pro_buf_size, bhy2);
|
||||
if (__error_code != BHY2_OK) {
|
||||
log_e("bhy2_get_and_process_fifo failed");
|
||||
free(__pro_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Update the callback table to enable parsing of sensor hintr_ctrl */
|
||||
bhy2_update_virtual_sensor_list(bhy2);
|
||||
|
||||
/* Get present virtual sensor */
|
||||
bhy2_get_virt_sensor_list(bhy2);
|
||||
|
||||
// Only register valid sensor IDs
|
||||
for (uint8_t i = 0; i < BHY2_SENSOR_ID_MAX; i++) {
|
||||
if (bhy2_is_sensor_available(i, bhy2)) {
|
||||
bhy2_register_fifo_parse_callback(i, BoschParse::parseData, NULL, bhy2);
|
||||
}
|
||||
}
|
||||
|
||||
if (__handler.irq != SENSOR_PIN_NONE) {
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
attachInterrupt((pin_size_t)(__handler.irq), handleISR, (PinStatus )RISING);
|
||||
#elif defined(NRF52840_XXAA) || defined(NRF52832_XXAA) || defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
|
||||
attachInterrupt(__handler.irq, handleISR, RISING);
|
||||
#else
|
||||
#error "Interrupt registration not implemented"
|
||||
#endif
|
||||
}
|
||||
|
||||
return __error_code == BHY2_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
struct bhy2_dev *bhy2 = NULL;
|
||||
SensorLibConfigure __handler;
|
||||
int8_t __error_code;
|
||||
static volatile bool __data_available;
|
||||
uint8_t *__pro_buf = NULL;
|
||||
size_t __pro_buf_size = BHY_PROCESS_BUFFER_SIZE;
|
||||
const uint8_t *__firmware;
|
||||
size_t __firmware_size;
|
||||
bool __write_flash;
|
||||
bool __boot_from_flash;
|
||||
uint16_t __max_rw_length;
|
||||
uint8_t __accuracy; /* Accuracy is reported as a meta event. */
|
||||
};
|
||||
|
||||
|
||||
#endif /*defined(ARDUINO)*/
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user