From a684511d01aa9becf3253494e33037be81b01735 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Fri, 25 Aug 2023 09:52:15 +0200 Subject: [PATCH] updates --- BUTTONDesc.h | 2 +- DefaultReceiver.ino | 19 ++++++++++++------- MPU.h | 38 ++++++++++++++++++++++++++++++++------ descriptionStruct.h | 9 --------- juPadReceiver.h | 9 ++++++++- structsAndDefines.h | 19 +++++++++++++++++++ 6 files changed, 72 insertions(+), 24 deletions(-) delete mode 100644 descriptionStruct.h create mode 100644 structsAndDefines.h diff --git a/BUTTONDesc.h b/BUTTONDesc.h index b45afcc..feb4fc9 100644 --- a/BUTTONDesc.h +++ b/BUTTONDesc.h @@ -1,4 +1,4 @@ -#include "descriptionStruct.h" +#include "structsAndDefines.h" #define jType_ANALOG_Desc 50 #define jType_BUTTON_Desc 51 #define jCommand_OUT_OF_BOUND 0xff diff --git a/DefaultReceiver.ino b/DefaultReceiver.ino index f4cce67..8689ef6 100644 --- a/DefaultReceiver.ino +++ b/DefaultReceiver.ino @@ -1,24 +1,28 @@ -#include "descriptionStruct.h" +#include "structsAndDefines.h" #define myId 0x01 #define myChannel 1 +#define jNAME "DefaultReceiver" #define jMPU #define jCOMP #define jGNSS -#define debug +#define jOUT +const byte jOutPins[] = {13, 12, 14, 27, 26, 25, 33, 32, 15 /*,2*/}; -//https://dl.espressif.com/dl/package_esp32_index.json -//1.0.6 +//#define debug ChannelDesc buttonDesc[32] = { - {3,"Armed"} + {BUTTONswitch,"arm"} }; ChannelDesc analogDesc[12] = { - -}; + {ANALOGused, "throttle"}, + {ANALOGused, "yaw"}, + {ANALOGused, "pitch"}, + {ANALOGused, "roll"}, +}; void onConnect(){ @@ -41,4 +45,5 @@ void setup(){ void loop(){ jLoop(); + } diff --git a/MPU.h b/MPU.h index d723618..733f61f 100644 --- a/MPU.h +++ b/MPU.h @@ -43,8 +43,34 @@ void initMPU(){ //mpu6050.calcGyroOffsets(false,50,50); } +int dcounterxy = 0; + void MPULoop(){ mpu6050.update(); + if((dcounterxy++)%100 == 0){ + Serial.print("AccX: "); + Serial.print(mpu6050.getAccX()); + Serial.print(" AccY: "); + Serial.print(mpu6050.getAccY()); + Serial.print(" AccZ: "); + Serial.print(mpu6050.getAccZ()); + Serial.println(); + Serial.print("GyroX: "); + Serial.print(mpu6050.getGyroX()); + Serial.print(" GyroY: "); + Serial.print(mpu6050.getGyroY()); + Serial.print(" GyroZ: "); + Serial.print(mpu6050.getGyroZ()); + Serial.println(); + Serial.print("AngleX: "); + Serial.print(mpu6050.getAngleX()); + Serial.print(" AngleY: "); + Serial.print(mpu6050.getAngleY()); + Serial.print(" AngleZ: "); + Serial.print(mpu6050.getAngleZ()); + Serial.println(); + Serial.println(); + } } void MPUradioTask(){ @@ -102,18 +128,18 @@ void MPUradioTask(){ case jCommand_MPU_get_calc_offsets_acc:{ mpuSendData data; data.command = jCommand_MPU_get_calc_offsets_acc; - data.X = mpu6050.getGyroXoffsetGlide(); - data.Y = mpu6050.getGyroYoffsetGlide(); - data.Z = mpu6050.getGyroZoffsetGlide(); + data.X = mpu6050.calcAccXoffset(); + data.Y = mpu6050.calcAccYoffset(); + data.Z = mpu6050.calcAccZoffset(); jSendNRF(&data, sizeof(data)); } break; case jCommand_MPU_get_calc_offsets_gyro:{ mpuSendData data; data.command = jCommand_MPU_get_calc_offsets_gyro; - data.X = mpu6050.calcAccXoffset(); - data.Y = mpu6050.calcAccYoffset(); - data.Z = mpu6050.calcAccZoffset(); + data.X = mpu6050.getGyroXoffsetGlide(); + data.Y = mpu6050.getGyroYoffsetGlide(); + data.Z = mpu6050.getGyroZoffsetGlide(); jSendNRF(&data, sizeof(data)); } break; diff --git a/descriptionStruct.h b/descriptionStruct.h deleted file mode 100644 index 577b0a4..0000000 --- a/descriptionStruct.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _descriptionStruct_h_ -#define _descriptionStruct_h_ - -typedef struct { - byte use; //0-3 || 0-1 - char text[29]; //Text -}ChannelDesc; - -#endif diff --git a/juPadReceiver.h b/juPadReceiver.h index 181e332..ddb0c43 100644 --- a/juPadReceiver.h +++ b/juPadReceiver.h @@ -1,12 +1,15 @@ #ifndef _juPadReceiver_h_ #define _juPadReceiver_h_ +#include "structsAndDefines.h" + #define maxLast 2500 typedef struct{ byte type = 0xff; - uint64_t pipe; byte channel; + uint64_t pipe; + char name[16] = "[UNNAMED]"; }nrfMulticast; #ifndef myId @@ -107,6 +110,10 @@ void jNoConn(){ nrfMulticast data; data.pipe = myPipe; data.channel = myChannel; +#ifdef jNAME + char nameMult[16] = jNAME; + strncpy(data.name, nameMult, 16); +#endif radio.write(&data, sizeof(data), true); radio.setChannel(myChannel); radio.startListening(); diff --git a/structsAndDefines.h b/structsAndDefines.h new file mode 100644 index 0000000..f5fff4e --- /dev/null +++ b/structsAndDefines.h @@ -0,0 +1,19 @@ +#ifndef _structsAndDefines_h_ +#define _structsAndDefines_h_ + +typedef struct { + byte use; //0-3 || 0-1 + char text[29]; //Text +}ChannelDesc; + +#define BUTTONunused 0 +#define BUTTONbutton 1 +#define BUTTONseeminglySwitch 2 +#define BUTTONswitch 3 + +#define ANALOGunused 0 +#define ANALOGused 1 + + + +#endif