Catalog npm
Back to packageRELEASE DETAILS

0.1.0

npm

16x2-lcd-menu

Library to quickly set up config menus on a 16x2 lcd

16x2adafruitpiraspberry
Published1 Jan 2019
Direct dependencies1
Transitive dependenciesNot calculated

README

Current package documentation

16x2-lcd-menu

Library to abstract Adafruit 16x2 Character LCD menus, favors configuration over code for creating menus and screen navigation.

Menu params

{
  id: String, // -- identifier
  name: String, // -- Name of template
  enabled: Bool,
  actions: {
    up: func || string || null || undefined, // Action to perform on button up, function, or a string (string name of menu)
    down: func || string || null || undefined, // if null, go up or down a line if template.length > 2
    left: func || string || undefined, // undefined does nothing
    right: func || string || undefined,
    select: func || string || undefined
  },
  template: [String], // array of template string, line by line, since this is an x2 display we join 0 and 1 by \n
  data: func // function to retrieve data

}

Usage

const LCDMENU = require('16x2-lcd-menu');
const lcdMenu = new LCDMENU(60, true); // timeout backlight after 60 seconds, debug on

lcdMenu.addMenu({
  id: 'testMenu',
  name: 'Test Menu',
  enabled: true,
  actions: {
    right: 'testMenu2',
  },
  template: [
    'This is a',
    'Test Menu',
    'Welcome',
    'To the Demo',
  ],
});

lcdMenu.addMenu({
  id: 'testMenu2',
  name: 'Test Menu',
  enabled: true,
  template: [
    'Test Menu 2'
  ],
  actions: {
    left: 'testMenu',
  },
});

lcdMenu.init();
process.on('exit', lcdMenu.close); // Cleanup

LCDMENU Methods

lcd

Raw access to instantiated lcd plate library

addMenu(Menu Object)

Adds a new menu

  • if actions are not set, set it to an empty object (if it is truthy but not an object this could cause a crash)
  • Defaults the id to match the name if an id is not set
  • sets the first menu as the currentMenu (WIP)

removeMenu(String id)

Removes menu specified by id

  • Does nothing if id not provided or menu with that id doesn't exist.
  • fails if there are no more menus registered

enableMenu(String id)

Enables the specified menu

disableMenu(String id)

Disables the specified menu

setBacklight(Boolean state)

Turns the backlight on or off based on state (truthy)

timeoutDisplay()

  • Times out the display backlight after the configured # of seconds has passed
  • does nothing if timeoutMs is set to 0

displayTimeout set/get

  • Set the display timeout in seconds.
  • Doesn't auto-clear previous timer

activeMenu set/get

  • Set re-renders the display if valid, if not valid, does nothing.

init()

Initializes the display

  • If no menu is configured, add a default one
  • Turn on backlight
  • Clears the screen
  • Runs render menu

renderMenu(String id)

Renders provided or active menu, or 0 indexed menu if none provided

clearDisplayTimeout()

Clears the timeout so the screen backlight stays on.

close()

  • Shuts down screen
  • Clears screen, turns off backlight, stops polling button presses

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 1

Native requirements
1 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
adafruit-i2c-lcd
Environment
{
  "local_name": "adafruit-i2c-lcd",
  "alias": false,
  "peer_metadata": null
}
^1.0.2runtime

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-uqNiRDVz14GawE9+kvKScsUkGxfoVWXi/cgLYV/xoNnLRsFbgrXV0lZL1PUztBtrbFkF8AHxxTZ2NVThmoQedA==",
  "shasum": "41008c2ed39eca68f0706e65801cdb7d54b5bcb6",
  "tarball": "https://registry.npmjs.org/16x2-lcd-menu/-/16x2-lcd-menu-0.1.0.tgz",
  "fileCount": 6,
  "unpackedSize": 14388,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcK8TVCRA9TVsSAnZWagAAyVQP/R705oBPjSpVFCyeBZhe\nddh/ANRNkK0SuvQ7JYPmgxr6Q8EkrA0zDIhoFRxh3A14GVF4i7g5YEye0TSO\nBUV/GEXNnj2Vk5+zN3t6OJHDxQ0MdmiRpXdBkICF80jpvC/1XS8emYviSAr4\nq4IDSnHSnaSyDws8qM64g4lk7zMWpAlOihA3DChYlA39f4DDvBWm96xQAPov\nxv0GxxmSocX+RCApIsqvGhg1D37+1Vp3TBWY4OyMv4MIoXzBrvzsDB4tJHtv\n2REeFSJ1y8lCVI0Yh9ue2uFA/pfEEp7iPSqLLCKPljuvIiBs3EHlmmV7TEeL\nV90uhQOaMUCfvECspHuGCyVnVVcTPgqL9+LA104PRi537K3Kot4Hb4plxEG/\nQHybzpS4NA7ZNhdRmGDfDODOQN4Hk7UL0O9hHsIOyC2w9Tg7CcLzzX2s54Og\nSpShCS2WaAqAbqP0wh7sz2z5lC1tfEivODPonpGPMG0cHvWDRP2vdUeRaXmm\n0tQ14FRruSil4z/0AgXvPG3XAARaYMmCNVibKZH9iAdN8XplajRtxbdhpyvO\nGRVSSclmCXk6wDaBgbyOgSOlXX0ChlviBQfqbepBsJ8JHv98jthUNkrYmv3H\nJQ7XkntM7J/uKdj2U5y0J670psqJPAbf0dzKu46rtc0Ewt3yazhFIyI/uTne\nHmXE\r\n=2zBc\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCnsIlDSwLOeQgfpF8tQbqf4oO3zk+LJsGusk3Tp365sAIhALfaH/So7hBBabX5D0KU59edyGrpLWpGhOJLunp9TcoR"
    }
  ]
}

Repository

PENDING
aphotix/16x2-lcd-menu

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:17 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:8768e379d77f8efdc82d0b23dae59b1fc44f41db64af05ab98aee4cc301e4aa6

Other collected versions

0.2.014 NovView all collected versions →