add BME280, try to work with SPI TFT display (no reaction yet)

This commit is contained in:
Edward Emelianov
2023-05-08 01:30:34 +03:00
parent e0352dde3f
commit 16f3b31f4f
14 changed files with 187 additions and 30 deletions

View File

@@ -17,12 +17,14 @@
*/
#include "adc.h"
#include "BMP280.h"
//#include "buttons.h"
//#include "can.h"
//#include "flash.h"
#include "hardware.h"
#include "i2c.h"
#include "proto.h"
#include "strfunc.h"
#include "usb.h"
#define MAXSTRLEN RBINSZ
@@ -47,6 +49,7 @@ int main(void){
USB_setup();
//CAN_setup(the_conf.CANspeed);
adc_setup();
BMP280_setup(0);
USBPU_ON();
uint32_t ctr = 0;
// CAN_message *can_mesg;
@@ -86,7 +89,23 @@ int main(void){
USB_sendstr(") - found device\n");
}
}
i2c_have_DMA_Rx(); // check if there's DMA Rx complete
//i2c_have_DMA_Rx(); // check if there's DMA Rx complete
BMP280_process();
BMP280_status s = BMP280_get_status();
if(s == BMP280_RDY){ // data ready - get it
float T, P, H;
if(BMP280_getdata(&T, &P, &H)){
USB_sendstr("T="); USB_sendstr(float2str(T, 2)); USB_sendstr("\nP=");
USB_sendstr(float2str(P, 1));
P *= 0.00750062f; USB_sendstr("\nPmm="); USB_sendstr(float2str(P, 1));
USB_sendstr("\nH="); USB_sendstr(float2str(H, 1));
USB_sendstr("\nTdew="); USB_sendstr(float2str(Tdew(T, H), 1));
newline();
}else USB_sendstr("Can't read data\n");
}else if(s == BMP280_ERR){
USB_sendstr("BME280 error\n");
BMP280_init();
}
int l = USB_receivestr(inbuff, MAXSTRLEN);
if(l < 0) USB_sendstr("ERROR: USB buffer overflow or string was too long\n");
else if(l){