Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7da4b9885 | ||
|
|
9e25b917f6 | ||
|
|
f247a103d2 | ||
|
|
a9227420e8 | ||
| 6e39ea1fe4 | |||
| 41917ba646 | |||
| e8685549de | |||
| 82fc3204b0 | |||
| e214d215d9 | |||
| 8fb26f494c | |||
| 75627e2b58 | |||
| 0eb12db053 | |||
| cec9d3c0b7 | |||
| 446176b877 | |||
| ad18313705 | |||
| 21512e3030 | |||
| e46483716d | |||
| 51b1a7b88d | |||
| 544c1ea468 | |||
| 6ca93b3035 | |||
| d3ef18cb79 | |||
| a88a16a0d6 | |||
| 1438959ff5 | |||
| 714bc7cfc5 | |||
| fa7479ccf3 | |||
| 413b4a401d | |||
| 8cd841b717 | |||
| 895f56c581 | |||
| b37eea2577 | |||
| 90bde3740b | |||
| 193e46bbda | |||
| 11ba173218 | |||
|
|
cd9ce99e93 | ||
| 97d57b139b | |||
| 0e29f51537 | |||
| 868888ee11 |
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
2024*.txt
|
2024*.txt
|
||||||
test/*
|
test/*
|
||||||
|
*.exe
|
||||||
|
doc/shopping_list.ods
|
||||||
|
|||||||
4
.vscode/arduino.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"board": "arduino:mbed_nano:nano33ble",
|
||||||
|
"sketch": "sender_module_final/sender_module_final.ino"
|
||||||
|
}
|
||||||
493
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,493 @@
|
|||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Arduino",
|
||||||
|
"compilerPath": "/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-w",
|
||||||
|
"-nostdlib"
|
||||||
|
],
|
||||||
|
"intelliSenseMode": "gcc-x64",
|
||||||
|
"includePath": [
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/cores/arduino",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/variants/ARDUINO_NANO33BLE",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/libraries/SPI",
|
||||||
|
"/home/foglar/Arduino/libraries/SD/src",
|
||||||
|
"/home/foglar/Arduino/libraries/Servo/src",
|
||||||
|
"/home/foglar/Arduino/libraries/Arduino_BMI270_BMM150/src",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/libraries/Wire",
|
||||||
|
"/home/foglar/Arduino/libraries/RF24",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/cores/arduino/api/deprecated",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/cores/arduino/api/deprecated-avr-comp",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/arm-none-eabi",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/backward",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/arm-none-eabi/7.2.1/include",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/arm-none-eabi/7.2.1/include-fixed",
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include"
|
||||||
|
],
|
||||||
|
"forcedInclude": [
|
||||||
|
"/home/foglar/.arduino15/packages/arduino/hardware/mbed_nano/4.1.3/cores/arduino/Arduino.h"
|
||||||
|
],
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++11",
|
||||||
|
"defines": [
|
||||||
|
"ARDUINO_ARCH_NRF52840",
|
||||||
|
"ARDUINO=10607",
|
||||||
|
"ARDUINO_ARDUINO_NANO33BLE",
|
||||||
|
"ARDUINO_ARCH_MBED_NANO",
|
||||||
|
"ARDUINO_ARCH_MBED",
|
||||||
|
"ARDUINO_LIBRARY_DISCOVERY_PHASE=0",
|
||||||
|
"__DBL_MIN_EXP__=(-1021)",
|
||||||
|
"__HQ_FBIT__=15",
|
||||||
|
"__FLT32X_MAX_EXP__=1024",
|
||||||
|
"__cpp_attributes=200809",
|
||||||
|
"__UINT_LEAST16_MAX__=0xffff",
|
||||||
|
"__ARM_SIZEOF_WCHAR_T=4",
|
||||||
|
"__ATOMIC_ACQUIRE=2",
|
||||||
|
"__SFRACT_IBIT__=0",
|
||||||
|
"__FLT_MIN__=1.1754943508222875e-38F",
|
||||||
|
"__GCC_IEC_559_COMPLEX=0",
|
||||||
|
"__cpp_aggregate_nsdmi=201304",
|
||||||
|
"__UFRACT_MAX__=0XFFFFP-16UR",
|
||||||
|
"__UINT_LEAST8_TYPE__=unsigned char",
|
||||||
|
"__DQ_FBIT__=63",
|
||||||
|
"__INTMAX_C(c)=c ## LL",
|
||||||
|
"__ULFRACT_FBIT__=32",
|
||||||
|
"__SACCUM_EPSILON__=0x1P-7HK",
|
||||||
|
"__CHAR_BIT__=8",
|
||||||
|
"__USQ_IBIT__=0",
|
||||||
|
"__UINT8_MAX__=0xff",
|
||||||
|
"__ACCUM_FBIT__=15",
|
||||||
|
"__WINT_MAX__=0xffffffffU",
|
||||||
|
"__FLT32_MIN_EXP__=(-125)",
|
||||||
|
"__cpp_static_assert=200410",
|
||||||
|
"__USFRACT_FBIT__=8",
|
||||||
|
"__ORDER_LITTLE_ENDIAN__=1234",
|
||||||
|
"__SIZE_MAX__=0xffffffffU",
|
||||||
|
"__ARM_ARCH_ISA_ARM=1",
|
||||||
|
"__WCHAR_MAX__=0xffffffffU",
|
||||||
|
"__LACCUM_IBIT__=32",
|
||||||
|
"__DBL_DENORM_MIN__=double(4.9406564584124654e-324L)",
|
||||||
|
"__GCC_ATOMIC_CHAR_LOCK_FREE=1",
|
||||||
|
"__GCC_IEC_559=0",
|
||||||
|
"__FLT32X_DECIMAL_DIG__=17",
|
||||||
|
"__FLT_EVAL_METHOD__=0",
|
||||||
|
"__cpp_binary_literals=201304",
|
||||||
|
"__LLACCUM_MAX__=0X7FFFFFFFFFFFFFFFP-31LLK",
|
||||||
|
"__FLT64_DECIMAL_DIG__=17",
|
||||||
|
"__GCC_ATOMIC_CHAR32_T_LOCK_FREE=1",
|
||||||
|
"__FRACT_FBIT__=15",
|
||||||
|
"__cpp_variadic_templates=200704",
|
||||||
|
"__UINT_FAST64_MAX__=0xffffffffffffffffULL",
|
||||||
|
"__SIG_ATOMIC_TYPE__=int",
|
||||||
|
"__UACCUM_FBIT__=16",
|
||||||
|
"__DBL_MIN_10_EXP__=(-307)",
|
||||||
|
"__FINITE_MATH_ONLY__=0",
|
||||||
|
"__ARMEL__=1",
|
||||||
|
"__cpp_variable_templates=201304",
|
||||||
|
"__LFRACT_IBIT__=0",
|
||||||
|
"__GNUC_PATCHLEVEL__=1",
|
||||||
|
"__FLT32_HAS_DENORM__=1",
|
||||||
|
"__LFRACT_MAX__=0X7FFFFFFFP-31LR",
|
||||||
|
"__UINT_FAST8_MAX__=0xffffffffU",
|
||||||
|
"__has_include(STR)=__has_include__(STR)",
|
||||||
|
"__DEC64_MAX_EXP__=385",
|
||||||
|
"__INT8_C(c)=c",
|
||||||
|
"__INT_LEAST8_WIDTH__=8",
|
||||||
|
"__UINT_LEAST64_MAX__=0xffffffffffffffffULL",
|
||||||
|
"__SA_FBIT__=15",
|
||||||
|
"__SHRT_MAX__=0x7fff",
|
||||||
|
"__LDBL_MAX__=1.7976931348623157e+308L",
|
||||||
|
"__FRACT_MAX__=0X7FFFP-15R",
|
||||||
|
"__UFRACT_FBIT__=16",
|
||||||
|
"__UFRACT_MIN__=0.0UR",
|
||||||
|
"__UINT_LEAST8_MAX__=0xff",
|
||||||
|
"__GCC_ATOMIC_BOOL_LOCK_FREE=1",
|
||||||
|
"__UINTMAX_TYPE__=long long unsigned int",
|
||||||
|
"__LLFRACT_EPSILON__=0x1P-63LLR",
|
||||||
|
"__DEC32_EPSILON__=1E-6DF",
|
||||||
|
"__FLT_EVAL_METHOD_TS_18661_3__=0",
|
||||||
|
"__CHAR_UNSIGNED__=1",
|
||||||
|
"__UINT32_MAX__=0xffffffffUL",
|
||||||
|
"__GXX_EXPERIMENTAL_CXX0X__=1",
|
||||||
|
"__ULFRACT_MAX__=0XFFFFFFFFP-32ULR",
|
||||||
|
"__TA_IBIT__=64",
|
||||||
|
"__LDBL_MAX_EXP__=1024",
|
||||||
|
"__WINT_MIN__=0U",
|
||||||
|
"__INT_LEAST16_WIDTH__=16",
|
||||||
|
"__ULLFRACT_MIN__=0.0ULLR",
|
||||||
|
"__SCHAR_MAX__=0x7f",
|
||||||
|
"__WCHAR_MIN__=0U",
|
||||||
|
"__INT64_C(c)=c ## LL",
|
||||||
|
"__DBL_DIG__=15",
|
||||||
|
"__GCC_ATOMIC_POINTER_LOCK_FREE=1",
|
||||||
|
"__LLACCUM_MIN__=(-0X1P31LLK-0X1P31LLK)",
|
||||||
|
"__SIZEOF_INT__=4",
|
||||||
|
"__SIZEOF_POINTER__=4",
|
||||||
|
"__GCC_ATOMIC_CHAR16_T_LOCK_FREE=1",
|
||||||
|
"__USACCUM_IBIT__=8",
|
||||||
|
"__USER_LABEL_PREFIX__",
|
||||||
|
"__STDC_HOSTED__=1",
|
||||||
|
"__LDBL_HAS_INFINITY__=1",
|
||||||
|
"__LFRACT_MIN__=(-0.5LR-0.5LR)",
|
||||||
|
"__HA_IBIT__=8",
|
||||||
|
"__FLT32_DIG__=6",
|
||||||
|
"__TQ_IBIT__=0",
|
||||||
|
"__FLT_EPSILON__=1.1920928955078125e-7F",
|
||||||
|
"__APCS_32__=1",
|
||||||
|
"__GXX_WEAK__=1",
|
||||||
|
"__SHRT_WIDTH__=16",
|
||||||
|
"__USFRACT_IBIT__=0",
|
||||||
|
"__LDBL_MIN__=2.2250738585072014e-308L",
|
||||||
|
"__FRACT_MIN__=(-0.5R-0.5R)",
|
||||||
|
"__DEC32_MAX__=9.999999E96DF",
|
||||||
|
"__DA_IBIT__=32",
|
||||||
|
"__ARM_SIZEOF_MINIMAL_ENUM=1",
|
||||||
|
"__FLT32X_HAS_INFINITY__=1",
|
||||||
|
"__INT32_MAX__=0x7fffffffL",
|
||||||
|
"__UQQ_FBIT__=8",
|
||||||
|
"__INT_WIDTH__=32",
|
||||||
|
"__SIZEOF_LONG__=4",
|
||||||
|
"__UACCUM_MAX__=0XFFFFFFFFP-16UK",
|
||||||
|
"__UINT16_C(c)=c",
|
||||||
|
"__PTRDIFF_WIDTH__=32",
|
||||||
|
"__DECIMAL_DIG__=17",
|
||||||
|
"__LFRACT_EPSILON__=0x1P-31LR",
|
||||||
|
"__FLT64_EPSILON__=2.2204460492503131e-16F64",
|
||||||
|
"__ULFRACT_MIN__=0.0ULR",
|
||||||
|
"__INTMAX_WIDTH__=64",
|
||||||
|
"__FLT64_MIN_EXP__=(-1021)",
|
||||||
|
"__has_include_next(STR)=__has_include_next__(STR)",
|
||||||
|
"__LDBL_HAS_QUIET_NAN__=1",
|
||||||
|
"__ULACCUM_IBIT__=32",
|
||||||
|
"__FLT64_MANT_DIG__=53",
|
||||||
|
"__UACCUM_EPSILON__=0x1P-16UK",
|
||||||
|
"__GNUC__=7",
|
||||||
|
"__ULLACCUM_MAX__=0XFFFFFFFFFFFFFFFFP-32ULLK",
|
||||||
|
"__GXX_RTTI=1",
|
||||||
|
"__cpp_delegating_constructors=200604",
|
||||||
|
"__HQ_IBIT__=0",
|
||||||
|
"__FLT_HAS_DENORM__=1",
|
||||||
|
"__SIZEOF_LONG_DOUBLE__=8",
|
||||||
|
"__BIGGEST_ALIGNMENT__=8",
|
||||||
|
"__STDC_UTF_16__=1",
|
||||||
|
"__FLT64_MAX_10_EXP__=308",
|
||||||
|
"__GNUC_STDC_INLINE__=1",
|
||||||
|
"__DQ_IBIT__=0",
|
||||||
|
"__FLT32_HAS_INFINITY__=1",
|
||||||
|
"__DBL_MAX__=double(1.7976931348623157e+308L)",
|
||||||
|
"__ULFRACT_IBIT__=0",
|
||||||
|
"__cpp_raw_strings=200710",
|
||||||
|
"__INT_FAST32_MAX__=0x7fffffff",
|
||||||
|
"__DBL_HAS_INFINITY__=1",
|
||||||
|
"__INT64_MAX__=0x7fffffffffffffffLL",
|
||||||
|
"__ACCUM_IBIT__=16",
|
||||||
|
"__DEC32_MIN_EXP__=(-94)",
|
||||||
|
"__THUMB_INTERWORK__=1",
|
||||||
|
"__INTPTR_WIDTH__=32",
|
||||||
|
"__LACCUM_MAX__=0X7FFFFFFFFFFFFFFFP-31LK",
|
||||||
|
"__FLT32X_HAS_DENORM__=1",
|
||||||
|
"__INT_FAST16_TYPE__=int",
|
||||||
|
"__LDBL_HAS_DENORM__=1",
|
||||||
|
"__cplusplus=201402L",
|
||||||
|
"__cpp_ref_qualifiers=200710",
|
||||||
|
"__DEC128_MAX__=9.999999999999999999999999999999999E6144DL",
|
||||||
|
"__INT_LEAST32_MAX__=0x7fffffffL",
|
||||||
|
"__ARM_PCS=1",
|
||||||
|
"__DEC32_MIN__=1E-95DF",
|
||||||
|
"__ACCUM_MAX__=0X7FFFFFFFP-15K",
|
||||||
|
"__DEPRECATED=1",
|
||||||
|
"__cpp_rvalue_references=200610",
|
||||||
|
"__DBL_MAX_EXP__=1024",
|
||||||
|
"__USACCUM_EPSILON__=0x1P-8UHK",
|
||||||
|
"__WCHAR_WIDTH__=32",
|
||||||
|
"__FLT32_MAX__=3.4028234663852886e+38F32",
|
||||||
|
"__DEC128_EPSILON__=1E-33DL",
|
||||||
|
"__SFRACT_MAX__=0X7FP-7HR",
|
||||||
|
"__FRACT_IBIT__=0",
|
||||||
|
"__PTRDIFF_MAX__=0x7fffffff",
|
||||||
|
"__UACCUM_MIN__=0.0UK",
|
||||||
|
"__UACCUM_IBIT__=16",
|
||||||
|
"__FLT32_HAS_QUIET_NAN__=1",
|
||||||
|
"__GNUG__=7",
|
||||||
|
"__LONG_LONG_MAX__=0x7fffffffffffffffLL",
|
||||||
|
"__SIZEOF_SIZE_T__=4",
|
||||||
|
"__ULACCUM_MAX__=0XFFFFFFFFFFFFFFFFP-32ULK",
|
||||||
|
"__cpp_rvalue_reference=200610",
|
||||||
|
"__cpp_nsdmi=200809",
|
||||||
|
"__SIZEOF_WINT_T__=4",
|
||||||
|
"__LONG_LONG_WIDTH__=64",
|
||||||
|
"__cpp_initializer_lists=200806",
|
||||||
|
"__FLT32_MAX_EXP__=128",
|
||||||
|
"__SA_IBIT__=16",
|
||||||
|
"__ULLACCUM_MIN__=0.0ULLK",
|
||||||
|
"__cpp_hex_float=201603",
|
||||||
|
"__GXX_ABI_VERSION=1011",
|
||||||
|
"__UTA_FBIT__=64",
|
||||||
|
"__SOFTFP__=1",
|
||||||
|
"__FLT_MIN_EXP__=(-125)",
|
||||||
|
"__USFRACT_MAX__=0XFFP-8UHR",
|
||||||
|
"__UFRACT_IBIT__=0",
|
||||||
|
"__cpp_lambdas=200907",
|
||||||
|
"__INT_FAST64_TYPE__=long long int",
|
||||||
|
"__FLT64_DENORM_MIN__=4.9406564584124654e-324F64",
|
||||||
|
"__DBL_MIN__=double(2.2250738585072014e-308L)",
|
||||||
|
"__FLT32X_EPSILON__=2.2204460492503131e-16F32x",
|
||||||
|
"__LACCUM_MIN__=(-0X1P31LK-0X1P31LK)",
|
||||||
|
"__ULLACCUM_FBIT__=32",
|
||||||
|
"__GXX_TYPEINFO_EQUALITY_INLINE=0",
|
||||||
|
"__FLT64_MIN_10_EXP__=(-307)",
|
||||||
|
"__ULLFRACT_EPSILON__=0x1P-64ULLR",
|
||||||
|
"__USES_INITFINI__=1",
|
||||||
|
"__DEC128_MIN__=1E-6143DL",
|
||||||
|
"__REGISTER_PREFIX__",
|
||||||
|
"__UINT16_MAX__=0xffff",
|
||||||
|
"__DBL_HAS_DENORM__=1",
|
||||||
|
"__ACCUM_MIN__=(-0X1P15K-0X1P15K)",
|
||||||
|
"__SQ_IBIT__=0",
|
||||||
|
"__FLT32_MIN__=1.1754943508222875e-38F32",
|
||||||
|
"__UINT8_TYPE__=unsigned char",
|
||||||
|
"__UHA_FBIT__=8",
|
||||||
|
"__NO_INLINE__=1",
|
||||||
|
"__SFRACT_MIN__=(-0.5HR-0.5HR)",
|
||||||
|
"__UTQ_FBIT__=128",
|
||||||
|
"__FLT_MANT_DIG__=24",
|
||||||
|
"__LDBL_DECIMAL_DIG__=17",
|
||||||
|
"__VERSION__=\"7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]\"",
|
||||||
|
"__UINT64_C(c)=c ## ULL",
|
||||||
|
"__ULLFRACT_FBIT__=64",
|
||||||
|
"__cpp_unicode_characters=200704",
|
||||||
|
"__FRACT_EPSILON__=0x1P-15R",
|
||||||
|
"__ULACCUM_MIN__=0.0ULK",
|
||||||
|
"__UDA_FBIT__=32",
|
||||||
|
"__cpp_decltype_auto=201304",
|
||||||
|
"__LLACCUM_EPSILON__=0x1P-31LLK",
|
||||||
|
"__GCC_ATOMIC_INT_LOCK_FREE=1",
|
||||||
|
"__FLT32_MANT_DIG__=24",
|
||||||
|
"__FLOAT_WORD_ORDER__=__ORDER_LITTLE_ENDIAN__",
|
||||||
|
"__USFRACT_MIN__=0.0UHR",
|
||||||
|
"__ULLACCUM_IBIT__=32",
|
||||||
|
"__UQQ_IBIT__=0",
|
||||||
|
"__SCHAR_WIDTH__=8",
|
||||||
|
"__INT32_C(c)=c ## L",
|
||||||
|
"__DEC64_EPSILON__=1E-15DD",
|
||||||
|
"__ORDER_PDP_ENDIAN__=3412",
|
||||||
|
"__DEC128_MIN_EXP__=(-6142)",
|
||||||
|
"__UHQ_FBIT__=16",
|
||||||
|
"__LLACCUM_FBIT__=31",
|
||||||
|
"__FLT32_MAX_10_EXP__=38",
|
||||||
|
"__INT_FAST32_TYPE__=int",
|
||||||
|
"__UINT_LEAST16_TYPE__=short unsigned int",
|
||||||
|
"__INT16_MAX__=0x7fff",
|
||||||
|
"__cpp_rtti=199711",
|
||||||
|
"__SIZE_TYPE__=unsigned int",
|
||||||
|
"__UINT64_MAX__=0xffffffffffffffffULL",
|
||||||
|
"__UDQ_FBIT__=64",
|
||||||
|
"__INT8_TYPE__=signed char",
|
||||||
|
"__cpp_digit_separators=201309",
|
||||||
|
"__ELF__=1",
|
||||||
|
"__ULFRACT_EPSILON__=0x1P-32ULR",
|
||||||
|
"__LLFRACT_FBIT__=63",
|
||||||
|
"__FLT_RADIX__=2",
|
||||||
|
"__INT_LEAST16_TYPE__=short int",
|
||||||
|
"__LDBL_EPSILON__=2.2204460492503131e-16L",
|
||||||
|
"__UINTMAX_C(c)=c ## ULL",
|
||||||
|
"__SACCUM_MAX__=0X7FFFP-7HK",
|
||||||
|
"__SIG_ATOMIC_MAX__=0x7fffffff",
|
||||||
|
"__GCC_ATOMIC_WCHAR_T_LOCK_FREE=1",
|
||||||
|
"__cpp_sized_deallocation=201309",
|
||||||
|
"__VFP_FP__=1",
|
||||||
|
"__SIZEOF_PTRDIFF_T__=4",
|
||||||
|
"__FLT32X_MANT_DIG__=53",
|
||||||
|
"__LACCUM_EPSILON__=0x1P-31LK",
|
||||||
|
"__FLT32X_MIN_EXP__=(-1021)",
|
||||||
|
"__DEC32_SUBNORMAL_MIN__=0.000001E-95DF",
|
||||||
|
"__INT_FAST16_MAX__=0x7fffffff",
|
||||||
|
"__FLT64_DIG__=15",
|
||||||
|
"__UINT_FAST32_MAX__=0xffffffffU",
|
||||||
|
"__UINT_LEAST64_TYPE__=long long unsigned int",
|
||||||
|
"__USACCUM_MAX__=0XFFFFP-8UHK",
|
||||||
|
"__SFRACT_EPSILON__=0x1P-7HR",
|
||||||
|
"__FLT_HAS_QUIET_NAN__=1",
|
||||||
|
"__FLT_MAX_10_EXP__=38",
|
||||||
|
"__LONG_MAX__=0x7fffffffL",
|
||||||
|
"__DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL",
|
||||||
|
"__FLT_HAS_INFINITY__=1",
|
||||||
|
"__cpp_unicode_literals=200710",
|
||||||
|
"__USA_FBIT__=16",
|
||||||
|
"__UINT_FAST16_TYPE__=unsigned int",
|
||||||
|
"__DEC64_MAX__=9.999999999999999E384DD",
|
||||||
|
"__ARM_32BIT_STATE=1",
|
||||||
|
"__INT_FAST32_WIDTH__=32",
|
||||||
|
"__CHAR16_TYPE__=short unsigned int",
|
||||||
|
"__PRAGMA_REDEFINE_EXTNAME=1",
|
||||||
|
"__SIZE_WIDTH__=32",
|
||||||
|
"__INT_LEAST16_MAX__=0x7fff",
|
||||||
|
"__DEC64_MANT_DIG__=16",
|
||||||
|
"__UINT_LEAST32_MAX__=0xffffffffUL",
|
||||||
|
"__SACCUM_FBIT__=7",
|
||||||
|
"__FLT32_DENORM_MIN__=1.4012984643248171e-45F32",
|
||||||
|
"__GCC_ATOMIC_LONG_LOCK_FREE=1",
|
||||||
|
"__SIG_ATOMIC_WIDTH__=32",
|
||||||
|
"__INT_LEAST64_TYPE__=long long int",
|
||||||
|
"__INT16_TYPE__=short int",
|
||||||
|
"__INT_LEAST8_TYPE__=signed char",
|
||||||
|
"__SQ_FBIT__=31",
|
||||||
|
"__DEC32_MAX_EXP__=97",
|
||||||
|
"__ARM_ARCH_ISA_THUMB=1",
|
||||||
|
"__INT_FAST8_MAX__=0x7fffffff",
|
||||||
|
"__ARM_ARCH=4",
|
||||||
|
"__INTPTR_MAX__=0x7fffffff",
|
||||||
|
"__QQ_FBIT__=7",
|
||||||
|
"__cpp_range_based_for=200907",
|
||||||
|
"__UTA_IBIT__=64",
|
||||||
|
"__FLT64_HAS_QUIET_NAN__=1",
|
||||||
|
"__FLT32_MIN_10_EXP__=(-37)",
|
||||||
|
"__EXCEPTIONS=1",
|
||||||
|
"__LDBL_MANT_DIG__=53",
|
||||||
|
"__SFRACT_FBIT__=7",
|
||||||
|
"__SACCUM_MIN__=(-0X1P7HK-0X1P7HK)",
|
||||||
|
"__DBL_HAS_QUIET_NAN__=1",
|
||||||
|
"__FLT64_HAS_INFINITY__=1",
|
||||||
|
"__SIG_ATOMIC_MIN__=(-__SIG_ATOMIC_MAX__ - 1)",
|
||||||
|
"__cpp_return_type_deduction=201304",
|
||||||
|
"__INTPTR_TYPE__=int",
|
||||||
|
"__UINT16_TYPE__=short unsigned int",
|
||||||
|
"__WCHAR_TYPE__=unsigned int",
|
||||||
|
"__SIZEOF_FLOAT__=4",
|
||||||
|
"__USQ_FBIT__=32",
|
||||||
|
"__UINTPTR_MAX__=0xffffffffU",
|
||||||
|
"__INT_FAST64_WIDTH__=64",
|
||||||
|
"__DEC64_MIN_EXP__=(-382)",
|
||||||
|
"__cpp_decltype=200707",
|
||||||
|
"__FLT32_DECIMAL_DIG__=9",
|
||||||
|
"__INT_FAST64_MAX__=0x7fffffffffffffffLL",
|
||||||
|
"__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1",
|
||||||
|
"__FLT_DIG__=6",
|
||||||
|
"__UINT_FAST64_TYPE__=long long unsigned int",
|
||||||
|
"__INT_MAX__=0x7fffffff",
|
||||||
|
"__LACCUM_FBIT__=31",
|
||||||
|
"__USACCUM_MIN__=0.0UHK",
|
||||||
|
"__UHA_IBIT__=8",
|
||||||
|
"__INT64_TYPE__=long long int",
|
||||||
|
"__FLT_MAX_EXP__=128",
|
||||||
|
"__UTQ_IBIT__=0",
|
||||||
|
"__DBL_MANT_DIG__=53",
|
||||||
|
"__cpp_inheriting_constructors=201511",
|
||||||
|
"__INT_LEAST64_MAX__=0x7fffffffffffffffLL",
|
||||||
|
"__DEC64_MIN__=1E-383DD",
|
||||||
|
"__WINT_TYPE__=unsigned int",
|
||||||
|
"__UINT_LEAST32_TYPE__=long unsigned int",
|
||||||
|
"__SIZEOF_SHORT__=2",
|
||||||
|
"__ULLFRACT_IBIT__=0",
|
||||||
|
"__LDBL_MIN_EXP__=(-1021)",
|
||||||
|
"__arm__=1",
|
||||||
|
"__FLT64_MAX__=1.7976931348623157e+308F64",
|
||||||
|
"__UDA_IBIT__=32",
|
||||||
|
"__WINT_WIDTH__=32",
|
||||||
|
"__INT_LEAST8_MAX__=0x7f",
|
||||||
|
"__FLT32X_MAX_10_EXP__=308",
|
||||||
|
"__LFRACT_FBIT__=31",
|
||||||
|
"__WCHAR_UNSIGNED__=1",
|
||||||
|
"__LDBL_MAX_10_EXP__=308",
|
||||||
|
"__ATOMIC_RELAXED=0",
|
||||||
|
"__DBL_EPSILON__=double(2.2204460492503131e-16L)",
|
||||||
|
"__UINT8_C(c)=c",
|
||||||
|
"__FLT64_MAX_EXP__=1024",
|
||||||
|
"__INT_LEAST32_TYPE__=long int",
|
||||||
|
"__SIZEOF_WCHAR_T__=4",
|
||||||
|
"__LLFRACT_MAX__=0X7FFFFFFFFFFFFFFFP-63LLR",
|
||||||
|
"__TQ_FBIT__=127",
|
||||||
|
"__INT_FAST8_TYPE__=int",
|
||||||
|
"__ULLACCUM_EPSILON__=0x1P-32ULLK",
|
||||||
|
"__UHQ_IBIT__=0",
|
||||||
|
"__ARM_FEATURE_COPROC=1",
|
||||||
|
"__LLACCUM_IBIT__=32",
|
||||||
|
"__FLT64_HAS_DENORM__=1",
|
||||||
|
"__FLT32_EPSILON__=1.1920928955078125e-7F32",
|
||||||
|
"__DBL_DECIMAL_DIG__=17",
|
||||||
|
"__STDC_UTF_32__=1",
|
||||||
|
"__INT_FAST8_WIDTH__=32",
|
||||||
|
"__DEC_EVAL_METHOD__=2",
|
||||||
|
"__FLT32X_MAX__=1.7976931348623157e+308F32x",
|
||||||
|
"__TA_FBIT__=63",
|
||||||
|
"__UDQ_IBIT__=0",
|
||||||
|
"__ORDER_BIG_ENDIAN__=4321",
|
||||||
|
"__cpp_runtime_arrays=198712",
|
||||||
|
"__UINT64_TYPE__=long long unsigned int",
|
||||||
|
"__ACCUM_EPSILON__=0x1P-15K",
|
||||||
|
"__UINT32_C(c)=c ## UL",
|
||||||
|
"__INTMAX_MAX__=0x7fffffffffffffffLL",
|
||||||
|
"__cpp_alias_templates=200704",
|
||||||
|
"__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__",
|
||||||
|
"__FLT_DENORM_MIN__=1.4012984643248171e-45F",
|
||||||
|
"__LLFRACT_IBIT__=0",
|
||||||
|
"__INT8_MAX__=0x7f",
|
||||||
|
"__LONG_WIDTH__=32",
|
||||||
|
"__UINT_FAST32_TYPE__=unsigned int",
|
||||||
|
"__CHAR32_TYPE__=long unsigned int",
|
||||||
|
"__FLT_MAX__=3.4028234663852886e+38F",
|
||||||
|
"__cpp_constexpr=201304",
|
||||||
|
"__USACCUM_FBIT__=8",
|
||||||
|
"__INT32_TYPE__=long int",
|
||||||
|
"__SIZEOF_DOUBLE__=8",
|
||||||
|
"__cpp_exceptions=199711",
|
||||||
|
"__FLT_MIN_10_EXP__=(-37)",
|
||||||
|
"__UFRACT_EPSILON__=0x1P-16UR",
|
||||||
|
"__FLT64_MIN__=2.2250738585072014e-308F64",
|
||||||
|
"__INT_LEAST32_WIDTH__=32",
|
||||||
|
"__INTMAX_TYPE__=long long int",
|
||||||
|
"__DEC128_MAX_EXP__=6145",
|
||||||
|
"__FLT32X_HAS_QUIET_NAN__=1",
|
||||||
|
"__ATOMIC_CONSUME=1",
|
||||||
|
"__GNUC_MINOR__=2",
|
||||||
|
"__INT_FAST16_WIDTH__=32",
|
||||||
|
"__UINTMAX_MAX__=0xffffffffffffffffULL",
|
||||||
|
"__DEC32_MANT_DIG__=7",
|
||||||
|
"__FLT32X_DENORM_MIN__=4.9406564584124654e-324F32x",
|
||||||
|
"__HA_FBIT__=7",
|
||||||
|
"__DBL_MAX_10_EXP__=308",
|
||||||
|
"__LDBL_DENORM_MIN__=4.9406564584124654e-324L",
|
||||||
|
"__INT16_C(c)=c",
|
||||||
|
"__cpp_generic_lambdas=201304",
|
||||||
|
"__STDC__=1",
|
||||||
|
"__ARM_ARCH_4T__=1",
|
||||||
|
"__FLT32X_DIG__=15",
|
||||||
|
"__PTRDIFF_TYPE__=int",
|
||||||
|
"__LLFRACT_MIN__=(-0.5LLR-0.5LLR)",
|
||||||
|
"__ATOMIC_SEQ_CST=5",
|
||||||
|
"__DA_FBIT__=31",
|
||||||
|
"__UINT32_TYPE__=long unsigned int",
|
||||||
|
"__FLT32X_MIN_10_EXP__=(-307)",
|
||||||
|
"__UINTPTR_TYPE__=unsigned int",
|
||||||
|
"__USA_IBIT__=16",
|
||||||
|
"__DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD",
|
||||||
|
"__ARM_EABI__=1",
|
||||||
|
"__DEC128_MANT_DIG__=34",
|
||||||
|
"__LDBL_MIN_10_EXP__=(-307)",
|
||||||
|
"__SIZEOF_LONG_LONG__=8",
|
||||||
|
"__ULACCUM_EPSILON__=0x1P-32ULK",
|
||||||
|
"__cpp_user_defined_literals=200809",
|
||||||
|
"__SACCUM_IBIT__=8",
|
||||||
|
"__GCC_ATOMIC_LLONG_LOCK_FREE=1",
|
||||||
|
"__FLT32X_MIN__=2.2250738585072014e-308F32x",
|
||||||
|
"__LDBL_DIG__=15",
|
||||||
|
"__FLT_DECIMAL_DIG__=9",
|
||||||
|
"__UINT_FAST16_MAX__=0xffffffffU",
|
||||||
|
"__GCC_ATOMIC_SHORT_LOCK_FREE=1",
|
||||||
|
"__INT_LEAST64_WIDTH__=64",
|
||||||
|
"__ULLFRACT_MAX__=0XFFFFFFFFFFFFFFFFP-64ULLR",
|
||||||
|
"__UINT_FAST8_TYPE__=unsigned int",
|
||||||
|
"__USFRACT_EPSILON__=0x1P-8UHR",
|
||||||
|
"__ULACCUM_FBIT__=32",
|
||||||
|
"__QQ_IBIT__=0",
|
||||||
|
"__cpp_init_captures=201304",
|
||||||
|
"__ATOMIC_ACQ_REL=4",
|
||||||
|
"__ATOMIC_RELEASE=3",
|
||||||
|
"USBCON"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "enter program name, for example ${workspaceFolder}/a.out",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"ostream": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
190
README.md
@ -1,31 +1,152 @@
|
|||||||
# CobraV2
|
# CobraV2
|
||||||
|
|
||||||
## Installation
|
## Table of contents
|
||||||
|
|
||||||
|
- [CobraV2](#cobrav2)
|
||||||
|
- [Table of contents](#table-of-contents)
|
||||||
|
- [Installation and compilation](#installation-and-compilation)
|
||||||
|
- [TTY listener](#tty-listener)
|
||||||
|
- [Monitoring tool](#monitoring-tool)
|
||||||
|
- [Sender and Reciever](#sender-and-reciever)
|
||||||
|
- [Overview](#overview)
|
||||||
|
- [Schema](#schema)
|
||||||
|
- [Sender](#sender)
|
||||||
|
- [Reciever](#reciever)
|
||||||
|
- [Master](#master)
|
||||||
|
- [Arduino Sender Format](#arduino-sender-format)
|
||||||
|
- [Modules](#modules)
|
||||||
|
- [10 DOF IMU](#10-dof-imu)
|
||||||
|
- [L76K GPS](#l76k-gps)
|
||||||
|
- [NMEA Sentence](#nmea-sentence)
|
||||||
|
- [NRF24L01+](#nrf24l01)
|
||||||
|
- [Wiring](#wiring)
|
||||||
|
- [10 DOF IMU Sensor](#10-dof-imu-sensor)
|
||||||
|
- [L76K GPS Module](#l76k-gps-module)
|
||||||
|
- [NRF24L01+ Module](#nrf24l01-module)
|
||||||
|
- [Issues / features](#issues--features)
|
||||||
|
- [Sender issues](#sender-issues)
|
||||||
|
- [Monitor app issues](#monitor-app-issues)
|
||||||
|
- [Sources](#sources)
|
||||||
|
|
||||||
|
## Installation and compilation
|
||||||
|
|
||||||
|
### TTY listener
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://www.github.com/foglar/cobraV2.git
|
git clone https://www.github.com/foglar/cobraV2.git
|
||||||
|
cd cobraV2/serial_read
|
||||||
|
|
||||||
|
# run or build the code
|
||||||
|
go run .
|
||||||
|
go build .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> You may have to delete `go.mod` file (if you have other go version) and `go mod init` the project.
|
||||||
|
> To install all dependencies you can use `go mod tidy` command or you can mannualy install them by `go get [package]` command.
|
||||||
|
|
||||||
|
### Monitoring tool
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Building serial read code yourself
|
git clone https://www.github.com/foglar/cobraV2.git
|
||||||
cd serial_read
|
cd cobraV2/monitor
|
||||||
go build main.go
|
|
||||||
|
# run or build the code
|
||||||
|
go run .
|
||||||
|
go build .
|
||||||
```
|
```
|
||||||
|
|
||||||
Upload sender and reciever code on the 2 arduino's
|
> [!IMPORTANT]
|
||||||
|
> For cross-compiling you will need to specify a `CC` to compile c-based libraries for pixel2 library.
|
||||||
|
> Example command: `CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build .`
|
||||||
|
> For more information see: [Pixel2 Wiki | Cross Compiling](https://github.com/gopxl/pixel/wiki/%5BWIP%5D-Cross-Compiling)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Sender and Reciever
|
||||||
|
|
||||||
|
Upload sender and reciever code on the 2 arduinos.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Uplading can be done via Arduino IDE or via arduino-cli terminal tool.
|
||||||
|
> Install arduino-ide or arduino-cli on your device, connect the arduino via usb,
|
||||||
|
> and upload the code.
|
||||||
|
|
||||||
|
#### Uplading via arduino-cli
|
||||||
|
|
||||||
|
To upload via arduino-cli connect arduino board to the computer.
|
||||||
|
|
||||||
|
- To get boards fbqn run `arduino-cli board list` command
|
||||||
|
- Then compile your code with `arduino-cli compile -b "fqbn" "path to script"`
|
||||||
|
- Finnaly upload your code to arduino with `arduino-cli upload -b "fqbn" -p "port" "path to script"`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ arduino-cli board list
|
||||||
|
arduino-cli board list
|
||||||
|
Port Protocol Type Board Name FQBN Core
|
||||||
|
/dev/ttyACM0 serial Serial Port (USB) Arduino UNO R4 WiFi arduino:renesas_uno:unor4wifi arduino:renesas_uno
|
||||||
|
|
||||||
|
$ arduino-cli compile -b arduino:renesas_uno:unor4wifi sender_module/
|
||||||
|
|
||||||
|
$ arduino-cli upload -b arduino:renesas_uno:unor4wifi -p /dev/ttyACM0 sender_module/
|
||||||
|
```
|
||||||
|
|
||||||
|
Required library for antenna: [RF24](https://nrf24.github.io/RF24), with arduino-cli you can install it with ```arduino-cli lib install RF24``` or via arduino-ide.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
`reciever_module/` - folder with code for reciver which will send data to the pc
|
`reciever_module/` - folder with code for reciver which will send data to the pc (arduino)
|
||||||
`sender_module/` - folder with code for sender, which transmit data to the reciever and save it on the micro sd card
|
`sender_module/` - folder with code for sender, which transmit data to the reciever and save it on the micro sd card (arduino)
|
||||||
`serial_read/` - read serial input and save it
|
`serial_read/` - read serial input and save it
|
||||||
|
`monitor` - folder with code for monitor which will recieve data and print them into the gui application (pc)
|
||||||
|
`testing/` - other tools and applications
|
||||||
|
|
||||||
|
### Schema
|
||||||
|
|
||||||
|
#### Sender
|
||||||
|
|
||||||
|
- device (arduino uno, arduino nano or arduino micro...) which recieves data from *[10DOF IMU](#10-dof-imu)* and *[L76K GPS](#l76k-gps)*, then it sends them via *[nrf24l01+](#nrf24l01)* in [sender format](#arduino-sender-format) to [reciever](#reciever)
|
||||||
|
|
||||||
|
#### Reciever
|
||||||
|
|
||||||
|
- device (arduino uno r4 wifi, arduino uno or arduino nano...) which recieves data from [sender](#sender) via *[nrf24l01+](#nrf24l01)* and then send them through serial line to the [master device](#master) in the [sender format](#arduino-sender-format)
|
||||||
|
|
||||||
|
#### Master
|
||||||
|
|
||||||
|
- device (pc, notebook, laptop), where the data are processed, parsed, saved and displayed realtime in the application monitor
|
||||||
|
|
||||||
|
### Arduino Sender Format
|
||||||
|
|
||||||
|
- sender sends data via antenna to reciever in this format **$[code of message];[value]\***
|
||||||
|
- in future will be added some other values, like gps and so on
|
||||||
|
|
||||||
|
| Identifier | Message Code | Value | Verificator |
|
||||||
|
| ---------- | ------------ | ---------------- | ----------- |
|
||||||
|
| $ | **1**; | roll [°] | * |
|
||||||
|
| $ | **2**; | pitch [°] | * |
|
||||||
|
| $ | **3**; | yaw [°] | * |
|
||||||
|
| $ | **4**; | temperature [°C] | * |
|
||||||
|
| $ | **5**; | pressure [hPa] | * |
|
||||||
|
| $ | **6**; | altitude [m] | * |
|
||||||
|
| $ | **7**; | gyroscope x | * |
|
||||||
|
| $ | **8**; | gyroscope y | * |
|
||||||
|
| $ | **9**; | gyroscope z | * |
|
||||||
|
| $ | **10**; | accelerometer x | * |
|
||||||
|
| $ | **11**; | accelerometer y | * |
|
||||||
|
| $ | **12**; | accelerometer z | * |
|
||||||
|
| $ | **13**; | magnitude x | * |
|
||||||
|
| $ | **14**; | magnitude y | * |
|
||||||
|
| $ | **15**; | magnitude z | * |
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> The **acceleration output** by the serial port of the sample program is the original value of the register (the value of the register). After this **value is divided by 16384**, it can be **converted** into a **value in g (gravitational acceleration constant)**.
|
||||||
|
> The **angular velocity output** by the serial port of the sample program is the original value of the register (the value of the register). After this **value is divided by 32.8**, it can be converted into a **value in dps (angle/second)**.
|
||||||
|
> The value of the **magnetic sensor output** by the serial port of the sample program is the original value of the register (that is, the value of the register). This **value is multiplied by 0.15** to convert it into a **value in μT (10-6 Tesla)**. [Reference](https://www.waveshare.com/wiki/Template:10_DOF_IMU_Sensor_D_Arduino_Guide#Serial_output_data_meaning)
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
### 10 DOF IMU
|
### 10 DOF IMU
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- **SDA** (Serial Data)
|
- **SDA** (Serial Data)
|
||||||
- **SCL** (Serial Clock)
|
- **SCL** (Serial Clock)
|
||||||
- **INT** (Interrupt) is a digital interrupt output
|
- **INT** (Interrupt) is a digital interrupt output
|
||||||
@ -33,8 +154,6 @@ Upload sender and reciever code on the 2 arduino's
|
|||||||
|
|
||||||
### L76K GPS
|
### L76K GPS
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- **PPS** (Pulse per second) powers a led wich will blink and indicate that GPS is working
|
- **PPS** (Pulse per second) powers a led wich will blink and indicate that GPS is working
|
||||||
- **RX** (UART communication)
|
- **RX** (UART communication)
|
||||||
- **TX** (UART communication)
|
- **TX** (UART communication)
|
||||||
@ -44,22 +163,19 @@ Upload sender and reciever code on the 2 arduino's
|
|||||||
$GPGAA,HHMMSS.SS,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
|
$GPGAA,HHMMSS.SS,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
|
||||||
|
|
||||||
| Sentence Identifier | Time | Latitude | Longtitude | Fix Quality | Number of Satellites | Horizontal Dilution of Precision | Altitude | Height of geoid above WGS84 ellipsoid | Time since last DGPS update | DGPS reference station id | Checksum |
|
| Sentence Identifier | Time | Latitude | Longtitude | Fix Quality | Number of Satellites | Horizontal Dilution of Precision | Altitude | Height of geoid above WGS84 ellipsoid | Time since last DGPS update | DGPS reference station id | Checksum |
|
||||||
| ------ | --------- | --------- | ---------- | - | -- | --- | ----- | ----- | --- | ---- | --- |
|
| ------------------- | --------- | ------------ | ------------- | ----------- | -------------------- | -------------------------------- | -------- | ------------------------------------- | --------------------------- | ------------------------- | -------- |
|
||||||
| $GPGAA | HHMMSS.SS | llll.ll a | yyyyy.yy a | x | xx | x.x | x.x M | x.x M | x.x | xxxx | *hh |
|
| $GPGAA | HHMMSS.SS | llll.ll a | yyyyy.yy a | x | xx | x.x | x.x M | x.x M | x.x | xxxx | *hh |
|
||||||
| $GPGAA | 170834 | 4124.8963, N | 08151.6838, W | 1 | 05 | 1.5 | 280.2, M | -34.0, M | blank | blank | *75 |
|
| $GPGAA | 170834 | 4124.8963, N | 08151.6838, W | 1 | 05 | 1.5 | 280.2, M | -34.0, M | blank | blank | *75 |
|
||||||
|
|
||||||
Fix Quality:
|
> [!TIP]
|
||||||
|
> Fix Quality:
|
||||||
- 0 = Invalid
|
> 0 = Invalid;
|
||||||
- 1 = GPS fix
|
> 1 = GPS fix;
|
||||||
- 2 = DGPS fix
|
> 2 = DGPS fix;
|
||||||
|
> [more about nmea sentences](https://aprs.gids.nl/nmea/)
|
||||||
[more about nmea sentences](https://aprs.gids.nl/nmea/)
|
|
||||||
|
|
||||||
### NRF24L01+
|
### NRF24L01+
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- **CE** (Chip Enable) is an active-high pin. When enabled, the nRF24L01 will either transmit or receive, depending on the mode.
|
- **CE** (Chip Enable) is an active-high pin. When enabled, the nRF24L01 will either transmit or receive, depending on the mode.
|
||||||
- **CSN** (Chip Select Not) is an active-low pin that is typically held HIGH. When this pin goes low, the nRF24L01 begins listening for data on its SPI port and processes it accordingly.
|
- **CSN** (Chip Select Not) is an active-low pin that is typically held HIGH. When this pin goes low, the nRF24L01 begins listening for data on its SPI port and processes it accordingly.
|
||||||
- **SCK** (Serial Clock) accepts clock pulses from the SPI bus master.
|
- **SCK** (Serial Clock) accepts clock pulses from the SPI bus master.
|
||||||
@ -100,6 +216,33 @@ Fix Quality:
|
|||||||
| MOSI | 11~ | SPI master out |
|
| MOSI | 11~ | SPI master out |
|
||||||
| MISO | 12 | SPI master in |
|
| MISO | 12 | SPI master in |
|
||||||
|
|
||||||
|
## Issues / features
|
||||||
|
|
||||||
|
### Sender issues
|
||||||
|
|
||||||
|
- [x] data stops being transmitted from sender after some short period time
|
||||||
|
- [ ] create a version which will send data via **IOT 433MHz LoRa LPWAN SX1278**
|
||||||
|
- [ ] create a communication in both ways, `start`, `stop`, `system health check` commands
|
||||||
|
- [ ] detection of apogeum and recovery system launch
|
||||||
|
- [ ] add timestamps and save everything to sd card
|
||||||
|
- [ ] add gps
|
||||||
|
|
||||||
|
### Monitor app issues
|
||||||
|
|
||||||
|
- [ ] application crash after some period of time, if don't recive any input from serial ports
|
||||||
|
- [ ] gui is not updating until it recieves serial input
|
||||||
|
- [ ] parser should be improved
|
||||||
|
- [ ] sender code should be improved
|
||||||
|
- [x] gui window
|
||||||
|
- [ ] error messages as windows not terminal
|
||||||
|
- [ ] serial monitor setup port and baudrate
|
||||||
|
- [ ] create a gui way of sending commands
|
||||||
|
- [ ] values change colour if they are not what they should be, or what are expected to be
|
||||||
|
- [ ] if recieved data for the parameter don't correspond with our expectations, change colour of the value indicator
|
||||||
|
- [ ] save all recieved data
|
||||||
|
- [ ] special characters
|
||||||
|
- [ ] don't hide the text on refresh
|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
|
|
||||||
Datasheets, documentation and sources
|
Datasheets, documentation and sources
|
||||||
@ -111,5 +254,8 @@ Datasheets, documentation and sources
|
|||||||
- [Waveshare L76K GPS Module - Demo code](https://files.waveshare.com/upload/9/94/L76K_GPS_Module_Arduino.zip)
|
- [Waveshare L76K GPS Module - Demo code](https://files.waveshare.com/upload/9/94/L76K_GPS_Module_Arduino.zip)
|
||||||
- [NRF24L01+ PA/LNA - Arduino guide](https://lastminuteengineers.com/nrf24l01-arduino-wireless-communication/)
|
- [NRF24L01+ PA/LNA - Arduino guide](https://lastminuteengineers.com/nrf24l01-arduino-wireless-communication/)
|
||||||
- [NRF24L01+ Guide - Guide](https://navody.dratek.cz/navody-k-produktum/arduino-wifi-modul-nrf24l01.html)
|
- [NRF24L01+ Guide - Guide](https://navody.dratek.cz/navody-k-produktum/arduino-wifi-modul-nrf24l01.html)
|
||||||
- [NRF24L01+ PA/LNA - Datasheet](nrf24lo1-datasheet.pdf)
|
- [NRF24L01+ PA/LNA - Datasheet](doc/nrf24lo1-datasheet.pdf)
|
||||||
- [NRF24L01+ PA/LNA - Demo code](https://img.gme.cz/files/eshop_data/eshop_data/10/775-034/prg.775-034.1.zip)
|
- [NRF24L01+ PA/LNA - Demo code](https://img.gme.cz/files/eshop_data/eshop_data/10/775-034/prg.775-034.1.zip)
|
||||||
|
- [Pixel2 (go gui library) - Github repository](https://github.com/gopxl/pixel)
|
||||||
|
- [LoraWAN Library](https://github.com/mcci-catena/arduino-lmic)
|
||||||
|
- All other reference materials are in the *doc/* directory
|
||||||
|
|||||||
45
arduino-quick-upload
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source "arduino-ports-enable"
|
||||||
|
|
||||||
|
# Check if a command-line argument is provided and if the path exists
|
||||||
|
if [ "$#" -eq 1 ] && [ -d "$1" ]; then
|
||||||
|
project_path="$1"
|
||||||
|
else
|
||||||
|
# Prompt the user for the project path
|
||||||
|
read -p "Enter the path to your Arduino project directory: " project_path
|
||||||
|
|
||||||
|
# Validate the project path
|
||||||
|
while [ ! -d "$project_path" ]; do
|
||||||
|
echo "Invalid path or path does not exist."
|
||||||
|
read -p "Please enter a valid path to your Arduino project DIRECTORY: " project_path
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the list of connected Arduinos
|
||||||
|
board_list=$(arduino-cli board list)
|
||||||
|
|
||||||
|
# Count the number of connected Arduinos
|
||||||
|
num_arduinos=$(echo "$board_list" | grep -c "Arduino")
|
||||||
|
|
||||||
|
if [ "$num_arduinos" -eq 0 ]; then
|
||||||
|
echo "No Arduino boards found."
|
||||||
|
exit 1
|
||||||
|
elif [ "$num_arduinos" -eq 1 ]; then
|
||||||
|
# If only one Arduino is connected, use it
|
||||||
|
arduino_port=$(echo "$board_list" | grep -oE '/dev/ttyACM[0-9]+')
|
||||||
|
clones_port=$(echo "$board_list" | grep -oE '/dev/ttyUSB[0-9]+')
|
||||||
|
board_type=$(echo "$board_list" | grep "$arduino_port" | awk '{print $(NF-1)}')
|
||||||
|
else
|
||||||
|
# If multiple Arduinos are connected, ask the user to select one
|
||||||
|
echo "Multiple Arduino boards found:"
|
||||||
|
echo "$board_list" | tail -n +2 | awk '{print $1, $NF}'
|
||||||
|
read -p "Please enter the port of the Arduino you want to upload to: " arduino_port
|
||||||
|
board_type=$(
|
||||||
|
echo "$board_list" | grep "$arduino_port" | awk '{print $(NF-1)}'
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compile and upload the project to the selected Arduino
|
||||||
|
arduino-cli compile -b "$board_type" "$project_path"
|
||||||
|
arduino-cli upload ./ -p "$arduino_port" -b "$board_type"
|
||||||
|
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 209 KiB |
80056
doc/ADA247666.pdf
Normal file
BIN
doc/CRC_prirucka_2024.pdf
Normal file
|
Before Width: | Height: | Size: 510 KiB After Width: | Height: | Size: 510 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
doc/Nano.png
Normal file
|
After Width: | Height: | Size: 272 KiB |
BIN
doc/UnoR4Wifi.png
Normal file
|
After Width: | Height: | Size: 458 KiB |
BIN
doc/application_preview_hyprland.png
Normal file
|
After Width: | Height: | Size: 416 KiB |
BIN
doc/application_preview_kde.png
Normal file
|
After Width: | Height: | Size: 125 KiB |
BIN
doc/ds_sx1276-7-8-9_w_app_v7.pdf
Normal file
BIN
doc/lora-device-developer-guide-orange.pdf
Normal file
61
doc/prehled.md
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Czech Rocket Challenge
|
||||||
|
|
||||||
|
## Přehled
|
||||||
|
|
||||||
|
### Role
|
||||||
|
|
||||||
|
**Základní** role
|
||||||
|
|
||||||
|
- Projektový manažer
|
||||||
|
- Avionika (Avionics)
|
||||||
|
- Náklad (Challenge ‐ Payload)
|
||||||
|
- Konstrukce (Structures)
|
||||||
|
- Záchranný systém (Recovery)
|
||||||
|
|
||||||
|
**Vedlejší** role
|
||||||
|
|
||||||
|
- Aerodynamika
|
||||||
|
- Akvizice dílů
|
||||||
|
- Příprava reportu
|
||||||
|
|
||||||
|
### Raketa
|
||||||
|
|
||||||
|
#### Requirements
|
||||||
|
|
||||||
|
- [ ] Motor Prometheus *
|
||||||
|
- [ ] Vnější průměr 60mm
|
||||||
|
- [ ] Centrum tlaku Cp musí být za těžištěm rakety Cg . Minimální aerodynamická stabilita musí být větší než 1,3
|
||||||
|
(pozn.: Cp by mělo být minimálně velikost průměru rakety za Cg ).
|
||||||
|
- [ ] Padák nebo stuha - Spuštění při rychlosti menší než **>15m/s** *
|
||||||
|
- [ ] Rychlost sestupu rakety **5-9m/s**, Satelit **5-15m/s**
|
||||||
|
- [ ] Odpalovací rampa *
|
||||||
|
- [ ] Certifikovaný výškoměr (záloha 1000Kč v den soutěžě) *
|
||||||
|
- [ ] Dokumentace (procedury pro sestavení rakety)
|
||||||
|
- [ ] Výdrž zapnutého systému
|
||||||
|
|
||||||
|
- [Dodatek A motor](./CRC_prirucka_2024.pdf)
|
||||||
|
- [Dodatek E návratový systém](./CRC_prirucka_2024.pdf)
|
||||||
|
- [Dodatek B odpalovací rampa](./CRC_prirucka_2024.pdf)
|
||||||
|
- [Dodatek C výškoměr](./CRC_prirucka_2024.pdf)
|
||||||
|
|
||||||
|
### Timeline
|
||||||
|
|
||||||
|
- [x] Registrace do 29.února, poplatek 300 Kč 42637800/2010 do 10.března
|
||||||
|
- Variabilní symbol: 20240229. Zpráva pro příjemce: Czech Rocket Challenge jméno týmu.
|
||||||
|
|
||||||
|
- [x] Workshop 1 - 9.-10. března
|
||||||
|
- Představení, Pravidla, Zkušenosti
|
||||||
|
- [x] Workshop 2 - 16.-17. března
|
||||||
|
- Práce v programu OpenRocket
|
||||||
|
- [ ] Workshop 3 - 23.-24. března
|
||||||
|
- Zážitky, úspěchy i překážky
|
||||||
|
- [ ] Workshop 4 - 6.-7. dubna
|
||||||
|
- Bezpečná avionika, a recovery systém
|
||||||
|
- [ ] Workshop 5 - 13.-14. dubna
|
||||||
|
- Standardizované testy
|
||||||
|
|
||||||
|
- [ ] Koncepční report - 30. dubna
|
||||||
|
- [ ] Draft finálového reportu - 11. června
|
||||||
|
- [ ] Osobní setkání se soutěžícími
|
||||||
|
- [ ] Finální report - 30. června
|
||||||
|
- [ ] Odpalovací den - 12. července
|
||||||
3
doc/shopping_list.csv
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Waveshare 10 DOF IMU Sensor **(D)**, https://rpishop.cz/orientace-v-prostoru/2100-waveshare-10-dof-imu-sensor-d-gyroskop-akcelerometr-kompasmagnetometr.html, 1, 1199Kč
|
||||||
|
Arduino Uno Rev3 originál, https://rpishop.cz/arduino-uno/1356-arduino-uno-r3.html, 2, 709Kč
|
||||||
|
RF24L01+PA+LNA, https://rpishop.cz/wi-fi-anteny/1800-modul-bezdratoveho-vysilace-a-prijimace-rf24l01palna.html, 2, 128Kč
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#include <SPI.h>
|
|
||||||
#include <nRF24L01.h>
|
|
||||||
#include <RF24.h>
|
|
||||||
RF24 radio(9, 8); // CE, CSN
|
|
||||||
const byte address[6] = "00001"; //address through which two modules communicate
|
|
||||||
void setup() {
|
|
||||||
while (!Serial)
|
|
||||||
;
|
|
||||||
Serial.begin(9600);
|
|
||||||
Serial.println("Reciver init");
|
|
||||||
radio.begin();
|
|
||||||
radio.openReadingPipe(0, address); //set the address
|
|
||||||
radio.startListening(); //Set module as receiver
|
|
||||||
}
|
|
||||||
void loop() {
|
|
||||||
//Read the data if available in buffer
|
|
||||||
if (radio.available()) {
|
|
||||||
char text[32] = { 0 };
|
|
||||||
radio.read(&text, sizeof(text));
|
|
||||||
Serial.println(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4
sender/ISSUES.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Problems
|
||||||
|
|
||||||
|
- Arduino Nano Couldn't power up the sd card reader, need to input 5V to micro SD card reader.
|
||||||
|
- Couldn't make Arduino Nano work with nRF24 - maybe same issue
|
||||||
26
sender/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Sender module
|
||||||
|
|
||||||
|
## Stages of flight
|
||||||
|
|
||||||
|
1. Preflight - Remove before flight button or smthing like that
|
||||||
|
- no communication, blocked parachute ejection, all systems down
|
||||||
|
2. Ready - Signal from groundstation
|
||||||
|
- sys check (modules calibration, battery check, atd...), blocked parachute ejection, wait for launch pin removed, only send data, do not save them
|
||||||
|
3. Launch - Removed pin from the rocket
|
||||||
|
- launch, all systems sending and saving data on sd card
|
||||||
|
4. Apogee - Detected that rocket is in apogee with accelerometer
|
||||||
|
- parachute ejection, all systems working, gps check and height check
|
||||||
|
5. Return - Rocket has no velocity
|
||||||
|
- all not needed systems shutdown/sleep, buzz on, gps sending location, battery check, turn off gyro and accelerometer
|
||||||
|
|
||||||
|
## Modules
|
||||||
|
|
||||||
|
- nRF24L01 - Communication with groundstation
|
||||||
|
- SD card reader - Write all recieved data to the SD card
|
||||||
|
- Buzzer - To find our rocket after launch
|
||||||
|
- Servo motors - Ejection of parachute
|
||||||
|
|
||||||
|
## Tasks
|
||||||
|
|
||||||
|
- send signal of listening
|
||||||
|
- wait for recieve
|
||||||
182
sender/sender_module_final.ino
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
#include <SPI.h>
|
||||||
|
#include <SD.h>
|
||||||
|
#include <Servo.h>
|
||||||
|
#include <Adafruit_MPU6050.h>
|
||||||
|
#include <Adafruit_Sensor.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
const int BUZZER_PIN = 2;
|
||||||
|
const int SERVO_A_PIN = 7;
|
||||||
|
const int CHIP_SELECT = 4;
|
||||||
|
|
||||||
|
// Create objects for modules
|
||||||
|
File dataFile;
|
||||||
|
Servo A;
|
||||||
|
Adafruit_MPU6050 mpu;
|
||||||
|
|
||||||
|
// Flight stages
|
||||||
|
enum FlightStage {
|
||||||
|
READY,
|
||||||
|
ARM,
|
||||||
|
ASCENT,
|
||||||
|
DESCENT,
|
||||||
|
LANDED
|
||||||
|
};
|
||||||
|
|
||||||
|
FlightStage current_stage = READY;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
pinMode(BUZZER_PIN, OUTPUT);
|
||||||
|
digitalWrite(BUZZER_PIN, LOW);
|
||||||
|
|
||||||
|
A.attach(SERVO_A_PIN);
|
||||||
|
A.write(80);
|
||||||
|
current_stage = READY;
|
||||||
|
|
||||||
|
// Initialize MPU6050
|
||||||
|
if (!mpu.begin()) {
|
||||||
|
Serial.println("Failed to find MPU6050 chip");
|
||||||
|
while (1) delay(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
mpu.setAccelerometerRange(MPU6050_RANGE_16_G);
|
||||||
|
mpu.setGyroRange(MPU6050_RANGE_250_DEG);
|
||||||
|
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
switch (current_stage) {
|
||||||
|
case READY:
|
||||||
|
ready_stage();
|
||||||
|
break;
|
||||||
|
case ARM:
|
||||||
|
arm_stage();
|
||||||
|
break;
|
||||||
|
case ASCENT:
|
||||||
|
ascent_stage();
|
||||||
|
break;
|
||||||
|
case DESCENT:
|
||||||
|
descent_stage();
|
||||||
|
break;
|
||||||
|
case LANDED:
|
||||||
|
landed_stage();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void beep() {
|
||||||
|
digitalWrite(BUZZER_PIN, HIGH);
|
||||||
|
delay(1000);
|
||||||
|
digitalWrite(BUZZER_PIN, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ready_stage() {
|
||||||
|
Serial.println("# READY stage");
|
||||||
|
analogWrite(LED_BUILTIN, HIGH);
|
||||||
|
beep();
|
||||||
|
|
||||||
|
Serial.println("# MPU6050 initialized");
|
||||||
|
current_stage = ARM;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_stage() {
|
||||||
|
Serial.println("# ARM stage");
|
||||||
|
beep();
|
||||||
|
beep();
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
bool toggle = false;
|
||||||
|
sensors_event_t a, g, temp;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
mpu.getEvent(&a, &g, &temp);
|
||||||
|
|
||||||
|
float x = a.acceleration.x;
|
||||||
|
float y = a.acceleration.y;
|
||||||
|
float z = a.acceleration.z;
|
||||||
|
|
||||||
|
Serial.print(x); Serial.print(", ");
|
||||||
|
Serial.print(y); Serial.print(", ");
|
||||||
|
Serial.println(z);
|
||||||
|
|
||||||
|
if (x > 1.0) {
|
||||||
|
Serial.println("# Launch Detect");
|
||||||
|
counter++;
|
||||||
|
} else {
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (counter >= 15) {
|
||||||
|
Serial.println("# Launching");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
digitalWrite(LED_BUILTIN, toggle ? HIGH : LOW);
|
||||||
|
toggle = !toggle;
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
current_stage = ASCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ascent_stage() {
|
||||||
|
Serial.println("# ASCENT stage");
|
||||||
|
unsigned long StartTime = millis();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
unsigned long CurrentTime = millis();
|
||||||
|
unsigned long ElapsedTime = CurrentTime - StartTime;
|
||||||
|
Serial.println(ElapsedTime);
|
||||||
|
|
||||||
|
sensors_event_t a, g, temp;
|
||||||
|
mpu.getEvent(&a, &g, &temp);
|
||||||
|
|
||||||
|
// Add orientation failure logic here if needed
|
||||||
|
|
||||||
|
if (ElapsedTime > 9000) {
|
||||||
|
Serial.println("# Apogee detected by time");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
current_stage = DESCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void descent_stage() {
|
||||||
|
Serial.println("# DESCENT stage");
|
||||||
|
A.write(80);
|
||||||
|
delay(1000);
|
||||||
|
A.write(180);
|
||||||
|
|
||||||
|
Serial.println("# Parachute deployed");
|
||||||
|
|
||||||
|
unsigned long StartTime = millis();
|
||||||
|
while (true) {
|
||||||
|
unsigned long CurrentTime = millis();
|
||||||
|
unsigned long ElapsedTime = CurrentTime - StartTime;
|
||||||
|
|
||||||
|
if (ElapsedTime > 300000) {
|
||||||
|
Serial.println("# Landing detected");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
current_stage = LANDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void landed_stage() {
|
||||||
|
while (true) {
|
||||||
|
Serial.println("# LANDED stage");
|
||||||
|
beep();
|
||||||
|
delay(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
sender/shell.nix
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
pkgs ? import <nixpkgs> { },
|
||||||
|
}:
|
||||||
|
pkgs.callPackage (
|
||||||
|
{
|
||||||
|
mkShell,
|
||||||
|
arduino,
|
||||||
|
arduino-cli,
|
||||||
|
arduino-ide
|
||||||
|
}:
|
||||||
|
mkShell {
|
||||||
|
strictDeps = true;
|
||||||
|
nativeBuildInputs = [
|
||||||
|
arduino
|
||||||
|
arduino-cli
|
||||||
|
arduino-ide
|
||||||
|
];
|
||||||
|
}
|
||||||
|
) { }
|
||||||
|
|
||||||
@ -1,743 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file Waveshare_10Dof-D.cpp
|
|
||||||
* @author Waveshare Team
|
|
||||||
* @version V1.0
|
|
||||||
* @date Dec-2018
|
|
||||||
* @brief T
|
|
||||||
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
||||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|
||||||
* TIME. AS A RESULT, WAVESHARE SHALL NOT BE HELD LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|
||||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|
||||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2018 Waveshare</center></h2>
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
#include "Waveshare_10Dof-D.h"
|
|
||||||
#include <Wire.h>
|
|
||||||
|
|
||||||
IMU_ST_SENSOR_DATA gstGyroOffset ={0,0,0};
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void imuAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz);
|
|
||||||
float invSqrt(float x);
|
|
||||||
|
|
||||||
void icm20948init(void);
|
|
||||||
bool icm20948Check(void);
|
|
||||||
void icm20948GyroRead(int16_t* ps16X, int16_t* ps16Y, int16_t* ps16Z);
|
|
||||||
void icm20948AccelRead(int16_t* ps16X, int16_t* ps16Y, int16_t* ps16Z);
|
|
||||||
void icm20948MagRead(int16_t* ps16X, int16_t* ps16Y, int16_t* ps16Z);
|
|
||||||
bool icm20948MagCheck(void);
|
|
||||||
void icm20948CalAvgValue(uint8_t *pIndex, int16_t *pAvgBuffer, int16_t InVal, int32_t *pOutVal);
|
|
||||||
void icm20948GyroOffset(void);
|
|
||||||
void icm20948ReadSecondary(uint8_t u8I2CAddr, uint8_t u8RegAddr, uint8_t u8Len, uint8_t *pu8data);
|
|
||||||
void icm20948WriteSecondary(uint8_t u8I2CAddr, uint8_t u8RegAddr, uint8_t u8data);
|
|
||||||
bool icm20948Check(void);
|
|
||||||
|
|
||||||
bool bmp280Check(void);
|
|
||||||
void bmp280Init(void);
|
|
||||||
/******************************************************************************
|
|
||||||
* interface driver *
|
|
||||||
******************************************************************************/
|
|
||||||
uint8_t I2C_ReadOneByte(uint8_t DevAddr, uint8_t RegAddr)
|
|
||||||
{
|
|
||||||
uint8_t value;
|
|
||||||
|
|
||||||
Wire.beginTransmission(DevAddr);
|
|
||||||
Wire.write((byte)RegAddr);
|
|
||||||
Wire.endTransmission();
|
|
||||||
|
|
||||||
Wire.requestFrom(DevAddr, (byte)1);
|
|
||||||
value = Wire.read();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C_WriteOneByte(uint8_t DevAddr, uint8_t RegAddr, uint8_t value)
|
|
||||||
{
|
|
||||||
Wire.beginTransmission(DevAddr);
|
|
||||||
Wire.write(RegAddr);
|
|
||||||
Wire.write(value);
|
|
||||||
Wire.endTransmission();
|
|
||||||
}
|
|
||||||
/******************************************************************************
|
|
||||||
* IMU module *
|
|
||||||
******************************************************************************/
|
|
||||||
#define Kp 4.50f // proportional gain governs rate of convergence to accelerometer/magnetometer
|
|
||||||
#define Ki 1.0f // integral gain governs rate of convergence of gyroscope biases
|
|
||||||
|
|
||||||
float angles[3];
|
|
||||||
float q0, q1, q2, q3;
|
|
||||||
|
|
||||||
void imuInit(IMU_EN_SENSOR_TYPE *penMotionSensorType, IMU_EN_SENSOR_TYPE *penPressureType)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
Wire.begin();
|
|
||||||
bRet = icm20948Check();
|
|
||||||
if( true == bRet)
|
|
||||||
{
|
|
||||||
*penMotionSensorType = IMU_EN_SENSOR_TYPE_ICM20948;
|
|
||||||
icm20948init();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*penMotionSensorType = IMU_EN_SENSOR_TYPE_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bRet = bmp280Check();
|
|
||||||
if( true == bRet)
|
|
||||||
{
|
|
||||||
*penPressureType = IMU_EN_SENSOR_TYPE_BMP280;
|
|
||||||
bmp280Init();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*penPressureType = IMU_EN_SENSOR_TYPE_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
q0 = 1.0f;
|
|
||||||
q1 = 0.0f;
|
|
||||||
q2 = 0.0f;
|
|
||||||
q3 = 0.0f;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void imuDataGet(IMU_ST_ANGLES_DATA *pstAngles,
|
|
||||||
IMU_ST_SENSOR_DATA *pstGyroRawData,
|
|
||||||
IMU_ST_SENSOR_DATA *pstAccelRawData,
|
|
||||||
IMU_ST_SENSOR_DATA *pstMagnRawData)
|
|
||||||
{
|
|
||||||
float MotionVal[9];
|
|
||||||
int16_t s16Gyro[3], s16Accel[3], s16Magn[3];
|
|
||||||
|
|
||||||
icm20948AccelRead(&s16Accel[0], &s16Accel[1], &s16Accel[2]);
|
|
||||||
icm20948GyroRead(&s16Gyro[0], &s16Gyro[1], &s16Gyro[2]);
|
|
||||||
icm20948MagRead(&s16Magn[0], &s16Magn[1], &s16Magn[2]);
|
|
||||||
|
|
||||||
MotionVal[0]=s16Gyro[0]/32.8;
|
|
||||||
MotionVal[1]=s16Gyro[1]/32.8;
|
|
||||||
MotionVal[2]=s16Gyro[2]/32.8;
|
|
||||||
MotionVal[3]=s16Accel[0];
|
|
||||||
MotionVal[4]=s16Accel[1];
|
|
||||||
MotionVal[5]=s16Accel[2];
|
|
||||||
MotionVal[6]=s16Magn[0];
|
|
||||||
MotionVal[7]=s16Magn[1];
|
|
||||||
MotionVal[8]=s16Magn[2];
|
|
||||||
imuAHRSupdate((float)MotionVal[0] * 0.0175, (float)MotionVal[1] * 0.0175, (float)MotionVal[2] * 0.0175,
|
|
||||||
(float)MotionVal[3], (float)MotionVal[4], (float)MotionVal[5],
|
|
||||||
(float)MotionVal[6], (float)MotionVal[7], MotionVal[8]);
|
|
||||||
|
|
||||||
|
|
||||||
pstAngles->fPitch = asin(-2 * q1 * q3 + 2 * q0* q2)* 57.3; // pitch
|
|
||||||
pstAngles->fRoll = atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1)* 57.3; // roll
|
|
||||||
pstAngles->fYaw = atan2(-2 * q1 * q2 - 2 * q0 * q3, 2 * q2 * q2 + 2 * q3 * q3 - 1) * 57.3;
|
|
||||||
|
|
||||||
pstGyroRawData->s16X = s16Gyro[0];
|
|
||||||
pstGyroRawData->s16Y = s16Gyro[1];
|
|
||||||
pstGyroRawData->s16Z = s16Gyro[2];
|
|
||||||
|
|
||||||
pstAccelRawData->s16X = s16Accel[0];
|
|
||||||
pstAccelRawData->s16Y = s16Accel[1];
|
|
||||||
pstAccelRawData->s16Z = s16Accel[2];
|
|
||||||
|
|
||||||
pstMagnRawData->s16X = s16Magn[0];
|
|
||||||
pstMagnRawData->s16Y = s16Magn[1];
|
|
||||||
pstMagnRawData->s16Z = s16Magn[2];
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void imuAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz)
|
|
||||||
{
|
|
||||||
float norm;
|
|
||||||
float hx, hy, hz, bx, bz;
|
|
||||||
float vx, vy, vz, wx, wy, wz;
|
|
||||||
float exInt = 0.0, eyInt = 0.0, ezInt = 0.0;
|
|
||||||
float ex, ey, ez, halfT = 0.024f;
|
|
||||||
|
|
||||||
float q0q0 = q0 * q0;
|
|
||||||
float q0q1 = q0 * q1;
|
|
||||||
float q0q2 = q0 * q2;
|
|
||||||
float q0q3 = q0 * q3;
|
|
||||||
float q1q1 = q1 * q1;
|
|
||||||
float q1q2 = q1 * q2;
|
|
||||||
float q1q3 = q1 * q3;
|
|
||||||
float q2q2 = q2 * q2;
|
|
||||||
float q2q3 = q2 * q3;
|
|
||||||
float q3q3 = q3 * q3;
|
|
||||||
|
|
||||||
norm = invSqrt(ax * ax + ay * ay + az * az);
|
|
||||||
ax = ax * norm;
|
|
||||||
ay = ay * norm;
|
|
||||||
az = az * norm;
|
|
||||||
|
|
||||||
norm = invSqrt(mx * mx + my * my + mz * mz);
|
|
||||||
mx = mx * norm;
|
|
||||||
my = my * norm;
|
|
||||||
mz = mz * norm;
|
|
||||||
|
|
||||||
// compute reference direction of flux
|
|
||||||
hx = 2 * mx * (0.5f - q2q2 - q3q3) + 2 * my * (q1q2 - q0q3) + 2 * mz * (q1q3 + q0q2);
|
|
||||||
hy = 2 * mx * (q1q2 + q0q3) + 2 * my * (0.5f - q1q1 - q3q3) + 2 * mz * (q2q3 - q0q1);
|
|
||||||
hz = 2 * mx * (q1q3 - q0q2) + 2 * my * (q2q3 + q0q1) + 2 * mz * (0.5f - q1q1 - q2q2);
|
|
||||||
bx = sqrt((hx * hx) + (hy * hy));
|
|
||||||
bz = hz;
|
|
||||||
|
|
||||||
// estimated direction of gravity and flux (v and w)
|
|
||||||
vx = 2 * (q1q3 - q0q2);
|
|
||||||
vy = 2 * (q0q1 + q2q3);
|
|
||||||
vz = q0q0 - q1q1 - q2q2 + q3q3;
|
|
||||||
wx = 2 * bx * (0.5 - q2q2 - q3q3) + 2 * bz * (q1q3 - q0q2);
|
|
||||||
wy = 2 * bx * (q1q2 - q0q3) + 2 * bz * (q0q1 + q2q3);
|
|
||||||
wz = 2 * bx * (q0q2 + q1q3) + 2 * bz * (0.5 - q1q1 - q2q2);
|
|
||||||
|
|
||||||
// error is sum of cross product between reference direction of fields and direction measured by sensors
|
|
||||||
ex = (ay * vz - az * vy) + (my * wz - mz * wy);
|
|
||||||
ey = (az * vx - ax * vz) + (mz * wx - mx * wz);
|
|
||||||
ez = (ax * vy - ay * vx) + (mx * wy - my * wx);
|
|
||||||
|
|
||||||
if(ex != 0.0f && ey != 0.0f && ez != 0.0f)
|
|
||||||
{
|
|
||||||
exInt = exInt + ex * Ki * halfT;
|
|
||||||
eyInt = eyInt + ey * Ki * halfT;
|
|
||||||
ezInt = ezInt + ez * Ki * halfT;
|
|
||||||
|
|
||||||
gx = gx + Kp * ex + exInt;
|
|
||||||
gy = gy + Kp * ey + eyInt;
|
|
||||||
gz = gz + Kp * ez + ezInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
q0 = q0 + (-q1 * gx - q2 * gy - q3 * gz) * halfT;
|
|
||||||
q1 = q1 + (q0 * gx + q2 * gz - q3 * gy) * halfT;
|
|
||||||
q2 = q2 + (q0 * gy - q1 * gz + q3 * gx) * halfT;
|
|
||||||
q3 = q3 + (q0 * gz + q1 * gy - q2 * gx) * halfT;
|
|
||||||
|
|
||||||
norm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3);
|
|
||||||
q0 = q0 * norm;
|
|
||||||
q1 = q1 * norm;
|
|
||||||
q2 = q2 * norm;
|
|
||||||
q3 = q3 * norm;
|
|
||||||
}
|
|
||||||
|
|
||||||
float invSqrt(float x)
|
|
||||||
{
|
|
||||||
float halfx = 0.5f * x;
|
|
||||||
float y = x;
|
|
||||||
|
|
||||||
long i = *(long*)&y; //get bits for floating value
|
|
||||||
i = 0x5f3759df - (i >> 1); //gives initial guss you
|
|
||||||
y = *(float*)&i; //convert bits back to float
|
|
||||||
y = y * (1.5f - (halfx * y * y)); //newtop step, repeating increases accuracy
|
|
||||||
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
/******************************************************************************
|
|
||||||
* icm20948 sensor device *
|
|
||||||
******************************************************************************/
|
|
||||||
void icm20948init(void)
|
|
||||||
{
|
|
||||||
/* user bank 0 register */
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_0);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_PWR_MIGMT_1, REG_VAL_ALL_RGE_RESET);
|
|
||||||
delay(10);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_PWR_MIGMT_1, REG_VAL_RUN_MODE);
|
|
||||||
|
|
||||||
/* user bank 2 register */
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_2);
|
|
||||||
I2C_WriteOneByte( I2C_ADD_ICM20948, REG_ADD_GYRO_SMPLRT_DIV, 0x07);
|
|
||||||
I2C_WriteOneByte( I2C_ADD_ICM20948, REG_ADD_GYRO_CONFIG_1,
|
|
||||||
REG_VAL_BIT_GYRO_DLPCFG_6 | REG_VAL_BIT_GYRO_FS_1000DPS | REG_VAL_BIT_GYRO_DLPF);
|
|
||||||
I2C_WriteOneByte( I2C_ADD_ICM20948, REG_ADD_ACCEL_SMPLRT_DIV_2, 0x07);
|
|
||||||
I2C_WriteOneByte( I2C_ADD_ICM20948, REG_ADD_ACCEL_CONFIG,
|
|
||||||
REG_VAL_BIT_ACCEL_DLPCFG_6 | REG_VAL_BIT_ACCEL_FS_2g | REG_VAL_BIT_ACCEL_DLPF);
|
|
||||||
|
|
||||||
/* user bank 0 register */
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_0);
|
|
||||||
|
|
||||||
delay(100);
|
|
||||||
/* offset */
|
|
||||||
icm20948GyroOffset();
|
|
||||||
|
|
||||||
icm20948MagCheck();
|
|
||||||
|
|
||||||
icm20948WriteSecondary( I2C_ADD_ICM20948_AK09916|I2C_ADD_ICM20948_AK09916_WRITE,
|
|
||||||
REG_ADD_MAG_CNTL2, REG_VAL_MAG_MODE_20HZ);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool icm20948Check(void)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
if(REG_VAL_WIA == I2C_ReadOneByte(I2C_ADD_ICM20948, REG_ADD_WIA))
|
|
||||||
{
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
void icm20948GyroRead(int16_t* ps16X, int16_t* ps16Y, int16_t* ps16Z)
|
|
||||||
{
|
|
||||||
uint8_t u8Buf[6];
|
|
||||||
int16_t s16Buf[3] = {0};
|
|
||||||
uint8_t i;
|
|
||||||
int32_t s32OutBuf[3] = {0};
|
|
||||||
static ICM20948_ST_AVG_DATA sstAvgBuf[3];
|
|
||||||
static int16_t ss16c = 0;
|
|
||||||
ss16c++;
|
|
||||||
|
|
||||||
u8Buf[0]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_GYRO_XOUT_L);
|
|
||||||
u8Buf[1]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_GYRO_XOUT_H);
|
|
||||||
s16Buf[0]= (u8Buf[1]<<8)|u8Buf[0];
|
|
||||||
|
|
||||||
u8Buf[0]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_GYRO_YOUT_L);
|
|
||||||
u8Buf[1]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_GYRO_YOUT_H);
|
|
||||||
s16Buf[1]= (u8Buf[1]<<8)|u8Buf[0];
|
|
||||||
|
|
||||||
u8Buf[0]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_GYRO_ZOUT_L);
|
|
||||||
u8Buf[1]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_GYRO_ZOUT_H);
|
|
||||||
s16Buf[2]= (u8Buf[1]<<8)|u8Buf[0];
|
|
||||||
|
|
||||||
for(i = 0; i < 3; i ++)
|
|
||||||
{
|
|
||||||
icm20948CalAvgValue(&sstAvgBuf[i].u8Index, sstAvgBuf[i].s16AvgBuffer, s16Buf[i], s32OutBuf + i);
|
|
||||||
}
|
|
||||||
*ps16X = s32OutBuf[0] - gstGyroOffset.s16X;
|
|
||||||
*ps16Y = s32OutBuf[1] - gstGyroOffset.s16Y;
|
|
||||||
*ps16Z = s32OutBuf[2] - gstGyroOffset.s16Z;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void icm20948AccelRead(int16_t* ps16X, int16_t* ps16Y, int16_t* ps16Z)
|
|
||||||
{
|
|
||||||
uint8_t u8Buf[2];
|
|
||||||
int16_t s16Buf[3] = {0};
|
|
||||||
uint8_t i;
|
|
||||||
int32_t s32OutBuf[3] = {0};
|
|
||||||
static ICM20948_ST_AVG_DATA sstAvgBuf[3];
|
|
||||||
|
|
||||||
u8Buf[0]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_ACCEL_XOUT_L);
|
|
||||||
u8Buf[1]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_ACCEL_XOUT_H);
|
|
||||||
s16Buf[0]= (u8Buf[1]<<8)|u8Buf[0];
|
|
||||||
|
|
||||||
u8Buf[0]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_ACCEL_YOUT_L);
|
|
||||||
u8Buf[1]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_ACCEL_YOUT_H);
|
|
||||||
s16Buf[1]= (u8Buf[1]<<8)|u8Buf[0];
|
|
||||||
|
|
||||||
u8Buf[0]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_ACCEL_ZOUT_L);
|
|
||||||
u8Buf[1]=I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_ACCEL_ZOUT_H);
|
|
||||||
s16Buf[2]= (u8Buf[1]<<8)|u8Buf[0];
|
|
||||||
|
|
||||||
for(i = 0; i < 3; i ++)
|
|
||||||
{
|
|
||||||
icm20948CalAvgValue(&sstAvgBuf[i].u8Index, sstAvgBuf[i].s16AvgBuffer, s16Buf[i], s32OutBuf + i);
|
|
||||||
}
|
|
||||||
*ps16X = s32OutBuf[0];
|
|
||||||
*ps16Y = s32OutBuf[1];
|
|
||||||
*ps16Z = s32OutBuf[2];
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
void icm20948MagRead(int16_t* ps16X, int16_t* ps16Y, int16_t* ps16Z)
|
|
||||||
{
|
|
||||||
uint8_t counter = 20;
|
|
||||||
uint8_t u8Data[MAG_DATA_LEN];
|
|
||||||
int16_t s16Buf[3] = {0};
|
|
||||||
uint8_t i;
|
|
||||||
int32_t s32OutBuf[3] = {0};
|
|
||||||
static ICM20948_ST_AVG_DATA sstAvgBuf[3];
|
|
||||||
while( counter>0 )
|
|
||||||
{
|
|
||||||
delay(10);
|
|
||||||
icm20948ReadSecondary( I2C_ADD_ICM20948_AK09916|I2C_ADD_ICM20948_AK09916_READ,
|
|
||||||
REG_ADD_MAG_ST2, 1, u8Data);
|
|
||||||
|
|
||||||
if ((u8Data[0] & 0x01) != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
counter--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(counter != 0)
|
|
||||||
{
|
|
||||||
icm20948ReadSecondary( I2C_ADD_ICM20948_AK09916|I2C_ADD_ICM20948_AK09916_READ,
|
|
||||||
REG_ADD_MAG_DATA,
|
|
||||||
MAG_DATA_LEN,
|
|
||||||
u8Data);
|
|
||||||
s16Buf[0] = ((int16_t)u8Data[1]<<8) | u8Data[0];
|
|
||||||
s16Buf[1] = ((int16_t)u8Data[3]<<8) | u8Data[2];
|
|
||||||
s16Buf[2] = ((int16_t)u8Data[5]<<8) | u8Data[4];
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < 3; i ++)
|
|
||||||
{
|
|
||||||
icm20948CalAvgValue(&sstAvgBuf[i].u8Index, sstAvgBuf[i].s16AvgBuffer, s16Buf[i], s32OutBuf + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
*ps16X = s32OutBuf[0];
|
|
||||||
*ps16Y = -s32OutBuf[1];
|
|
||||||
*ps16Z = -s32OutBuf[2];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void icm20948ReadSecondary(uint8_t u8I2CAddr, uint8_t u8RegAddr, uint8_t u8Len, uint8_t *pu8data)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t u8Temp;
|
|
||||||
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_3); //swtich bank3
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV0_ADDR, u8I2CAddr);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV0_REG, u8RegAddr);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV0_CTRL, REG_VAL_BIT_SLV0_EN|u8Len);
|
|
||||||
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_0); //swtich bank0
|
|
||||||
|
|
||||||
u8Temp = I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_USER_CTRL);
|
|
||||||
u8Temp |= REG_VAL_BIT_I2C_MST_EN;
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_USER_CTRL, u8Temp);
|
|
||||||
delay(5);
|
|
||||||
u8Temp &= ~REG_VAL_BIT_I2C_MST_EN;
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_USER_CTRL, u8Temp);
|
|
||||||
|
|
||||||
for(i=0; i<u8Len; i++)
|
|
||||||
{
|
|
||||||
*(pu8data+i) = I2C_ReadOneByte(I2C_ADD_ICM20948, REG_ADD_EXT_SENS_DATA_00+i);
|
|
||||||
|
|
||||||
}
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_3); //swtich bank3
|
|
||||||
|
|
||||||
u8Temp = I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_I2C_SLV0_CTRL);
|
|
||||||
u8Temp &= ~((REG_VAL_BIT_I2C_MST_EN)&(REG_VAL_BIT_MASK_LEN));
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV0_CTRL, u8Temp);
|
|
||||||
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_0); //swtich bank0
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void icm20948WriteSecondary(uint8_t u8I2CAddr, uint8_t u8RegAddr, uint8_t u8data)
|
|
||||||
{
|
|
||||||
uint8_t u8Temp;
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_3); //swtich bank3
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV1_ADDR, u8I2CAddr);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV1_REG, u8RegAddr);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV1_DO, u8data);
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV1_CTRL, REG_VAL_BIT_SLV0_EN|1);
|
|
||||||
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_0); //swtich bank0
|
|
||||||
|
|
||||||
u8Temp = I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_USER_CTRL);
|
|
||||||
u8Temp |= REG_VAL_BIT_I2C_MST_EN;
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_USER_CTRL, u8Temp);
|
|
||||||
delay(5);
|
|
||||||
u8Temp &= ~REG_VAL_BIT_I2C_MST_EN;
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_USER_CTRL, u8Temp);
|
|
||||||
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_3); //swtich bank3
|
|
||||||
|
|
||||||
u8Temp = I2C_ReadOneByte(I2C_ADD_ICM20948,REG_ADD_I2C_SLV0_CTRL);
|
|
||||||
u8Temp &= ~((REG_VAL_BIT_I2C_MST_EN)&(REG_VAL_BIT_MASK_LEN));
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_I2C_SLV0_CTRL, u8Temp);
|
|
||||||
|
|
||||||
I2C_WriteOneByte(I2C_ADD_ICM20948, REG_ADD_REG_BANK_SEL, REG_VAL_REG_BANK_0); //swtich bank0
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void icm20948CalAvgValue(uint8_t *pIndex, int16_t *pAvgBuffer, int16_t InVal, int32_t *pOutVal)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
*(pAvgBuffer + ((*pIndex) ++)) = InVal;
|
|
||||||
*pIndex &= 0x07;
|
|
||||||
|
|
||||||
*pOutVal = 0;
|
|
||||||
for(i = 0; i < 8; i ++)
|
|
||||||
{
|
|
||||||
*pOutVal += *(pAvgBuffer + i);
|
|
||||||
}
|
|
||||||
*pOutVal >>= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
void icm20948GyroOffset(void)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
int16_t s16Gx = 0, s16Gy = 0, s16Gz = 0;
|
|
||||||
int32_t s32TempGx = 0, s32TempGy = 0, s32TempGz = 0;
|
|
||||||
for(i = 0; i < 32; i ++)
|
|
||||||
{
|
|
||||||
icm20948GyroRead(&s16Gx, &s16Gy, &s16Gz);
|
|
||||||
s32TempGx += s16Gx;
|
|
||||||
s32TempGy += s16Gy;
|
|
||||||
s32TempGz += s16Gz;
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
gstGyroOffset.s16X = s32TempGx >> 5;
|
|
||||||
gstGyroOffset.s16Y = s32TempGy >> 5;
|
|
||||||
gstGyroOffset.s16Z = s32TempGz >> 5;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool icm20948MagCheck(void)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
uint8_t u8Ret[2];
|
|
||||||
|
|
||||||
icm20948ReadSecondary( I2C_ADD_ICM20948_AK09916|I2C_ADD_ICM20948_AK09916_READ,
|
|
||||||
REG_ADD_MAG_WIA1, 2,u8Ret);
|
|
||||||
if( (u8Ret[0] == REG_VAL_MAG_WIA1) && ( u8Ret[1] == REG_VAL_MAG_WIA2) )
|
|
||||||
{
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* BMP280 sensor device *
|
|
||||||
******************************************************************************/
|
|
||||||
typedef struct {
|
|
||||||
uint16_t T1; /*<calibration T1 data*/
|
|
||||||
int16_t T2; /*<calibration T2 data*/
|
|
||||||
int16_t T3; /*<calibration T3 data*/
|
|
||||||
uint16_t P1; /*<calibration P1 data*/
|
|
||||||
int16_t P2; /*<calibration P2 data*/
|
|
||||||
int16_t P3; /*<calibration P3 data*/
|
|
||||||
int16_t P4; /*<calibration P4 data*/
|
|
||||||
int16_t P5; /*<calibration P5 data*/
|
|
||||||
int16_t P6; /*<calibration P6 data*/
|
|
||||||
int16_t P7; /*<calibration P7 data*/
|
|
||||||
int16_t P8; /*<calibration P8 data*/
|
|
||||||
int16_t P9; /*<calibration P9 data*/
|
|
||||||
int32_t T_fine; /*<calibration t_fine data*/
|
|
||||||
}BMP280_HandleTypeDef;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint8_t Index;
|
|
||||||
int32_t AvgBuffer[8];
|
|
||||||
}BMP280_AvgTypeDef;
|
|
||||||
|
|
||||||
#define dig_T1 bmp280.T1
|
|
||||||
#define dig_T2 bmp280.T2
|
|
||||||
#define dig_T3 bmp280.T3
|
|
||||||
#define dig_P1 bmp280.P1
|
|
||||||
#define dig_P2 bmp280.P2
|
|
||||||
#define dig_P3 bmp280.P3
|
|
||||||
#define dig_P4 bmp280.P4
|
|
||||||
#define dig_P5 bmp280.P5
|
|
||||||
#define dig_P6 bmp280.P6
|
|
||||||
#define dig_P7 bmp280.P7
|
|
||||||
#define dig_P8 bmp280.P8
|
|
||||||
#define dig_P9 bmp280.P9
|
|
||||||
#define t_fine bmp280.T_fine
|
|
||||||
|
|
||||||
#define MSLP 101325 // Mean Sea Level Pressure = 1013.25 hPA (1hPa = 100Pa = 1mbar)
|
|
||||||
|
|
||||||
BMP280_HandleTypeDef bmp280;
|
|
||||||
int32_t gs32Pressure0 = MSLP;
|
|
||||||
|
|
||||||
bool bmp280Check(void)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
if(0x58 == I2C_ReadOneByte(BMP280_ADDR, BMP280_REGISTER_CHIPID))
|
|
||||||
{
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bmp280ReadCalibration(void)
|
|
||||||
{
|
|
||||||
uint8_t lsb, msb;
|
|
||||||
|
|
||||||
/* read the temperature calibration parameters */
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_T1_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_T1_MSB_REG);
|
|
||||||
dig_T1 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_T2_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_T2_MSB_REG);
|
|
||||||
dig_T2 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_T3_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_T3_MSB_REG);
|
|
||||||
dig_T3 = msb << 8 | lsb;
|
|
||||||
|
|
||||||
/* read the pressure calibration parameters */
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P1_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P1_MSB_REG);
|
|
||||||
dig_P1 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P2_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P2_MSB_REG);
|
|
||||||
dig_P2 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P3_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P3_MSB_REG);
|
|
||||||
dig_P3 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P4_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P4_MSB_REG);
|
|
||||||
dig_P4 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P5_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P5_MSB_REG);
|
|
||||||
dig_P5 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P6_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P6_MSB_REG);
|
|
||||||
dig_P6 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P7_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P7_MSB_REG);
|
|
||||||
dig_P7 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P8_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P8_MSB_REG);
|
|
||||||
dig_P8 = msb << 8 | lsb;
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P9_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_DIG_P9_MSB_REG);
|
|
||||||
dig_P9 = msb << 8 | lsb;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void bmp280Init(void)
|
|
||||||
{
|
|
||||||
I2C_WriteOneByte(BMP280_ADDR, BMP280_REGISTER_CONTROL, 0xFF);
|
|
||||||
I2C_WriteOneByte(BMP280_ADDR, BMP280_REGISTER_CONFIG, 0x14);
|
|
||||||
bmp280ReadCalibration();
|
|
||||||
}
|
|
||||||
|
|
||||||
float bmp280CompensateTemperature(int32_t adc_T)
|
|
||||||
{
|
|
||||||
int64_t var1, var2, temperature;
|
|
||||||
|
|
||||||
var1 = ((((adc_T>>3) - ((int64_t)dig_T1 <<1))) *((int64_t)dig_T2)) >> 11;
|
|
||||||
var2 = (((((adc_T>>4) - ((int64_t)dig_T1)) *((adc_T>>4) - ((int64_t)dig_T1))) >> 12) *
|
|
||||||
((int64_t)dig_T3)) >> 14;
|
|
||||||
t_fine = var1 + var2;
|
|
||||||
|
|
||||||
temperature = (t_fine * 5 + 128) >> 8;
|
|
||||||
|
|
||||||
return (float)temperature;
|
|
||||||
}
|
|
||||||
|
|
||||||
float bmp280CompensatePressure(int32_t adc_P)
|
|
||||||
{
|
|
||||||
int64_t var1, var2;
|
|
||||||
uint64_t pressure;
|
|
||||||
#if 1
|
|
||||||
var1 = ((int64_t)t_fine) - 128000;
|
|
||||||
var2 = var1 * var1 * (int64_t)dig_P6;
|
|
||||||
var2 = var2 + ((var1*(int64_t)dig_P5)<<17);
|
|
||||||
var2 = var2 + (((int64_t)dig_P4)<<35);
|
|
||||||
var1 = ((var1 * var1 * (int64_t)dig_P3)>>8) + ((var1 * (int64_t)dig_P2)<<12);
|
|
||||||
var1 = (((((int64_t)1)<<47)+var1))*((int64_t)dig_P1)>>33;
|
|
||||||
|
|
||||||
if (var1 == 0) {
|
|
||||||
return 0; // avoid exception caused by division by zero
|
|
||||||
}
|
|
||||||
|
|
||||||
pressure = 1048576.0 - adc_P;
|
|
||||||
pressure = (((pressure<<31) - var2)*3125) / var1;
|
|
||||||
var1 = (((int64_t)dig_P9) * (pressure>>13) * (pressure>>13)) >> 25;
|
|
||||||
var2 = (((int64_t)dig_P8) * pressure) >> 19;
|
|
||||||
pressure = ((pressure + var1 + var2) >> 8) + (((int64_t)dig_P7)<<4);
|
|
||||||
return (float)pressure/256;
|
|
||||||
#else
|
|
||||||
var1 = (((int64_t)t_fine)>>1) - (int64_t)64000;
|
|
||||||
var2 = (((var1>>2) * (var1>>2)) >> 11 ) *((int64_t)dig_P6);
|
|
||||||
var2 = var2 + ((var1 *((int64_t)dig_P5))<<1);
|
|
||||||
var2 = (var2>>2) + (((int64_t)dig_P4)<<16);
|
|
||||||
var1 = (((dig_P3 * (((var1>>2) * (var1>>2))>>13))>>3) + ((((int64_t)dig_P2) * var1)>>1))>>18;
|
|
||||||
var1 = ((((32768+var1))*((int64_t)dig_P1))>>15);
|
|
||||||
if(var1 ==0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
pressure = (1048576.0 - adc_P) - (var2>>12)*3125;
|
|
||||||
if(pressure < 0x80000000)
|
|
||||||
{
|
|
||||||
pressure = (pressure<<1)/((uint64_t)var1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pressure = (pressure/(uint64_t)var1)*2;
|
|
||||||
}
|
|
||||||
var1 = (((int64_t)dig_P9) *((int64_t)(((pressure>>3)*(pressure>>3))>>13)))>>12;
|
|
||||||
var2 = (((int64_t)(pressure>>2))*((int64_t)dig_P8))>>13;
|
|
||||||
pressure = (uint64_t)((int64_t)pressure) +((var1 + var2 + dig_P7)>>4);
|
|
||||||
return (float)pressure;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void bmp280TandPGet(float *temperature, float *pressure)
|
|
||||||
{
|
|
||||||
uint8_t lsb, msb, xlsb;
|
|
||||||
int32_t adc_P,adc_T;
|
|
||||||
|
|
||||||
xlsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_TEMP_XLSB_REG);
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_TEMP_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_TEMP_MSB_REG);
|
|
||||||
//adc_T = (msb << 12) | (lsb << 4) | (xlsb >> 4);
|
|
||||||
adc_T = msb;
|
|
||||||
adc_T <<= 8;
|
|
||||||
adc_T |= lsb;
|
|
||||||
adc_T <<= 8;
|
|
||||||
adc_T |= xlsb;
|
|
||||||
adc_T >>= 4;
|
|
||||||
//adc_T = 415148;
|
|
||||||
*temperature = bmp280CompensateTemperature(adc_T);
|
|
||||||
|
|
||||||
xlsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_PRESS_XLSB_REG);
|
|
||||||
lsb = I2C_ReadOneByte(BMP280_ADDR, BMP280_PRESS_LSB_REG);
|
|
||||||
msb = I2C_ReadOneByte(BMP280_ADDR, BMP280_PRESS_MSB_REG);
|
|
||||||
//adc_P = (msb << 12) | (lsb << 4) | (xlsb >> 4);
|
|
||||||
adc_P = msb;
|
|
||||||
adc_P <<= 8;
|
|
||||||
adc_P |= lsb;
|
|
||||||
adc_P <<= 8;
|
|
||||||
adc_P |= xlsb;
|
|
||||||
adc_P >>= 4;
|
|
||||||
//adc_P = 51988;
|
|
||||||
*pressure = bmp280CompensatePressure(adc_P);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bmp280CalAvgValue(uint8_t *pIndex, int32_t *pAvgBuffer, int32_t InVal, int32_t *pOutVal)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
*(pAvgBuffer + ((*pIndex) ++)) = InVal;
|
|
||||||
*pIndex &= 0x07;
|
|
||||||
|
|
||||||
*pOutVal = 0;
|
|
||||||
for(i = 0; i < 8; i ++)
|
|
||||||
{
|
|
||||||
*pOutVal += *(pAvgBuffer + i);
|
|
||||||
}
|
|
||||||
*pOutVal >>= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bmp280CalculateAbsoluteAltitude(int32_t *pAltitude, int32_t PressureVal)
|
|
||||||
{
|
|
||||||
*pAltitude = 4433000 * (1 - pow((PressureVal / (float)gs32Pressure0), 0.1903));
|
|
||||||
}
|
|
||||||
|
|
||||||
void pressSensorDataGet(int32_t *ps32Temperature, int32_t *ps32Pressure, int32_t *ps32Altitude)
|
|
||||||
{
|
|
||||||
float CurPressure, CurTemperature;
|
|
||||||
int32_t CurAltitude;
|
|
||||||
static BMP280_AvgTypeDef BMP280_Filter[3];
|
|
||||||
|
|
||||||
bmp280TandPGet(&CurTemperature, &CurPressure);
|
|
||||||
bmp280CalAvgValue(&BMP280_Filter[0].Index, BMP280_Filter[0].AvgBuffer, (int32_t)(CurPressure), ps32Pressure);
|
|
||||||
|
|
||||||
bmp280CalculateAbsoluteAltitude(&CurAltitude, (*ps32Pressure));
|
|
||||||
bmp280CalAvgValue(&BMP280_Filter[1].Index, BMP280_Filter[1].AvgBuffer, CurAltitude, ps32Altitude);
|
|
||||||
bmp280CalAvgValue(&BMP280_Filter[2].Index, BMP280_Filter[2].AvgBuffer, (int32_t)CurTemperature, ps32Temperature);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@ -1,236 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file Waveshare_10Dof-D.h
|
|
||||||
* @author Waveshare Team
|
|
||||||
* @version V1.0
|
|
||||||
* @date Dec-2018
|
|
||||||
* @brief
|
|
||||||
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
||||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|
||||||
* TIME. AS A RESULT, WAVESHARE SHALL NOT BE HELD LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|
||||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|
||||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2018 Waveshare</center></h2>
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
#ifndef __Waveshare_10DOF_D_H__
|
|
||||||
#define __Waveshare_10DOF_D_H__
|
|
||||||
#if ARDUINO >= 100
|
|
||||||
#include "Arduino.h"
|
|
||||||
#else
|
|
||||||
#include "WProgram.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* define ICM-20948 Device I2C address*/
|
|
||||||
#define I2C_ADD_ICM20948 0x68
|
|
||||||
#define I2C_ADD_ICM20948_AK09916 0x0C
|
|
||||||
#define I2C_ADD_ICM20948_AK09916_READ 0x80
|
|
||||||
#define I2C_ADD_ICM20948_AK09916_WRITE 0x00
|
|
||||||
/* define ICM-20948 Register */
|
|
||||||
/* user bank 0 register */
|
|
||||||
#define REG_ADD_WIA 0x00
|
|
||||||
#define REG_VAL_WIA 0xEA
|
|
||||||
#define REG_ADD_USER_CTRL 0x03
|
|
||||||
#define REG_VAL_BIT_DMP_EN 0x80
|
|
||||||
#define REG_VAL_BIT_FIFO_EN 0x40
|
|
||||||
#define REG_VAL_BIT_I2C_MST_EN 0x20
|
|
||||||
#define REG_VAL_BIT_I2C_IF_DIS 0x10
|
|
||||||
#define REG_VAL_BIT_DMP_RST 0x08
|
|
||||||
#define REG_VAL_BIT_DIAMOND_DMP_RST 0x04
|
|
||||||
#define REG_ADD_PWR_MIGMT_1 0x06
|
|
||||||
#define REG_VAL_ALL_RGE_RESET 0x80
|
|
||||||
#define REG_VAL_RUN_MODE 0x01 //Non low-power mode
|
|
||||||
#define REG_ADD_LP_CONFIG 0x05
|
|
||||||
#define REG_ADD_PWR_MGMT_1 0x06
|
|
||||||
#define REG_ADD_PWR_MGMT_2 0x07
|
|
||||||
#define REG_ADD_ACCEL_XOUT_H 0x2D
|
|
||||||
#define REG_ADD_ACCEL_XOUT_L 0x2E
|
|
||||||
#define REG_ADD_ACCEL_YOUT_H 0x2F
|
|
||||||
#define REG_ADD_ACCEL_YOUT_L 0x30
|
|
||||||
#define REG_ADD_ACCEL_ZOUT_H 0x31
|
|
||||||
#define REG_ADD_ACCEL_ZOUT_L 0x32
|
|
||||||
#define REG_ADD_GYRO_XOUT_H 0x33
|
|
||||||
#define REG_ADD_GYRO_XOUT_L 0x34
|
|
||||||
#define REG_ADD_GYRO_YOUT_H 0x35
|
|
||||||
#define REG_ADD_GYRO_YOUT_L 0x36
|
|
||||||
#define REG_ADD_GYRO_ZOUT_H 0x37
|
|
||||||
#define REG_ADD_GYRO_ZOUT_L 0x38
|
|
||||||
#define REG_ADD_EXT_SENS_DATA_00 0x3B
|
|
||||||
#define REG_ADD_REG_BANK_SEL 0x7F
|
|
||||||
#define REG_VAL_REG_BANK_0 0x00
|
|
||||||
#define REG_VAL_REG_BANK_1 0x10
|
|
||||||
#define REG_VAL_REG_BANK_2 0x20
|
|
||||||
#define REG_VAL_REG_BANK_3 0x30
|
|
||||||
|
|
||||||
/* user bank 1 register */
|
|
||||||
/* user bank 2 register */
|
|
||||||
#define REG_ADD_GYRO_SMPLRT_DIV 0x00
|
|
||||||
#define REG_ADD_GYRO_CONFIG_1 0x01
|
|
||||||
#define REG_VAL_BIT_GYRO_DLPCFG_2 0x10 /* bit[5:3] */
|
|
||||||
#define REG_VAL_BIT_GYRO_DLPCFG_4 0x20 /* bit[5:3] */
|
|
||||||
#define REG_VAL_BIT_GYRO_DLPCFG_6 0x30 /* bit[5:3] */
|
|
||||||
#define REG_VAL_BIT_GYRO_FS_250DPS 0x00 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_GYRO_FS_500DPS 0x02 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_GYRO_FS_1000DPS 0x04 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_GYRO_FS_2000DPS 0x06 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_GYRO_DLPF 0x01 /* bit[0] */
|
|
||||||
#define REG_ADD_ACCEL_SMPLRT_DIV_2 0x11
|
|
||||||
#define REG_ADD_ACCEL_CONFIG 0x14
|
|
||||||
#define REG_VAL_BIT_ACCEL_DLPCFG_2 0x10 /* bit[5:3] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_DLPCFG_4 0x20 /* bit[5:3] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_DLPCFG_6 0x30 /* bit[5:3] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_FS_2g 0x00 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_FS_4g 0x02 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_FS_8g 0x04 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_FS_16g 0x06 /* bit[2:1] */
|
|
||||||
#define REG_VAL_BIT_ACCEL_DLPF 0x01 /* bit[0] */
|
|
||||||
|
|
||||||
/* user bank 3 register */
|
|
||||||
#define REG_ADD_I2C_SLV0_ADDR 0x03
|
|
||||||
#define REG_ADD_I2C_SLV0_REG 0x04
|
|
||||||
#define REG_ADD_I2C_SLV0_CTRL 0x05
|
|
||||||
#define REG_VAL_BIT_SLV0_EN 0x80
|
|
||||||
#define REG_VAL_BIT_MASK_LEN 0x07
|
|
||||||
#define REG_ADD_I2C_SLV0_DO 0x06
|
|
||||||
#define REG_ADD_I2C_SLV1_ADDR 0x07
|
|
||||||
#define REG_ADD_I2C_SLV1_REG 0x08
|
|
||||||
#define REG_ADD_I2C_SLV1_CTRL 0x09
|
|
||||||
#define REG_ADD_I2C_SLV1_DO 0x0A
|
|
||||||
|
|
||||||
/* define ICM-20948 Register end */
|
|
||||||
|
|
||||||
/* define ICM-20948 MAG Register */
|
|
||||||
#define REG_ADD_MAG_WIA1 0x00
|
|
||||||
#define REG_VAL_MAG_WIA1 0x48
|
|
||||||
#define REG_ADD_MAG_WIA2 0x01
|
|
||||||
#define REG_VAL_MAG_WIA2 0x09
|
|
||||||
#define REG_ADD_MAG_ST2 0x10
|
|
||||||
#define REG_ADD_MAG_DATA 0x11
|
|
||||||
#define REG_ADD_MAG_CNTL2 0x31
|
|
||||||
#define REG_VAL_MAG_MODE_PD 0x00
|
|
||||||
#define REG_VAL_MAG_MODE_SM 0x01
|
|
||||||
#define REG_VAL_MAG_MODE_10HZ 0x02
|
|
||||||
#define REG_VAL_MAG_MODE_20HZ 0x04
|
|
||||||
#define REG_VAL_MAG_MODE_50HZ 0x05
|
|
||||||
#define REG_VAL_MAG_MODE_100HZ 0x08
|
|
||||||
#define REG_VAL_MAG_MODE_ST 0x10
|
|
||||||
/* define ICM-20948 MAG Register end */
|
|
||||||
|
|
||||||
#define MAG_DATA_LEN 6
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BMP280 I2c address
|
|
||||||
*/
|
|
||||||
#define BMP280_AD0_LOW 0x76 //address pin low (GND)
|
|
||||||
#define BMP280_AD0_HIGH 0x77 //address pin high (VCC)
|
|
||||||
#define BMP280_ADDR BMP280_AD0_HIGH // default I2C address
|
|
||||||
/*
|
|
||||||
* BMP280 register address
|
|
||||||
*/
|
|
||||||
#define BMP280_REGISTER_DIG_T1 0x88
|
|
||||||
#define BMP280_REGISTER_DIG_T2 0x8A
|
|
||||||
#define BMP280_REGISTER_DIG_T3 0x8C
|
|
||||||
|
|
||||||
#define BMP280_REGISTER_DIG_P1 0x8E
|
|
||||||
#define BMP280_REGISTER_DIG_P2 0x90
|
|
||||||
#define BMP280_REGISTER_DIG_P3 0x92
|
|
||||||
#define BMP280_REGISTER_DIG_P4 0x94
|
|
||||||
#define BMP280_REGISTER_DIG_P5 0x96
|
|
||||||
#define BMP280_REGISTER_DIG_P6 0x98
|
|
||||||
#define BMP280_REGISTER_DIG_P7 0x9A
|
|
||||||
#define BMP280_REGISTER_DIG_P8 0x9C
|
|
||||||
#define BMP280_REGISTER_DIG_P9 0x9E
|
|
||||||
|
|
||||||
#define BMP280_REGISTER_CHIPID 0xD0
|
|
||||||
#define BMP280_REGISTER_VERSION 0xD1
|
|
||||||
#define BMP280_REGISTER_SOFTRESET 0xE0
|
|
||||||
#define BMP280_REGISTER_STATUS 0xF3
|
|
||||||
#define BMP280_REGISTER_CONTROL 0xF4
|
|
||||||
#define BMP280_REGISTER_CONFIG 0xF5
|
|
||||||
|
|
||||||
#define BMP280_TEMP_XLSB_REG 0xFC /*Temperature XLSB Register */
|
|
||||||
#define BMP280_TEMP_LSB_REG 0xFB /*Temperature LSB Register */
|
|
||||||
#define BMP280_TEMP_MSB_REG 0xFA /*Temperature LSB Register */
|
|
||||||
#define BMP280_PRESS_XLSB_REG 0xF9 /*Pressure XLSB Register */
|
|
||||||
#define BMP280_PRESS_LSB_REG 0xF8 /*Pressure LSB Register */
|
|
||||||
#define BMP280_PRESS_MSB_REG 0xF7 /*Pressure MSB Register */
|
|
||||||
|
|
||||||
/*calibration parameters */
|
|
||||||
#define BMP280_DIG_T1_LSB_REG 0x88
|
|
||||||
#define BMP280_DIG_T1_MSB_REG 0x89
|
|
||||||
#define BMP280_DIG_T2_LSB_REG 0x8A
|
|
||||||
#define BMP280_DIG_T2_MSB_REG 0x8B
|
|
||||||
#define BMP280_DIG_T3_LSB_REG 0x8C
|
|
||||||
#define BMP280_DIG_T3_MSB_REG 0x8D
|
|
||||||
#define BMP280_DIG_P1_LSB_REG 0x8E
|
|
||||||
#define BMP280_DIG_P1_MSB_REG 0x8F
|
|
||||||
#define BMP280_DIG_P2_LSB_REG 0x90
|
|
||||||
#define BMP280_DIG_P2_MSB_REG 0x91
|
|
||||||
#define BMP280_DIG_P3_LSB_REG 0x92
|
|
||||||
#define BMP280_DIG_P3_MSB_REG 0x93
|
|
||||||
#define BMP280_DIG_P4_LSB_REG 0x94
|
|
||||||
#define BMP280_DIG_P4_MSB_REG 0x95
|
|
||||||
#define BMP280_DIG_P5_LSB_REG 0x96
|
|
||||||
#define BMP280_DIG_P5_MSB_REG 0x97
|
|
||||||
#define BMP280_DIG_P6_LSB_REG 0x98
|
|
||||||
#define BMP280_DIG_P6_MSB_REG 0x99
|
|
||||||
#define BMP280_DIG_P7_LSB_REG 0x9A
|
|
||||||
#define BMP280_DIG_P7_MSB_REG 0x9B
|
|
||||||
#define BMP280_DIG_P8_LSB_REG 0x9C
|
|
||||||
#define BMP280_DIG_P8_MSB_REG 0x9D
|
|
||||||
#define BMP280_DIG_P9_LSB_REG 0x9E
|
|
||||||
#define BMP280_DIG_P9_MSB_REG 0x9F
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
IMU_EN_SENSOR_TYPE_NULL = 0,
|
|
||||||
IMU_EN_SENSOR_TYPE_ICM20948,
|
|
||||||
IMU_EN_SENSOR_TYPE_BMP280,
|
|
||||||
IMU_EN_SENSOR_TYPE_MAX
|
|
||||||
}IMU_EN_SENSOR_TYPE;
|
|
||||||
|
|
||||||
typedef struct imu_st_angles_data_tag
|
|
||||||
{
|
|
||||||
float fYaw;
|
|
||||||
float fPitch;
|
|
||||||
float fRoll;
|
|
||||||
}IMU_ST_ANGLES_DATA;
|
|
||||||
|
|
||||||
typedef struct imu_st_sensor_data_tag
|
|
||||||
{
|
|
||||||
int16_t s16X;
|
|
||||||
int16_t s16Y;
|
|
||||||
int16_t s16Z;
|
|
||||||
}IMU_ST_SENSOR_DATA;
|
|
||||||
|
|
||||||
typedef struct icm20948_st_avg_data_tag
|
|
||||||
{
|
|
||||||
uint8_t u8Index;
|
|
||||||
int16_t s16AvgBuffer[8];
|
|
||||||
}ICM20948_ST_AVG_DATA;
|
|
||||||
|
|
||||||
void imuInit(IMU_EN_SENSOR_TYPE *penMotionSensorType, IMU_EN_SENSOR_TYPE *penPressureType);
|
|
||||||
void imuDataGet(IMU_ST_ANGLES_DATA *pstAngles,
|
|
||||||
IMU_ST_SENSOR_DATA *pstGyroRawData,
|
|
||||||
IMU_ST_SENSOR_DATA *pstAccelRawData,
|
|
||||||
IMU_ST_SENSOR_DATA *pstMagnRawData);
|
|
||||||
void pressSensorDataGet(int32_t *ps32Temperature, int32_t *ps32Pressure, int32_t *ps32Altitude);
|
|
||||||
|
|
||||||
uint8_t I2C_ReadOneByte(uint8_t DevAddr, uint8_t RegAddr);
|
|
||||||
void I2C_WriteOneByte(uint8_t DevAddr, uint8_t RegAddr, uint8_t value);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //__Waveshare_10DOF_D_H__
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
#include <SPI.h>
|
|
||||||
#include <nRF24L01.h>
|
|
||||||
#include <RF24.h>
|
|
||||||
#include "Waveshare_10Dof-D.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
|
|
||||||
bool gbSenserConnectState = false;
|
|
||||||
//create an RF24 object
|
|
||||||
RF24 radio(9, 8); // CE, CSN
|
|
||||||
const byte address[6] = "00001"; //address through which two modules communicate
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
// init radio
|
|
||||||
radio.begin();
|
|
||||||
radio.openWritingPipe(address);
|
|
||||||
radio.stopListening(); //Set module as transmitter
|
|
||||||
|
|
||||||
// init motion sensor
|
|
||||||
bool bRet;
|
|
||||||
IMU_EN_SENSOR_TYPE enMotionSensorType, enPressureType;
|
|
||||||
Serial.begin(115200);
|
|
||||||
|
|
||||||
imuInit(&enMotionSensorType, &enPressureType);
|
|
||||||
if(IMU_EN_SENSOR_TYPE_ICM20948 == enMotionSensorType)
|
|
||||||
{
|
|
||||||
Serial.println("Motion sersor is ICM-20948");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.println("Motion sersor NULL");
|
|
||||||
}
|
|
||||||
if(IMU_EN_SENSOR_TYPE_BMP280 == enPressureType)
|
|
||||||
{
|
|
||||||
Serial.println("Pressure sersor is BMP280");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.println("Pressure sersor NULL");
|
|
||||||
}
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
IMU_ST_ANGLES_DATA stAngles;
|
|
||||||
IMU_ST_SENSOR_DATA stGyroRawData;
|
|
||||||
IMU_ST_SENSOR_DATA stAccelRawData;
|
|
||||||
IMU_ST_SENSOR_DATA stMagnRawData;
|
|
||||||
int32_t s32PressureVal = 0, s32TemperatureVal = 0, s32AltitudeVal = 0;
|
|
||||||
|
|
||||||
imuDataGet( &stAngles, &stGyroRawData, &stAccelRawData, &stMagnRawData);
|
|
||||||
pressSensorDataGet(&s32TemperatureVal, &s32PressureVal, &s32AltitudeVal);
|
|
||||||
char result[8];
|
|
||||||
float temperature = (s32TemperatureVal / 100);
|
|
||||||
dtostrf(temperature, 6, 2, result);
|
|
||||||
//Send message to receiver
|
|
||||||
radio.write(&result, sizeof(result));
|
|
||||||
//delay(1000);
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
module foglar/serial_read
|
|
||||||
|
|
||||||
go 1.21.6
|
|
||||||
|
|
||||||
require github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
|
||||||
|
|
||||||
require golang.org/x/sys v0.16.0 // indirect
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=
|
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
|
||||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
|
||||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
@ -1,148 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/tarm/serial"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func portInput() string {
|
|
||||||
var port string
|
|
||||||
for true {
|
|
||||||
port = ""
|
|
||||||
fmt.Print("Enter port to listen on (for example - '/dev/ttyACM0'): ")
|
|
||||||
fmt.Scanln(&port)
|
|
||||||
|
|
||||||
if port == "" {
|
|
||||||
port = "/dev/ttyACM0"
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := os.Stat(port)
|
|
||||||
if !os.IsNotExist(err) {
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
fmt.Println("Invalid port")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return port
|
|
||||||
}
|
|
||||||
|
|
||||||
func baudrateInput() int {
|
|
||||||
var baudrate int
|
|
||||||
var s_baudrate string
|
|
||||||
|
|
||||||
fmt.Print("Enter baudrate (for example - '9600'): ")
|
|
||||||
fmt.Scanln(&s_baudrate)
|
|
||||||
baudrate = baudrateCheck(s_baudrate)
|
|
||||||
return baudrate
|
|
||||||
}
|
|
||||||
|
|
||||||
func baudrateCheck(s_baudrate string) int {
|
|
||||||
var baudrate int
|
|
||||||
switch s_baudrate {
|
|
||||||
case "4800":
|
|
||||||
baudrate = 4800
|
|
||||||
case "9600":
|
|
||||||
baudrate = 9600
|
|
||||||
case "115200":
|
|
||||||
baudrate = 115200
|
|
||||||
default:
|
|
||||||
baudrate = 9600
|
|
||||||
}
|
|
||||||
return baudrate
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func UserInput() (string, int) {
|
|
||||||
port := portInput()
|
|
||||||
baudrate := baudrateInput()
|
|
||||||
|
|
||||||
return port, baudrate
|
|
||||||
}
|
|
||||||
|
|
||||||
func getTime() string {
|
|
||||||
return time.Now().Format("2006-1-2_15:4:5")
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
args := os.Args[1:]
|
|
||||||
var port string
|
|
||||||
var baudrate int
|
|
||||||
|
|
||||||
if len(args) == 0 {
|
|
||||||
port, baudrate = UserInput()
|
|
||||||
} else {
|
|
||||||
i := 0
|
|
||||||
for i < len(args) {
|
|
||||||
if args[i] == "-p" && i+1 < len(args) {
|
|
||||||
port = args[i+1]
|
|
||||||
}
|
|
||||||
if args[i] == "-h" || args[i] == "--help" {
|
|
||||||
fmt.Println("-h, --help - prints this message")
|
|
||||||
fmt.Println("-p [port] - listens on port")
|
|
||||||
fmt.Println("-b [baudrate] - sets the baudrate")
|
|
||||||
fmt.Println("-d - runs the script with default values")
|
|
||||||
os.Exit(0)
|
|
||||||
|
|
||||||
}
|
|
||||||
if args[i] == "-b" && i+1 < len(args) {
|
|
||||||
var err error
|
|
||||||
baudrate, err = strconv.Atoi(args[i+1])
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Invalid baudrate")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if args[i] == "-d" {
|
|
||||||
port = "/dev/ACM0"
|
|
||||||
baudrate = 9600
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
if port == "" {
|
|
||||||
port = portInput()
|
|
||||||
}
|
|
||||||
if baudrate == 0 {
|
|
||||||
baudrate = baudrateInput()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Listen on port
|
|
||||||
fmt.Printf("Listening on port %s with baudrate %d:\n", port, baudrate)
|
|
||||||
c := &serial.Config{Name: port, Baud: baudrate}
|
|
||||||
|
|
||||||
// Create file
|
|
||||||
filename := getTime() + ".txt"
|
|
||||||
f, err := os.Create(filename)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
// Open port
|
|
||||||
s, err := serial.OpenPort(c)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var n int
|
|
||||||
for {
|
|
||||||
// create a buffer
|
|
||||||
buf := make([]byte, 254)
|
|
||||||
|
|
||||||
// Read length of serial input
|
|
||||||
n, err = s.Read(buf)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print as a string
|
|
||||||
fmt.Print(string(buf[:n]))
|
|
||||||
f.WriteString(string(buf[:n]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||