Skip to content

Commit acfb9b6

Browse files
committed
apds9960: Add test scenario for gesture and color sensor.
1 parent 5cff376 commit acfb9b6

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

tests/scenarios/apds9960.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
driver: apds9960
2+
driver_class: uAPDS9960
3+
i2c_address: 0x39
4+
5+
# I2C config for hardware tests (STeaMi board - STM32WB55)
6+
i2c:
7+
id: 1
8+
9+
# Register values for mock tests
10+
mock_registers:
11+
# ID register (0x92): expected 0xAB
12+
0x92: 0xAB
13+
# ENABLE (0x80): power off at start
14+
0x80: 0x00
15+
# CONTROL (0x8F): used by read-modify-write in init
16+
0x8F: 0x00
17+
# CONFIG2 (0x90): default
18+
0x90: 0x01
19+
# CONFIG3 (0x9F): default
20+
0x9F: 0x00
21+
# GCONF2 (0xA3): used by gesture config
22+
0xA3: 0x00
23+
# GCONF4 (0xAB): used by gesture config
24+
0xAB: 0x00
25+
# STATUS (0x93): AVALID + PVALID
26+
0x93: 0x03
27+
# Ambient light: clear channel = 256 (0x0100)
28+
0x94: 0x00 # CDATAL
29+
0x95: 0x01 # CDATAH
30+
# Red = 128
31+
0x96: 0x80 # RDATAL
32+
0x97: 0x00 # RDATAH
33+
# Green = 64
34+
0x98: 0x40 # GDATAL
35+
0x99: 0x00 # GDATAH
36+
# Blue = 32
37+
0x9A: 0x20 # BDATAL
38+
0x9B: 0x00 # BDATAH
39+
# Proximity = 80
40+
0x9C: 0x50
41+
42+
tests:
43+
- name: "Verify device ID register"
44+
action: call
45+
method: _read_byte_data
46+
args: [0x92]
47+
expect: 0xAB
48+
mode: [mock, hardware]
49+
50+
- name: "Read ambient light returns expected value"
51+
action: call
52+
method: readAmbientLight
53+
expect: 256
54+
mode: [mock]
55+
56+
- name: "Read proximity returns expected value"
57+
action: call
58+
method: readProximity
59+
expect: 80
60+
mode: [mock]
61+
62+
- name: "Read red light returns expected value"
63+
action: call
64+
method: readRedLight
65+
expect: 128
66+
mode: [mock]
67+
68+
- name: "Ambient light in plausible range"
69+
action: call
70+
method: readAmbientLight
71+
expect_range: [0, 65535]
72+
mode: [hardware]
73+
74+
- name: "Proximity in plausible range"
75+
action: call
76+
method: readProximity
77+
expect_range: [0, 255]
78+
mode: [hardware]
79+
80+
- name: "Light and proximity values feel correct"
81+
action: manual
82+
display:
83+
- method: readAmbientLight
84+
label: "Ambient light"
85+
unit: ""
86+
- method: readProximity
87+
label: "Proximity"
88+
unit: ""
89+
prompt: "Les valeurs de lumière ambiante et de proximité sont-elles cohérentes ?"
90+
expect_true: true
91+
mode: [hardware]

0 commit comments

Comments
 (0)