Exemplo n.º 1
0
void vConsolePutChar(xConsole *pxW, char cChar){
  xConsoleProps *xP;
  
  if(!pxW)
    return;
  
  xP = pxW->pvProp;
  
  if(xP->xqConsole && xConsoleWnd && xConsoleWnd->bVisible)
    xQueueSendToBack(xP->xqConsole, &cChar, OS_DELAY_MS(100));
}
Exemplo n.º 2
0
static void config_adxl362(spi_device dev)
{
        uint8_t cmd[3];

        /* reset ADXL362 */
        cmd[0] = ADXL362_CMD_WRITE_REG;
        cmd[1] = ADXL362_REG_SOFT_RESET;
        cmd[2] = ADXL362_RESET_CODE;
        ad_spi_write(dev, cmd, sizeof(cmd));
        OS_DELAY_MS(1);

        /*
         * configure filter control register
         * range: 4g
         * halved bandwidth: true
         * external sampling trigger: false
         * output data rate: 25 Hz
         */
        cmd[0] = ADXL362_CMD_WRITE_REG;
        cmd[1] = ADXL362_REG_FILTER_CTL;
        cmd[2] = ADXL362_FILTER_CTL_CODE;
        ad_spi_write(dev, cmd, sizeof(cmd));

        /*
         * configure power control register
         * external clock: false
         * low noise: ultralow noise mode
         * wake-up mode: false
         * autosleep: false
         * measure mode: measure
         */
        cmd[0] = ADXL362_CMD_WRITE_REG;
        cmd[1] = ADXL362_REG_POWER_CTL;
        cmd[2] = ADXL362_POWER_CTL_CODE;
        ad_spi_write(dev, cmd, sizeof(cmd));

        /* wait for first measurement's value */
        OS_DELAY_MS(1000 / 25 + 1);
}
void ICACHE_FLASH_ATTR user_init(void){
	DBG("user_init() started\n");
	//
	//prepare test vars and buffers
	wlcd_text_draw_settings_struct S;
	//
	char* Str = os_malloc(256);
	uint8_t* ImgData = os_malloc(11000); //arrays allocated by os_malloc() are also always 4-bytes aligned (at least on ESP8266 SDK). Make sure that the buffer is big enough
	if((Str==NULL)||(ImgData==NULL)) return; //os_malloc() failed => abort
	uint16_t W, H;
	uint32_t t, t2;
	uint16_t i;
	uint16_t DoneXOffs;
	uint16_t DoneYOffs;
	//
	//init display
	wlcd_init();
	//
#if(WLCD_BPP==WLCD_16BPP)
	wfof_get_file_data_fast(WFOF_IDX_WLCD_DEMO_16BPP, (uint32_t*)ImgData, 0, WFOF_SIZE_WLCD_DEMO_16BPP);
#else
	wfof_get_file_data_fast(WFOF_IDX_WLCD_DEMO_24BPP, (uint32_t*)ImgData, 0, WFOF_SIZE_WLCD_DEMO_24BPP);
#endif
	//
	while(1){
		//
		//---- WLCD test / demo intro (countdown)
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		//demo image
		wlcd_img_draw(ImgData, (WLCD_WIDTH-wlcd_img_get_width(ImgData))/2, ((WLCD_HEIGHT-wlcd_img_get_height(ImgData))/2)-10);
		//
		//test countdown
		S.X = 10;
		S.Y = 10;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0x5C, 0x20);
		S.FontIdx = 2;
		S.FontZoomAdd = 0;
		S.BoldAdd = 0;
		S.HSpc = 0;
		S.VSpc = 0;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = 40;
		S.WrapStyle = WLCD_WRAP_NONE;
		//
		wlcd_text_measure("DONE", &S, &W, &H);
		DoneXOffs = (WLCD_WIDTH-W)/2;
		DoneYOffs = (WLCD_HEIGHT-H)/2;
		//
#if(WLCD_DISPLAY==WLCD_ILI9341)
		ets_sprintf(Str, "WLCD %s, ILI9341, %d bpp", wlcd_get_version(), WLCD_BPP);
#elif(WLCD_DISPLAY==WLCD_ILI9488_KDv4_HACK)
		ets_sprintf(Str, "WLCD %s, ILI9488_KDv4_HACK, %d bpp", wlcd_get_version(), WLCD_BPP);
#elif(WLCD_DISPLAY==WLCD_ILI9488)
		ets_sprintf(Str, "WLCD %s, ILI9488, %d bpp", wlcd_get_version(), WLCD_BPP);
#endif
		wlcd_text_draw(Str, &S);
		//
		S.X = 10;
		S.Y = 25;
#ifdef WLCD_USE_HSPI
		ets_sprintf(Str, "HW mode, HSPI CLK = %d kHz", ((uint32_t)system_get_cpu_freq()*1000) / WLCD_SPI_CLK_PREDIV / WLCD_SPI_CLK_CNTDIV);
#else
		ets_sprintf(Str, "SW mode");
#endif
		wlcd_text_draw(Str, &S);
		//
		S.X = 10;
		S.Y = WLCD_HEIGHT - 10 - wlcd_text_nrows_height(1, &S) - 3;
		ets_sprintf(Str, "Test starts in ");
		wlcd_text_measure(Str, &S, &W, &H);
		wlcd_text_draw(Str, &S);
		//wlcd_text_draw_or_measure(Str, &S, 0, &W, &H); //this is also possible instead of two lines above
		//
		S.FontZoomAdd = 1;
		S.X = 10 + W;
		S.Y = WLCD_HEIGHT - 10 - wlcd_text_nrows_height(1, &S);
		S.MaxW = WLCD_WIDTH - 10 - S.X;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0xFF, 0xFF);
		for(i=50;i>0;i--){
			wlcd_rect_fill(S.X, S.Y, wlcd_text_nchars_width(5, &S), wlcd_text_nrows_height(1, &S), 0);
			//
			ets_sprintf(Str, "%d.%d s", i/10, i%10);
			wlcd_text_draw(Str, &S);
			//
			OS_DELAY_MS(100);
		}
		S.FontZoomAdd = 0;
		//
		//---- random lines / line speed test
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		//draw 1000 random lines
		t = system_get_time();
		for(i=0;i<1000;i++){
			wlcd_line_draw(
				RAND_0_TO_X(WLCD_WIDTH-1), RAND_0_TO_X(WLCD_HEIGHT-1),
				RAND_0_TO_X(WLCD_WIDTH-1), RAND_0_TO_X(WLCD_HEIGHT-1),
				WLCD_RGB_TO_COLOR(0b00111000, 0b00111100, 0b01111000));
			//
			if(i%50==0) system_soft_wdt_feed(); //prevent rebooting if this loop takes too long
		}
		t = system_get_time() - t;
		//
		//compensate for "rand()" calculation
		t2 = system_get_time();
		volatile uint16_t Tmp;
		for(i=0;i<1000;i++){
			Tmp = RAND_0_TO_X(WLCD_WIDTH-1);
			Tmp = RAND_0_TO_X(WLCD_HEIGHT-1);
			Tmp = RAND_0_TO_X(WLCD_WIDTH-1);
			Tmp = RAND_0_TO_X(WLCD_HEIGHT-1);
		}
		t2 = system_get_time() - t2;
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0xFF, 0xFF);
		S.X = DoneXOffs;
		S.Y = DoneYOffs;
		wlcd_text_draw("DONE", &S);
		//
		OS_DELAY_MS(1000);
		//
		//clear whole display (black) and show stats
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b01111000, 0b01111100, 0b11111000);
		S.X = 10;
		S.Y = 10;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = WLCD_HEIGHT-20;
		S.WrapStyle = WLCD_WRAP_WORDS;
		ets_sprintf(Str, "1000 random lines on display %dx%d took %d ms (compensated for \"rand()\" calculation)", WLCD_WIDTH, WLCD_HEIGHT, (t-t2)/1000);
		wlcd_text_draw(Str, &S);
		OS_DELAY_MS(5000);
		//
		//---- image draw / image speed test
		//
#if(WLCD_BPP==WLCD_16BPP)
		wfof_get_file_data_fast(WFOF_IDX_SMILEY_50X50_U16BPP, (uint32_t*)ImgData, 0, WFOF_SIZE_SMILEY_50X50_U16BPP);
#else
		wfof_get_file_data_fast(WFOF_IDX_SMILEY_50X50_U24BPP, (uint32_t*)ImgData, 0, WFOF_SIZE_SMILEY_50X50_U24BPP);
#endif
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		t = system_get_time();
		for(i=0;i<1000;i++){
			wlcd_img_draw(ImgData, RAND_0_TO_X(WLCD_WIDTH-1-50), RAND_0_TO_X(WLCD_HEIGHT-1-50));
			//
			if(i%50==0) system_soft_wdt_feed(); //prevent rebooting if this loop takes too long
		}
		t = system_get_time() - t;
		//
		S.Color.u32t = 0;
		S.X = DoneXOffs;
		S.Y = DoneYOffs;
		wlcd_text_draw("DONE", &S);
		//
		OS_DELAY_MS(1000);
		//
		//clear whole display (black) and show stats
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b11111000, 0b01111100, 0b01111000);
		S.X = 10;
		S.Y = 10;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = WLCD_HEIGHT-20;
		S.WrapStyle = WLCD_WRAP_WORDS;
		ets_sprintf(Str, "1000 images (50x50 pixels, uncompressed image) took %d ms", t/1000);
		wlcd_text_draw(Str, &S);
		OS_DELAY_MS(5000);
		//
		//---- text draw / text speed test
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		ets_sprintf(Str, "This is a test of text drawing of 60 chars and with wrapping");
		t = system_get_time();
		for(i=0;i<100;i++){
			S.X = 10 + RAND_0_TO_X(10);
			S.Y = 10 + RAND_0_TO_X(100);
			S.MaxW = WLCD_WIDTH - 10 - S.X;
			S.MaxH = WLCD_HEIGHT - 10 - S.Y;
			S.Color.u32t = RAND_0_TO_X(0xFFFFFF);
			wlcd_text_draw(Str, &S);
			//
			if(i%50==0) system_soft_wdt_feed(); //prevent rebooting if this loop takes too long
		}
		t = system_get_time() - t;
		//
		S.Color.u32t = 0;
		S.X = DoneXOffs;
		S.Y = DoneYOffs;
		wlcd_text_draw("DONE", &S);
		//
		OS_DELAY_MS(1000);
		//
		//clear whole display (black) and show stats
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b11111000, 0b01111100, 0b11111000);
		S.X = 10;
		S.Y = 10;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = WLCD_HEIGHT-20;
		S.WrapStyle = WLCD_WRAP_WORDS;
		ets_sprintf(Str, "100 text sentences of 60 letters with word wrapping took %d ms", t/1000);
		wlcd_text_draw(Str, &S);
		OS_DELAY_MS(5000);
		//
		//---- text / font test - code page 1250 test
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0x5C, 0x20);
		S.X = 10;
		S.Y = 10;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = WLCD_HEIGHT-20;
		S.WrapStyle = WLCD_WRAP_WORDS;
		wlcd_text_draw("This is a test of code page 1250 font text output:\n\nP°эЪernь ЮluЭouшk¤ k∙Є ·pьl ясbelskщ єdy.", &S);
		//
		OS_DELAY_MS(4000);
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0xFF, 0x00);
		S.FontZoomAdd = 1;
		wlcd_text_draw("P°эЪernь ЮluЭouшk¤ k∙Є ·pьl ясbelskщ єdy.", &S);
		//
		OS_DELAY_MS(3000);
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		S.Y = 10;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0x00, 0xFF, 0);
		S.FontZoomAdd = 0;
		S.FontIdx = 0;
		wlcd_text_draw("This is some text.", &S);
		//
		S.Y = 30;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0x00, 0xFF, 0xFF);
		S.BoldAdd = 1;
		wlcd_text_draw("And this is the same font bolder.", &S);
		//
		S.Y = 50;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b11000000, 0b00111100, 0b11111000);
		S.HSpc = 5;
		wlcd_text_draw("We can also add horiz./vert. spacing.", &S);
		//
		S.Y = 75;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b11111000, 0b00111100, 0b01111000);
		S.FontZoomAdd = 1;
		S.BoldAdd = 0;
		S.HSpc = 0;
		wlcd_text_draw("Or zoom ...", &S);
		//
		S.Y = 105;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b10010000, 0b11111100, 0b01111000);
		S.FontZoomAdd = 2;
		S.HSpc = 0;
		wlcd_text_draw("ZOOM", &S);
		//
		S.Y = 140;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b01000000, 0b10000000, 0b11111000);
		S.FontZoomAdd = 0;
		S.FontIdx = 3;
		wlcd_text_draw("Different font\n0123456789", &S);
		//
		S.Y = 180;
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0xFF, 0x00);
		S.FontIdx = 2;
		wlcd_text_draw("And another different font (you can generate your own fonts)", &S);
		//
		OS_DELAY_MS(6000);
		//
		//---- read display data RAM back into buffer as WLCD image and use it to draw many copies of that image
		//
#ifndef WLCD_NO_READ
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		for(i=0;i<50;i++){
			wlcd_line_draw(
				RAND_0_TO_X(WLCD_WIDTH-1), RAND_0_TO_X(WLCD_HEIGHT-1),
				RAND_0_TO_X(WLCD_WIDTH-1), RAND_0_TO_X(WLCD_HEIGHT-1),
				WLCD_RGB_TO_COLOR(0b01111000, 0b01111100, 0b01111000));
		}
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0b00001000, 0b11110100, 0b01111000);
		S.X = 10;
		S.Y = 10;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = WLCD_HEIGHT-20;
		S.WrapStyle = WLCD_WRAP_WORDS;
		wlcd_text_draw("It's also possible to read LCD memory into buffer - creating a WLCD image (uncompressed stream of pixels) and re-use this image", &S);
		//
		wlcd_line_draw(10   , 10   , 10+29, 10   , 0xFFFFFF);
		wlcd_line_draw(10+29, 10   , 10+29, 10+29, 0xFFFFFF);
		wlcd_line_draw(10+29, 10+29, 10   , 10+29, 0xFFFFFF);
		wlcd_line_draw(10   , 10+29, 10   , 10   , 0xFFFFFF);
		//
		uint32_t Ret = wlcd_img_get((uint32_t*)ImgData, 10, 10, 30, 30);
		for(i=0;i<WLCD_WIDTH-30;i+=35){
			wlcd_img_draw(ImgData, i, 100);
		}
		//
		OS_DELAY_MS(8000);
#endif
		//
		//---- logo, github address
		//
		//clear whole display (black)
		wlcd_rect_fill(0,0, WLCD_WIDTH, WLCD_HEIGHT, 0);
		//
		//demo image
#if(WLCD_BPP==WLCD_16BPP)
		wfof_get_file_data_fast(WFOF_IDX_WLCD_DEMO_16BPP, (uint32_t*)ImgData, 0, WFOF_SIZE_WLCD_DEMO_16BPP);
#else
		wfof_get_file_data_fast(WFOF_IDX_WLCD_DEMO_24BPP, (uint32_t*)ImgData, 0, WFOF_SIZE_WLCD_DEMO_24BPP);
#endif
		wlcd_img_draw(ImgData, (WLCD_WIDTH-wlcd_img_get_width(ImgData))/2, ((WLCD_HEIGHT-wlcd_img_get_height(ImgData))/2)-20);
		//
		S.Color.u32t = WLCD_RGB_TO_COLOR(0xFF, 0x5C, 0x58);
		S.FontIdx = 1;
		S.X = 10;
		S.Y = WLCD_HEIGHT-40;
		S.MaxW = WLCD_WIDTH-20;
		S.MaxH = 40;
		S.VSpc = 4;
		S.WrapStyle = WLCD_WRAP_WORDS;
		wlcd_text_draw("https://github.com/wdim0/esp8266_fast_lcd_driver_hspi", &S);
		//
		OS_DELAY_MS(6000);
		//
		//----
		//
	}
	//
	//clean-up (yes, we never get here .. but it's always good to keep things structured)
	os_free(Str);
	os_free(ImgData);
}
Exemplo n.º 4
0
/*
 * Function needed by Bosch Sensortec driver
 */
static void bme280_wrap_delay(BME280_MDELAY_DATA_TYPE time)
{
        OS_DELAY_MS(time);
}
Exemplo n.º 5
0
static int sensor_board_bmg160_read(i2c_device dev)
{
        /* variable used for read the sensor data*/
        s16 v_gyro_datax_s16, v_gyro_datay_s16, v_gyro_dataz_s16 = BMG160_INIT_VALUE;
        /* result of communication results*/
        s32 com_rslt = ERROR;
        bool sign;
        uint32_t conv_val;
        bmg160_dev = dev;

        /*
         * Initialize driver data, feed Bosch driver with functions needed to access I2C bus.
         */
        com_rslt = bmg160_init(&bmg160);

        /* Wait for data ready */
        OS_DELAY_MS(9);

        /*
         * For initialization it is required to set the mode of
         * the sensor as "NORMAL"
         * data acquisition/read/write is possible in this mode
         * by using the below API able to set the power mode as NORMAL
         */
        com_rslt += bmg160_set_power_mode(BMG160_MODE_NORMAL);

        /* Wait for data ready */
        OS_DELAY_MS(9);

        /* Set range */
        com_rslt += bmg160_set_range_reg(BMG160_RANGE_500);

        /*
         * Set bandwidth of 230Hz
         */
        com_rslt += bmg160_set_bw(C_BMG160_BW_230HZ_U8X);

        /* Wait for data ready */
        OS_DELAY_MS(9);

        /* Read Gyro data xyz */
        com_rslt += bmg160_get_data_X(&v_gyro_datax_s16);
        com_rslt += bmg160_get_data_Y(&v_gyro_datay_s16);
        com_rslt += bmg160_get_data_Z(&v_gyro_dataz_s16);

        /* print raw values */
        printf(NEWLINE "Gyroscope data (raw 16 bit) - x: %04X, y: %04X, z: %04X",
                                        (uint16_t) v_gyro_datax_s16, (uint16_t) v_gyro_datay_s16,
                                                                (uint16_t) v_gyro_dataz_s16);
        /* convert and print values in  deg/s (degree per second)*/
        printf(NEWLINE "Gyroscope data - ");
        convert_gyro_value(v_gyro_datax_s16, &sign, &conv_val);
        printf("x: %s%lu.%02lu deg/s, ", (sign ? "-" : ""), conv_val / 100, conv_val % 100);
        convert_gyro_value(v_gyro_datay_s16, &sign, &conv_val);
        printf("y: %s%lu.%02lu deg/s, ", (sign ? "-" : ""), conv_val / 100, conv_val % 100);
        convert_gyro_value(v_gyro_dataz_s16, &sign, &conv_val);
        printf("z: %s%lu.%02lu deg/s", (sign ? "-" : ""), conv_val / 100, conv_val % 100);

        /*
         * For de-initialization it is required to set the mode of
         * the sensor as "DEEPSUSPEND"
         * the device reaches the lowest power consumption only
         * interface selection is kept alive
         * No data acquisition is performed
         * The DEEPSUSPEND mode set from the register 0x11 bit 5
         * by using the below API able to set the power mode as DEEPSUSPEND
         * For the read/ write operation it is required to provide least 450us
         * micro second delay
         */
        com_rslt += bmg160_set_power_mode(BMG160_MODE_DEEPSUSPEND);

        return com_rslt;
}
Exemplo n.º 6
0
/*
 * Function needed by Bosch Sensortec driver
 */
static void bmg160_wrap_delay(BMG160_MDELAY_DATA_TYPE time)
{
        OS_DELAY_MS(time + 3);
}
Exemplo n.º 7
0
/*
 * Function needed by Bosch Sensortec driver
 */
static void bmm150_wrap_delay(BMM050_MDELAY_DATA_TYPE time)
{
        OS_DELAY_MS(time);
}
Exemplo n.º 8
0
static int sensor_board_bme280_read(i2c_device dev)
{
        /* The variable used to read uncompensated temperature */
        s32 v_data_uncomp_tem_s32 = BME280_INIT_VALUE;
        /* The variable used to read uncompensated pressure */
        s32 v_data_uncomp_pres_s32 = BME280_INIT_VALUE;
        /* The variable used to read uncompensated pressure */
        s32 v_data_uncomp_hum_s32 = BME280_INIT_VALUE;
        /* The variable used to read real temperature */
        s32 v_actual_temp_s32 = BME280_INIT_VALUE;
        /* The variable used to read real pressure */
        u32 v_actual_press_u32 = BME280_INIT_VALUE;
        /* The variable used to read real humidity */
        u32 v_actual_humity_u32 = BME280_INIT_VALUE;
        /* result of communication results */
        s32 com_rslt = 0;
        bme280_dev = dev;
        u8 delay;

        /*
         * Initialize driver data, feed Bosch driver with functions needed to access I2C bus.
         */
        com_rslt = bme280_init(&bme280);

        /*
         * For initialization it is required to set the mode of
         * the sensor as "NORMAL"
         * data acquisition/read/write is possible in this mode
         * by using the below API able to set the power mode as NORMAL
         */
        com_rslt += bme280_set_power_mode(BME280_NORMAL_MODE);

        /*
         * For reading the pressure, humidity and temperature data it is required to
         * set the OSS setting of humidity, pressure and temperature
         * The "BME280_CTRLHUM_REG_OSRSH" register sets the humidity
         * data acquisition options of the device.
         * changes to this registers only become effective after a write operation to
         * "BME280_CTRLMEAS_REG" register.
         * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
         * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
         * the "BME280_CTRLMEAS_REG" register in the function
         */
        com_rslt += bme280_set_oversamp_humidity(BME280_OVERSAMP_1X);

        /* set the pressure oversampling */
        com_rslt += bme280_set_oversamp_pressure(BME280_OVERSAMP_2X);

        /* set the temperature oversampling */
        com_rslt += bme280_set_oversamp_temperature(BME280_OVERSAMP_4X);

        /*
         * Normal mode comprises an automated perpetual cycling between an (active)
         * Measurement period and an (inactive) standby period.
         * The standby time is determined by the contents of the register t_sb.
         * Standby time can be set using BME280_STANDBYTIME_125_MS.
         * Usage Hint : bme280_set_standbydur(BME280_STANDBYTIME_125_MS)
         */
        com_rslt += bme280_set_standby_durn(BME280_STANDBY_TIME_1_MS);

        /*
         * Computation time depends on what measurements are selected and which oversampling is
         * used. This helper function will calculate time to wait before data can be read.
         */
        bme280_compute_wait_time(&delay);

        /*
         * Wait for calculated time.
         */
        OS_DELAY_MS(delay);

        /*
         * Read raw ADC value from sensor
         */
        com_rslt += bme280_read_uncomp_pressure_temperature_humidity(&v_data_uncomp_tem_s32,
                                                &v_data_uncomp_pres_s32, &v_data_uncomp_hum_s32);

        printf(NEWLINE "Uncompensated temp=%d, pres=%d, hum=%u", v_data_uncomp_tem_s32,
                v_data_uncomp_pres_s32, v_data_uncomp_hum_s32);

        /*
         * Read the true temperature, humidity and pressure.
         * This function will convert ADC value to true values according to calibration data.
         * Pressure humidity and temperature are fixed point values.
         * Temperature in 0.01C, pressure in Pa, humidity in 0.001%.
         */
        com_rslt += bme280_read_pressure_temperature_humidity(&v_actual_press_u32,
                                                        &v_actual_temp_s32, &v_actual_humity_u32);

        printf(NEWLINE "Compensated pressure=%d.%02d hPa, temp=%d.%02d C, hum=%u.%03d %%",
                v_actual_press_u32 / 100, v_actual_press_u32 % 100,
                v_actual_temp_s32 / 100, v_actual_temp_s32 % 100,
                v_actual_humity_u32 / 1000, v_actual_humity_u32 % 1000);
        /*
         * For de-initialization it is required to set the mode of
         * the sensor as "SLEEP"
         * the device reaches the lowest power consumption only
         * In SLEEP mode no measurements are performed
         * All registers are accessible
         * by using the below API able to set the power mode as SLEEP
         */
        com_rslt += bme280_set_power_mode(BME280_SLEEP_MODE);

        return com_rslt;
}