vgatext library  v0.90
Provides functions to simplify Propeller text display on a VGA monitor
Functions | Variables
vgatext.c File Reference
#include <stdlib.h>
#include <string.h>
#include <propeller.h>
#include "simpletext.h"
#include "vgatext.h"

Functions

vgatext * vgatext_open (int basepin)
 Open a VGA connection. This function launches VGA driver code into the next available cog.
void vgatext_close (vgatext *device)
 Close VGA connection, stop and recover cog running VGA code and memory that was allocated.
int vgatext_start (volatile vgatextdev_t *vga, int basepin)
void vgatext_stop (int id)
void vgatext_setColorPalette (char *ptr)
 sets the palette using a character array. This overrides the default color palette.
int vgatext_out (int c)
 Prints a character at current cursor position or performs a screen function based on the following table:
int vgatext_putchar (vgatext *vga, int c)
 Print character to screen.
void vgatext_clear (void)
 Clear the VGA display.
void vgatext_home (void)
 Send cursor to top-left home position.
void vgatext_clearEOL (void)
 Clear to end of line, then place cursor after the last character printed on the line.
void vgatext_setCoordPosition (int x, int y)
 Set cursor position to Cartesian x, y from bottom-left.
void vgatext_setXY (int x, int y)
 Set position to x rows and y columns from top-left.
void vgatext_setX (int x)
 Set cursor to x columns from left.
void vgatext_setY (int y)
 Set cursor to y rows from top.
int vgatext_getX (void)
 get cursor's column position.
int vgatext_getY (void)
 Get cursor's row position.
void vgatext_setColors (int value)
 Set palette color index.
int vgatext_getColors (void)
 Get palette color index.
int vgatext_getColumns (void)
 Get screen width.
int vgatext_getRows (void)
 Get screen height.

Variables

HUBDATA volatile vgatextdev_t gVgaText
HUBDATA short gVgaScreen [VGA_TEXT_SCREENSIZE]
char greypalette [VGA_TEXT_COLORTABLE_SIZE]

Detailed Description

This is the main libkbvga program file.

VGA_Text native device driver interface.

Copyright (c) 2013, Parallax Inc Written by Steve Denson See end of file for terms of use.

Function Documentation

void vgatext_close ( vgatext *  device)

Close VGA connection, stop and recover cog running VGA code and memory that was allocated.

Parameters
*devicevalue that was returned by vgatext_open.
int vgatext_getColors ( void  )

Get palette color index.

Returns
number representing color set index See vgatext color indices.
int vgatext_getColumns ( void  )

Get screen width.

Returns
Screen column count.
int vgatext_getRows ( void  )

Get screen height.

Returns
Screen row count.
int vgatext_getX ( void  )

get cursor's column position.

Returns
columns from left.
int vgatext_getY ( void  )

Get cursor's row position.

Returns
rows from top.
vgatext* vgatext_open ( int  basepin)

Open a VGA connection. This function launches VGA driver code into the next available cog.

Parameters
basepincan be 0, 8, 16, or 24, which correspond to base pins of P0, P8, or P16 or P24. The basepin should be connected to VGA V, basepin + 1 to VGA H, and so on... Here is the full connection list.

basepin Connected to

  • 7 R1
  • 6 R0
  • 5 G1
  • 4 G0
  • 3 B1
  • 2 B0
  • 1 H
  • 0 V
Returns
vgatext identifier. It's the address that gets copied to a pointer variable, which is passed as an identifier to simpletext functions with text_t *dev parameters and/or vgatext functions with vgatext *vga parameters.
int vgatext_out ( int  c)

Prints a character at current cursor position or performs a screen function based on the following table:

0 = clear screen
1 = home
8 = backspace
9 = tab (8 spaces per)
10 = set X position (X follows)
11 = set Y position (Y follows)
12 = set color (color follows)
13 = return
16 = clear screen
others = printable characters

Parameters
cchar to print.
int vgatext_putchar ( vgatext *  vga,
int  c 
)

Print character to screen.

Parameters
*vgathe device identifier
cis character to print
void vgatext_setColorPalette ( char *  palette)

sets the palette using a character array. This overrides the default color palette.

Each custom color palette is defined in a byte with values of r, g, and b that can range from 0 to 3, and are packed as follows:

Example: Set color palette 0 foreground to r = 1, g = 2, b = 3 and background to r = 3, b = 0, and g = 1. Also set color palette 1's foreground with color palette 0's background and vice-versa.

char custom[16];

custom[0] = (1 << 4) | (2 << 2) | 3; // Foreground 0
custom[1] = (3 << 4) | (0 << 2) | 1; // Background 0
custom[2] = (3 << 4) | (0 << 2) | 1; // Foreground 1
custom[3] = (1 << 4) | (2 << 2) | 3; // Background 1
// ...etc up to custom[15] for background 7

Parameters
paletteis a char array[16].
void vgatext_setColors ( int  value)

Set palette color index.

Parameters
valueis a color set index number 0 .. 7 See vgatext color indices.
void vgatext_setCoordPosition ( int  x,
int  y 
)

Set cursor position to Cartesian x, y from bottom-left.

Parameters
xis column counted from left.
yis row counted from bottom.
void vgatext_setX ( int  x)

Set cursor to x columns from left.

Parameters
xcolumns from left
void vgatext_setXY ( int  x,
int  y 
)

Set position to x rows and y columns from top-left.

Parameters
xcolumns from left.
yrows from top.
void vgatext_setY ( int  y)

Set cursor to y rows from top.

Parameters
yrows from top

Variable Documentation

char greypalette[VGA_TEXT_COLORTABLE_SIZE]
Initial value:
{
0b111111, 0b000001,
0b000001, 0b111111,
0b111111, 0b000000,
0b000000, 0b111111,
0b010101, 0b000000,
0b000000, 0b010101,
0b111111, 0b010101,
0b010101, 0b111111
}