Git Product home page Git Product logo

ssd1322's Introduction

SSD1322

Build Status Hex.pm

This package provides an interface for controlling OLED displays using the common SSD1322 chipset, as available here (or many other vendors). In addition to supporting a number of bitmap formats for display, you can also control various aspects of the display such as contrast values, enabling / disabling the display and other tasks.

Hardware

This library requires a 4 wire SPI connection to the display board, in addition to two GPIO lines. All connections are made using the Elixir Circuits library.

If using this library via Nerves and wiring your hardware up in the manner described in the 'Putting it together' section of this article, the default values will be sufficient. In other situations, you may need to explicitly set hardware parameters as detailed in the next section.

Usage

Common usage looks like so:

# Initialize your connection
{:ok, pid} = SSD1322.start_link()

# You can also override a bunch of options if needed:
{:ok, pid} = SSD1322.start_link(spi_connection_opts: [spi_dev: "spidev0.0", dc_pin: 24, reset_pin: 25], width: 256, height: 64, name: "my_display")

# Display the image defined by data. data is a binary containing row-wise 
# 4-bit greyscale pixel data in linear order. It follows that there data is
# W x H / 2 bytes long. Check out github.com/mtrudel/ex_paint for a library that
# can produce this format with little effort
SSD1322.draw(pid, data)

# You can also turn the display on and off
SSD1322.display_on(pid)
SSD1322.display_off(pid)

# Set the contrast to a value between 0 and 255
SSD1322.contrast(pid, contrast)

# Clear the display to a given grey (black by default)
SSD1322.clear(pid, grey \\ 0x00)

# Or reset the connection if something goes wrong
SSD1322.reset(pid)

Note that although this library serializes access for callers sharing a single connection instance, neither this library nor the underlying Elixir Circuits library provide any protection against multiple concurrent access to an attached display by across multiple connection instances.

Installation

This package can be installed by adding ssd1322 to your list of dependencies in mix.exs:

def deps do
  [
    {:ssd1322, "~> 0.1.0"}
  ]
end

Docs can be found at https://hexdocs.pm/ssd1322.

ssd1322's People

Contributors

mtrudel avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

shunte88

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.