# OLEDVirtual

OLEDVirtual is a virtual version of the [oled]( library.

Its main purpose it to reduce the roundtrip time during development 
by fully virtualizing the oled display.

It also comes with a `MultiDisplay` module to use both hardware and virtual display at the same time.

![Demo: Showing the virtual LiveView powered version on the web interface and the real screen on the device](guides/images/demo.png)

## Installation

The package can be installed
by adding `oled_virtual` to your list of dependencies in `mix.exs`:

def deps do
    {:oled_virtual, "~> 1.0"}

## Quickstart

1. Define the display module

defmodule MyApp.OledVirtual do
  use OLEDVirtual.Display, app: :my_app

  def on_display(data, dimensions) do
    # React to new frames
    payload = %{
      data: data,
      dimensions: dimensions
    Phoenix.PubSub.broadcast(MyApp.PubSub, "oled-virtual", %{event: "on_display", payload: payload})

2. Define the dimensions of the display

config :my_app, MyApp.OledVirtual,
   width: 128,
   height: 64

3. Add the virtual display to your supervision tree.

defmodule MyApp.Application do
  use Application

  @impl true
  def start(_type, _args) do
    children = [
      # Add this line

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)

4. Use it

# Draw something
MyApp.OledVirtual.rect(0, 0, 127, 63)
MyApp.OledVirtual.line(0, 0, 127, 63)
MyApp.OledVirtual.line(0, 63, 127, 0)

# Display it!


The whole documentation can be found at [](