mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 10:45:11 +03:00
fix negative numbers bug in dewpoint
This commit is contained in:
parent
c1ee273258
commit
3c1bc7ff3d
Binary file not shown.
@ -135,7 +135,7 @@ static struct{
|
||||
uint8_t ID; // identificator
|
||||
uint8_t regctl; // control register base value [(params.t_os << 5) | (params.p_os << 2)]
|
||||
} params = {
|
||||
.filter = BMP280_FILTER_16,
|
||||
.filter = BMP280_FILTER_OFF,
|
||||
.p_os = BMP280_OVERS16,
|
||||
.t_os = BMP280_OVERS16,
|
||||
.h_os = BMP280_OVERS16,
|
||||
|
||||
@ -52,12 +52,12 @@
|
||||
#define BMP280_CHIP_ID 0x58
|
||||
#define BME280_CHIP_ID 0x60
|
||||
|
||||
typedef enum{ // Nsamples for filtering
|
||||
BMP280_FILTER_OFF = 0,
|
||||
BMP280_FILTER_2 = 1,
|
||||
BMP280_FILTER_4 = 2,
|
||||
BMP280_FILTER_8 = 3,
|
||||
BMP280_FILTER_16 = 4,
|
||||
typedef enum{ // K for filtering: next = [prev*(k-1) + data_ADC]/k
|
||||
BMP280_FILTER_OFF = 0, // k=1, no filtering
|
||||
BMP280_FILTER_2 = 1, // k=2, 2 samples to reach >75% of data_ADC
|
||||
BMP280_FILTER_4 = 2, // k=4, 5 samples
|
||||
BMP280_FILTER_8 = 3, // k=8, 11 samples
|
||||
BMP280_FILTER_16 = 4, // k=16, 22 samples
|
||||
BMP280_FILTERMAX
|
||||
} BMP280_Filter;
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ static char *get_USB(){
|
||||
|
||||
static void showd(int32_t mT, int32_t mH){
|
||||
USB_send("Dewpoint=");
|
||||
USB_send(u2str(dewpoint(mT, mH)));
|
||||
USB_send(i2str(dewpoint(mT, mH)));
|
||||
USB_send("*10degrC\n");
|
||||
}
|
||||
|
||||
|
||||
@ -280,4 +280,3 @@ char *i2str(int32_t i){
|
||||
}else val = i;
|
||||
return _2str(val, minus);
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,12 @@ char *get_USB(){
|
||||
void showd(int32_t mT, int32_t mH){
|
||||
if(mT == -10000 || mH == -10000) return;
|
||||
USB_send("Dewpoint=");
|
||||
USB_send(u2str(dewpoint(mT, mH)));
|
||||
int32_t d = dewpoint(mT, mH);
|
||||
if(d < 0){
|
||||
USB_send("-");
|
||||
d = -d;
|
||||
}
|
||||
USB_send(u2str(d));
|
||||
USB_send("*10degrC\n");
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user