Skip to content

Commit 1818855

Browse files
author
Owen
authored
Merge pull request #280 from sparkfun/add-getTempDegC
2 parents d1caa08 + 7dc3d0c commit 1818855

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cores/arduino/sdk/core-extend/AnalogInternal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int analogReadTemp( void );
3333
int analogReadVCCDiv3( void );
3434
int analogReadVSS( void );
3535

36+
float getTempDegC( void );
3637
float getTempDegF( void );
3738
float getVCCV( void );
3839

cores/arduino/sdk/core-implement/CommonAnalog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ap3_adc_channel_config_t ap3_adc_channel_configs[] = {
5252
{ 0, AP3_ADC_INTERNAL_CHANNELS_VSS, AM_HAL_ADC_SLOT_CHSEL_VSS, 0, },
5353
};
5454

55-
float getTempDegF( void ) {
55+
float getTempDegC( void ) {
5656
const float v_ref = 2.0;
5757
uint16_t counts = analogReadTemp();
5858

@@ -74,6 +74,11 @@ float getTempDegF( void ) {
7474
return fVT[1]; // Get the temperature
7575
}
7676

77+
float getTempDegF( void ) {
78+
float temp_deg_c = getTempDegC();
79+
return ((9.0f/5.0f)*temp_deg_c) + 32.0f;
80+
}
81+
7782
float getVCCV( void ){
7883
return ((float)analogReadVCCDiv3() * 6.0) / 16384.0;
7984
}

0 commit comments

Comments
 (0)