All Projects → visrealm → vrEmuLcd

visrealm / vrEmuLcd

Licence: MIT license
Character LCD emulator library (C99 engine, web front-end).

Programming Languages

c
50402 projects - #5 most used programming language
javascript
184084 projects - #8 most used programming language
Batchfile
5799 projects

Projects that are alternatives of or similar to vrEmuLcd

picoLCD
Example code for interfacing with a LCD with a Raspberry Pi Pico
Stars: ✭ 25 (-44.44%)
Mutual labels:  lcd, lcd-display
hd44780-driver
Implementation of the embedded-hal traits for the HD44780.
Stars: ✭ 21 (-53.33%)
Mutual labels:  hd44780, lcd-display
qnapdisplay
Qnap lcd python module, features both writing to the display as wel as reading keypresses from the panel keys. It was developed on a Qnap TS-459 and a TS-453A, it works on some other models as well.
Stars: ✭ 37 (-17.78%)
Mutual labels:  lcd, lcd-display
eigen-js
⚡ Eigen-js is a port of the Eigen C++ linear algebra library
Stars: ✭ 78 (+73.33%)
Mutual labels:  emscripten
perl.js
emscripten build settings for perl
Stars: ✭ 31 (-31.11%)
Mutual labels:  emscripten
rogue.js
JavaScript porting of original Rogue source code using Emscripten
Stars: ✭ 33 (-26.67%)
Mutual labels:  emscripten
wrenjs
The Wren Programming Language, in the browser
Stars: ✭ 28 (-37.78%)
Mutual labels:  emscripten
U8g2
U8glib library for monochrome displays, version 2
Stars: ✭ 2,737 (+5982.22%)
Mutual labels:  lcd
Header-Only-GL-Helpers
A collection of header files that can ease OpenGL programming
Stars: ✭ 25 (-44.44%)
Mutual labels:  emscripten
webgl
http://gam0022.net/webgl/
Stars: ✭ 43 (-4.44%)
Mutual labels:  emscripten
magnum-extras
Extras for the Magnum C++11/C++14 graphics engine
Stars: ✭ 26 (-42.22%)
Mutual labels:  emscripten
bazel-emscripten
C++ to WASM or JS using Bazel and Emscripten
Stars: ✭ 40 (-11.11%)
Mutual labels:  emscripten
bergamot-translator
Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
Stars: ✭ 181 (+302.22%)
Mutual labels:  emscripten
helloworld-sdl2-opengl-emscripten
Basic program that uses SDL2+OpenGL, compiling both locally and via emscripten
Stars: ✭ 71 (+57.78%)
Mutual labels:  emscripten
wasm-raytracer
a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL
Stars: ✭ 158 (+251.11%)
Mutual labels:  emscripten
alia
a declarative UI library for C++
Stars: ✭ 76 (+68.89%)
Mutual labels:  emscripten
roswasm suite
Libraries for compiling C++ ROS nodes to Webassembly using Emscripten
Stars: ✭ 62 (+37.78%)
Mutual labels:  emscripten
node-seal
Homomorphic Encryption for TypeScript or JavaScript - Microsoft SEAL
Stars: ✭ 139 (+208.89%)
Mutual labels:  emscripten
OpenLCD
An open source serial LCD (HD44780) controller based on the ATmega328.
Stars: ✭ 28 (-37.78%)
Mutual labels:  lcd-display
wasm4
Build retro games using WebAssembly for a fantasy console.
Stars: ✭ 711 (+1480%)
Mutual labels:  emscripten

vrEmuLcd - HD44780 Character LCD Emulator

Core engine written in C with a flexible Web front-end.

This Character LCD Emulator can be used to emulate most standard LCD displays.

It accepts and responds to most commands listed in the HD44780 datasheet

It also now support most commands for a 128x64 graphics LCD 12864B datasheet

Screenshots:

Hello, World!

Hello, World!

Different Colors

Different Colors!

Different Sizes

Different Sizes!

128 x 64 Graphics LCD

HBC-56 Emulator LCD Window

Custom characters (CGRAM support)

Custom characters (CGRAM support)!

Live examples:

Usage

C

#define LCD_WIDTH 20
#define LCD_HEIGHT 4

VrEmuLcd      *lcd = vrEmuLcdNew(LCD_WIDTH, LCD_HEIGHT, EmuLcdRomA00);

// send it commands:
vrEmuLcdSendCommand(lcd, LCD_CMD_FUNCTION | LCD_CMD_FUNCTION_LCD_2LINE | 0x10);
vrEmuLcdSendCommand(lcd, LCD_CMD_CLEAR);
vrEmuLcdSendCommand(lcd, LCD_CMD_HOME);
vrEmuLcdSendCommand(lcd, LCD_CMD_DISPLAY | LCD_CMD_DISPLAY_ON);

// send it data
vrEmuLcdWriteByte(lcd, 'H');
vrEmuLcdWriteByte(lcd, 'e');
vrEmuLcdWriteByte(lcd, 'l');
vrEmuLcdWriteByte(lcd, 'l');
vrEmuLcdWriteByte(lcd, 'o');

// or cheat
vrEmuLcdWriteString(lcd, " world!");

// then periodically, render it. 
vrEmuLcdUpdatePixels(lcd);   // generates a snapshot of the pixels state

for (int y = 0; y < vrEmuLcdNumPixelsY(lcd); ++y) {
  for (int x = 0; x < vrEmuLcdNumPixelsX(lcd); ++x) {
    // do whatever you like with the pixel information. render it to a texture, output it to  a console, whatever
   // values returned are:  -1 = no pixel (character borders), 0 = pixel off, 1 = pixel on
    char pixel = vrEmuLcdPixelState(lcd, x, y);
  }
}

Web

HTML (local)

<script src="src/vrEmuLcd.js"></script>
<script src="bin/vrEmuLcdWasm.js"></script>

HTML (live)

<script src="https://visrealm.github.io/vrEmuLcd/src/vrEmuLcd.js"></script>
<script src="https://visrealm.github.io/vrEmuLcd/bin/vrEmuLcdWasm.js"></script>

Example

<canvas id="lcd"></canvas>
...
<script>
    var canv = document.getElementById('lcd');
    var ctx = canv.getContext('2d');

    vrEmuLcd.setLoadedCallback(function () {

      // create a new LCD object
      var lcd = vrEmuLcd.newLCD(16, 2, vrEmuLcd.CharacterRom.Eurpoean);

      // set up the display
      lcd.sendCommand(LCD_CMD_DISPLAY | LCD_CMD_DISPLAY_ON);

      lcd.writeString("Hello, World!");

      lcd.render(ctx, 0, 0, 800, 400);
    });
</script>

LCD API

constuctor

var lcd = vrEmuLcd.newLCD(columns, rows, charSet);
  • columns: - number of columns
  • rows: - number of rows
  • charSet: - character set. One of: vrEmuLcd.CharacterRom.European, vrEmuLcd.CharacterRom.Japanese

sendCommand(commandByte)

Send a command to the instruction register of the lcd Command constants are defined:

  • LCD_CMD_CLEAR - clear the display

  • LCD_CMD_HOME - reset display to home position

  • LCD_CMD_ENTRY_MODE - entry mode (the following to be bitwise-OR'd)

    • LCD_CMD_ENTRY_MODE_INCREMENT - automatically increment the cursor or display
    • LCD_CMD_ENTRY_MODE_DECREMENT - automatically decrement the cursor or display
    • LCD_CMD_ENTRY_MODE_SHIFT - automaticallt shift the entire display instead of the cursor
  • LCD_CMD_DISPLAY - display mode (the following to be bitwise-OR'd)

    • LCD_CMD_DISPLAY_ON - turn the display on
    • LCD_CMD_DISPLAY_CURSOR - display a cursor (bottom row)
    • LCD_CMD_DISPLAY_CURSOR_BLINK - display a blink cursor (flashing entire character block)
  • LCD_CMD_SHIFT - move the cursor or scroll display (the following to be bitwise-OR'd)

    • LCD_CMD_SHIFT_CURSOR - shift the cursor (default)
    • LCD_CMD_SHIFT_DISPLAY - shift the display
    • LCD_CMD_SHIFT_LEFT - shift the cursor or display left (default)
    • LCD_CMD_SHIFT_RIGHT - shift the cursor or display right
  • LCD_CMD_SET_CGRAM_ADDR - set the CGRAM address (actual address uses lower 6 bits)

  • LCD_CMD_SET_DRAM_ADDR - set the CGRAM address (actual address uses lower 7 bits)

writeByte(dataByte)

Write a byte to the data register of the lcd

writeString(str)

Write a string to the data register of the lcd

getDataOffset(screenX, screenY)

Return the ddram offset for the given screen location

readByte()

Read the current byte from cgram or ddram (determined by current address)

readAddress()

Read the current address offset in cgram or ddram

pixelState(pixelX, pixelY)

Return the pixel state at the given location

  • -1 - no pixel (eg. margin)
  • 0 - pixel off
  • 1 - pixel on

colorScheme

Set/get the color scheme. eg:

lcd.colorScheme = vrEmuLcd.Schemes.WhiteOnBlue;

Standard color schemes:

  • vrEmuLcd.Schemes.WhiteOnBlue (default)
  • vrEmuLcd.Schemes.BlackOnBlue
  • vrEmuLcd.Schemes.BlackOnGreen
  • vrEmuLcd.Schemes.RedOnBlack
  • vrEmuLcd.Schemes.BlueOnBlack

or, provide your own. { BackColor: <backcolor>, PixelOnColor: <pixeloncolor>, PixelOffColor: <pixeloffcolor> }

render(ctx, x, y, width, height)

Render to a 2d canvas context

  • ctx - the canvas to render to

License

This code is licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].