2007-02-17 00:35:01 +00:00
|
|
|
#ifndef _DISPLAY_H
|
|
|
|
#define _DISPLAY_H
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
class Display : public IO_Module
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Display()
|
|
|
|
{
|
|
|
|
this->parent = NULL;
|
|
|
|
this->moduleId = 0;
|
2007-02-17 13:42:00 +00:00
|
|
|
this->cursorVisible = false;
|
|
|
|
this->illuminationEnabled = true;
|
|
|
|
this->commandClear = 0;
|
|
|
|
this->commandReturnCursor = 0;
|
|
|
|
this->commandNewLine = 0;
|
|
|
|
this->commandSetting = 0;
|
|
|
|
this->settingCursorVisible = 0;
|
|
|
|
this->settingIllumination = 0;
|
|
|
|
this->settingCursorPosition = 0;
|
2007-02-17 00:35:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Display(uint32 displayId)
|
|
|
|
{
|
|
|
|
this->parent = NULL;
|
|
|
|
this->moduleId = displayId;
|
2007-02-17 13:42:00 +00:00
|
|
|
this->cursorVisible = false;
|
|
|
|
this->illuminationEnabled = true;
|
2007-02-17 00:35:01 +00:00
|
|
|
|
|
|
|
switch(displayId)
|
|
|
|
{
|
|
|
|
case IO_DISPLAY_MAIN:
|
2007-02-17 13:42:00 +00:00
|
|
|
this->commandClear = 12;
|
|
|
|
this->commandReturnCursor = 13;
|
|
|
|
this->commandNewLine = 10;
|
|
|
|
this->commandSetting = 27;
|
|
|
|
this->settingCursorVisible = 67;
|
|
|
|
this->settingIllumination = 76;
|
|
|
|
this->settingCursorPosition = 79;
|
2007-02-17 00:35:01 +00:00
|
|
|
msleep(500);
|
|
|
|
uart1_init(103);//9600 BAUD at 16MHz Atmel
|
|
|
|
sleep(2);
|
|
|
|
break;
|
|
|
|
default:
|
2007-02-17 13:42:00 +00:00
|
|
|
this->commandClear = 0;
|
|
|
|
this->commandReturnCursor = 0;
|
|
|
|
this->commandNewLine = 0;
|
|
|
|
this->commandSetting = 0;
|
|
|
|
this->settingCursorVisible = 0;
|
|
|
|
this->settingIllumination = 0;
|
|
|
|
this->settingCursorPosition = 0;
|
2007-02-17 00:35:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2007-02-17 13:42:00 +00:00
|
|
|
bool cursorVisible;
|
|
|
|
bool illuminationEnabled;
|
|
|
|
//Commands
|
|
|
|
uint8 commandClear;
|
|
|
|
uint8 commandReturnCursor;
|
|
|
|
uint8 commandNewLine;
|
|
|
|
uint8 commandSetting;
|
|
|
|
//Settings
|
|
|
|
uint8 settingCursorVisible;
|
|
|
|
uint8 settingIllumination;
|
|
|
|
uint8 settingCursorPosition;
|
|
|
|
|
|
|
|
void SendCommand(uint8 newCommand)
|
|
|
|
{
|
|
|
|
switch(moduleId)
|
|
|
|
{
|
|
|
|
case IO_DISPLAY_MAIN:
|
|
|
|
uart1_putc(newCommand);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-02-17 00:35:01 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void Print(char* newString)
|
|
|
|
{
|
|
|
|
switch(moduleId)
|
|
|
|
{
|
|
|
|
case IO_DISPLAY_MAIN:
|
|
|
|
uart1_puts(newString);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Print(int32 newInteger)
|
|
|
|
{
|
|
|
|
char buffer[12];
|
|
|
|
ltoa(newInteger, buffer, 10);
|
|
|
|
Print(buffer);
|
|
|
|
}
|
2007-02-17 13:42:00 +00:00
|
|
|
|
|
|
|
void Print(char* newString, uint8 xPos, uint8 yPos)
|
|
|
|
{
|
|
|
|
SetCursorPosition(xPos, yPos);
|
|
|
|
Print(newString);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Print(int32 newInteger, uint8 xPos, uint8 yPos)
|
|
|
|
{
|
|
|
|
SetCursorPosition(xPos, yPos);
|
|
|
|
Print(newInteger);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
SendCommand(commandClear);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReturnCursor()
|
|
|
|
{
|
|
|
|
SendCommand(commandReturnCursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewLine()
|
|
|
|
{
|
|
|
|
SendCommand(commandNewLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetCursorVisible()
|
|
|
|
{
|
|
|
|
return cursorVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCursorVisible(bool newStatus)
|
|
|
|
{
|
|
|
|
cursorVisible = newStatus;
|
|
|
|
|
|
|
|
SendCommand(commandSetting);
|
|
|
|
SendCommand(settingCursorVisible);
|
|
|
|
|
|
|
|
if(cursorVisible)
|
|
|
|
{
|
|
|
|
SendCommand(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendCommand(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetLightingEnabled()
|
|
|
|
{
|
|
|
|
return illuminationEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLightingEnabled(bool newStatus)
|
|
|
|
{
|
|
|
|
illuminationEnabled = newStatus;
|
|
|
|
|
|
|
|
SendCommand(commandSetting);
|
|
|
|
SendCommand(settingIllumination);
|
|
|
|
|
|
|
|
if(illuminationEnabled)
|
|
|
|
{
|
|
|
|
SendCommand(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendCommand(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCursorPosition(uint8 newX, uint8 newY)
|
|
|
|
{
|
|
|
|
if(!newX || newX > 20) return;
|
|
|
|
if(!newY || newY > 4) return;
|
|
|
|
|
|
|
|
SendCommand(commandSetting);
|
|
|
|
SendCommand(settingCursorPosition);
|
|
|
|
SendCommand(newX);
|
|
|
|
SendCommand(newY);
|
|
|
|
}
|
2007-02-17 00:35:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|