1"""
2Testing ap3216c python driver
3
4The below i2c configuration is needed in your board.json.
5
6"ap3216c": {
7    "type": "I2C",
8    "port": 1,
9    "addrWidth": 7,
10    "freq": 100000,
11    "mode": "master",
12    "devAddr": 30
13}
14"""
15print("testing ap3216c...")
16from ap3216c import AP3216C
17
18ap3216cDev = AP3216C()
19ap3216cDev.open("ap3216c")
20ap3216cDev.init()
21print("ap3216c init finished")
22
23brightness = ap3216cDev.ap3216c_read_ambient_light()
24print("ap3216c brightness is:" , brightness)
25
26ir_data = ap3216cDev.ap3216c_read_ir_data()
27print("ap3216c ir_data is:" , ir_data)
28
29ps_data = ap3216cDev.ap3216c_read_ps_data()
30print("ap3216c ps_data is:" , ps_data)
31
32if ((ps_data >> 15) & 1):
33    print("near !")
34else:
35    print("far !")
36
37ap3216cDev.close()
38print("test ap3216c success!");
39