您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ write4bits函数代码示例

51自学网 2021-06-03 10:03:48
  C++
这篇教程C++ write4bits函数代码示例写得很实用,希望能帮到您。

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

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

示例1: delay

void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {        if (lines > 1) {                _displayfunction |= LCD_2LINE;        }        _numlines = lines;        // for some 1 line displays you can select a 10 pixel high font        if ((dotsize != 0) && (lines == 1)) {                _displayfunction |= LCD_5x10DOTS;        }        // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!        // according to datasheet, we need at least 40ms after power rises above 2.7V        // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50        delay(50);        // Now we pull both RS and R/W low to begin commands        expanderWrite(_backlightval);   // reset expanderand turn backlight off (Bit 8 =1)        delay(1000);        //put the LCD into 4 bit mode        // this is according to the hitachi HD44780 datasheet        // figure 24, pg 46          // we start in 8bit mode, try to set 4 bit mode   write4bits(0x03 << 4);   delayMicroseconds(4500); // wait min 4.1ms   // second try   write4bits(0x03 << 4);   delayMicroseconds(4500); // wait min 4.1ms   // third go!   write4bits(0x03 << 4);   delayMicroseconds(150);   // finally, set to 4-bit interface   write4bits(0x02 << 4);        // set # lines, font size, etc.        command(LCD_FUNCTIONSET | _displayfunction);        // turn the display on with no cursor or blinking default        _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;        display();        // clear it off        clear();        // Initialize to default text direction (for roman languages)        _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;        // set the entry mode        command(LCD_ENTRYMODESET | _displaymode);        home();}
开发者ID:alfo,项目名称:door-sign,代码行数:60,


示例2: delayMicroseconds

void CleanCrystal::begin() {  delayMicroseconds(50000);    digitalWrite(LCD_PIN_RESET, LOW);  digitalWrite(LCD_PIN_ENABLE, LOW);    write4bits(0x03);  delayMicroseconds(4500); // wait min 4.1ms  write4bits(0x03);  delayMicroseconds(4500); // wait min 4.1ms  write4bits(0x03);   delayMicroseconds(150);  write4bits(0x02);   // finally, set # lines, font size, etc.  command(LCD_FUNCTIONSET | LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS);    // turn the display on with no cursor or blinking default  _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;    display();  // clear it off  clear();  // Initialize to default text direction (for romance languages)  _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;  // set the entry mode  command(LCD_ENTRYMODESET | _displaymode);}
开发者ID:m-lima,项目名称:SynthByte,代码行数:30,


示例3: spiOut

void SpiLcd::begin(uint8_t cols, uint8_t lines) {	_numlines = lines;	_currline = 0;	_currpos = 0;  	// Set all outputs of shift register to low, this turns the backlight ON.	_spiByte = 0x00;	spiOut();		// The following initialization sequence should be compatible with: 	// - Newhaven OLED displays	// - Standard HD44780 or S6A0069 LCD displays	delayMicroseconds(50000); // wait 50 ms just to be sure that the lcd is initialized	write4bits(0x03); //set to 8-bit	delayMicroseconds(50000); // wait > 4.1ms	write4bits(0x03); //set to 8-bit	delayMicroseconds(1000); // wait > 100us	write4bits(0x03); //set to 8-bit	delayMicroseconds(50000); // wait for execution	write4bits(0x02); //set to 4-bit	delayMicroseconds(50000); // wait for execution	command(0x28); // set to 4-bit, 2-line			clear();	// display clear	// Entry Mode Set:	leftToRight();	noAutoscroll();		home();		//noCursor();	display();}
开发者ID:DigitalWarrior,项目名称:brewpi-avr,代码行数:34,


示例4: delayMicroseconds

void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {	if (lines > 1) {		_displayfunction |= LCD_2LINE;	}	_numlines = lines;	_currline = 0;	// for some 1 line displays you can select a 10 pixel high font	if ((dotsize != 0) && (lines == 1)) {		_displayfunction |= LCD_5x10DOTS;	}	// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!	// according to datasheet, we need at least 40ms after power rises above 2.7V	// before sending commands. Arduino can turn on way before 4.5V so we'll wait 50	delayMicroseconds(50000);	// Now we pull both RS and R/W low to begin commands	digitalWrite(_rs_pin, LOW);	digitalWrite(_enable_pin, LOW);	if (_rw_pin != 255) {		digitalWrite(_rw_pin, LOW);	}	//put the LCD into 4 bit or 8 bit mode	if (! (_displayfunction & LCD_8BITMODE)) {		// this is according to the hitachi HD44780 datasheet		// figure 24, pg 46		// we start in 8bit mode, try to set 4 bit mode		write4bits(0x03);		delayMicroseconds(4500); // wait min 4.1ms		// second try		write4bits(0x03);		delayMicroseconds(4500); // wait min 4.1ms		// third go!		write4bits(0x03);		delayMicroseconds(150);		// finally, set to 4-bit interface		write4bits(0x02);		} else {		// this is according to the hitachi HD44780 datasheet		// page 45 figure 23		// Send function set command sequence		command(LCD_FUNCTIONSET | _displayfunction);		delayMicroseconds(4500); // wait more than 4.1ms		// second try		command(LCD_FUNCTIONSET | _displayfunction);		delayMicroseconds(150);		// third go		command(LCD_FUNCTIONSET | _displayfunction);	}	// finally, set # lines, font size, etc.	command(LCD_FUNCTIONSET | _displayfunction);	// turn the display on with no cursor or blinking default	_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;	display();	// clear it off	clear();	// Initialize to default text direction (for romance languages)	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;	// set the entry mode	command(LCD_ENTRYMODESET | _displaymode);}
开发者ID:pesilajo,项目名称:mystepcschas,代码行数:59,


示例5: delay

void PCF8574_HD44780_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {	if (lines > 1) {		_displayfunction |= LCD_2LINE;	}	_numlines = lines;	// for some 1 line displays you can select a 10 pixel high font	if ((dotsize != 0) && (lines == 1)) {		_displayfunction |= LCD_5x10DOTS;	}	// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!	// according to datasheet, we need at least 40ms after power rises above 2.7V	// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50	delay(50);   	// !NOT NECESSARY! //	// Now we pull both RS and R/W low to begin commands	//expanderWrite(_backlightval);	// reset expanderand turn backlight off (Bit 8 =1) - _backlightval = LCD_NOBACKLIGHT;	//delay(1000);  	// put the LCD into 4 bit mode	// this is according to the hitachi HD44780 datasheet	// figure 24, pg 46		// LCD automatically start in 8bit mode, but we manually repeat	// the 8bit initialization instructions for safety	write4bits(_BV(P4) | _BV(P5));		delay(5); // wait min 4.1ms	write4bits(_BV(P4) | _BV(P5));		delayMicroseconds(150); // wait min 100us	write4bits(_BV(P4) | _BV(P5));			// !NOT NECESSARY! //	//delayMicroseconds(150);		// Set interface to be 4 bits long	write4bits(_BV(P5));	// set # lines, font size, etc.	command(LCD_FUNCTIONSET | _displayfunction);  		// turn the display on with no cursor or blinking default	_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;	display();		// clear it off	clear();		// Initialize to default text direction (for roman languages)	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;		// set the entry mode	command(LCD_ENTRYMODESET | _displaymode);		home();  }
开发者ID:simonecab,项目名称:ArdSim,代码行数:59,


示例6: setRowOffsets

void LCD::begin(uint8_t cols, uint8_t rows, uint8_t charsize) {	if (rows > 1) {		displayFunction |= LCD_2LINE;	}	numLines = rows;		setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols);		if ((charsize != LCD_5x8DOTS) && (rows == 1)) {		displayFunction |= LCD_5x10DOTS;	}	pinMode(pinRS, OUTPUT);	pinMode(pinE, OUTPUT);		if (pinRW != 255)		pinMode(pinRW, OUTPUT);		for (int i=0; i<((displayFunction & LCD_8BITMODE) ? 8 : 4); ++i)		pinMode(pinData[i], OUTPUT);		_delay_us(50000);		digitalOutput(pinRS, LOW);	digitalOutput(pinE, LOW);	if (pinRW != 255)		digitalOutput(pinRW, LOW);		if (! (displayFunction & LCD_8BITMODE)) {		write4bits(0x03);		_delay_us(4500);				write4bits(0x03);		_delay_us(4500);				write4bits(0x03);		_delay_us(150);				write4bits(0x02);		} else {				command(LCD_FUNCTIONSET | displayFunction);		_delay_us(4500);				command(LCD_FUNCTIONSET | displayFunction);		_delay_us(150);				command(LCD_FUNCTIONSET | displayFunction);	}	command(LCD_FUNCTIONSET | displayFunction);	displayControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;	display();	clear();		displayMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;	command(LCD_ENTRYMODESET | displayMode);}
开发者ID:Enigma0960,项目名称:AVR_Clock,代码行数:59,


示例7: setBacklight

void ControLeo_LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {    // Start I2C    _i2c.begin();        // Turn on the backlight    setBacklight(HIGH);    if (lines > 1)        _displayfunction |= LCD_2LINE;    _numlines = lines;    _currline = 0;        // For some 1 line displays you can select a 10 pixel high font    if ((dotsize != 0) && (lines == 1)) {        _displayfunction |= LCD_5x10DOTS;    }    // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!    // According to datasheet, we need at least 40ms after power rises above 2.7V    // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50    delayMicroseconds(50000);        // Now we pull both RS and R/W low to begin commands    _i2c.digitalWrite(_rs_pin, LOW);    _i2c.digitalWrite(_enable_pin, LOW);        //Put the LCD into 4 bit mode    // This is according to the hitachi HD44780 datasheet figure 24, pg 46    // We start in 8bit mode, try to set 4 bit mode    write4bits(0x03);    delayMicroseconds(4500); // wait min 4.1ms        // Second try    write4bits(0x03);    delayMicroseconds(4500); // wait min 4.1ms        // Third go!    write4bits(0x03);    delayMicroseconds(150);        // Finally, set to 8-bit interface    write4bits(0x02);        // Finally, set # lines, font size, etc.    command(LCD_FUNCTIONSET | _displayfunction);        // Turn the display on with no cursor or blinking default    _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;    display();        // Clear the display    clear();        // Initialize to default text direction (for romance languages)    _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;    // Set the entry mode    command(LCD_ENTRYMODESET | _displaymode);}
开发者ID:DickGrier,项目名称:ControLeo,代码行数:58,


示例8: write4bits

//// send - write either command or datavoid LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) {    // No need to use the delay routines since the time taken to write takes    // longer that what is needed both for toggling and enable pin an to execute    // the command.    if (mode == FOUR_BITS) {        write4bits( (value & 0xf), COMMAND );    } else {        write4bits(value >> 4, mode);        write4bits(value & 0xf, mode);    }}
开发者ID:tsandmann,项目名称:ctbot-misc,代码行数:14,


示例9: pinMode

void OLEDFourBit::begin(uint8_t cols, uint8_t lines) {	_numlines = lines;	_currline = 0;		pinMode(_rs_pin, OUTPUT);	pinMode(_rw_pin, OUTPUT);	pinMode(_enable_pin, OUTPUT);		digitalWrite(_rs_pin, LOW);	digitalWrite(_enable_pin, LOW);	digitalWrite(_rw_pin, LOW);		// SEE PAGE 20 of NHD-0420DZW-AY5	delayMicroseconds(50000); // wait 50 ms just to be sure tha the lcd is initialized		// Now we pull both RS and R/W low to begin commands		for (int i = 0; i < 4; i++) {		pinMode(_data_pins[i], OUTPUT);		digitalWrite(_data_pins[i], LOW);	}	delayMicroseconds(100000);	write4bits(0x03);	delayMicroseconds(100000);	write4bits(0x02);	delayMicroseconds(10000);	write4bits(0x02);	delayMicroseconds(10000);	write4bits(0x08);			//command(0x28);	delayMicroseconds(10000);		command(0x08);	// Display off	delayMicroseconds(10000);		command(0x01);	// display clear	delayMicroseconds(10000);	command(0x06);	// Entry Mode Set:	delayMicroseconds(10000);		command(0x02);	// Home	delayMicroseconds(10000);	command(0x0C);	// display on/ cursor on/ cursor blink	delayMicroseconds(10000);		defineCustomCharacters(); // write custom characters to OLED}
开发者ID:djimoun,项目名称:SabreCE,代码行数:53,


示例10: digitalWrite

// write either command or data, with automatic 4/8-bit selectionvoid PCFCrystal::send(uint8_t value, uint8_t mode) {/*    // ORIGINAL CODE  digitalWrite(_rs_pin, mode);  // if there is a RW pin indicated, set it low to Write  if (_rw_pin != -1) {     digitalWrite(_rw_pin, LOW);  }*/  setBit(modeBuffer(), _rs_pin, mode);  // if there is a RW pin indicated, set it low to Write  if (_rw_pin) {     setBit(modeBuffer(), _rw_pin, LOW);  }  writePCF(modeAddress(), *modeBuffer());//return;  if (_displayfunction & LCD_8BITMODE) {    write8bits(value);   } else {    write4bits(value>>4);    write4bits(value);  }}
开发者ID:Nm8574,项目名称:Ardugo,代码行数:27,


示例11: digitalWrite

// write either command or datavoid OLEDFourBit::send(uint8_t value, uint8_t mode) {	digitalWrite(_rs_pin, mode);	pinMode(_rw_pin, OUTPUT);	digitalWrite(_rw_pin, LOW);		write4bits(value>>4);	write4bits(value);}
开发者ID:djimoun,项目名称:SabreCE,代码行数:9,


示例12: write4bits

// write either command or data, with automatic 4/8-bit selectionvoid LiquidCrystal::send(uint8_t value, uint8_t mode) {  	s2pdriver.set(SR_RS, mode);	s2pdriver.write();	 	write4bits(value>>4);	write4bits(value);}
开发者ID:chapuzzo,项目名称:LiquidCrystalS2P,代码行数:9,


示例13: digitalWrite

void CleanCrystal::print(const char * value) {  digitalWrite(LCD_PIN_RESET, HIGH);  for (_bufferPos = 0; _bufferPos < 16; _bufferPos++) {    if (value[_bufferPos] == '/0') return;    write4bits(value[_bufferPos]>>4);    write4bits(value[_bufferPos]);    _cursorPos++;  }}
开发者ID:m-lima,项目名称:SynthByte,代码行数:9,


示例14: write8bits

// write either command or data, with automatic 4/8-bit selectionvoid ShiftLCD::send(uint8_t value, uint8_t mode) {    if (_displayfunction & LCD_8BITMODE) {    write8bits(value, mode);   } else {    write4bits(value>>4, mode);    write4bits(value, mode);  }}
开发者ID:felipehfj,项目名称:Arduino,代码行数:10,


示例15: defined

// write either command or datavoid LiquidCrystal::send(uint8_t value, uint8_t mode) {#if defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1284__)    if (_type == LCD_I2C) {        uint8_t highnib=value&0xf0;        uint8_t lownib=(value<<4)&0xf0;        write4bits((highnib)|mode);        write4bits((lownib)|mode);    }#endif    if (_type == LCD_STD) {        digitalWrite(_rs_pin, mode);        // if there is a RW pin indicated, set it low to Write        if (_rw_pin != 255) {            digitalWrite(_rw_pin, LOW);        }        write4bits(value>>4);        write4bits(value);    }
开发者ID:PeteBa,项目名称:OpenSprinkler-Firmware,代码行数:21,


示例16: writeControl

void LCD_Low_Level::sendData(uint8_t value, uint8_t rs_bit) {  	writeControl(rs_bit, 0);		if (_display_function & LCD_8BitMode) {		write8bits(value);	} else {		write4bits((value & 0xF0)>>4);		write4bits(value & 0x0F);	}}
开发者ID:EvanBuelt,项目名称:Arduino-Projects,代码行数:11,


示例17: bitSet

// write either command or datavoid SpiLcd::send(uint8_t value, uint8_t mode) {	if(mode){		bitSet(_spiByte, LCD_SHIFT_RS);	}	else{		bitClear(_spiByte, LCD_SHIFT_RS);	}	spiOut();	write4bits(value>>4);	write4bits(value);}
开发者ID:DigitalWarrior,项目名称:brewpi-avr,代码行数:12,


示例18: send

// static declarationsstatic upm_result_t send(const lcm1602_context dev, uint8_t value,                         int mode){    assert(dev != NULL);    uint8_t h;    uint8_t l;    upm_result_t rv = UPM_SUCCESS;    if (dev->isI2C)    {        h = value & 0xf0;        l = (value << 4) & 0xf0;        if (write4bits(dev, h | mode))            rv = UPM_ERROR_OPERATION_FAILED;        if (write4bits(dev, l | mode))            rv = UPM_ERROR_OPERATION_FAILED;        return rv;    }    // else, gpio (4 bit)    // register select    if (mraa_gpio_write(dev->gpioRS, mode))    {        printf("%s: mraa_gpio_write() failed/n", __FUNCTION__);        rv = UPM_ERROR_OPERATION_FAILED;    }    h = value >> 4;    l = value & 0x0f;    if (write4bits(dev, h))        rv = UPM_ERROR_OPERATION_FAILED;    if (write4bits(dev, l))        rv = UPM_ERROR_OPERATION_FAILED;    return rv;}
开发者ID:chihchun,项目名称:upm,代码行数:42,


示例19: write4bits

// write either command or data, with automatic 4/8-bit selectionvoid PortDLCD::send(uint8_t value, uint8_t mode) {  //digitalWrite(_rs_pin, mode);	if (mode) {		PORTD |= (1 << RS_PIN);	} else {		PORTD &= ~(1 << RS_PIN);	}	    write4bits(value>>4);    write4bits(value);}
开发者ID:vaddieg,项目名称:arduino,代码行数:13,


示例20: digitalOutput

void LCD::send(uint8_t value, uint8_t mode) {	digitalOutput(pinRS, mode);	if (pinRW != 255)		digitalOutput(pinRW, LOW);		if (displayFunction & LCD_8BITMODE)		write8bits(value);	else {		write4bits(value>>4);		write4bits(value);	}}
开发者ID:Enigma0960,项目名称:AVR_Clock,代码行数:13,


示例21: digitalWrite

// write either command or data, with automatic 4/8-bit selectionvoid LiquidCrystal::send(uint8_t value, uint8_t mode) {	digitalWrite(_rs_pin, mode);	// if there is a RW pin indicated, set it low to Write	if (_rw_pin != 255) {		digitalWrite(_rw_pin, LOW);	}	if (_displayfunction & LCD_8BITMODE) {		write8bits(value);		} else {		write4bits(value>>4);		write4bits(value);	}}
开发者ID:pesilajo,项目名称:mystepcschas,代码行数:14,


示例22: SET

// write either command or data, with automatic 4/8-bit selectionvoid LiquidCrystal::send(unsigned char value, bool mode) {    if (this->realTimeDisplay) {        if (mode) {            SET(_rs_pin);        } else {            RESET(_rs_pin);        }        write4bits(value >> 4);        pulseEnable(1);        write4bits(value);        pulseEnable(delayAfterCommand);    } else {        if (!lcdActions.isFull()) {
开发者ID:norbim1,项目名称:preenFM2,代码行数:15,


示例23: delayMicroseconds

void LiquidCrystalNew_T3TWI::initChip(uint8_t dotsize, byte witchEnablePin) {  	byte	displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;	byte i;	if (_lcd_lines > 1) displayfunction |= LCD_2LINE;	// for some 1 line displays you can select a 10 pixel high font	if ((dotsize != 0) && (_lcd_lines == 1)) displayfunction |= LCD_5x10DOTS;	for (i=0;i<18;i++) {		delayMicroseconds(LCD_STARTUP_DLY);	}	setDataMode(0);//COMMAND MODE	writeGpio(_theData & ~witchEnablePin);  // En LOW---------------------------------------*/	write4bits(0x03);	delayMicroseconds(5000); // I have one LCD for which 4500 here was not long enough.	// second try	write4bits(0x03);      	delayMicroseconds(150); // wait 	// third go!	write4bits(0x03); 	delayMicroseconds(150);	// finally, set to 4-bit interface	write4bits(0x02); 	delayMicroseconds(150);	// finally, set # lines, font size, etc.	command(LCD_FUNCTIONSET | displayfunction);  	// turn the display on with no cursor or blinking default	_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;  	display();	// clear it off	clear();	// Initialize to default text direction (for romance languages)	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;	// set the entry mode	command(LCD_ENTRYMODESET | _displaymode);		noAutoscroll();}
开发者ID:sumotoy,项目名称:LiquidCrystalNewV2,代码行数:37,


示例24: write8bits

// write either command or data, with automatic 4/8-bit selectionvoid LiquidCrystal::send(uint8_t value, uint8_t mode) {  IO::digitalWrite(LCD_RS_PIN, mode);  // if there is a RW pin indicated, set it low to Write#ifdef LCD_RW_PIN    IO::digitalWrite(LCD_RW_PIN, LOW);#endif#ifdef LCD_ENABLE_8BITMODE    write8bits(value);#else    write4bits(value>>4);    write4bits(value);#endif //LCD_ENABLE_8BITMODE}
开发者ID:9DSmart,项目名称:cheali-charger,代码行数:16,


示例25: setRowOffsets

void LiquidCrystal_EADIP204_6::begin(uint8_t dotsize) {//  _displayfunction |= LCD_2LINE;    setRowOffsets(0x00, 0x20, 0x40, 0x60);    pinMode(_rs_pin, OUTPUT);    // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#    if (_rw_pin != 255) {        pinMode(_rw_pin, OUTPUT);    }    pinMode(_enable_pin, OUTPUT);    // Do these once, instead of every time a character is drawn for speed reasons.    for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i)    {        pinMode(_data_pins[i], OUTPUT);    }    // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!    // according to datasheet, we need at least 40ms after power rises above 2.7V    // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50    delayMicroseconds(50000);    // Now we pull both RS and R/W low to begin commands    digitalWrite(_rs_pin, LOW);    digitalWrite(_enable_pin, LOW);    if (_rw_pin != 255) {        digitalWrite(_rw_pin, LOW);    }    //put the LCD into 4 bit or 8 bit mode    if (! (_displayfunction & LCD_8BITMODE)) {        // this is according to the hitachi HD44780 datasheet        // figure 24, pg 46        // we start in 8bit mode, try to set 4 bit mode        write4bits(0x03);        delayMicroseconds(4500); // wait min 4.1ms        // second try        write4bits(0x03);        delayMicroseconds(4500); // wait min 4.1ms        // third go!        write4bits(0x03);        delayMicroseconds(150);        // finally, set to 4-bit interface        write4bits(0x02);        delayMicroseconds(4500);        command(LCD_FSET | LCD_RE); //function set RE=1 lcd.command (0x24) / /        delayMicroseconds(4500);        command(LCD_4L5DF);        delayMicroseconds(4500);        command(LCD_SETCGRAMADDR);        delayMicroseconds(4500);        for (int i = 0; i < 16; ++i) {            send(LCD_SYM_MODE_OFF, HIGH);        }        delayMicroseconds(4500);        command(LCD_FSET);        delayMicroseconds(4500);        delayMicroseconds(4500);    } else {        // this is according to the hitachi HD44780 datasheet        // page 45 figure 23        // Send function set command sequence        command(LCD_FUNCTIONSET | _displayfunction);        delayMicroseconds(4500);  // wait more than 4.1ms        // second try        command(LCD_FUNCTIONSET | _displayfunction);        delayMicroseconds(150);        // third go        command(LCD_FUNCTIONSET | _displayfunction);    }    // finally, set # lines, font size, etc.//  command(LCD_FUNCTIONSET | _displayfunction);    // turn the display on with no cursor or blinking default    _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;    display();    // clear it off    clear();    // Initialize to default text direction (for romance languages)    _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;    // set the entry mode    command(LCD_ENTRYMODESET | _displaymode);}
开发者ID:jucs,项目名称:arduino-due,代码行数:97,


示例26: lcm1602_i2c_init

lcm1602_context lcm1602_i2c_init(int bus, int address, bool is_expander,                                 uint8_t num_columns, uint8_t num_rows){    lcm1602_context dev =        (lcm1602_context)malloc(sizeof(struct _lcm1602_context));    if (!dev)        return NULL;    memset((void *)dev, 0, sizeof(struct _lcm1602_context));    // make sure MRAA is initialized    int mraa_rv;    if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)    {        printf("%s: mraa_init() failed (%d)./n", __FUNCTION__, mraa_rv);        lcm1602_close(dev);        return NULL;    }    // initialize the MRAA context    if (!(dev->i2c = mraa_i2c_init(bus)))    {        printf("%s: mraa_i2c_init failed./n", __FUNCTION__);        lcm1602_close(dev);        return NULL;    }    // now check the address...    if (mraa_i2c_address(dev->i2c, address) != MRAA_SUCCESS)    {        printf("%s: mraa_i2c_address failed./n", __FUNCTION__);        lcm1602_close(dev);        return NULL;    }    dev->isI2C = true;    dev->backlight = HD44780_BACKLIGHT;    dev->columns = num_columns;    dev->rows = num_rows;    // if we are not dealing with an expander we will only initialize    // the I2C context and bail, leaving it up to the caller to handle    // further communications (like JHD1313M1)    if (!is_expander)        return dev;    upm_delay_us(50000);    lcm1602_backlight_on(dev, true);    upm_delay_us(100000);    // try to put us into 4 bit mode    write4bits(dev, 0x03 << 4);    upm_delay_us(4500);    write4bits(dev, 0x30);    upm_delay_us(4500);    write4bits(dev,0x30);    upm_delay_us(150);    // Put us into 4 bit mode, for realz yo.    write4bits(dev, 0x20);    // Set number of lines    lcm1602_command(dev, HD44780_FUNCTIONSET | 0x0f);    // default display control    dev->displayControl = HD44780_DISPLAYON | HD44780_CURSOROFF        | HD44780_BLINKOFF;    lcm1602_command(dev, HD44780_DISPLAYCONTROL | dev->displayControl);    upm_delay_us(2000);    lcm1602_clear(dev);    // Set entry mode.    dev->entryDisplayMode = HD44780_ENTRYLEFT | HD44780_ENTRYSHIFTDECREMENT;    lcm1602_command(dev, HD44780_ENTRYMODESET | dev->entryDisplayMode);    lcm1602_home(dev);    return dev;}
开发者ID:chihchun,项目名称:upm,代码行数:88,


示例27: write4bits

// write either command or datavoid LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) {	uint8_t highnib=value&0xf0;	uint8_t lownib=(value<<4)&0xf0;       write4bits((highnib)|mode);	write4bits((lownib)|mode); }
开发者ID:Paul-NA8E,项目名称:Tentec506,代码行数:7,


示例28: pinMode

void LCD_Low_Level::begin(uint8_t columns, uint8_t rows, uint8_t dotsize) {  if (rows > 1) {    _display_function |= LCD_2Line;  }  if ((dotsize != LCD_5x8Dots) && (rows == 1)) {    _display_function |= LCD_5x10Dots;  }  pinMode(_rs_pin, OUTPUT);  pinMode(_rw_pin, OUTPUT);  pinMode(_enable_pin, OUTPUT);  // According to datasheet, we need at least 40ms after power rises above 2.7V  // before sending commands.  Wait 50ms to be safe.  delayMicroseconds(50000);  // Pull RS and RW low to begin sending commands  digitalWrite(_rs_pin, LOW);  digitalWrite(_rw_pin, LOW);  // Put the LCD into 4 bit or 8 bit mode  if (! (_display_function & LCD_8BitMode)) {    // LCD starts in 8-bit mode.  Try to set 4 bit mode    write4bits(0x03);    delayMicroseconds(4500); // wait min 4.1 ms    // Second try    write4bits(0x03);    delayMicroseconds(4500); // wait min 4.1 ms    // Third try    write4bits(0x03);    delayMicroseconds(150);    // Fourth try will set the LCD to 4-bit interface    write4bits(0x02);  } else {    // Send function set command sequence    command(LCD_FunctionSet | _display_function);    delayMicroseconds(4500); // wait more than 4.1 ms    // Second try    command(LCD_FunctionSet | _display_function);    delayMicroseconds(150);    // Third try    command(LCD_FunctionSet | _display_function);  }  // Set # lines, font size, etc  command(LCD_FunctionSet | _display_function);  // turn the display on with no cursor or blinking default  displayControl(LCD_DisplayOn, LCD_CursorOff, LCD_BlinkOn);  // Clear the display  clearDisplay();  // Initialize default text direction for romance language  entrySetMode(LCD_CursorRight, LCD_DisplayLeft);  }
开发者ID:EvanBuelt,项目名称:Arduino-Projects,代码行数:65,



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


C++ write8函数代码示例
C++ write32_delegate函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。