UNPKG

node-red-contrib-lcd20x4-i2c

Version:

Driver for 20x4 HD44780 LCD Display connected via I2C PCF8574

141 lines (133 loc) 5 kB
<!-- Copyright 2013,2014 IBM Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <script type="text/x-red" data-template-name="LCD20x4-I2C"> <div class="form-row"> <label for="node-input-address"><i class="fa fa-network-wired"></i> I2C Address</label> <select type="text" id="node-input-address" style="width:100px;"> <option value="0x27">0x27</option> <option value="0x26">0x26</option> <option value="0x25">0x25</option> <option value="0x24">0x24</option> <option value="0x23">0x23</option> <option value="0x22">0x22</option> <option value="0x21">0x21</option> <option value="0x20">0x20</option> <option value="0x3F">0x3F</option> <option value="0x3E">0x3E</option> <option value="0x3D">0x3D</option> <option value="0x3C">0x3C</option> <option value="0x3B">0x3B</option> <option value="0x3A">0x3A</option> <option value="0x39">0x39</option> <option value="0x38">0x38</option> </select> </div> <div class="form-row"> <label for="node-input-speed"><i class="fa fa-tachometer"></i> Scroll Speed</label> <select type="text" id="node-input-speed" style="width:100px;"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </div> <div class="form-row"> <label for="node-input-size"><i class="fa fa-list"></i> LCD Size</label> <select type="text" id="node-input-size" style="width:100px;"> <option value="20x4">20x4</option>> </select> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</span></label> <input type="text" id="node-input-name"> </div> </script> <script type="text/x-red" data-help-name="LCD20x4-I2C"> <p>Dependencies: SMBus, enable i2c in raspi-config<p> <p><pre> sudo apt-get install python-smbus sudo raspi-config Interfacing Options>I2C>Enable </pre></p> <p>This node will accept an object msg.payload.msgs. If the object passed does not contain 4 lines, the difference is filled with blank lines.</p> <p>Line data structure:</p> <ul> <li>msg must be a string.</li> <ul><li>If msg is more than 20 characters the node will handle scrolling.</li></ul> <li>pos (position) is optional and must be a number with any value between 1-20. This value is used for offsetting text, but you can also insert spaces in to msg instead of supplying pos.</li> <ul><li>If pos is not supplied it will default to 1.</li></ul> <li>center is optional and must be a boolean value passed as a string</li> <ul><li>If pos and center are both set, center will override pos.</li></ul> </ul> <p>If there is an error it will be logged to Node-RED and display an error on the LCD screen.</p> <p><pre>Object format: msg.payload = { msgs: [ { msg: "string", pos: number, center: "boolean" }, { msg: "string", pos: number, center: "boolean" }, { msg: "string", pos: number, center: "boolean" }, { msg: "string", pos: number, center: "boolean" } ] }; </pre></p> </script> <script type="text/javascript"> var pinsInUse = {}; RED.nodes.registerType('LCD20x4-I2C',{ category: 'output', label: 'LCD20x4-I2C', color:"Silver", defaults: { name: { value:"" }, speed: { value:"3" }, size: { value:"20x4" }, address: { value:"0x27" } }, inputs:1, outputs:0, icon: "display.png", align: "right", label: function() { return this.name || "20x4 LCD Output" ; }, labelStyle: function() { return this.name?"node_label_italic":""; } }); </script>