Skip to content

Commit 7a81341

Browse files
committed
fix(bh1750): fix missing RTOS headers and update test_apps
close #521
1 parent 6f25eba commit 7a81341

File tree

9 files changed

+48
-8
lines changed

9 files changed

+48
-8
lines changed

.gitlab/ci/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,14 @@ build_components_sensors_imu_lis2dh12_test_apps:
15221522
variables:
15231523
EXAMPLE_DIR: components/sensors/imu/lis2dh12/test_apps
15241524

1525+
build_components_sensors_light_sensor_bh1750_test_apps:
1526+
extends:
1527+
- .build_examples_template
1528+
- .rules:build:components_sensors_light_sensor_bh1750_test_apps
1529+
- .build_idf_active_release_version
1530+
variables:
1531+
EXAMPLE_DIR: components/sensors/light_sensor/bh1750/test_apps
1532+
15251533
build_components_sensors_light_sensor_veml6040_test_apps:
15261534
extends:
15271535
- .build_examples_template

.gitlab/ci/rules.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,7 @@
24042404
- <<: *if-dev-push
24052405
changes: *patterns-components_sensors_imu_mpu6050
24062406

2407-
.rules:build:components_sensors_light_sensor_bh1750_test:
2407+
.rules:build:components_sensors_light_sensor_bh1750_test_apps:
24082408
rules:
24092409
- <<: *if-protected
24102410
- <<: *if-label-build
@@ -2414,6 +2414,8 @@
24142414
changes: *patterns-build_system
24152415
- <<: *if-dev-push
24162416
changes: *patterns-components_sensors_light_sensor_bh1750
2417+
- <<: *if-dev-push
2418+
changes: *patterns-components_i2c_bus
24172419

24182420
.rules:build:components_sensors_light_sensor_veml6040_test_apps:
24192421
rules:

components/sensors/light_sensor/bh1750/bh1750.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66

77
#include <stdio.h>
8+
#include "freertos/FreeRTOS.h"
9+
#include "freertos/task.h"
810
#include "bh1750.h"
911

1012
#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */

components/sensors/light_sensor/bh1750/test/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.5)
4+
5+
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
6+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
7+
project(bh1750_test)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
idf_component_register(SRC_DIRS "."
2+
PRIV_REQUIRES unity test_utils i2c_bus)

components/sensors/light_sensor/bh1750/test/bh1750_test.c renamed to components/sensors/light_sensor/bh1750/test_apps/main/bh1750_test.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
#include "unity.h"
99
#include "bh1750.h"
1010
#include "esp_log.h"
11+
#include "freertos/FreeRTOS.h"
12+
#include "freertos/task.h"
1113

12-
#define I2C_MASTER_SCL_IO 22 /*!< gpio number for I2C master clock */
13-
#define I2C_MASTER_SDA_IO 21 /*!< gpio number for I2C master data */
14-
#define I2C_MASTER_NUM I2C_NUM_1 /*!< I2C port number for master dev */
14+
#define I2C_MASTER_SCL_IO 2 /*!< gpio number for I2C master clock */
15+
#define I2C_MASTER_SDA_IO 1 /*!< gpio number for I2C master data */
16+
#define I2C_MASTER_NUM I2C_NUM_0 /*!< I2C port number for master dev */
1517
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master do not need buffer */
1618
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master do not need buffer */
1719
#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */
@@ -44,7 +46,7 @@ static void bh1750_test_get_data()
4446
int ret;
4547
bh1750_cmd_measure_t cmd_measure;
4648
float bh1750_data;
47-
int cnt = 2;
49+
int cnt = 10;
4850

4951
while (cnt--) {
5052
bh1750_power_on(bh1750);
@@ -80,3 +82,15 @@ TEST_CASE("Sensor BH1750 test", "[bh1750][iot][sensor]")
8082
bh1750_test_get_data();
8183
bh1750_test_deinit();
8284
}
85+
86+
void app_main(void)
87+
{
88+
printf(" ____ _ _ _ _____ ____ ___ _____ _____ ____ _____ \n");
89+
printf("| __ )| | | / |___ | ___| / _ \\ |_ _| ____/ ___|_ _|\n");
90+
printf("| _ \\| |_| | | / /|___ \\| | | | | | | _| \\___ \\ | | \n");
91+
printf("| |_) | _ | | / / ___) | |_| | | | | |___ ___) || | \n");
92+
printf("|____/|_| |_|_|/_/ |____/ \\___/ |_| |_____|____/ |_| \n");
93+
printf(" \n");
94+
95+
unity_run_menu();
96+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dependencies:
2+
idf: ">=4.4"
3+
bh1750:
4+
version: "*"
5+
override_path: "../../../bh1750"
6+
i2c_bus:
7+
version: "*"
8+
override_path: "../../../../../i2c_bus"

0 commit comments

Comments
 (0)