豌豆小车/Buggy

Methods

(static) getBatteryValue(moduleIndex) → {Promise.<int>}

Source:
获取电池电量值
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
电池电量值,范围 0~100
Type
Promise.<int>

(static) setBuzzer(moduleIndex, frequency)

Source:
设置蜂鸣器声音频率(Hz) 设置频率为0表示关闭蜂鸣器
Parameters:
Name Type Description
moduleIndex int 模块序号
frequency int 频率:0~20000 Hz

(static) setLed1(moduleIndex, r, g, b)

Source:
设置led1灯颜色(r,g,b 参数都设置为0时,关闭LED)
Parameters:
Name Type Description
moduleIndex int 模块序号
r int 红色:0~255
g int 绿色:0~255
b int 蓝色:0~255

(static) setLed2(moduleIndex, r, g, b)

Source:
设置led1灯颜色(r,g,b 参数都设置为0时,关闭LED)
Parameters:
Name Type Description
moduleIndex int 模块序号
r int 红色:0~255
g int 绿色:0~255
b int 蓝色:0~255

(static) setMotors(moduleIndex, speed_left, speed_right)

Source:
设置电机A转动
Parameters:
Name Type Description
moduleIndex int 模块序号
speed_left int 转速:-100~100 符号表示转动方向,绝对值为转动速度
speed_right int 转速:-100~100 符号表示转动方向,绝对值为转动速度

(static) getS1(moduleIndex) → {Promise.<float>}

Source:
获取s1检测的亮度值 亮度值代表相对强度,值越大代表亮度越强
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
亮度值,范围 0~100
Type
Promise.<float>

(static) getS2(moduleIndex) → {Promise.<float>}

Source:
获取s2检测的亮度值 亮度值代表相对强度,值越大代表亮度越强
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
亮度值,范围 0~100
Type
Promise.<float>

(static) getTracerAllBlackState(moduleIndex) → {Promise.<bool>}

Source:
判断循迹传感器是否全部检测为黑
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
True:循迹传感器全部检测为黑 False:循迹传感器任意一个检测到白
Type
Promise.<bool>

(static) getTracerAllWhiteState(moduleIndex) → {Promise.<bool>}

Source:
判断循迹传感器是否全部检测为白
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
True:循迹传感器全部检测为白 False:循迹传感器任意一个检测到黑
Type
Promise.<bool>

(static) isTracerCheckBlack(moduleIndex, channel) → {Promise.<bool>}

Source:
判断某个循迹传感器是否检测为黑
Parameters:
Name Type Description
moduleIndex int 模块序号
channel int 通道:1~5 表示t1~t5
Returns:
True:对应循迹传感器全部检测为黑 False:对应循迹传感器全部检测为白
Type
Promise.<bool>

(static) getTracerValue(moduleIndex, channel) → {Promise.<float>}

Source:
获取某个循迹传感器的检测值
Parameters:
Name Type Description
moduleIndex int 模块序号
channel int 通道:1~5 表示t1~τ5
Returns:
Type
Promise.<float>

(static) isT6CheckUnobstructed(moduleIndex) → {Promise.<bool>}

Source:
判断t6是否无遮挡
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
True:t6无遮挡 False:t6被遮挡
Type
Promise.<bool>

(static) isT7CheckUnobstructed(moduleIndex) → {Promise.<bool>}

Source:
判断t7是否无遮挡
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
True:t7无遮挡 False:t7被遮挡
Type
Promise.<bool>

(static) setCalibrationPercentage(moduleIndex, value)

Source:
设置循迹传感器的阈值百分比为value 阈值 = 循迹传感器检测的黑色值 * value% + 循迹传感器检测的白色值 * (1 - value%)
Parameters:
Name Type Description
moduleIndex int 模块序号
value int 值:0~100

(static) calibrationBlack(moduleIndex)

Source:
校准循迹传感器的黑色值
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) calibrationWhite(moduleIndex)

Source:
校准循迹传感器的白色值
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) getFirmwareVersion(moduleIndex) → {Promise.<int>}

Source:
获取当前模块版本号
Parameters:
Name Type Description
moduleIndex int 模块序号
Returns:
Type
Promise.<int>

(static) setOnboardRGB(moduleIndex, rgb)

Source:
设置板载LED的颜色
Parameters:
Name Type Description
moduleIndex int 模块序号
rgb int '红': 1,'绿':2,'蓝':3,'浅蓝':4,'黄':5,'紫':6,'白': 7,'不亮': 8

(static) regBatteryValue(moduleIndex)

Source:
注册电池电量值上传,当电池电量发生改变时会接收到数据
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) regS1(moduleIndex)

Source:
注册s1检测的光强值上传,当s1检测的光强值改变时会接收到数据
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) regS2(moduleIndex)

Source:
注册s2检测的光强值上传,当s2检测的光强值改变时会接收到数据
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) regTracerState(moduleIndex)

Source:
注册循迹传感器检测状态上传,当s循迹传感器检测状态改变时会接收到数据 True表示检测为黑色,False表示检测为白色 channel表示通道,1~5表示选择t1~t5通道 当channel为0时,上传数据为list(bool), 5个通道的检测状态一起上传
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) unregBatteryValue(moduleIndex)

Source:
注销电池电量值上传
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) unregS1(moduleIndex)

Source:
注销s1检测的光强值上传
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) unregS2(moduleIndex)

Source:
注销s2检测的光强值上传
Parameters:
Name Type Description
moduleIndex int 模块序号

(static) unregTracerState(moduleIndex)

Source:
注销循迹传感器检测状态上传
Parameters:
Name Type Description
moduleIndex int 模块序号