Skip to content

Commit 2b88be9

Browse files
authored
Merge pull request #130 from tmobile/tsl2540-sample-wip
Implement light-to-dark sample
2 parents 62da992 + 9102b33 commit 2b88be9

File tree

7 files changed

+423
-0
lines changed

7 files changed

+423
-0
lines changed

samples/illuminance/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2023 T-Mobile USA, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
cmake_minimum_required(VERSION 3.20.0)
6+
7+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
8+
project(illuminance)
9+
10+
target_sources(app PRIVATE "src/main.c")

samples/illuminance/Kconfig

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2023 T-Mobile USA, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
mainmenu "ams OSRAM TSL2540"
7+
8+
config APP_LIGHT_ALERT_HIGH_THRESH
9+
int "High threshold for alert trigger in lux"
10+
range 0 79110
11+
default 1000
12+
help
13+
TODO: replace the following text with relevant information
14+
Set this to enable alerts for high lux
15+
although this will work with one shot enabled,
16+
it requires continuous monitoring mode to be enabled
17+
to work in real time.
18+
See spec sheet for more details.
19+
20+
config APP_LIGHT_ALERT_LOW_THRESH
21+
int "Low threshold for alert trigger in lux"
22+
range 0 79110
23+
default 10
24+
help
25+
TODO: replace the following text with relevant information
26+
Set this to enable alerts for low temperatures
27+
although this will work with one shot enabled,
28+
it requires continuous monitoring mode to be enabled
29+
to work in real time.
30+
See spec sheet for more details.
31+
32+
source "Kconfig.zephyr"

samples/illuminance/README.rst

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.
2+
.
3+
.
4+
=============
5+
Sample output
6+
=============
7+
8+
9+
>> *** Booting Zephyr OS build 596dd391de46 ***
10+
11+
Welcome to T-Mobile - Internet of Things
12+
13+
This application aims to demonstrate the Gecko's Energy Mode 2 (EM2) (Deep Sleep
14+
Mode) sleep/wake capabilities in conjunction with the high/low illuminance
15+
threshold detection circuitry of the TSL2540 light sensor integrated into the
16+
tmo_dev_edge.
17+
18+
19+
While observing the console output, increase the light illuminating the
20+
tmo_dev_edge's light sensor until the sensor readings at or above the high
21+
threshold are displayed. Reducing the intensity of the light source will cause
22+
the alerts to cease. Casting a shadow over the light sensor will cause sensor
23+
readings at or below the low threshold to be displayed.
24+
25+
26+
Awaiting TSL2540 illuminance threshold-high/threshold-low alerts
27+
28+
[00:00:01.007,000] <inf> illuminance: Set up button at gpio@4000a030 pin 13
29+
30+
Set SENSOR_ATTR_UPPER_THRESH (1000lx)
31+
Set SENSOR_ATTR_LOWER_THRESH (10lx)
32+
[00:00:01.259,000] <inf> tsl2540: Interrupt status(0x93): 0x10: AINT
33+
uart:~$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2023 T-Mobile USA, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
CONFIG_BT_DEVICE_NAME="TMO DevEdge"
6+
CONFIG_POSIX_CLOCK=y
7+
CONFIG_CMU_HFCLK_HFXO=y
8+
CONFIG_DEVICE_SHELL=y
9+
CONFIG_GPIO_SHELL=n
10+
CONFIG_SOC_GECKO_EMU_DCDC=y
11+
CONFIG_SOC_GECKO_EMU_DCDC_MODE_OFF=y
12+
CONFIG_I2C=y
13+
CONFIG_SPI=y
14+
CONFIG_REBOOT=y
15+
CONFIG_COUNTER=y
16+
CONFIG_LED=y
17+
CONFIG_LED_PWM=y
18+
CONFIG_LED_SHELL=y
19+
CONFIG_PWM=y
20+
CONFIG_PWM_SHELL=n
21+
CONFIG_PWM_GECKO=y
22+
CONFIG_SENSOR=y
23+
CONFIG_SENSOR_SHELL=y
24+
CONFIG_LPS22HH=n
25+
CONFIG_LIS2DW12=n
26+
CONFIG_TSL2540=y
27+
CONFIG_TMP108=n
28+
CONFIG_CXD5605=n
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* Copyright (c) 2023 T-Mobile USA, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/

samples/illuminance/prj.conf

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2023 T-Mobile USA, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# UART support
6+
CONFIG_SERIAL=y
7+
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=1024
8+
CONFIG_RING_BUFFER=y
9+
10+
# Sensor
11+
CONFIG_SENSOR=y
12+
CONFIG_STDOUT_CONSOLE=y
13+
CONFIG_CBPRINTF_FP_SUPPORT=y
14+
CONFIG_I2C=y
15+
16+
# TSL2540 interrupt support
17+
# CONFIG_TSL2540_TRIGGER_NONE=y
18+
# CONFIG_TSL2540_TRIGGER_GLOBAL_THREAD=y
19+
CONFIG_TSL2540_TRIGGER_OWN_THREAD=y
20+
21+
# Power Management
22+
CONFIG_PM=y
23+
# CONFIG_PM_DEVICE=y
24+
25+
# GPIO
26+
CONFIG_GPIO=y
27+
CONFIG_SHELL=y
28+
CONFIG_SHELL_LOG_LEVEL_INF=y
29+
CONFIG_SHELL_CMD_BUFF_SIZE=2100
30+
31+
# Logging
32+
CONFIG_LOG=y
33+
CONFIG_LOG_MODE_IMMEDIATE=y

0 commit comments

Comments
 (0)