Weeemake Arduino Libaries API Reference

class WeUltrasonicSensor

描述:超声波传感器类名定义

其可直接调用的成员函数如下:

(1) WeUltrasonicSensor(uint8_t port=0)

描述:构造函数,在定义超声波类时可定义接口

参数:

port

选择端口,如PORT_A,PORT_1

返回值:无

示例:WeUltrasonicSensor ultrasonic_sensor(PORT_A);

备注:在定义类时,可以不直接传入port的值(初值为0),可之后设置:

WeUltrasonicSensor ultrasonic_sensor;

之后调用:ultrasonic_sensor.reset(PORT_A);

 

(2) void reset(uint8_t port=0)

描述:可重新设置接口

参数:

port

选择端口,如PORT_A,PORT_1

返回值:无

 

(3) double distanceCm(void)

描述:获取超声波测距数据

参数:无

返回值:双精度浮点数,范围3~500,单位:厘米

 

(4) void setColor(uint8_t index, uint8_t red, uint8_t green, uint8_t blue)

描述:设置超声波内置RGB灯的显示颜色并显示

参数:

index

选择RGB灯,范围1~31为左,2为右,3为全部

red

红色分量设置(0~255

green

绿色分量设置(0~255

blue

蓝色分量设置(0~255

返回值:无

 

(5) void setLed(uint8_t index, bool isOn);

描述:驱动Mini RGB超声波传感器板载上两颗黄色LED

参数:

index

选择LED灯,范围1~31为左,2为右,3为全部

isOn

设置LED灯的状态,0为灭,1为亮

返回值:无

 

class WeLineFollower

描述:双路巡线传感器类名定义

其可直接调用的成员函数如下:

(1) WeLineFollower(uint8_t port=0)

描述:构造函数,在定义超声波类时可定义接口

参数:

port

选择端口,如PORT_A,PORT_1

返回值:无

示例:WeLineFollower linefollower_sensor(PORT_A);

备注:在定义类时,可以不直接传入port的值(初值为0),可之后设置:

WeLineFollower linefollower_sensor;

之后调用:linefollower_sensor.reset(PORT_A);

 

(2) void reset(uint8_t port=0)

描述:可重新设置接口

参数:

port

选择端口,如PORT_A,PORT_1

返回值:无

 

(3) uint16_t startRead(uint8_t index)

描述:获取巡线探头测量数据

参数:

index

选择探头,1S12S2

返回值:整数,范围0~1023

 

class WeSingleLineFollower

(1) WeSingLineFollower(uint8_t port=0)

描述:构造函数,在定义超声波类时可定义接口

参数:

port

选择端口,只能选择模拟口,ELF主控板的PORT_1~PORT_6ELF MINI主控板的PORT_A~PORT_D

返回值:无

 

(2) uint16_t read(void)

描述:获取巡线探头测量数据

参数:无

返回值:整数,范围0~1023