{"id":17474009,"url":"https://github.com/fivdi/lcd","last_synced_at":"2025-04-16T04:46:19.146Z","repository":{"id":11692008,"uuid":"14203948","full_name":"fivdi/lcd","owner":"fivdi","description":"Node.js Hitachi HD44780 LCD driver","archived":false,"fork":false,"pushed_at":"2021-09-26T07:52:43.000Z","size":131,"stargazers_count":55,"open_issues_count":2,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-20T00:22:28.578Z","etag":null,"topics":["beaglebone","beaglebone-black","hd44780","iot","javascript","lcd","nodejs","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivdi.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-07T13:07:13.000Z","updated_at":"2023-09-08T16:43:17.000Z","dependencies_parsed_at":"2022-09-01T01:20:44.391Z","dependency_job_id":null,"html_url":"https://github.com/fivdi/lcd","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Flcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Flcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Flcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Flcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivdi","download_url":"https://codeload.github.com/fivdi/lcd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249197929,"owners_count":21228660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beaglebone","beaglebone-black","hd44780","iot","javascript","lcd","nodejs","raspberry-pi"],"created_at":"2024-10-18T18:08:05.260Z","updated_at":"2025-04-16T04:46:19.131Z","avatar_url":"https://github.com/fivdi.png","language":"JavaScript","readme":"[![Build Status](https://app.travis-ci.com/fivdi/lcd.svg?branch=master)](https://app.travis-ci.com/github/fivdi/lcd)\n[![npm Version](http://img.shields.io/npm/v/lcd.svg)](https://www.npmjs.com/package/lcd)\n[![Downloads Per Month](http://img.shields.io/npm/dm/lcd.svg)](https://www.npmjs.com/package/lcd)\n\n## lcd\n\nA **Node.js** Hitachi HD44780 LCD driver for Linux boards like the Raspberry Pi\nor BeagleBone. Heavily inspired by the Arduino\n[LiquidCrystal library](http://arduino.cc/en/Tutorial/LiquidCrystal).\n\nMost LCDs compatible with the HD44780 have a sixteen pin interface. This\nNode.js module uses six of these interface pins for controlling such displays.\nRegister select (RS), enable (E), and four data bus pins (D4-D7). The\nread/write (R/W) pin is assumed to be tied low to permanently select write\nmode.\n\nlcd supports Node.js versions 10, 12, 14, 15 and 16.\n\n## Installation\n\n```\nnpm install lcd\n```\n\n## Usage\n\nThe following program can be used to make a UTC digital clock.\n\n```js\nconst Lcd = require('lcd');\nconst lcd = new Lcd({rs: 45, e: 44, data: [66, 67, 68, 69], cols: 8, rows: 1});\n\nlcd.on('ready', _ =\u003e {\n  setInterval(_ =\u003e {\n    lcd.setCursor(0, 0);\n    lcd.print(new Date().toISOString().substring(11, 19), err =\u003e {\n      if (err) {\n        throw err;\n      }\n    });\n  }, 1000);\n});\n\n// If ctrl+c is hit, free resources and exit.\nprocess.on('SIGINT', _ =\u003e {\n  lcd.close();\n  process.exit();\n});\n```\n\nHere it is up and running on a BeagleBone Black wired up to an 8x1 display:\n\n\u003cimg src=\"https://github.com/fivdi/lcd/raw/master/example/digital-clock-8x1.jpg\"\u003e\n\nAfter requiring the lcd module, the above program creates an Lcd object. The\nconstructor function is passed all the necessary information.\n\nThe six LCD interface pins used to control the display need to be wired up to\nsix GPIOs on the BeagleBone Black. GPIOs on Linux are identified by unsigned\nintegers. The relevant information for all six GPIOs used here is shown in the\nfollowing table:\n\nBBB Expansion Header | GPIO No. | LCD Function | LCD Pin No.\n:---: | :---: | :---: | :---:\nP8_7 | 66 | Data Bus Bit 4 | 11\nP8_8 | 67 | Data Bus Bit 5 | 12\nP8_10 | 68 | Data Bus Bit 6 | 13\nP8_9 | 69 | Data Bus Bit 7 | 14\nP8_11 | 45 | Register Select |  4\nP8_12 | 44 | Enable  |  6\n\nThe constructor function is also told how many columns and rows the display\nhas, eight and one respectively in this case.\n\nIt takes several milliseconds to initialize an LCD. The constructor starts the\ninitialization process, but it doesn't wait for it to complete. Instead,\na 'ready' event is emitted after the LCD has been completely initialized and is\nready for usage.\n\nThe 'ready' handler leverages setInterval to execute a function that updates\nthe time displayed on the LCD once a second.\n\n## API\n\n**Lcd(config)**\n\nReturns a new Lcd object which inherits from EventEmitter. A 'ready' event will\nbe emitted when the display is ready for usage.\n\nThe config object has these possibilities:\n\n * **cols** LCD column count. Defaults to 16.\n * **rows** LCD row count. Defaults to 1.\n * **largeFont** Use 5x10 dot font. Defaults to false for 5x8 dot font.\n * **rs** Register select GPIO number.\n * **e** Enable GPIO number.\n * **data** Array of four GPIO numbers for data bus bits D4 through D7.\n\n**print(val, [callback])**\n\nConverts val to string and writes it to the display **asynchronously**.\n\nIf the optional completion callback is omitted, a 'printed' event is emitted\nafter the operation has completed. The string representation of val is passed\nto the 'printed' event handler as the first argument. If an error occurs, an\n'error' event will be emitted and an error object will be passed to the\n'error' event handler as the first argument.\n\nIf the optional completion callback is specified, it gets two arguments\n(err, str), where err is reserved for an error object and str is the string\nrepresentation of val. If the optional completion callback is specified, no\n'printed' or 'error' event will be emitted.\n\nThe example print-twice-20x4.js demonstrates how to print two strings in\nsuccession.\n\n**clear([callback])**\n\nClears display and returns cursor to the home position **asynchronously**.\n\nIf the optional completion callback is omitted, a 'clear' event is emitted\nafter the operation has completed. If an error occurs, an 'error' event will\nbe emitted and an error object will be passed to the 'error' event handler\nas the first argument.\n\nIf the optional completion callback is specified, it gets one argument (err),\nwhere err is reserved for an error object. If the optional completion callback\nis specified, no 'clear' or 'error' event will be emitted.\n\n**home([callback])**\n\nReturns cursor to home position **asynchronously**. Also returns display being\nshifted to the original position.\n\nIf the optional completion callback is omitted, a 'home' event is emitted\nafter the operation has completed. If an error occurs, an 'error' event will\nbe emitted and an error object will be passed to the 'error' event handler\nas the first argument.\n\nIf the optional completion callback is specified, it gets one argument (err),\nwhere err is reserved for an error object. If the optional completion callback\nis specified, no 'home' or 'error' event will be emitted.\n\n**setCursor(col, row)** Moves the cursor to the specified col and row.\nNumbering for col and row starts at zero.\n\n**cursor()** Turn cursor on.\n\n**noCursor()** Turn cursor off.\n\n**blink()** Turn cursor blink on.\n\n**noBlink()** Turn cursor blink off.\n\n**scrollDisplayLeft()** Shift display to the left. Cursor follows the display\nshift.\n\n**scrollDisplayRight()** Shift display to the right. Cursor follows the display\nshift.\n\n**leftToRight()** Sets cursor move direction to left to right.\n\n**rightToLeft()** Sets cursor move direction to right to left.\n\n**autoscroll()** Automatically shift display when data is written to display.\n\n**noAutoscroll()** Turn automatic shifting off.\n\n**close()** Frees (unexports) all GPIOs used by the Lcd.\n\n## Example \"Hello, World!\" on an 8x1 display\n\n\"Hello, World!\" is five characters too long for an 8x1 display, but by moving\nthe cursor to the ninth column, turning autoscroll on, and displaying a new\ncharacter every 300 milliseconds the text can be scrolled onto the display\ncharacter by character. Note that an 8x1 display actually has eighty columns\nbut only eight of them are visible.\n\n```js\nconst Lcd = require('../lcd');\nconst lcd = new Lcd({rs: 45, e: 44, data: [66, 67, 68, 69], cols: 8, rows: 1});\n\nconst print = (str, pos) =\u003e {\n  pos = pos || 0;\n\n  if (pos === str.length) {\n    pos = 0;\n  }\n\n  lcd.print(str[pos], err =\u003e {\n    if (err) {\n      throw err;\n    }\n\n    setTimeout(_ =\u003e {\n      print(str, pos + 1);\n    }, 300);\n  });\n};\n\nlcd.on('ready', _ =\u003e {\n  lcd.setCursor(8, 0);\n  lcd.autoscroll();\n  print('Hello, World! ** ');\n});\n\n// If ctrl+c is hit, free resources and exit.\nprocess.on('SIGINT', _ =\u003e {\n  lcd.close();\n  process.exit();\n});\n```\n\n## Tested with the following displays\n\n[NHD-0108FZ-FL-YBW-33V3](http://www.newhavendisplay.com/nhd0108fzflybw33v3-p-5155.html)\n\n[NHD-0420DZ-FL-YBW-33V3](http://www.newhavendisplay.com/nhd0420dzflybw33v3-p-5168.html)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivdi%2Flcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivdi%2Flcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivdi%2Flcd/lists"}