//***************************************************************************** // //! \brief Write data or command to the HD44780. //! //! \param ucRS determines if the IR or DR to select. //! //! The parameter of ucRS can be: //! - HD44780_RS_COMMAND - select the IR. //! - HD44780_RS_DATA - select the DR. //! //! \return None. // //***************************************************************************** void HD44780Write(unsigned char ucRS, unsigned char ucInstruction) { int i; // // Check Arguments. // xASSERT((ucRS == HD44780_RS_COMMAND) || (ucRS == HD44780_RS_DATA)); // // RS:Command, RW:Write, E:Enable // _digitalWrite(ucRsPin, ucRS); _digitalWrite(ucEnablePin, HD44780_E_ENABLE); // // Output Data // for ( i = 0; i < 4; i++) { _digitalWrite(ucDataPin[i], (ucInstruction >> (i+4)) & 0x01); } PulseEnable(); xSysCtlDelay(10); _digitalWrite(ucEnablePin, HD44780_E_ENABLE); for ( i = 0; i < 4; i++) { _digitalWrite(ucDataPin[i], (ucInstruction >> (i)) & 0x01); } xSysCtlDelay(10); PulseEnable(); }
void LiquidCrystal::pulseEnable(void) { _digitalWrite(_enable_pin, LOW); delayMicroseconds(1); _digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns _digitalWrite(_enable_pin, LOW); delayMicroseconds(100); // commands need > 37us to settle }
// write either command or data, with automatic 4/8-bit selection void 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); } }
void Digital::digitalWrite(int value){ if(_digitalMode==DIGITAL_MODE_NULL) return; if(_digitalMode==DIGITAL_MODE_OUT)_digitalWrite(value); else{ if(value==1)setupDigitalInPullUp(); else if(value==0)setupDigitalInPullDown(); else setupDigitalIn(); } }
bool Device::setValue(value_t value, bool sync){ currentValue = value; if(sensor == false){ if(type == Device::DIGITAL){ if(inverted) value = ! value; _digitalWrite(pin, (value == 0 ? LOW : HIGH)); }else{ _analogWrite(pin, value); } notifyListeners(); // Notify internal listeners (onChange) // Send value to server/client if(sync){ if(syncListerner) (*syncListerner)(id, currentValue); } } return true; }
void Adafruit_RGBLCDShield::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // check if i2c if (_i2cAddr != 255) { //_i2c.begin(_i2cAddr); Wire.begin(); _i2c.begin(); _i2c.pinMode(8, OUTPUT); _i2c.pinMode(6, OUTPUT); _i2c.pinMode(7, OUTPUT); setBacklight(0x7); if (_rw_pin) _i2c.pinMode(_rw_pin, OUTPUT); _i2c.pinMode(_rs_pin, OUTPUT); _i2c.pinMode(_enable_pin, OUTPUT); for (uint8_t i=0; i<4; i++) _i2c.pinMode(_data_pins[i], OUTPUT); for (uint8_t i=0; i<5; i++) { _i2c.pinMode(_button_pins[i], INPUT); _i2c.pullUp(_button_pins[i], 1); } } 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 _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 8-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); }
void digitalWrite(int pin, ePinLevel level) { _digitalWrite(pin, (int)level); }
/********************************************************************** * @brief write a desired logic to output pin * * @param PIN selected pin (see pin mapping above) * @param VAL logic valuee, should be * - HIGH * - LOW * @return none **********************************************************************/ void digitalWrite(uint8_t PIN,uint8_t VAL) { _digitalWrite(getGPIOPortPointer(PIN), digitalPinToGPIOPin(PIN), VAL); }
void PulseEnable(void) { _digitalWrite(ucEnablePin, HD44780_E_DISABLE); xSysCtlDelay(100); // commands need > 37us to settle }
//***************************************************************************** // //! \brief Sets the entire LCD display backlight. //! //! \param None. //! //! \return None. // //***************************************************************************** void HD44780BackLightOn(void) { _digitalWrite(7, 1); }
// Allows to set the backlight, if the LCD backpack is used void LiquidCrystal::setBacklight(uint8_t status) { // check if i2c or SPI if ((_i2cAddr != 255) || (_SPIclock != 255)) { _digitalWrite(7, status); // backlight is on pin 7 } }
int Digital::digitalRead(){ if(_digitalMode==DIGITAL_MODE_NULL) return 0; if(_digitalMode==DIGITAL_MODE_IN||_digitalMode==DIGITAL_MODE_PULLUP||_digitalMode==DIGITAL_MODE_PULLDOWN)return _digitalRead(); else return _digitalWrite(); }