adesaesd 发表于 2019-10-6 13:46:19

求助syn6288模块库使用问题

#ifndef SYN6288_H_
#define SYN6288_H_
#define uchar unsigned char
#define HEAD_LEN 5
#define BKM_MAX 5

class Syn6288
{
public:
Syn6288();
void Speech(const char * txt,uchar bkm,uchar port);
void Speech(const char * txt,uchar bkm);
void Speech(const char * txt);
private:
uchar _nPort;
uchar _nBkm;
};

#endif


#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

#include "Syn6288.h"

Syn6288::Syn6288()
{
_nPort = 1;
_nBkm = 0;
}

void Syn6288::Speech(const char * txt,uchar bkm,uchar port)
{
uchar i=0;
uchar head;
uchar x=0;          //FD 00 05 01 08

head=0xfd;
head=0x00;
head=0x01;

_nPort=port;
_nBkm=bkm % (BKM_MAX + 1);
head=sizeof(txt) + 3;
head=_nBkm << 3;
Serial.write(head,HEAD_LEN);
for(i=0;i<HEAD_LEN;i++)
{
x=x^head;
if(_nPort==1)
Serial.write(head);
}


for(i=0;i<head;i++)
{
x=x^txt;
if(_nPort==1)
Serial.write(txt);

}
if(_nPort == 1)
Serial.write(x);

}

void Syn6288::Speech(const char * txt,uchar bkm)
{
Speech(txt,bkm,_nPort);
}

void Syn6288::Speech(const char * txt)
{
Speech(txt,_nBkm,_nPort);
}


上面是库文件   想问一下_nBkm 这个变量是什么?bkm 又是什么? 现在可以编译通过,但是通过端口监视器查看输出的数据只有 前5段头代码,没有TXT 内容代码,我想这个库文件应该是无法把汉字直接转换成 GB2312编码的,于是把TXT 内容换成 GB2312代码还是无法输出txt内容,
下面是 程序代码
#include <Syn6288.h>
Syn6288 myTalk;

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
}

void loop() {
myTalk.Speech("文本1",1,2);
delay(3000);
}
页: [1]
查看完整版本: 求助syn6288模块库使用问题