本文整理汇总了C++中writeData函数的典型用法代码示例。如果您正苦于以下问题:C++ writeData函数的具体用法?C++ writeData怎么用?C++ writeData使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
// read the next channel data.. fill it in *tone
// if tone isn't touched.. it should be inited so it just plays silence
// return 0 if it's passing more data
// return -1 if it's passing nothing (end of data)
int SoundGenPCJr::getNextNote_v2(int ch) {
ToneChan *tpcm;
SndGenChan *chan;
const byte *data;
assert(ch < CHAN_MAX);
if (!_vm->getFlag(VM_FLAG_SOUND_ON))
return -1;
tpcm = &_tchannel[ch];
chan = &_channel[ch];
if (!chan->avail)
return -1;
while (chan->duration <= 0) {
data = chan->data;
// read the duration of the note
chan->duration = READ_LE_UINT16(data); // duration
// if it's 0 then it's not going to be played
// if it's 0xFFFF then the channel data has finished.
if ((chan->duration == 0) || (chan->duration == 0xFFFF)) {
tpcm->genTypePrev = -1;
tpcm->freqCountPrev = -1;
break;
}
_tchannel[ch].genTypePrev = -1;
_tchannel[ch].freqCountPrev = -1;
// only tone channels dissolve
if ((ch != 3) && (_dissolveMethod != 0)) // != noise??
chan->dissolveCount = 0;
// attenuation (volume)
writeData(data[4]);
// frequency
writeData(data[3]);
writeData(data[2]);
// data now points to the next data seg-a-ment
chan->data += 5;
}
if (chan->duration == 0xFFFF) {
// kill channel
chan->avail = 0;
chan->attenuation = 0x0F; // silent
chan->attenuationCopy = 0x0F; // dunno really
return -1;
}
chan->duration--;
return 0;
}
示例2: address
void AQCM0802::character(int column, int row, int c) {
int a = address(column, row);
writeCommand(a);
writeData(c);
}
示例3: reset
// Initialise the display with the require screen orientation
void ILI9163::init(Rotation rotation) {
width = ILI9163_WIDTH;
height = ILI9163_HEIGHT;
m_cs->write(1);
m_reset->write(1);
// Hardware reset the LCD
reset();
writeCommand(ILI9163_CMD_EXIT_SLEEP_MODE);
_delay_ms(5); // Wait for the screen to wake up
writeCommand(ILI9163_CMD_SET_PIXEL_FORMAT);
writeData(0x05); // 16 bits per pixel
writeCommand(ILI9163_CMD_SET_GAMMA_CURVE);
writeData(0x04); // Select gamma curve 3
writeCommand(ILI9163_CMD_GAM_R_SEL);
writeData(0x01); // Gamma adjustment enabled
writeCommand(ILI9163_CMD_POSITIVE_GAMMA_CORRECT);
writeData(0x3f); // 1st Parameter
writeData(0x25); // 2nd Parameter
writeData(0x1c); // 3rd Parameter
writeData(0x1e); // 4th Parameter
writeData(0x20); // 5th Parameter
writeData(0x12); // 6th Parameter
writeData(0x2a); // 7th Parameter
writeData(0x90); // 8th Parameter
writeData(0x24); // 9th Parameter
writeData(0x11); // 10th Parameter
writeData(0x00); // 11th Parameter
writeData(0x00); // 12th Parameter
writeData(0x00); // 13th Parameter
writeData(0x00); // 14th Parameter
writeData(0x00); // 15th Parameter
writeCommand(ILI9163_CMD_NEGATIVE_GAMMA_CORRECT);
writeData(0x20); // 1st Parameter
writeData(0x20); // 2nd Parameter
writeData(0x20); // 3rd Parameter
writeData(0x20); // 4th Parameter
writeData(0x05); // 5th Parameter
writeData(0x00); // 6th Parameter
writeData(0x15); // 7th Parameter
writeData(0xa7); // 8th Parameter
writeData(0x3d); // 9th Parameter
writeData(0x18); // 10th Parameter
writeData(0x25); // 11th Parameter
writeData(0x2a); // 12th Parameter
writeData(0x2b); // 13th Parameter
writeData(0x2b); // 14th Parameter
writeData(0x3a); // 15th Parameter
writeCommand(ILI9163_CMD_FRAME_RATE_CONTROL1);
writeData(0x08); // DIVA = 8
writeData(0x08); // VPA = 8
writeCommand(ILI9163_CMD_DISPLAY_INVERSION);
writeData(0x07); // NLA = 1, NLB = 1, NLC = 1 (all on Frame Inversion)
writeCommand(ILI9163_CMD_POWER_CONTROL1);
writeData(0x0a); // VRH = 10: GVDD = 4.30
writeData(0x02); // VC = 2: VCI1 = 2.65
writeCommand(ILI9163_CMD_POWER_CONTROL2);
writeData(0x02); // BT = 2: AVDD = 2xVCI1, VCL = -1xVCI1, VGH = 5xVCI1, VGL = -2xVCI1
writeCommand(ILI9163_CMD_VCOM_CONTROL1);
writeData(0x50); // VMH = 80: VCOMH voltage = 4.5
writeData(0x5b); // VML = 91: VCOML voltage = -0.225
writeCommand(ILI9163_CMD_VCOM_OFFSET_CONTROL);
writeData(0x40); // nVM = 0, VMF = 64: VCOMH output = VMH, VCOML output = VML
writeCommand(ILI9163_CMD_SET_COLUMN_ADDRESS);
writeData(0x00); // XSH
writeData(0x00); // XSL
writeData(0x00); // XEH
writeData(0x7f); // XEL (128 pixels x)
writeCommand(ILI9163_CMD_SET_PAGE_ADDRESS);
writeData(0x00);
writeData(0x00);
writeData(0x00);
writeData(0x7f); // 128 pixels y
// Select display orientation
//writeCommand(ILI9163_CMD_SET_ADDRESS_MODE);
//writeData(rotation);
setRotation(rotation);
// Set the display to on
writeCommand(ILI9163_CMD_SET_DISPLAY_ON);
writeCommand(ILI9163_CMD_WRITE_MEMORY_START);
}
示例4: writeData
/**
* \par Function
* writeReg
* \par Description
* Write the registor of i2c device.
* \param[in]
* reg - the address of registor.
* \param[in]
* data - the data that will be written to the registor.
* \par Output
* None
* \return
* Return the error code.
* the definition of the value of variable return_value:
* 0:success
* 1:BUFFER_LENGTH is shorter than size
* 2:address send, nack received
* 3:data send, nack received
* 4:other twi error
* refer to the arduino official library twi.c
* \par Others
* To set the registor for initializing.
*/
int8_t MeGyro::writeReg(int16_t reg, uint8_t data)
{
int8_t return_value = 0;
return_value = writeData(reg, &data, 1);
return(return_value);
}
示例5: runCommand
int runCommand(int argc, char *argv[]){
if (!readData()) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: Error reading mystore.dat\n\n%s|\n", Usage);
return 1;
}
if (command == ADD && !add(argv[1],argv[2])) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: Failure to add new item|\n");
return 1;
}
if (command == STAT) {
printf("running stat\n");
status();
}
if (command == SEARCH && !search(argv[1])) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: Cannot search %s|\n",argv[1]);
return 1;
}
if (command == DISPLAY && !display(argv[1])) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: Cannot display %s|\n",argv[1]);
return 1;
}
if (command == DELETE && !delete(argv[1])) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: Cannot delete %s|\n", argv[1]);
return 1;
}
if (command == EDIT && !edit(argv[1])) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: cannot edit %s|\n",argv[1]);
return 1;
}
if (rewrite) {
printf("rewriting\n");
if (!writeData()) {
if (errmsg[0] != '\0')
printf("|status: ERROR: %s|\n", errmsg);
else
printf("|status: ERROR: Could not write the data, file may be destroyed|\n");
return 1;
}
}
return 0;
}
示例6: processCommand
void processCommand( unsigned char cmd ) {
if ( cmd == CMD_SELECT_DEVICE ) {
selectedDevice = uart_getc( );
uart_putc( BYTE_CR );
} else if ( cmd == CMD_SHOW_ID ) {
uart_puts( AVRISP_IDENTIFIER );
} else if ( cmd == CMD_SOFTWARE_VERSION ) {
uart_puts( AVRISP_SWVER );
} else if ( cmd == CMD_HARDWARE_VERSION ) {
uart_puts( AVRISP_HWVER );
} else if ( cmd == CMD_LIST_SUPPORTED_DEVICES ) {
uart_puts( AVRISP_SUPPORTED_DEVICES );
uart_putc( 0 ); // terminating null character needs to be sent
} else if ( cmd == CMD_PROGRAMMER_TYPE ) {
uart_putc( AVRISP_PROGRAMMER_TYPE );
} else if ( cmd == CMD_SUPPORTS_AUTOINCREMENT ) {
uart_putc( AVRISP_RESP_YES );
} else if ( cmd == CMD_SET_LED ) {
LED_on( );
uart_putc( BYTE_CR );
} else if ( cmd == CMD_CLEAR_LED ) {
LED_off( );
uart_putc( BYTE_CR );
} else if ( selectedDevice == 0 ) {
// require a device for the rest of the commands
uart_putc( AVRISP_RESP_UNKNOWN );
return;
}
// command not specified above
if ( cmd == CMD_ENTER_PROGRAM_MODE ) {
enableProgramMode( );
} else if ( cmd == CMD_LEAVE_PROGRAM_MODE ) {
leaveProgramMode( );
} else if ( cmd == CMD_WRITE_PROG_H ) {
writeProgH( );
} else if ( cmd == CMD_WRITE_PROG_L ) {
writeProgL( );
} else if ( cmd == CMD_READ_PROG ) {
readProg( );
} else if ( cmd == CMD_LOAD_ADDRESS ) {
loadAddress( );
} else if ( cmd == CMD_WRITE_DATA ) {
writeData( );
} else if ( cmd == CMD_READ_DATA ) {
readData( );
} else if ( cmd == CMD_CHIP_ERASE ) {
chipErase( );
} else if ( cmd == CMD_WRITE_LOCK_BITS ) {
writeLockBits( );
} else if ( cmd == CMD_READ_SIGNATURE ) {
readSignature( );
} else if ( cmd == CMD_WRITE_PROGRAM_PAGE ) {
writeProgramPage( );
} else if ( cmd == CMD_UNIVERSAL_3 ) {
universalWrite3( );
} else if ( cmd == CMD_UNIVERSAL_4 ) {
universalWrite4( );
} else if ( cmd == CMD_LOAD_ADDRESS_0 ) {
currentAddress = 0;
uart_putc( BYTE_CR );
}
}
示例7: doShell
void doShell(Client* shellClient) {
Client* p;
char head[HEAD_SIZE], value[VALUE_SIZE];
char fileBuffer[FILE_BUFFER_SIZE + 1];
char fileChunk[FILE_CHUNK_SIZE];
char filename[256];
unsigned long fileSize;
int fd;
FILE* fp;
FDEBUG(("shell start\n"));
while (1) {
// shell 담당 서버는 shell 클라이언트로부터 신호를 받아야만 일합니다.
readMsg(shellClient->socket, head, value);
if ( !strcmp(head, ADD) ) {
// 파일 추가
FDEBUG(("get ADD message\n"));
fileSize = 0;
// 우선 해당 이름으로 파일을 엽니다.
strcpy(filename, value);
fd = open(filename, O_WRONLY | O_CREAT, 0644);
if (fd == -1) {
writeMsg(shellClient->socket, ERR, "fileopen_err");
continue;
}
// 다른 일반 클라이언트들에게도 이 사실을 알립니다.
writeMsg(shellClient->socket, ACCEPT, "fileadd");
p = front;
while (p) {
writeMsg(p->pipe[1], ADD, filename);
p = p->nextClient;
}
// 파일 구분자를 입력받습니다.
readMsg(shellClient->socket, head, fileChunk);
writeMsg(shellClient->socket, ACCEPT, "filechunk");
p = front;
while (p) {
writeMsg(p->pipe[1], CHUNK, fileChunk);
p = p->nextClient;
}
// 파일을 읽어서 클라이언트에게 전달합니다. 서버에도 한 부 저장합니다.
FDEBUG(("start reading file\n"));
while (true) {
memset(fileBuffer, 0, sizeof(fileBuffer));
readData(shellClient->socket, fileBuffer);
p = front;
while (p) {
writeData(p->pipe[1], fileBuffer);
p = p->nextClient;
}
// 파일 전송이 끝나면 끝냅니다.
if ( !strcmp(fileBuffer, fileChunk) ) break;
// 아니라면 서버에 저장하고 다음 부분을 보내달라고 요청합니다.
else writeData(fd, fileBuffer);
writeMsg(shellClient->socket, CHUNK, fileChunk);
fileSize += strlen(fileBuffer);
}
// 파일을 전부 기록했습니다. 닫고 EOF 메시지를 전달합니다.
close(fd);
writeMsg(shellClient->socket, ACCEPT, "eof");
p = front;
while (p) {
writeMsg(p->pipe[1], ACCEPT, "eof");
p = p->nextClient;
}
// 결과를 출력합니다.
Notice("ADD ");
printf("[%s][%ldbyte] from Client(%d)\n", filename, fileSize, shellClient->clientNo);
} else
if ( !strcmp(head, DEL) ) {
// 삭제할 파일의 크기를 구합니다.
fp = fopen(value, "r");
fseek(fp, 0L, SEEK_END);
fileSize = ftell(fp);
fclose(fp);
// 결과를 출력합니다.
Notice ("DELETE ");
printf("[%s][%ldbyte] from Client(%d)\n", value, fileSize, shellClient->clientNo);
// 파일을 삭제하고 다른 클라이언트에게 알립니다.
remove( value );
p = front;
while (p) {
writeMsg(p->pipe[1], head, value);
p = p->nextClient;
}
}
//.........这里部分代码省略.........
示例8: writeData
qint64 AudioRingBuffer::writeSamples(const int16_t* source, qint64 maxSamples) {
return writeData((const char*) source, maxSamples * sizeof(int16_t));
}
示例9: numBytesForPacketHeader
int AudioRingBuffer::parseData(const QByteArray& packet) {
int numBytesPacketHeader = numBytesForPacketHeader(packet);
return writeData(packet.data() + numBytesPacketHeader, packet.size() - numBytesPacketHeader);
}
示例10: writeCommand
void TextLCD::character(int column, int row, int c) {
int address = 0x80 + (row * 40) + column; // memory starts at 0x80, and is 40 chars long per row
writeCommand(address);
writeData(c);
}
示例11: writeData
void Profiler::shutdown()
{
writeData();
}
示例12: writeCommand
void TFTLCD::writeRegister(uint16_t addr, uint16_t data) {
writeCommand(addr);
writeData(data);
}
示例13: msg_error
//.........这里部分代码省略.........
*outfile << std::endl;
//Write Cells
unsigned int numberOfCells, totalSize;
numberOfCells = ( (writeEdges.getValue()) ? topology->getNbEdges() : 0 )
+( (writeTriangles.getValue()) ? topology->getNbTriangles() : 0 )
+( (writeQuads.getValue()) ? topology->getNbQuads() : 0 )
+( (writeTetras.getValue()) ? topology->getNbTetras() : 0 )
+( (writeHexas.getValue()) ? topology->getNbHexas() : 0 );
totalSize = ( (writeEdges.getValue()) ? 3 * topology->getNbEdges() : 0 )
+( (writeTriangles.getValue()) ? 4 *topology->getNbTriangles() : 0 )
+( (writeQuads.getValue()) ? 5 *topology->getNbQuads() : 0 )
+( (writeTetras.getValue()) ? 5 *topology->getNbTetras() : 0 )
+( (writeHexas.getValue()) ? 9 *topology->getNbHexas() : 0 );
*outfile << "CELLS " << numberOfCells << " " << totalSize << std::endl;
if (writeEdges.getValue())
{
for (int i=0 ; i<topology->getNbEdges() ; i++)
*outfile << 2 << " " << topology->getEdge(i) << std::endl;
}
if (writeTriangles.getValue())
{
for (int i=0 ; i<topology->getNbTriangles() ; i++)
*outfile << 3 << " " << topology->getTriangle(i) << std::endl;
}
if (writeQuads.getValue())
{
for (int i=0 ; i<topology->getNbQuads() ; i++)
*outfile << 4 << " " << topology->getQuad(i) << std::endl;
}
if (writeTetras.getValue())
{
for (int i=0 ; i<topology->getNbTetras() ; i++)
*outfile << 4 << " " << topology->getTetra(i) << std::endl;
}
if (writeHexas.getValue())
{
for (int i=0 ; i<topology->getNbHexas() ; i++)
*outfile << 8 << " " << topology->getHexa(i) << std::endl;
}
*outfile << std::endl;
*outfile << "CELL_TYPES " << numberOfCells << std::endl;
if (writeEdges.getValue())
{
for (int i=0 ; i<topology->getNbEdges() ; i++)
*outfile << 3 << std::endl;
}
if (writeTriangles.getValue())
{
for (int i=0 ; i<topology->getNbTriangles() ; i++)
*outfile << 5 << std::endl;
}
if (writeQuads.getValue())
{
for (int i=0 ; i<topology->getNbQuads() ; i++)
*outfile << 9 << std::endl;
}
if (writeTetras.getValue())
{
for (int i=0 ; i<topology->getNbTetras() ; i++)
*outfile << 10 << std::endl;
}
if (writeHexas.getValue())
{
for (int i=0 ; i<topology->getNbHexas() ; i++)
*outfile << 12 << std::endl;
}
*outfile << std::endl;
//write dataset attributes
if (!pointsData.empty())
{
*outfile << "POINT_DATA " << nbp << std::endl;
writeData(pointsDataObject, pointsDataField, pointsDataName);
}
if (!cellsData.empty())
{
*outfile << "CELL_DATA " << numberOfCells << std::endl;
writeData(cellsDataObject, cellsDataField, cellsDataName);
}
outfile->close();
++nbFiles;
msg_info() << "Export VTK in file " << filename << " done.";
}
示例14: writeData
void RawData::writeData(const QByteArray& data)
{
writeData(data,data.length());
}
示例15: fprintf
void SocksClient::processOutgoing(const QByteArray &block)
{
#ifdef PROX_DEBUG
// show hex
fprintf(stderr, "SocksClient: client recv { ");
for(int n = 0; n < (int)block.size(); ++n)
fprintf(stderr, "%02X ", (unsigned char)block[n]);
fprintf(stderr, " } \n");
#endif
d->recvBuf += block;
if(d->step == StepVersion) {
SPSS_VERSION s;
int r = sps_get_version(d->recvBuf, &s);
if(r == -1) {
resetConnection(true);
setError(ErrProxyNeg);
return;
}
else if(r == 1) {
if(s.version != 0x05 || s.method == 0xff) {
#ifdef PROX_DEBUG
fprintf(stderr, "SocksClient: Method selection failed\n");
#endif
resetConnection(true);
setError(ErrProxyNeg);
return;
}
QString str;
if(s.method == 0x00) {
str = "None";
d->authMethod = AuthNone;
}
else if(s.method == 0x02) {
str = "Username/Password";
d->authMethod = AuthUsername;
}
else {
#ifdef PROX_DEBUG
fprintf(stderr, "SocksClient: Server wants to use unknown method '%02x'\n", s.method);
#endif
resetConnection(true);
setError(ErrProxyNeg);
return;
}
if(d->authMethod == AuthNone) {
// no auth, go straight to the request
do_request();
}
else if(d->authMethod == AuthUsername) {
d->step = StepAuth;
#ifdef PROX_DEBUG
fprintf(stderr, "SocksClient: Authenticating [Username] ...\n");
#endif
writeData(spc_set_authUsername(d->user.toLatin1(), d->pass.toLatin1()));
}
}
}
if(d->step == StepAuth) {
if(d->authMethod == AuthUsername) {
SPSS_AUTHUSERNAME s;
int r = sps_get_authUsername(d->recvBuf, &s);
if(r == -1) {
resetConnection(true);
setError(ErrProxyNeg);
return;
}
else if(r == 1) {
if(s.version != 0x01) {
resetConnection(true);
setError(ErrProxyNeg);
return;
}
if(!s.success) {
resetConnection(true);
setError(ErrProxyAuth);
return;
}
do_request();
}
}
}
else if(d->step == StepRequest) {
SPS_CONNREQ s;
int r = sp_get_request(d->recvBuf, &s);
if(r == -1) {
resetConnection(true);
setError(ErrProxyNeg);
return;
}
else if(r == 1) {
if(s.cmd != RET_SUCCESS) {
#ifdef PROX_DEBUG
fprintf(stderr, "SocksClient: client << Error >> [%02x]\n", s.cmd);
#endif
resetConnection(true);
if(s.cmd == RET_UNREACHABLE)
//.........这里部分代码省略.........