传感器的方向定义:

使用rshell 连上开发板测试。
~$ rshell --buffer-size=30 -p /dev/ttyS4
/home/xdl> repl
MicroPython v1.11-427-gd5cbee3cf-dirty on 2019-10-24; F4DISC with STM32F407
Type "help()" for more information.
>>>
>>> import staccel
>>> accel=staccel.STAccel() # 初始化一个实例
>>> accel. # 可使用的方法和属性
__class__ __init__ __module__ __qualname__
__dict__ x y spi
convert_raw_to_g read_bytes write_bytes
read_id z xyz cs_pin
who_am_i sensitivity
>>> accel.who_am_i # 返回加速度传感器的寄存器ID地址
59
>>> bin(59)
'0b111011'
对比LIS302DL数据手册上的Who_Am_I地址

相同说明能够正常使用。。。
分别获取X,Y,Z方向上的加速度值
>>> accel.x()
0.288
>>> accel.y()
-0.036
>>> accel.z()
0.81
>>> accel.xyz() # 返回三个方向上加速度的三元组
(-0.306, 0.306, 1.008)