本文整理汇总了C++中write4bits函数的典型用法代码示例。如果您正苦于以下问题:C++ write4bits函数的具体用法?C++ write4bits怎么用?C++ write4bits使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write4bits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例8: write4bits
//
// send - write either command or data
void 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);
}
}
示例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
}
示例10: digitalWrite
// write either command or data, with automatic 4/8-bit selection
void 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);
}
}
示例11: digitalWrite
// write either command or data
void 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);
}
示例12: write4bits
// write either command or data, with automatic 4/8-bit selection
void LiquidCrystal::send(uint8_t value, uint8_t mode) {
s2pdriver.set(SR_RS, mode);
s2pdriver.write();
write4bits(value>>4);
write4bits(value);
}
示例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++;
}
}
示例14: write8bits
// write either command or data, with automatic 4/8-bit selection
void ShiftLCD::send(uint8_t value, uint8_t mode) {
if (_displayfunction & LCD_8BITMODE) {
write8bits(value, mode);
} else {
write4bits(value>>4, mode);
write4bits(value, mode);
}
}
示例15: defined
// write either command or data
void 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);
}