当前位置: 首页>>代码示例>>C++>>正文


C++ writeByte函数代码示例

本文整理汇总了C++中writeByte函数的典型用法代码示例。如果您正苦于以下问题:C++ writeByte函数的具体用法?C++ writeByte怎么用?C++ writeByte使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了writeByte函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: coding

//display function.Write to full-screen.
void TM1637::display(int8_t DispData[])
{
  int8_t SegData[4];
  uint8_t i;
  for(i = 0;i < 4;i ++)
  {
    SegData[i] = DispData[i];
  }
  coding(SegData);
  start();          //start signal sent to TM1637 from MCU
  writeByte(ADDR_AUTO);//
  stop();           //
  start();          //
  writeByte(Cmd_SetAddr);//
  for(i=0;i < 4;i ++)
  {
    writeByte(SegData[i]);        //
  }
  stop();           //
  start();          //
  writeByte(Cmd_DispCtrl);//
  stop();           //
}
开发者ID:Seeed-Studio,项目名称:Grove-Starter-Kit-for-LaunchPad,代码行数:24,代码来源:TM1637.cpp

示例2: digitalWritePiFaceSpecial

void digitalWritePiFaceSpecial (int pin, int value)
{
    uint8_t mask = 1 << pin ;
    uint8_t old ;

    old = readByte (GPIOA) ;

    if (value == 0)
        old &= (~mask) ;
    else
        old |=   mask ;

    writeByte (GPIOA, old) ;
}
开发者ID:carriercomm,项目名称:raspberry-webradio,代码行数:14,代码来源:wiringPiFace.c

示例3: delay

void mcp23016::begin(bool protocolInitOverride) {
	if (!protocolInitOverride && !_error){
		Wire.begin();
		#if ARDUINO >= 157
			Wire.setClock(400000UL); // Set I2C frequency to 400kHz
		#else
			TWBR = ((F_CPU / 400000UL) - 16) / 2; // Set I2C frequency to 400kHz
		#endif
	}	
	delay(100);
	writeByte(IOCON,0b00000000);//read datasheet for details!
	_gpioDirection = 0xFFFF;//all in
	_gpioState = 0x0000;//all low 
}
开发者ID:koson,项目名称:gpio_expander,代码行数:14,代码来源:mcp23016.cpp

示例4: coding

// Display function.Write to full-screen.
void TM1637::display(int8_t disp_data[])
{
  int8_t seg_data[DIGITS];
  uint8_t i;

  for (i = 0; i < DIGITS; i++)
    seg_data[i] = disp_data[i];

  coding(seg_data);
  start();              // Start signal sent to TM1637 from MCU
  writeByte(ADDR_AUTO); // Command1: Set data
  stop();
  start();
  writeByte(cmd_set_addr); // Command2: Set address (automatic address adding)

  for (i = 0; i < DIGITS; i++)
    writeByte(seg_data[i]); // Transfer display data (8 bits x num_of_digits)

  stop();
  start();
  writeByte(cmd_disp_ctrl); // Control display
  stop();
}
开发者ID:Seeed-Studio,项目名称:Grove_4Digital_Display,代码行数:24,代码来源:TM1637.cpp

示例5: _rs

TextLCD::TextLCD(PinName rs, PinName e, PinName d4, PinName d5,
                 PinName d6, PinName d7, LCDType type) : _rs(rs),
        _e(e), _d(d4, d5, d6, d7),
        _type(type) {

    _e  = 1;
    _rs = 0;            // command mode

    wait(0.015);        // Wait 15ms to ensure powered up

    // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
    for (int i=0; i<3; i++) {
        writeByte(0x3);
        wait(0.00164);  // this command takes 1.64ms, so wait for it
    }
    writeByte(0x2);     // 4-bit mode
    wait(0.000040f);    // most instructions take 40us

    writeCommand(0x28); // Function set 001 BW N F - -
    writeCommand(0x0C);
    writeCommand(0x6);  // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
    cls();
}
开发者ID:AlienEngineer,项目名称:demo-cortex-m3,代码行数:23,代码来源:TextLCD.cpp

示例6: getTypeSize

CSymbol* CData::addVariable (const int &scope, const std::string &name, const int &type, int size, const int &address)
{
   if (size == 0) {
      size = getTypeSize(type);
   }

   CSymbol *symbol = new CSymbol (scope, name, type, size, CSymbol::VAR, address);

   _symbols.push_back(symbol);

   if (type == CSymbol::STRING) {
      // Para strings constantes e variaveis eh necessario indicar a categoria
      writeByte(CSymbol::VAR);
   }

   //_data += symbol->getBinary();
   for (int i=0; i < symbol->getTypeSize(); i++) {
      // TODO: horrivel :-)
      writeByte ('\0');
   }

   return symbol;
}
开发者ID:BackupTheBerlios,项目名称:gpt-svn,代码行数:23,代码来源:CData.cpp

示例7: writeByte

/*
 * packetPing(): send Ping heart beat data to OneNet
 * 
 */
edp_pkt *packetPing()
{
  int32 remainlen = 0x00;
  edp_pkt* pkt;

  if((pkt = packetCreate()) == NULL)
    return NULL;
  /* msg type */
  writeByte(pkt, PINGREQ);
  /* remain len */
  writeRemainlen(pkt, remainlen); 

  return pkt;
}
开发者ID:wi-cuckoo,项目名称:IOT-Programming,代码行数:18,代码来源:edp.c

示例8: writeByte

void DDS::setFreq(double frequency){

  //enter frequency as Hz
  if(frequency > 40000000){
      Serial.println("Frequency is set Higher than board can output");
      Serial.println("Setting to Maximum Freq ");
      frequency = 40000000;
  }
  
  #ifdef DEBUG
    Serial.print("Freq: ");
    Serial.print(frequency);
    Serial.println(" Hz");    
  #endif
  
  int32_t freq = frequency * 4294967295 / 125000000;  // note 125 MHz clock on 9850
  for (int b = 0; b < 4; b++, freq>>=8) {
    writeByte(freq & 0xFF);
  }
  writeByte(0x000);   // Final control byte
  pulseHigh(FU_UD);  // Done!  Should see output
  
}
开发者ID:Ximidar,项目名称:AD9850_Test_Code,代码行数:23,代码来源:AD9850.cpp

示例9: switch

void CDMRTX::process()
{
  if (m_state == DMRTXSTATE_IDLE)
    return;

  if (m_poLen == 0U) {
    switch (m_state) {
      case DMRTXSTATE_SLOT1:
        createData(0U);
        m_state = DMRTXSTATE_CACH2;
        break;

      case DMRTXSTATE_CACH2:
        createCACH(1U, 0U);
        m_state = DMRTXSTATE_SLOT2;
        break;

      case DMRTXSTATE_SLOT2:
        createData(1U);
        m_state = DMRTXSTATE_CACH1;
        break;
        
      default:
        createCACH(0U, 1U);
        m_state = DMRTXSTATE_SLOT1;
        break;
    }
  }

  if (m_poLen > 0U) {
    uint16_t space = io.getSpace();
    
    while (space > (4U * DMR_RADIO_SYMBOL_LENGTH) && space < 1000U) {
      uint8_t c = m_poBuffer[m_poPtr];
      uint8_t m = m_markBuffer[m_poPtr];
      m_poPtr++;

      writeByte(c, m);

      space -= 4U * DMR_RADIO_SYMBOL_LENGTH;
      
      if (m_poPtr >= m_poLen) {
        m_poPtr = 0U;
        m_poLen = 0U;
        return;
      }
    }
  }
}
开发者ID:Tyrox25,项目名称:MMDVM,代码行数:49,代码来源:DMRTX.cpp

示例10: digitalWrite

// Read the thermocouple temperature either in Degree Celsius or Fahrenheit. Internally,
// the conversion takes place in the background within 155 ms, or longer depending on the
// number of samples in each reading (see CR1).
// Returns the temperature, or an error (FAULT_OPEN, FAULT_VOLTAGE or NO_MAX31856)
double	MAX31856::readThermocouple(byte unit)
{
    double temperature;
    long data;

    // Select the MAX31856 chip
    digitalWrite(_cs, LOW);

    // Read data starting with register 0x0c
    writeByte(READ_OPERATION(0x0c));

    // Read 4 registers
    data = readData();

    // Deselect MAX31856 chip
    digitalWrite(_cs, HIGH);

    // If there is no communication from the IC then data will be all 1's because
    // of the internal pullup on the data line (INPUT_PULLUP)
    if (data == 0xFFFFFFFF)
        return NO_MAX31856;

    // If the value is zero then the temperature could be exactly 0.000 (rare), or
    // the IC's registers are uninitialized.
    if (data == 0 && verifyMAX31856() == NO_MAX31856)
        return NO_MAX31856;

    // Was there an error?
    if (data & SR_FAULT_OPEN)
        temperature = FAULT_OPEN;
    else if (data & SR_FAULT_UNDER_OVER_VOLTAGE)
        temperature = FAULT_VOLTAGE;
    else {
        // Strip the unused bits and the Fault Status Register
        data = data >> 13;

        // Negative temperatures have been automagically handled by the shift above :-)

        // Convert to Celsius
        temperature = (double) data * 0.0078125;
	
        // Convert to Fahrenheit if desired
        if (unit == FAHRENHEIT)
            temperature = (temperature * 9.0/5.0)+ 32;
    }

    // Return the temperature
    return (temperature);
}
开发者ID:engineertype,项目名称:MAX31856,代码行数:53,代码来源:MAX31856.cpp

示例11: writeByte

void Sensor::playMelody(unsigned char* song, int length){

	
	
	for(int i = 0; i<length; i+=2)
	{

		if(song[i+1] != 100)
		{
			writeByte(ID, BUZZER_DATA_TIME, 254);
			writeByte(ID, BUZZER_DATA_NOTE, song[i+1]);
			usleep(40000*song[i]);
		}
		else
		{
			writeByte(ID, BUZZER_DATA_TIME, 0);
			usleep(40000*song[i]);
		}
			
		
	}
	writeByte(ID, BUZZER_DATA_TIME, 0);
	
}
开发者ID:tverrkraftig,项目名称:motor,代码行数:24,代码来源:sensor.cpp

示例12: _wiringPiSetupPiFace

static int _wiringPiSetupPiFace (void)
{
  if ((spiFd = open (spiDevice, O_RDWR)) < 0)
    return -1 ;

// Set SPI parameters
//	Why are we doing a read after write?
//	I don't know - just blindliy copying an example elsewhere... -GH-

  if (ioctl (spiFd, SPI_IOC_WR_MODE, &spiMode) < 0)
    return -1 ;

  if (ioctl (spiFd, SPI_IOC_RD_MODE, &spiMode) < 0)
    return -1 ;

  if (ioctl (spiFd, SPI_IOC_WR_BITS_PER_WORD, &spiBPW) < 0)
    return -1 ;

  if (ioctl (spiFd, SPI_IOC_RD_BITS_PER_WORD, &spiBPW) < 0)
    return -1 ;

  if (ioctl (spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &spiSpeed) < 0)
    return -1 ;

  if (ioctl (spiFd, SPI_IOC_RD_MAX_SPEED_HZ, &spiSpeed) < 0)
    return -1 ;

// Setup the MCP23S17

  writeByte (IOCON, IOCON_INIT) ;

  writeByte (IODIRA, 0x00) ;	// Port A -> Outputs
  writeByte (IODIRB, 0xFF) ;	// Port B -> Inputs

  return 0 ;
}
开发者ID:gitpan,项目名称:HiPi,代码行数:36,代码来源:wiringPiFace.c

示例13: myDigitalWrite

void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
{
  uint8_t mask, old ;

  pin -= node->pinBase ;
  mask = 1 << pin ;
  old  = readByte (MCP23x17_GPIOA) ;

  if (value == 0)
    old &= (~mask) ;
  else
    old |=   mask ;

  writeByte (MCP23x17_GPIOA, old) ;
}
开发者ID:cschirin,项目名称:computergraphics,代码行数:15,代码来源:piFaceOld.c

示例14: mcp23s17Setup

int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
{
  int    x ;
  struct wiringPiNodeStruct *node ;

  if ((x = wiringPiSPISetup (spiPort, MCP_SPEED)) < 0)
    return x ;

  writeByte (spiPort, devId, MCP23x17_IOCON,  IOCON_INIT | IOCON_HAEN) ;
  writeByte (spiPort, devId, MCP23x17_IOCONB, IOCON_INIT | IOCON_HAEN) ;

  node = wiringPiNewNode (pinBase, 16) ;

  node->data0           = spiPort ;
  node->data1           = devId ;
  node->pinMode         = myPinMode ;
  node->pullUpDnControl = myPullUpDnControl ;
  node->digitalRead     = myDigitalRead ;
  node->digitalWrite    = myDigitalWrite ;
  node->data2           = readByte (spiPort, devId, MCP23x17_OLATA) ;
  node->data3           = readByte (spiPort, devId, MCP23x17_OLATB) ;

  return 0 ;
}
开发者ID:frank71726,项目名称:rpi_camera,代码行数:24,代码来源:mcp23s17.c

示例15: clock

void SX1509::keypad(byte rows, byte columns, unsigned int sleepTime, byte scanTime, byte debounceTime)
{
	unsigned int tempWord;
	byte tempByte;
	
	// If clock hasn't been set up, set it to internal 2MHz
	if (_clkX == 0)
		clock(INTERNAL_CLOCK_2MHZ);
	
	// Set regDir 0:7 outputs, 8:15 inputs:
	tempWord = readWord(REG_DIR_B);
	for (int i=0; i<rows; i++)
		tempWord &= ~(1<<i);
	for (int i=8; i<(columns * 2); i++)
		tempWord |= (1<<i);
	writeWord(REG_DIR_B, tempWord);
	
	// Set regOpenDrain on 0:7:
	tempByte = readByte(REG_OPEN_DRAIN_A);
	for (int i=0; i<rows; i++)
		tempByte |= (1<<i);
	writeByte(REG_OPEN_DRAIN_A, tempByte);
	
	// Set regPullUp on 8:15:
	tempByte = readByte(REG_PULL_UP_B);
	for (int i=0; i<columns; i++)
		tempByte |= (1<<i);
	writeByte(REG_PULL_UP_B, tempByte);
	
	// Debounce Time must be less than scan time
	debounceTime = constrain(debounceTime, 1, 64);
	scanTime = constrain(scanTime, 1, 128);
	if (debounceTime >= scanTime)
	{
		debounceTime = scanTime >> 1; // Force debounceTime to be less than scanTime
	}
开发者ID:brucetsao,项目名称:LIB_for_MCU,代码行数:36,代码来源:SparkFunSX1509.cpp


注:本文中的writeByte函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。