I saw someone had written an sdk using c#, but I don't use that, so I figured why not write my own...
It's basically just a class that you can instantiate and then use things like myDisplay.PrintText("I like hotdogs"); and myDisplay.SetCursorPos(4, 3);
This is my first version, so I haven't yet put in the stuff for using keypad input, but most of the main commands can be sent very easily.
http:\\www.kmcgrail.com\OrbitalDisplay.zip
So to use it, basically just put include the header. And then create an instance of OrbitalDisplay and use it's included functions.
This little sample just draws 4 Horizontal graphs accross the screen a few times. There is a blocking pause function added so animation can be done.
Code: Select all
#include <OrbitalDisplay.h>
int main(void)
{
OrbitalDisplay myDisplay;
myDisplay.InitDisplay("COM3");
//myDisplay.ToggleLineScroll(FALSE);
//myDisplay.ToggleCursorBlinking(FALSE);
//myDisplay.ToggleCursorUnderline(FALSE);
myDisplay.InitHorizontalBarGraph();
for(int i = 0; i < 400; i++)
{
myDisplay.DrawHorizontalBarGraph(1, 1, HORIZ_LEFT_TO_RIGHT, i%100);
myDisplay.DrawHorizontalBarGraph(2, 20, HORIZ_RIGHT_TO_LEFT, i%100);
myDisplay.DrawHorizontalBarGraph(3, 1, HORIZ_LEFT_TO_RIGHT, i%100);
myDisplay.DrawHorizontalBarGraph(4, 20, HORIZ_RIGHT_TO_LEFT, i%100);
myDisplay.Pause(0.05f);
}
return 0;
}
Code: Select all
//===================================================================
// Function: InitDisplay()
// Purpose: Creates the handle to the display COM port
// initialized default display values.
// Parameters: char* _szComPort -> COM port display is connected to.
// Return: BOOL -> Did we get a handle to the port
//===================================================================
BOOL InitDisplay(char* _szComPort, DWORD _dwRows = 4, DWORD _dwColumns = 20);
//===================================================================
// Function: SendCommand()
// Purpose: Sends a command to the COM port using WriteFile
// Parameters: DWORD _dwCommand -> The command to send
// DWORD _dwParam1 -> First parameter to command
// DWORD _dwParam2 -> Second parameter to command
// Return: None
//===================================================================
void SendCommand(DWORD _dwCommand, DWORD _dwParam1 = -1, DWORD _dwParam2 = -1, DWORD _dwParam3 = -1, DWORD _dwParam4 = -1);
//===================================================================
// Function: PrintText()
// Purpose: Prints the string passed in to the current cursor
// position on the oribital display.
// Parameters: char* _szString -> The string to print
// Return: None
//===================================================================
void PrintText(char* szString);
//===================================================================
// Function: SetCursorPos()
// Purpose: Sets the current cursor position on the display
// (Row, Column)
// Parameters: DWORD _dwRow -> Row to move to
// DWORD _dwColumn -> Column to move to
// Return: None
//===================================================================
void SetCursorPos(DWORD _dwRow = 0, DWORD _dwColumn = 0);
//===================================================================
// Function: SetCursorPosCR()
// Purpose: Sets the current cursor position on the display
// (Column, Row) for those people who are backwards
// Parameters: DWORD _dwColumn -> Column to move to
// DWORD _dwRow -> Row to move to
// Return: None
//===================================================================
void SetCursorPosCR(DWORD _dwColumn = 0, DWORD _dwRow = 0);
//===================================================================
// Function: ToggleCursorUnderline()
// Purpose: Toggles if the underline cursor is turned on or off
// Parameters: BOOL _OnOff -> TRUE(on) FALSE(off)
// Return: None
//===================================================================
void ToggleCursorUnderline(BOOL _OnOff = TRUE);
//===================================================================
// Function: ToggleCursorlinking()
// Purpose: Toggles if the blinking block cursor is turned
// on or off
// Parameters: BOOL _OnOff -> TRUE(on) FALSE(off)
// Return: None
//===================================================================
void ToggleCursorBlinking(BOOL _OnOff = TRUE);
//===================================================================
// Function: CursorMoveLeft()
// Purpose: Moves the current cursor position to the left
// by _dwHowManySpaces
// Parameters: DWORD _dwHowManySpaces -> How many spaces to move
// Return: None
//===================================================================
void CursorMoveLeft(DWORD _dwHowManySpaces);
//===================================================================
// Function: CursorMoveRight()
// Purpose: Moves the current cursor position to the right
// by _dwHowManySpaces
// Parameters: DWORD _dwHowManySpaces -> How many spaces to move
// Return: None
//===================================================================
void CursorMoveRight(DWORD _dwHowManySpaces);
//===================================================================
// Function: ToggleBacklight()
// Purpose: Toggles the units backlight.
// Parameters: BOOL _OnOff -> TRUE(on), FALSE(off)
// Return: None
//===================================================================
void ToggleBacklight(BOOL _OnOff = TRUE);
//===================================================================
// Function: ToggleLinewrap()
// Purpose: Toggles line wrapping at the end of each line. Not
// word wrap.
// Parameters: BOOL _OnOff -> TRUE(on), FALSE(off)
// Return: None
//===================================================================
void ToggleLineWrap(BOOL _OnOff = TRUE);
//===================================================================
// Function: ToggleLineScroll()
// Purpose: Toggles line scrolling when the end bottom of the
// display is hit.
// Parameters: BOOL _OnOff -> TRUE(on), FALSE(off)
// Return: None
//===================================================================
void OrbitalDisplay::ToggleLineScroll(BOOL _OnOff);
//===================================================================
// Function: SendCursorHome()
// Purpose: Sets the cursor to the top left corner of the display
// Parameters: None
// Return: None
//===================================================================
void SendCursorHome();
//===================================================================
// Function: SetContrast()
// Purpose: Sets the contrast of the display
// Parameters: DWORD _dwContrast -> Contrast amount (0->255)
// BOOL _bSave -> TRUE(Save), FALSE(Do not save)
// Return: None
//===================================================================
void SetContrast(DWORD _dwContrast, BOOL _bSave = TRUE);
//===================================================================
// Function: SetBacklightBrightness()
// Purpose: Sets the Backlight Brightness of the display
// Parameters: DWORD _dwBrightness -> Brightness amount (0->255)
// BOOL _bSave -> TRUE(Save), FALSE(Do not save)
// Return: None
//===================================================================
void SetBacklightBrightness(DWORD _dwBrightness, BOOL _bSave = TRUE);
//===================================================================
// Function: ClearDisplay()
// Purpose: Clears the entire display
// Parameters: None
// Return: None
//===================================================================
void ClearDisplay();
//===================================================================
// Function: Pause()
// Purpose: Pauses everything, useful for animations, (BLOCKING)
// Parameters: DWORD _dwSeconds -> Number of seconds to pause
// Return: None
//===================================================================
void Pause(float _fSeconds);
//===================================================================
// Function: InitHorizontalBarGraph()
// Purpose: Initializes horizontal graph
// Parameters: None
// Return: None
//===================================================================
void InitHorizontalBarGraph();
//===================================================================
// Function: DrawHorizontalBarGraph()
// Purpose: Draws a horizontal graph
// Parameters: DWORD _dwRow -> Row to draw in
// DWORD _dwColumn -> Column to start drawing in.
// DWORD _dwDirection -> HORIZ_LEFT_TO_RIGHT or
// HORIZ_RIGHT_TO_LEFT
// DWORD _dwLength -> Length in pixels of the bar
// Return: None
//===================================================================
void DrawHorizontalBarGraph(DWORD _dwRow, DWORD _dwColumn, DWORD _dwDirection, DWORD _dwLength);
//===================================================================
// Function: InitVerticalBarGraphNarrow()
// Purpose: Initialized narrow Vertical bar graph
// Parameters: None
// Return: None
//===================================================================
void InitVerticalBarGraphNarrow();
//===================================================================
// Function: Pause()
// Purpose: Initialized wide Vertical bar graph
// Parameters: None
// Return: None
//===================================================================
void InitVerticalBarGraphWide();
//===================================================================
// Function: DrawVerticalBarGraph()
// Purpose: Draws a vertical graph
// Parameters: DWORD _dwColumn -> Column to drawing in.
// DWORD _dwHeight -> Height in pixels of the bar
// Return: None
//===================================================================
void OrbitalDisplay::DrawVerticalBarGraph(DWORD _dwColumn, DWORD _dwHeight);