差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
wm_wiki:arduino_ide:api_document [2019/05/14 22:03] juneral [2. 单路巡线传感器API] |
wm_wiki:arduino_ide:api_document [2019/05/15 14:34] (当前版本) juneral [MP3模块API] |
||
---|---|---|---|
行 906: | 行 906: | ||
lang=ZH-CN>表示未播放完</span></span></p> | lang=ZH-CN>表示未播放完</span></span></p> | ||
</body></html> | </body></html> | ||
+ | |||
+ | <sxh c/c++; first-line: 1;highlight: [50,100]; title: mp3_test.ino> | ||
+ | #include "WeELF328P.h" | ||
+ | |||
+ | WeMP3 mp3(PORT_A); | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | mp3.appointVolume(20); //Volume 0~23 | ||
+ | mp3.appointDevice(4); //2-TF; 4-FLASH | ||
+ | mp3.appointMusic(1); //0~3000 | ||
+ | } | ||
+ | void loop() | ||
+ | { | ||
+ | if(mp3.isOver()==1) | ||
+ | { | ||
+ | mp3.nextMusic(); | ||
+ | } | ||
+ | } | ||
+ | </sxh> | ||
+ | \\ | ||
+ | |||
+ | ===== 电子指南针传感器API ===== | ||
+ | |||
+ | <html><body> | ||
+ | <p class=MsoNormal align=left style='text-align:left;background:white'><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"; | ||
+ | color:#8000FF'>class</span></b><span style='font-size:10.0pt;font-family:"Courier New"; | ||
+ | mso-fareast-font-family:"Times New Roman";color:black'> </span><span | ||
+ | class=SpellE><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | mso-fareast-font-family:"Times New Roman";color:#0080FF'>WeCompassSensor</span></b></span><span | ||
+ | style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-font-family: | ||
+ | "Times New Roman"'><o:p></o:p></span></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>描述:电子罗盘传感器类名定义</span></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>其可直接调用的成员函数如下:</span></p> | ||
+ | |||
+ | <p class=MsoNormal align=left style='text-align:left;background:white'><b><span | ||
+ | style='font-size:12.0pt;font-family:"News Gothic MT",sans-serif'>(1)</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New"'> </span></b><span | ||
+ | class=SpellE><span class=GramE><b><span style='font-size:16.0pt;font-family: | ||
+ | "Courier New";mso-fareast-font-family:"Times New Roman";color:#0080FF'>WeCompassSensor</span></b></span></span><span | ||
+ | class=GramE><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | color:black'>(</span></b></span><b><span style='font-size:16.0pt;font-family: | ||
+ | "Courier New";color:#8000FF'>uint8_t</span></b><span style='font-size:10.0pt; | ||
+ | font-family:"Courier New";color:black'> </span><b><span style='font-size:16.0pt; | ||
+ | font-family:"Courier New";color:#0080FF'>port</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:black'>=</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:red'>0</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:black'>)</span></b></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>描述:构造函数,在定义电子罗盘传感器类时可定义接口</span></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>参数:</span></p> | ||
+ | |||
+ | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 | ||
+ | style='border-collapse:collapse;mso-yfti-tbllook:1184;mso-padding-alt:0in 0in 0in 0in'> | ||
+ | <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes; | ||
+ | height:25.6pt'> | ||
+ | <td style='border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt; | ||
+ | height:25.6pt'> | ||
+ | <p class=MsoNormal><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | color:#0080FF'>port</span></b></p> | ||
+ | </td> | ||
+ | <td width=330 style='width:247.4pt;border:solid windowtext 1.0pt;border-left: | ||
+ | none;padding:0in 5.4pt 0in 5.4pt;height:25.6pt'> | ||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线; | ||
+ | color:windowtext'>选择端口,如</span><span style='font-size:14.0pt;color:windowtext'>PORT_A,PORT_1</span><span | ||
+ | lang=ZH-CN style='font-size:14.0pt;font-family:等线;color:windowtext'>等</span></p> | ||
+ | </td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>返回值:无</span></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>示例:</span><span | ||
+ | class=SpellE><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | mso-fareast-font-family:"Times New Roman";color:#0080FF'>WeCompassSensor</span></b></span><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:#0080FF'> <span | ||
+ | class=GramE>compass(</span>PORT_A);</span></b></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>备注:在定义类时,可以不直接传入</span><span | ||
+ | style='font-size:14.0pt'>port</span><span lang=ZH-CN style='font-size:14.0pt; | ||
+ | font-family:等线'>的值</span><span style='font-size:14.0pt'>(</span><span | ||
+ | lang=ZH-CN style='font-size:14.0pt;font-family:等线'>初值为</span><span | ||
+ | style='font-size:14.0pt'>0)</span><span lang=ZH-CN style='font-size:14.0pt; | ||
+ | font-family:等线'>,可之后设置:</span></p> | ||
+ | |||
+ | <p class=MsoNormal style='margin-left:.5in'><span class=SpellE><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"; | ||
+ | color:#0080FF'>WeCompassSensor</span></b></span><b><span style='font-size:16.0pt; | ||
+ | font-family:"Courier New";color:#0080FF'> compass;</span></b></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>之后调用:</span><span | ||
+ | class=SpellE><span class=GramE><b><span style='font-size:16.0pt;font-family: | ||
+ | "Courier New";color:#0080FF'>compass.reset</span></b></span></span><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:#0080FF'>(PORT_B);</span></b></p> | ||
+ | |||
+ | <p class=MsoNormal> </p> | ||
+ | |||
+ | <p class=MsoNormal align=left style='text-align:left;background:white'><b><span | ||
+ | style='font-size:12.0pt;font-family:"News Gothic MT",sans-serif'>(2)</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:#8000FF'> void</span></b><span | ||
+ | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span | ||
+ | class=GramE><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | color:#0080FF'>reset</span></b><b><span style='font-size:16.0pt;font-family: | ||
+ | "Courier New";color:black'>(</span></b></span><b><span style='font-size:16.0pt; | ||
+ | font-family:"Courier New";color:#8000FF'>uint8_t</span></b><span | ||
+ | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:#0080FF'>port</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:black'>=</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:red'>0</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";color:black'>)</span></b></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>描述:可重新设置接口</span></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>参数:</span></p> | ||
+ | |||
+ | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 | ||
+ | style='border-collapse:collapse;mso-yfti-tbllook:1184;mso-padding-alt:0in 0in 0in 0in'> | ||
+ | <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes; | ||
+ | height:25.6pt'> | ||
+ | <td style='border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt; | ||
+ | height:25.6pt'> | ||
+ | <p class=MsoNormal><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | color:#0080FF'>port</span></b></p> | ||
+ | </td> | ||
+ | <td width=330 style='width:247.4pt;border:solid windowtext 1.0pt;border-left: | ||
+ | none;padding:0in 5.4pt 0in 5.4pt;height:25.6pt'> | ||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线; | ||
+ | color:windowtext'>选择端口,如</span><span style='font-size:14.0pt;color:windowtext'>PORT_A,PORT_1</span><span | ||
+ | lang=ZH-CN style='font-size:14.0pt;font-family:等线;color:windowtext'>等</span></p> | ||
+ | </td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>返回值:无</span></p> | ||
+ | |||
+ | <p class=MsoNormal><span style='font-size:10.0pt;font-family:等线'> </span></p> | ||
+ | |||
+ | <p class=MsoNormal align=left style='text-align:left;background:white'><b><span | ||
+ | style='font-size:12.0pt;font-family:"News Gothic MT",sans-serif'>(3)</span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New"'> </span></b><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"; | ||
+ | color:#8000FF'>uint16_t</span></b><span style='font-size:10.0pt;font-family: | ||
+ | "Courier New";mso-fareast-font-family:"Times New Roman";color:black'> </span><span | ||
+ | class=SpellE><span class=GramE><b><span style='font-size:16.0pt;font-family: | ||
+ | "Courier New";mso-fareast-font-family:"Times New Roman";color:#0080FF'>readValue</span></b></span></span><span | ||
+ | class=GramE><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | mso-fareast-font-family:"Times New Roman";color:black'>(</span></b></span><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"; | ||
+ | color:#8000FF'>uint8_t</span></b><span style='font-size:10.0pt;font-family: | ||
+ | "Courier New";mso-fareast-font-family:"Times New Roman";color:black'> </span><b><span | ||
+ | style='font-size:16.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"; | ||
+ | color:#0080FF'>index</span></b><b><span style='font-size:16.0pt;font-family: | ||
+ | "Courier New";mso-fareast-font-family:"Times New Roman";color:black'>)</span></b><span | ||
+ | style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-font-family: | ||
+ | "Times New Roman"'><o:p></o:p></span></p> | ||
+ | |||
+ | <p class=MsoNormal align=left style='text-align:left;background:white'><span | ||
+ | lang=ZH-CN style='font-size:14.0pt;font-family:等线'>描述:获取定向数据</span></p> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>参数:</span></p> | ||
+ | |||
+ | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 | ||
+ | style='border-collapse:collapse;mso-yfti-tbllook:1184;mso-padding-alt:0in 0in 0in 0in'> | ||
+ | <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes; | ||
+ | height:25.6pt'> | ||
+ | <td style='border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt; | ||
+ | height:25.6pt'> | ||
+ | <p class=MsoNormal><b><span style='font-size:16.0pt;font-family:"Courier New"; | ||
+ | mso-fareast-font-family:"Times New Roman";color:#0080FF'>index</span></b></p> | ||
+ | </td> | ||
+ | <td width=593 style='width:444.8pt;border:solid windowtext 1.0pt;border-left: | ||
+ | none;padding:0in 5.4pt 0in 5.4pt;height:25.6pt'> | ||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线; | ||
+ | color:windowtext'>选择获取某一方向轴上的定向角度,</span><span style='font-size:14.0pt; | ||
+ | font-family:等线;color:windowtext'>0<span lang=ZH-CN>为</span>X<span lang=ZH-CN>轴,</span>1<span | ||
+ | lang=ZH-CN>为</span>Y<span lang=ZH-CN>轴,</span>2<span lang=ZH-CN>为</span>Z<span | ||
+ | lang=ZH-CN>轴</span></span></p> | ||
+ | </td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | <p class=MsoNormal><span lang=ZH-CN style='font-size:14.0pt;font-family:等线'>返回值:整数,</span><span | ||
+ | style='font-size:14.0pt;font-family:等线'>0~360</span></p> | ||
+ | |||
+ | <p class=MsoNormal> <span lang=ZH-CN style='font-size:14.0pt;font-family: | ||
+ | 等线'>编程示例:</span> </p> | ||
+ | </body></html> | ||
+ | |||
+ | <sxh c/c++; first-line: 1;highlight: [50,100]; title: compass_test.ino> | ||
+ | #include "WeELF328P.h" | ||
+ | | ||
+ | WeCompassSensor compass(PORT_A); | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | Serial.begin(115200); | ||
+ | } | ||
+ | void loop() | ||
+ | { | ||
+ | int16_t head_X; | ||
+ | compass.update(); | ||
+ | head_X = compass.readValue(0); | ||
+ | Serial.print("Compass:"); | ||
+ | Serial.println(head_X); | ||
+ | delay(200); | ||
+ | } | ||
+ | |||
+ | </sxh> | ||
+ | \\ |