Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Member Functions | List of all members
SerialWombat18ABVGA Class Reference

A class for the Serial Wombat SW18AB chip VGA Driver. More...

`#include <SerialWombat18ABVGA.h>`

Inheritance diagram for SerialWombat18ABVGA:
[legend]
Collaboration diagram for SerialWombat18ABVGA:
[legend]

## Public Member Functions
| SerialWombat18ABVGA (SerialWombatChip &serialWombat)
| Constructor for the SerialWombat18ABVGA class.
int16_t | begin (uint8_t vsyncPin, uint16_t bufferIndex=0)
| Initalize the SerialWombat18ABVGA.
int16_t | writePixel (uint8_t x, uint8_t y, uint8_t color)
| Write a pixel to the buffer.
int16_t | fillScreen (uint8_t color)
| fill the entire screen
int16_t | fillRect (uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color)
| Draw a filled rectangle on the screen.
int16_t | setLineColor (uint8_t color, uint8_t y)
| Set the color of a horizontal line.
int16_t | setLineColor (uint8_t color, uint8_t start, uint8_t end)
| Set the color of a horizontal line.
Public Member Functions inherited from SerialWombatPin
| SerialWombatPin (SerialWombatChip &serialWombatChip)
| Instantiates a Serial Wombat Pin.
| SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
| Instantiates a Serial Wombat Pin.
uint16_t | readPublicData ()
| Read the 16 Bit public data associated with this pin.
void | pinMode (uint8_t mode, bool pullDown=false, bool openDrain=false)
| Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
void | digitalWrite (uint8_t val)
| Set output pin High or Low.
int | digitalRead ()
| Reads the state of the Pin.
uint16_t | writePublicData (uint16_t value)
| Write a 16 bit value to this pin.
uint8_t | pin ()
| Returns the current SW pin number. Used primarily for virtual calls by derived classes.
uint8_t | swPinModeNumber ()
| Returns the Mode number. Used primarily by derived classes to populate packet data.
int16_t | initPacketNoResponse (uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0, uint16_t param1, uint8_t param2=0x55)
int16_t | disable ()
| Disables the pin mode (if applicable)
int16_t | enablePullup (bool enabled)
| Enables the weak pull up on a pin. Implemented on SW18AB and SW8B only.
int16_t | enablePulldown (bool enabled)
| Enables the weak pull down on a pin. Implemented on SW18AB and SW8B only.
int16_t | enableOpenDrain (bool enabled)
| Enables open drain mode on a pin. Implemented on SW18AB and SW8B only.
int16_t | forceDMA (bool enabled)
| Forces use of DMA instead of hardware timing resources on SW18AB.

## Additional Inherited Members
Protected Attributes inherited from SerialWombatPin
uint8_t | _pin = 255
SerialWombatChip & | _sw
uint8_t | _pinMode = 0

## Detailed Description

A class for the Serial Wombat SW18AB chip VGA Driver.

A Tutorial video is avaialble: https://youtu.be/DcOSat8VybA

This file/pin mode is designed to drive a VGA monitor RGB and H and V Sync lines. The output is essentially 1 bit, with the ability to change the color between 8 colors (including black) by horizonal line.

This pin mode is unusual among SW18AB pin modes because it requires specific pins to be used for certain things. Pins must be:

VGA VSYNC (VGA Pin 14) -> 100 ohm Resistor -> SW Pin 18 VGA HSYNC (VGA Pin 13) -> 100 ohm Resistor ->SW Pin 17 VGA Red (VGA Pin 1) -> 280 ohm Resistor -> SW Pin 16 VGA Blue (VGA Pin 2) -> 280 ohm Resistor -> SW Pin 15 VGA Green (VGA Pin 3) -> 280 ohm Resistor -> SW Pin 14

Thank you to Nick Gammon who published a very informative article on driving a VGA monitor here: http://www.gammon.com.au/forum/?id=11608

\warn This pin mode stretches the limits of what the SW18AB chip can do while still being able to do other things - some flicker / jitter is to be expected

The rate at which the display can be updated is slower than with a hardware connected LCD or OLED. The Serial Wombat protocol's 8 byte in / 8 byte out packet structure is not ideal for moving large blocks of data such as screen pixel data. This mode is better suited to data displays than real-time games, for example.

The pin mode is capable of limited color generation with the restriction that an entire horizontal line must be the same color. Colors are achieved by turning Red, Green, and Blue lines totally on or off in combinations.

This pin mode implements a 160x120 pixel output to a monitor in 640x480 mode with black bars around part of the screen. This was the best I could do using the chip's SPI in DMA mode.

The SerialWombat18ABVGADriver class (A separate Arduino Library) is designed to act as a wrapper between this pin mode and the AdafruitGFX library. See the Arduino examples for this pin mode for an example.

This pin mode uses a significant amount of SW18AB time that is not measured using typical methods due to the high number of interrupts it produces. These interrupts happen both during and outside of the main loop executive processing, so actual system utilization is higher than normal metrics indicate.

Definition at line 80 of file SerialWombat18ABVGA.h.

## Constructor & Destructor Documentation

## ◆ SerialWombat18ABVGA()

SerialWombat18ABVGA::SerialWombat18ABVGA | ( | SerialWombatChip & | serialWombat | ) |
| inline

Constructor for the SerialWombat18ABVGA class.

Parameters

  serialWombat | The Serial Wombat Chip on which the SerialWombat18ABVGA instance will run.

Definition at line 87 of file SerialWombat18ABVGA.h.

## Member Function Documentation

## ◆ begin()

int16_t SerialWombat18ABVGA::begin | ( | uint8_t | vsyncPin,
|  | uint16_t | bufferIndex = 0 )
| inline

Initalize the SerialWombat18ABVGA.

Parameters

  vsyncPin | Pin attached to the VGA VSync pin (Must be 18)
  bufferIndex | - Index into the buffer where the 2520 byte frame buffer will be stored

Returns
  0 or higher for success, negative number for error

Definition at line 96 of file SerialWombat18ABVGA.h.

## ◆ fillRect()

int16_t SerialWombat18ABVGA::fillRect | ( | uint8_t | x,
|  | uint8_t | y,
|  | uint8_t | w,
|  | uint8_t | h,
|  | uint8_t | color )
| inline

Draw a filled rectangle on the screen.

Parameters

  x | The x coordinate. 0 - 159
  y | The y coordinate 0-119
  w | Width
  h | Height
  color | 0 - off (black) 1- on (assigned line color)

Returns
  0 or higher for success, negative number for error

Definition at line 165 of file SerialWombat18ABVGA.h.

## ◆ fillScreen()

int16_t SerialWombat18ABVGA::fillScreen | ( | uint8_t | color | ) |
| inline

fill the entire screen

Parameters

  color | 0 - off (black) 1- on (assigned line color)

Returns
  0 or higher for success, negative number for error

Definition at line 140 of file SerialWombat18ABVGA.h.

## ◆ setLineColor() [1/2]

int16_t SerialWombat18ABVGA::setLineColor | ( | uint8_t | color,
|  | uint8_t | start,
|  | uint8_t | end )
| inline

Set the color of a horizontal line.

Parameters

  color | : 1 = Blue, 2 = Green 3= Cyan, 4 = Red, 5 = Magenta, 6 = Yellow, 7 = White
  start | first y Line to set
  end | last y Line to set

Returns
  0 or higher for success, negative number for error

Definition at line 213 of file SerialWombat18ABVGA.h.

## ◆ setLineColor() [2/2]

int16_t SerialWombat18ABVGA::setLineColor | ( | uint8_t | color,
|  | uint8_t | y )
| inline

Set the color of a horizontal line.

Parameters

  color | : 1 = Blue, 2 = Green 3= Cyan, 4 = Red, 5 = Magenta, 6 = Yellow, 7 = White
  y | Line to set

Returns
  0 or higher for success, negative number for error

Definition at line 191 of file SerialWombat18ABVGA.h.

## ◆ writePixel()

int16_t SerialWombat18ABVGA::writePixel | ( | uint8_t | x,
|  | uint8_t | y,
|  | uint8_t | color )
| inline

Write a pixel to the buffer.

Parameters

  x | The x coordinate. 0 - 159
  y | The y coordinate 0-119
  color | 0 - off (black) 1- on (assigned line color)

Returns
  0 or higher for success, negative number for error

Definition at line 120 of file SerialWombat18ABVGA.h.