diff --git a/main/bme280.h b/main/bme280.h index d7aaf06..313f38f 100644 --- a/main/bme280.h +++ b/main/bme280.h @@ -1,3 +1,6 @@ +#ifndef __BME280_H__ +#define __BME280_H__ + #include #include #include @@ -122,3 +125,4 @@ class BME280: public BMP280 } ; +#endif // __BME280_H__ diff --git a/main/bmp180.h b/main/bmp180.h index 1ee2506..485c073 100644 --- a/main/bmp180.h +++ b/main/bmp180.h @@ -1,3 +1,6 @@ +#ifndef __BMP180_H__ +#define __BMP180_H__ + #include #include #include @@ -144,3 +147,5 @@ class BMP180 Pressure += (X1+X2+3791)>>4; } } ; + +#endif // __BMP180_H__ diff --git a/main/bmp280.h b/main/bmp280.h index a848e56..9a57300 100644 --- a/main/bmp280.h +++ b/main/bmp280.h @@ -1,3 +1,6 @@ +#ifndef __BMP280_H__ +#define __BMP280_H__ + #include #include #include @@ -21,7 +24,7 @@ class BMP280 static const uint8_t REG_PRESS_LSB = 0xF8; // Pressure result: LSB static const uint8_t REG_PRESS_XLSB = 0xF9; // Pressure result: more LSB - static const uint8_t REG_TEMP = 0xFA; // Temperature result: + static const uint8_t REG_TEMP_ = 0xFA; // Temperature result: static const uint8_t REG_TEMP_MSB = 0xFA; // Temperature result: MSB static const uint8_t REG_TEMP_LSB = 0xFB; // Temperature result: LSB static const uint8_t REG_TEMP_XLSB = 0xFC; // Temperature result: more LSB @@ -113,7 +116,7 @@ class BMP280 uint8_t ReadRawTemp(void) // read raw temperature ADC conversion result { RawTemp=0; - Error=I2C_Read(Bus, ADDR, REG_TEMP, (uint8_t *)(&RawTemp), 3); if(Error) return Error; + Error=I2C_Read(Bus, ADDR, REG_TEMP_, (uint8_t *)(&RawTemp), 3); if(Error) return Error; RawTemp = ((RawTemp<<16)&0xFF0000) | (RawTemp&0x00FF00) | ((RawTemp>>16)&0x0000FF); RawTemp>>=4; return 0; } @@ -154,3 +157,5 @@ class BMP280 } } ; + +#endif // __BMP280_H__ diff --git a/main/ctrl.cpp b/main/ctrl.cpp index cd9caf9..9853411 100644 --- a/main/ctrl.cpp +++ b/main/ctrl.cpp @@ -10,6 +10,7 @@ #include "hal.h" #include "rf.h" +#include "sens.h" #include "ctrl.h" #include "log.h" @@ -313,6 +314,43 @@ void OLED_DrawSystem(u8g2_t *OLED) Line[Len]=0; u8g2_DrawStr(OLED, 0, 12, Line); + Len=0; +#ifdef WITH_RFM69 + Len+=Format_String(Line+Len, "RFM69 v"); // Type of RF chip used + if(isTxTypeHW()) Line[Len++]='H'; + Line[Len++]='W'; +#endif +#ifdef WITH_RFM95 + Len+=Format_String(Line+Len, "RFM95 v"); +#endif +#ifdef WITH_SX1272 + Len+=Format_String(Line+Len, "SX1272 v"); +#endif + Len+=Format_Hex(Line+Len, TRX.chipVer); + Line[Len++]=' '; + Len+=Format_SignDec(Line+Len, (int16_t)TRX.chipTemp); + Line[Len++]=0xB0; + Line[Len++]='C'; + Line[Len]=0; + u8g2_DrawStr(OLED, 0, 24, Line); + + Len=0; +#ifdef WITH_BMP180 + Len+=Format_String(Line+Len, "BMP180 0x"); +#endif +#ifdef WITH_BMP280 + Len+=Format_String(Line+Len, "BMP280 0x"); +#endif +#ifdef WITH_BME280 + Len+=Format_String(Line+Len, "BME280 0x"); +#endif +#ifdef WITH_MS5607 + Len+=Format_String(Line+Len, "MS5607 0x"); +#endif + Len+=Format_Hex(Line+Len, Baro.ADDR); + Line[Len]=0; + u8g2_DrawStr(OLED, 0, 36, Line); + #ifdef WITH_SD Len=0; Len += Format_String(Line+Len, "SD "); diff --git a/main/rf.cpp b/main/rf.cpp index 6d16f2a..9de0381 100644 --- a/main/rf.cpp +++ b/main/rf.cpp @@ -19,7 +19,7 @@ static const uint8_t *OGN_SYNC = OGN1_SYNC; static const uint8_t *OGN_SYNC = OGN2_SYNC; #endif -static RFM_TRX TRX; // radio transceiver + RFM_TRX TRX; // radio transceiver uint8_t RX_AverRSSI; // [-0.5dBm] average RSSI int8_t RF_Temp; // [degC] temperature of the RF chip: uncalibrated @@ -239,10 +239,10 @@ extern "C" #ifdef WITH_RFM69 TRX.TriggerTemp(); // trigger RF chip temperature readout vTaskDelay(1); // while(TRX.RunningTemp()) taskYIELD(); // wait for conversion to be ready - RF_Temp= 165-TRX.ReadTemp(); // [degC] read RF chip temperature + RF_Temp= TRX.ReadTemp(); // [degC] read RF chip temperature #endif #ifdef WITH_RFM95 - RF_Temp= 15-TRX.ReadTemp(); // [degC] read RF chip temperature + RF_Temp= TRX.ReadTemp(); // [degC] read RF chip temperature #endif RF_Temp+=Parameters.RFchipTempCorr; // Note: on RFM95 temperature sens does not work in STANDBY diff --git a/main/rf.h b/main/rf.h index 8679497..b12acac 100644 --- a/main/rf.h +++ b/main/rf.h @@ -1,3 +1,6 @@ +#ifndef __RF_H__ +#define __RF_H__ + #include #include "hal.h" @@ -15,6 +18,7 @@ extern uint8_t RX_OGN_Packets; // [packets] counts received packets extern uint8_t RX_AverRSSI; // [-0.5dBm] average RSSI extern int8_t RF_Temp; // [degC] temperature of the RF chip: uncalibrated + extern RFM_TRX TRX; // RF transceiver extern FreqPlan RF_FreqPlan; // frequency hopping pattern calculator extern uint16_t TX_Credit; // counts transmitted packets vs. time to avoid using more than 1% of the time extern uint16_t RX_OGN_Count64; // counts received packets for the last 64 seconds @@ -28,3 +32,4 @@ #endif void vTaskRF(void* pvParameters); +#endif // __RF_H__ diff --git a/main/rfm.h b/main/rfm.h index e504f83..13d5cc3 100644 --- a/main/rfm.h +++ b/main/rfm.h @@ -1,3 +1,8 @@ +#ifndef __RFM_H__ +#define __RFM_H__ + +#include + // ----------------------------------------------------------------------------------------------------------------------- #include "config.h" @@ -140,6 +145,9 @@ class RFM_RxPktData // packet received by the RF chip class RFM_TRX { public: // hardware access functions + uint8_t chipVer; // [] version ID read from the RF chip + int8_t chipTemp; // [degC] temperature read from the RF chip + #ifdef USE_BLOCK_SPI // SPI transfers in blocks, implicit control of the SPI-select void (*TransferBlock)(uint8_t *Data, uint8_t Len); static const size_t MaxBlockLen = 64; @@ -464,7 +472,7 @@ class RFM_TRX #endif - uint8_t ReadVersion(void) { return ReadByte(REG_VERSION); } // normally returns: 0x24 + uint8_t ReadVersion(void) { chipVer=ReadByte(REG_VERSION); return chipVer; } // 0x24 for RFM69 or 0x12 for RFM95 #ifdef WITH_RFM69 void TriggerRSSI(void) { WriteByte(0x01, REG_RSSICONFIG); } // trigger measurement @@ -475,11 +483,10 @@ class RFM_TRX #ifdef WITH_RFM69 void TriggerTemp(void) { WriteByte(0x08, REG_TEMP1); } // trigger measurement uint8_t RunningTemp(void) { return ReadByte(REG_TEMP1) & 0x04; } // still running ? - uint8_t ReadTemp(void) { return ReadByte(REG_TEMP2); } // read value: -1 deg/LSB + int8_t ReadTemp(void) { chipTemp=165-ReadByte(REG_TEMP2); return chipTemp; } // [deg] #endif -// #ifdef WITH_RFM95 #if defined(WITH_RFM95) || defined(WITH_SX1272) - uint8_t ReadTemp(void) { return ReadByte(REG_TEMP); } // read value: -1 deg/LSB + int8_t ReadTemp(void) { chipTemp = 15-ReadByte(REG_TEMP); return chipTemp; } // [degC] #endif /* void Dump(uint8_t EndAddr=0x20) @@ -491,4 +498,5 @@ class RFM_TRX */ } ; +#endif // __RFM_H__ diff --git a/main/sens.cpp b/main/sens.cpp index f9d9c61..c139820 100644 --- a/main/sens.cpp +++ b/main/sens.cpp @@ -13,22 +13,6 @@ #if defined(WITH_BMP180) || defined(WITH_BMP280) || defined(WITH_MS5607) || defined(WITH_BME280) -#ifdef WITH_BMP180 -#include "bmp180.h" -#endif - -#ifdef WITH_BMP280 -#include "bmp280.h" -#endif - -#ifdef WITH_BME280 -#include "bme280.h" -#endif - -#ifdef WITH_MS5607 -#include "ms5607.h" -#endif - #include "atmosphere.h" #include "slope.h" #include "lowpass2.h" @@ -60,19 +44,19 @@ void VarioSound(int32_t ClimbRate) #endif // WITH_BEEPER #ifdef WITH_BMP180 -static BMP180 Baro; // BMP180 barometer sensor + BMP180 Baro; // BMP180 barometer sensor #endif #ifdef WITH_BMP280 -static BMP280 Baro; // BMP280 barometer sensor + BMP280 Baro; // BMP280 barometer sensor #endif #ifdef WITH_BME280 -static BME280 Baro; // BMP280 barometer sensor with humidity sensor + BME280 Baro; // BMP280 barometer sensor with humidity sensor #endif #ifdef WITH_MS5607 -static MS5607 Baro; // BMP280 barometer sensor + MS5607 Baro; // BMP280 barometer sensor #endif static uint32_t AverPress; // [ Pa] summed Pressure over several readouts diff --git a/main/sens.h b/main/sens.h index a3b2c52..9da4840 100644 --- a/main/sens.h +++ b/main/sens.h @@ -1,6 +1,30 @@ +#ifndef __SENS_H__ +#define __SENS_H__ + +#ifdef WITH_BMP180 +#include "bmp180.h" +extern BMP180 Baro; // BMP180 barometer sensor +#endif + +#ifdef WITH_BMP280 +#include "bmp280.h" +extern BMP280 Baro; // BMP280 barometer sensor +#endif + +#ifdef WITH_BME280 +#include "bme280.h" +extern BME280 Baro; // BMP280 barometer sensor with humidity sensor +#endif + +#ifdef WITH_MS5607 +#include "ms5607.h" +extern MS5607 Baro; // BMP280 barometer sensor +#endif + + #ifdef __cplusplus extern "C" #endif void vTaskSENS(void* pvParameters); - +#endif // __SENS_H__ diff --git a/main/sx1276.h b/main/sx1276.h index 5e1fc03..49f0edd 100644 --- a/main/sx1276.h +++ b/main/sx1276.h @@ -12,8 +12,8 @@ License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Miguel Luis and Gregory Cristian */ -#ifndef __SX1276_REGS_FSK_H__ -#define __SX1276_REGS_FSK_H__ +#ifndef __SX1276_H__ +#define __SX1276_H__ /*! * ============================================================================ @@ -1125,7 +1125,7 @@ Maintainer: Miguel Luis and Gregory Cristian #define RF_PLL_BANDWIDTH_225 0x80 #define RF_PLL_BANDWIDTH_300 0xC0 // Default -#endif // __SX1276_REGS_FSK_H__ +#endif // __SX1276_H__