- ANALOG METER, initial offering - Emulation of an analog/mechanical meter using the SPI TFT display \"http://mbed.org/cookbook/SPI-driven-QVGA-TFT\" (touch not used) Meter takes an integer number from 0 - 100 and uses that number to position the meter\'s needle - An additional auto-scaling feature allows for + floating numbers from 0.0 - 10000.0 in \"NewfNumb\" Scaling is noted two ways a. Color of the meter body changes b. A text scale factor is displayed in the upper, right-hand corner, near the full scale reading Value of \"NewfNumb\" Meter_Body Scale_Factor < -0.0 Blue 0 0.1 - 9.9 Green x1 10.0 - 99.0 Yellow x10 100.0 - 999.0 Orange x100 1000.0 - 9990.0 Red x1k >= 10000.0 Red peg! - If NewfNumb is > 600.0, a flashing yellow warning message appears in the center of the meter movement - The date and time are displayed in the lower right corner of the display - The value of NewfNumb being shown in the movement is also displayed in the lower left coener of the display - A timer ISR automatically updates the meter\'s movement Other Stuff: - Additional demo test program, walks analog meter up and down through all auto scales by manipulating the value of NewfNumb - USB serial port used to dump a few messages. Not needed, set to 921600 BAUD - LED1 slowly gets brighter and dimmer as main loop runs - If for some reason, the \"MeterNumber\" int register ends up >100 or <0, a Purple display appears at 50% movement with a \"bad#\" scale factor - There is NO provision for setting the RTC. Note that TimeZone and DST are added to the RTC number

Dependencies:   mbed

Committer:
loopsva
Date:
Tue Jan 31 19:40:57 2012 +0000
Revision:
0:fc70640071d2
100

Who changed what in which revision?

UserRevisionLine numberNew contents of line
loopsva 0:fc70640071d2 1 /* mbed TextDisplay Library Base Class
loopsva 0:fc70640071d2 2 * Copyright (c) 2007-2009 sford
loopsva 0:fc70640071d2 3 * Released under the MIT License: http://mbed.org/license/mit
loopsva 0:fc70640071d2 4 *
loopsva 0:fc70640071d2 5 * A common base class for Text displays
loopsva 0:fc70640071d2 6 * To port a new display, derive from this class and implement
loopsva 0:fc70640071d2 7 * the constructor (setup the display), character (put a character
loopsva 0:fc70640071d2 8 * at a location), rows and columns (number of rows/cols) functions.
loopsva 0:fc70640071d2 9 * Everything else (locate, printf, putc, cls) will come for free
loopsva 0:fc70640071d2 10 *
loopsva 0:fc70640071d2 11 * The model is the display will wrap at the right and bottom, so you can
loopsva 0:fc70640071d2 12 * keep writing and will always get valid characters. The location is
loopsva 0:fc70640071d2 13 * maintained internally to the class to make this easy
loopsva 0:fc70640071d2 14 */
loopsva 0:fc70640071d2 15
loopsva 0:fc70640071d2 16 #ifndef MBED_TEXTDISPLAY_H
loopsva 0:fc70640071d2 17 #define MBED_TEXTDISPLAY_H
loopsva 0:fc70640071d2 18
loopsva 0:fc70640071d2 19 #include "mbed.h"
loopsva 0:fc70640071d2 20
loopsva 0:fc70640071d2 21 class TextDisplay : public Stream {
loopsva 0:fc70640071d2 22 public:
loopsva 0:fc70640071d2 23
loopsva 0:fc70640071d2 24 // functions needing implementation in derived implementation class
loopsva 0:fc70640071d2 25 /** Create a TextDisplay interface
loopsva 0:fc70640071d2 26 *
loopsva 0:fc70640071d2 27 * @param name The name used in the path to access the strean through the filesystem
loopsva 0:fc70640071d2 28 */
loopsva 0:fc70640071d2 29 TextDisplay(const char *name = NULL);
loopsva 0:fc70640071d2 30
loopsva 0:fc70640071d2 31 /** output a character at the given position
loopsva 0:fc70640071d2 32 *
loopsva 0:fc70640071d2 33 * @param column column where charater must be written
loopsva 0:fc70640071d2 34 * @param row where character must be written
loopsva 0:fc70640071d2 35 * @param c the character to be written to the TextDisplay
loopsva 0:fc70640071d2 36 */
loopsva 0:fc70640071d2 37 virtual void character(int column, int row, int c) = 0;
loopsva 0:fc70640071d2 38
loopsva 0:fc70640071d2 39 /** return number if rows on TextDisplay
loopsva 0:fc70640071d2 40 * @result number of rows
loopsva 0:fc70640071d2 41 */
loopsva 0:fc70640071d2 42 virtual int rows() = 0;
loopsva 0:fc70640071d2 43
loopsva 0:fc70640071d2 44 /** return number if columns on TextDisplay
loopsva 0:fc70640071d2 45 * @result number of rows
loopsva 0:fc70640071d2 46 */
loopsva 0:fc70640071d2 47 virtual int columns() = 0;
loopsva 0:fc70640071d2 48
loopsva 0:fc70640071d2 49 // functions that come for free, but can be overwritten
loopsva 0:fc70640071d2 50
loopsva 0:fc70640071d2 51 /** redirect output from a stream (stoud, sterr) to display
loopsva 0:fc70640071d2 52 * @param stream stream that shall be redirected to the TextDisplay
loopsva 0:fc70640071d2 53 */
loopsva 0:fc70640071d2 54 virtual bool claim (FILE *stream);
loopsva 0:fc70640071d2 55
loopsva 0:fc70640071d2 56 /** clear screen
loopsva 0:fc70640071d2 57 */
loopsva 0:fc70640071d2 58 virtual void cls();
loopsva 0:fc70640071d2 59 virtual void locate(int column, int row);
loopsva 0:fc70640071d2 60 virtual void foreground(uint16_t colour);
loopsva 0:fc70640071d2 61 virtual void background(uint16_t colour);
loopsva 0:fc70640071d2 62 // putc (from Stream)
loopsva 0:fc70640071d2 63 // printf (from Stream)
loopsva 0:fc70640071d2 64
loopsva 0:fc70640071d2 65 protected:
loopsva 0:fc70640071d2 66
loopsva 0:fc70640071d2 67 virtual int _putc(int value);
loopsva 0:fc70640071d2 68 virtual int _getc();
loopsva 0:fc70640071d2 69
loopsva 0:fc70640071d2 70 // character location
loopsva 0:fc70640071d2 71 uint16_t _column;
loopsva 0:fc70640071d2 72 uint16_t _row;
loopsva 0:fc70640071d2 73
loopsva 0:fc70640071d2 74 // colours
loopsva 0:fc70640071d2 75 uint16_t _foreground;
loopsva 0:fc70640071d2 76 uint16_t _background;
loopsva 0:fc70640071d2 77 char *_path;
loopsva 0:fc70640071d2 78 };
loopsva 0:fc70640071d2 79
loopsva 0:fc70640071d2 80 #endif