Skip to content

Commit

Permalink
nano pi air hat adc change
Browse files Browse the repository at this point in the history
  • Loading branch information
TSKangetsu committed May 25, 2024
1 parent d6b3f17 commit 03251d2
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 3 deletions.
71 changes: 71 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,75 @@
"-DFULLSTATIC=true",
"-DOPENWRT=true"
],
"files.associations": {
"iostream": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"hash_map": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
},
}
18 changes: 17 additions & 1 deletion src/SingleAPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int SingleAPMAPI::RPiSingleAPM::RPiSingleAPMInit(APMSettinngs APMInit)
{
SF._uORB_BAT_Voltage =
DF.ADCDevice->ADS111xReadmV({
.Pin = 5,
.Pin = ADC_VBAT_PIN,
.Range = ADS111x::SL_RangeFSR::V4_096,
.DataRate = ADS111x::SL_DataRateSPS::SPS_860,
}) /
Expand Down Expand Up @@ -2257,6 +2257,22 @@ void SingleAPMAPI::RPiSingleAPM::AttitudeUpdate()
EF._uORB_A2_Speed = EF._uORB_A2_Speed > EF._Flag_Max__Throttle ? EF._Flag_Max__Throttle : EF._uORB_A2_Speed;
EF._uORB_B1_Speed = EF._uORB_B1_Speed > EF._Flag_Max__Throttle ? EF._Flag_Max__Throttle : EF._uORB_B1_Speed;
EF._uORB_B2_Speed = EF._uORB_B2_Speed > EF._Flag_Max__Throttle ? EF._Flag_Max__Throttle : EF._uORB_B2_Speed;

// TODO: prepare for new flexable mixer table
// motors for non-servo mixes
// for (int i = 0; i < motorCount; i++)
// {
// rpyMix[i] =
// (input[PITCH] * currentMixer[i].pitch +
// input[ROLL] * currentMixer[i].roll +
// -motorYawMultiplier * input[YAW] * currentMixer[i].yaw) *
// mixerScale;

// if (rpyMix[i] > rpyMixMax)
// rpyMixMax = rpyMix[i];
// if (rpyMix[i] < rpyMixMin)
// rpyMixMin = rpyMix[i];
// }
}
TF._Tmp_IMUAttThreadLast = GetTimestamp();
}
Expand Down
8 changes: 6 additions & 2 deletions src/SingleAPM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@
#define I2CPCA_ADDR 0x70
#define I2CADS111x_ADDR 0x49

#define ADC_FRONT_GAIN 0.0934343
#define ADC_VBAT_PIN 5
#define ADC_FRONT_GAIN 0.0909 // to ground 1KΩ , to port 10KΩ, ADC_FRONT_GAIN will be 1K / (1K + 10K) = 0.09090909;
#define ADC_VBAT_PIN 4 // 4 is ain0 5 is ain1

// old rockpi4b hat R version
// #define ADC_FRONT_GAIN 0.0934343
// #define ADC_VBAT_PIN 5

#define BlackBoxIInterval 32
#define BlackBoxFirmware "Cleanflight"
Expand Down

0 comments on commit 03251d2

Please sign in to comment.