Serial Wombat Arduino Library
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:
SerialWombatPin

Public Member Functions

 SerialWombat18ABVGA (SerialWombatChip &serialWombat)
 Constructor for the SerialWombat18ABVGA class. More...
 
int16_t begin (uint8_t vsyncPin, uint16_t bufferIndex=0)
 Initalize the SerialWombat18ABVGA. More...
 
int16_t writePixel (uint8_t x, uint8_t y, uint8_t color)
 Write a pixel to the buffer. More...
 
int16_t fillScreen (uint8_t color)
 fill the entire screen More...
 
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. More...
 
int16_t setLineColor (uint8_t color, uint8_t y)
 Set the color of a horizontal line. More...
 
int16_t setLineColor (uint8_t color, uint8_t start, uint8_t end)
 Set the color of a horizontal line. More...
 
- Public Member Functions inherited from SerialWombatPin
 SerialWombatPin (SerialWombatChip &serialWombatChip)
 Instantiates a Serial Wombat Pin. More...
 
 SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
 Instantiates a Serial Wombat Pin. More...
 
uint16_t readPublicData ()
 Read the 16 Bit public data associated with this pin. More...
 
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. More...
 
void digitalWrite (uint8_t val)
 Set output pin High or Low. More...
 
int digitalRead ()
 Reads the state of the Pin. More...
 
uint16_t writePublicData (uint16_t value)
 Write a 16 bit value to this pin. More...
 
uint8_t pin ()
 Returns the current SW pin number. Used primarily for virtual calls by derived classes. More...
 
uint8_t swPinModeNumber ()
 Returns the Mode number. Used primarily by derived classes to populate packet data. More...
 

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:

TODO - Video coming soon //TODO - Video coming soon

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.

Constructor & Destructor Documentation

◆ SerialWombat18ABVGA()

SerialWombat18ABVGA::SerialWombat18ABVGA ( SerialWombatChip serialWombat)
inline

Constructor for the SerialWombat18ABVGA class.

Parameters
serialWombatThe Serial Wombat Chip on which the SerialWombat18ABVGA instance will run.

Member Function Documentation

◆ begin()

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

Initalize the SerialWombat18ABVGA.

Parameters
vsyncPinPin 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

◆ 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
xThe x coordinate. 0 - 159
yThe y coordinate 0-119
wWidth
hHeight
color0 - off (black) 1- on (assigned line color)
Returns
0 or higher for success, negative number for error

◆ fillScreen()

int16_t SerialWombat18ABVGA::fillScreen ( uint8_t  color)
inline

fill the entire screen

Parameters
color0 - off (black) 1- on (assigned line color)
Returns
0 or higher for success, negative number for error

◆ 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
startfirst y Line to set
endlast y Line to set
Returns
0 or higher for success, negative number for error

◆ 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
yLine to set
Returns
0 or higher for success, negative number for error

◆ writePixel()

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

Write a pixel to the buffer.

Parameters
xThe x coordinate. 0 - 159
yThe y coordinate 0-119
color0 - off (black) 1- on (assigned line color)
Returns
0 or higher for success, negative number for error