Giter VIP home page Giter VIP logo

node-onion-omega-oled-text's Introduction

onion-omega-oled-text

Write text with big 16x16 font on the OLED expansion of the Onion Omega / Omega2

Any contributions / PRs welcome!

Prerequisites

  • Onion Omega / Onion Omega 2
  • Onion OLED expansion

Installation

  1. Make sure you have Node.js and npm installed on your Omega. To do so, ssh into your device (or open the terminal from the web console) and then run the following commands:
opkg update
opkg install nodejs
opkg install npm

Then check if the oled-exp command works by running the following:

oled-exp -h

It should print out a help containing a list of commands.

Then go into your local project directory and execute:

npm install onion-omega-oled-text

Example usage

Within your project, create a .js file like this:

var omegaOledText = require('onion-omega-oled-text');

omegaOledText.init().then(function() {
  omegaOledText.writeText('Hello\nworld!');
});

More examples

Check out example.clock.js

(When using the example code in a local folder where you plan to use it with the node module, please change require('./index') to require('onion-omega-oled-text')).

Character support

Out of the box, the following characters are supported:

  • 0-9
  • a-z
  • A-Z
  • !?"':,;+-=()$./@
  • space character

You can, however, add your own custom characters! There is a character editor available (editor.html) which will help you creating the necessary matrix for the character. Once you have created your character, copy the character byte matrix array from the input field at the bottom of the page and use it e.g. as follows:

var omegaOledText = require('onion-omega-oled-text');

omegaOledText.addCharacter('♥', ['0x00','0x78','0xfc','0xfe','0xfe','0xfc','0xf8','0xf0','0xf8','0xfc','0xfe','0xfe','0xfc','0x78','0x00','0x00','0x00','0x00','0x01','0x07','0x0f','0x1f','0x3f','0x7f','0x3f','0x1f','0x0f','0x03','0x01','0x00','0x00','0x00']);

omegaOledText.init().then(function() {
  omegaOledText.writeText('Hello! ♥');
});

Please also note that currently (02/2017) the vi/vim/nano versions of the omega do not support all utf8 characters, therefore it's possible that you see other characters instead. This does however not influence the execution of the script.

Commands

  • init() Initialize the display
  • writeText(text, reset = true) If reset is set to true (default), text will start at the beginning of the display and other contents will be erased.
  • addCharacter(character, byteMatrix) Add a new character that can be used in writeText or replace an existing one, see custom character example above
  • setStandbyTimeout(secondsOfInactivity = 0) Configures the time of inactivity (in seconds) after which the display should turn off to save power. Display is turned back on automatically when writeText is called next time. Disabled (0) by default.

If you need more commands, have a look at: https://github.com/jonathan-reisdorf/node-onion-omega-oled

Additional information

How many 16x16 characters fit onto the OLED screen?

8 characters x 4 lines

Line breaks

As shown in the example, you can create line breaks by inserting \n into your text.

node-onion-omega-oled-text's People

Contributors

jonathan-reisdorf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-onion-omega-oled-text's Issues

How to "convert" fonts?

Hey @jonathan-reisdorf! Great work!

I was messing around here with my Omega2+ and found a program called GLCD Font Creator
mikroelektronika-glcd-font-creator-software

And looks like it basically is a font editor that allows you to set the device size. So I was trying to export but I've noticed that the HEX formats are different. Do you have any convertion table you've used for converting the current script font?

Oh, and I've found a bunch of fonts 16x16 that can be used here since its Public Domain.

I can make script that would allow anyone to convert but I need to know how you did it.

Thanks!

commit converted font

...instead of source format to skip converting step and speed up initial rendering

character editor not working

Hi, I'm working on a project that's heavily based on your code.

I stumbled upon your character editor and I just can't get it to work. I tried every browser and even triple-checked if js is enabled.

Also, if I define a character that already exists, such as a 0 for example, does it automatically get "overwritten"?

Thanks for your help!

add promise to writeText

wait for exec callback so that newly rendered text doesn't conflict with rendering in progress

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.