From 56d9bdd39ed36c36e9a61411b86c76d5228b2133 Mon Sep 17 00:00:00 2001 From: sicarius Date: Sun, 11 Feb 2007 18:32:03 +0000 Subject: Added lot's of code-files used during work --- source/qFix/qfixLCD.h | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 source/qFix/qfixLCD.h (limited to 'source/qFix/qfixLCD.h') diff --git a/source/qFix/qfixLCD.h b/source/qFix/qfixLCD.h new file mode 100644 index 0000000..9ecd93f --- /dev/null +++ b/source/qFix/qfixLCD.h @@ -0,0 +1,216 @@ +//------------------------------------------------------------------ +// qfixLCD.h +// +// This file contains the class LCD which represents the +// LCD display. +// +// Copyright 2004 by KTB mechatronics GmbH +// Author: Stefan Enderle +//------------------------------------------------------------------ + +#ifndef qfixLCD_h +#define qfixLCD_h + + +#include "qfixI2C.h" +#include "qfixI2CDefs.h" +#include "string.h" + + +static const uint8_t LCD_CMD_CHANGEID = 0; +static const uint8_t LCD_CMD_CLEAR = 1; +static const uint8_t LCD_CMD_PRINTSTR = 2; +static const uint8_t LCD_CMD_PRINTSTRXY = 3; +static const uint8_t LCD_CMD_LIGHTON = 4; +static const uint8_t LCD_CMD_LIGHTOFF = 5; +static const uint8_t LCD_CMD_PRINTINT = 6; +static const uint8_t LCD_CMD_PRINTINTXY = 7; + + + +/** +* \class LCD +* \brief Represents the qfix LC-display. +* \author Stefan Enderle +* +* The class LCD represents the +* physical LC-display and can be used to output text. +* The I2C bus is completely abstracted. +*/ +class LCD +{ +private: + I2C i2c; + uint8_t id; + +public: + /** Default constructor. If only one LC-display is used, + * this constructor can be used. It sets the internal ID to 0. + */ + LCD(); + + /** Constructor with given ID. + * If two or more LC-displays are used, + * this constructor must be used. It sets the internal ID to the given value. + */ + LCD(uint8_t ID); + + /** Change logical device ID + */ + void changeID(uint8_t newID); + + /** Clears the display + */ + void clear(); + + /** prints the string data at the current cursor position. + * The string must end with 0. + */ + void print(char* data); + + /** Prints the string data at position line/col. The string + * must end with 0. + */ + void print(uint8_t line, uint8_t col, char* data); + + /** prints the integer data at the current cursor position. + */ + void print(int data); + + /** Prints the integer data at position line/col. + */ + void print(uint8_t line, uint8_t col, int data); + + /** Puts on the backlight. + * \see lightOff + */ + void lightOn(); + + /** Puts off the backlight. + * \see lightOff + */ + void lightOff(); +}; + + + +LCD::LCD() : i2c(), id(0) +{ +} + + +LCD::LCD(uint8_t ID) : i2c(), id(ID) +{ +} + + +void LCD::clear() +{ + uint8_t buf[2]; + + buf[0] = id; + buf[1] = LCD_CMD_CLEAR; + i2c.send(I2C_ADDR_LCD, buf, 2); +} + + +void LCD::print(char* data) +{ + int len=strlen(data); + uint8_t buf[len+2]; + + buf[0] = id; + buf[1] = LCD_CMD_PRINTSTR; + for (int i=0; i