LCD Library: LiquidCrystal_I2C_ByVac.cpp Source File

| LCD Library 1.3.0 LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.

- Main Page
- Classes
- Files

- File List
- File Members

LiquidCrystal_I2C_ByVac.cpp
Go to the documentation of this file.

    00001 // ---------------------------------------------------------------------------
    00002 // Created by GHPS on 5/06/2012.
    00003 // Copyright 2012 - Under creative commons license 3.0:
    00004 //        Attribution-ShareAlike CC BY-SA
    00005 //
    00006 // This software is furnished "as is", without technical support, and with no
    00007 // warranty, express or implied, as to its usefulness for any purpose.
    00008 //
    00009 // Thread Safe: No
    00010 // Extendable: Yes
    00011 //
    00012 // @file LiquidCrystal_I2C_ByVac.c
    00013 // This file implements a basic liquid crystal library that comes as standard
    00014 // in the Arduino SDK but using the extension board BV4218/BV4208 from ByVac.
    00015 //
    00016 // @brief
    00017 // This is a basic implementation of the LiquidCrystal library of the
    00018 // Arduino SDK. The original library has been reworked in such a way that
    00019 // this class implements the all methods to command an LCD based
    00020 // on the Hitachi HD44780 and compatible chipsets using I2C extension
    00021 // backpack BV4218 from ByVac.
    00022 //
    00023 // The functionality provided by this class and its base class is identical
    00024 // to the original functionality of the Arduino LiquidCrystal library.
    00025 //
    00026 // @author GHPS - ghps@users.sourceforge.net
    00027 // ---------------------------------------------------------------------------
    00028 #if (ARDUINO <  100)
    00029 #include <WProgram.h>
    00030 #else
    00031 #include <Arduino.h>
    00032 #endif
    00033 #include <inttypes.h>
    00034 #include "LiquidCrystal_I2C_ByVac.h"
    00035
    00036 // CONSTRUCTORS
    00037 // ---------------------------------------------------------------------------
    00038 LiquidCrystal_I2C_ByVac::LiquidCrystal_I2C_ByVac( uint8_t lcd_Addr )
    00039 {
    00040    _Addr = lcd_Addr;
    00041    _polarity == NEGATIVE;
    00042 }
    00043
    00044 // PUBLIC METHODS
    00045 // ---------------------------------------------------------------------------
    00046
    00047 //
    00048 // begin
    00049 void LiquidCrystal_I2C_ByVac::begin(uint8_t cols, uint8_t lines, uint8_t dotsize)
    00050 {
    00051    Wire.begin();
    00052    LCD::begin ( cols, lines, dotsize );
    00053 }
    00054
    00055 // User commands - users can expand this section
    00056 //----------------------------------------------------------------------------
    00057 // Turn the integrated backlight off/on
    00058
    00059 // setBacklight
    00060 void LiquidCrystal_I2C_ByVac::setBacklight( uint8_t value )
    00061 {
    00062   Wire.beginTransmission(_Addr);
    00063   Wire.write(0x03);                                     //  ByVac command code 0x03 for backlight
    00064   if (value==0) Wire.write(1); else Wire.write((byte)0);        // 1 for off since polarity is NEGATIVE
    00065   Wire.endTransmission();
    00066 }
    00067
    00068 // Turn the contrast off/on
    00069
    00070 // setContrast
    00071 void LiquidCrystal_I2C_ByVac::setContrast( uint8_t value )
    00072 {
    00073   Wire.beginTransmission(_Addr);
    00074   Wire.write(0x05);                                     //  ByVac command code 0x05 for contrast
    00075   if (value==0) Wire.write((byte)0); else Wire.write(1);
    00076   Wire.endTransmission();
    00077 }
    00078
    00079 // PRIVATE METHODS
    00080 // ---------------------------------------------------------------------------
    00081
    00082 //
    00083 // init
    00084 int LiquidCrystal_I2C_ByVac::init()
    00085 {
    00086    int status = 0;
    00087
    00088    // ByVac backpack initialized by onboard firmware
    00089    // ------------------------------------------------------------------------
    00090    status=1;
    00091    return ( status );
    00092 }
    00093
    00094 // low level data pushing commands
    00095 //----------------------------------------------------------------------------
    00096
    00097 //
    00098 // send - write either command or data
    00099 void LiquidCrystal_I2C_ByVac::send(uint8_t value, uint8_t mode)
    00100 {
    00101   Wire.beginTransmission(_Addr);
    00102   Wire.write(mode+1); // map COMMAND (0) -> ByVac command code 0x01/ DATA  (1) ->  ByVac command code 0x02
    00103   Wire.write(value);
    00104   Wire.endTransmission();
    00105 }

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines