get distance from ultrasonic sensor and print it with circle_UI on Nokia LCD

Dependencies:   RangeFinder mbed

Committer:
ryought
Date:
Thu Oct 18 15:41:43 2012 +0000
Revision:
0:8dccbeedd000
first

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryought 0:8dccbeedd000 1 /* mbed NokiaLCD Library, for a 130x130 Nokia colour LCD
ryought 0:8dccbeedd000 2 * Copyright (c) 2007-2010, sford
ryought 0:8dccbeedd000 3 *
ryought 0:8dccbeedd000 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
ryought 0:8dccbeedd000 5 * of this software and associated documentation files (the "Software"), to deal
ryought 0:8dccbeedd000 6 * in the Software without restriction, including without limitation the rights
ryought 0:8dccbeedd000 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
ryought 0:8dccbeedd000 8 * copies of the Software, and to permit persons to whom the Software is
ryought 0:8dccbeedd000 9 * furnished to do so, subject to the following conditions:
ryought 0:8dccbeedd000 10 *
ryought 0:8dccbeedd000 11 * The above copyright notice and this permission notice shall be included in
ryought 0:8dccbeedd000 12 * all copies or substantial portions of the Software.
ryought 0:8dccbeedd000 13 *
ryought 0:8dccbeedd000 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
ryought 0:8dccbeedd000 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ryought 0:8dccbeedd000 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
ryought 0:8dccbeedd000 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
ryought 0:8dccbeedd000 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ryought 0:8dccbeedd000 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
ryought 0:8dccbeedd000 20 * THE SOFTWARE.
ryought 0:8dccbeedd000 21 */
ryought 0:8dccbeedd000 22
ryought 0:8dccbeedd000 23 #ifndef MBED_NOKIALCD_H
ryought 0:8dccbeedd000 24 #define MBED_NOKIALCD_H
ryought 0:8dccbeedd000 25
ryought 0:8dccbeedd000 26 #include "mbed.h"
ryought 0:8dccbeedd000 27
ryought 0:8dccbeedd000 28 /** An interface for the 130x130 Nokia Mobile phone screens
ryought 0:8dccbeedd000 29 *
ryought 0:8dccbeedd000 30 * @code
ryought 0:8dccbeedd000 31 * #include "mbed.h"
ryought 0:8dccbeedd000 32 * #include "NokiaLCD.h"
ryought 0:8dccbeedd000 33 *
ryought 0:8dccbeedd000 34 * NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::6610); // mosi, sclk, cs, rst, type
ryought 0:8dccbeedd000 35 *
ryought 0:8dccbeedd000 36 * int main() {
ryought 0:8dccbeedd000 37 * lcd.printf("Hello World!");
ryought 0:8dccbeedd000 38 * }
ryought 0:8dccbeedd000 39 * @endcode
ryought 0:8dccbeedd000 40 */
ryought 0:8dccbeedd000 41 class NokiaLCD : public Stream {
ryought 0:8dccbeedd000 42
ryought 0:8dccbeedd000 43 public:
ryought 0:8dccbeedd000 44 /** LCD panel format */
ryought 0:8dccbeedd000 45 enum LCDType {
ryought 0:8dccbeedd000 46 LCD6100 /**< Nokia 6100, as found on sparkfun board (default) */
ryought 0:8dccbeedd000 47 , LCD6610 /**< Nokia 6610, as found on olimex board */
ryought 0:8dccbeedd000 48 , PCF8833
ryought 0:8dccbeedd000 49 };
ryought 0:8dccbeedd000 50
ryought 0:8dccbeedd000 51 /** Create and Nokia LCD interface, using a SPI and two DigitalOut interfaces
ryought 0:8dccbeedd000 52 *
ryought 0:8dccbeedd000 53 * @param mosi SPI data out
ryought 0:8dccbeedd000 54 * @param sclk SPI clock
ryought 0:8dccbeedd000 55 * @param cs Chip Select (DigitalOut)
ryought 0:8dccbeedd000 56 * @param rst Reset (DigitalOut)
ryought 0:8dccbeedd000 57 * @param type The LCDType to select driver chip variants
ryought 0:8dccbeedd000 58 */
ryought 0:8dccbeedd000 59 NokiaLCD(PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type = LCD6100);
ryought 0:8dccbeedd000 60
ryought 0:8dccbeedd000 61 #if DOXYGEN_ONLY
ryought 0:8dccbeedd000 62 /** Write a character to the LCD
ryought 0:8dccbeedd000 63 *
ryought 0:8dccbeedd000 64 * @param c The character to write to the display
ryought 0:8dccbeedd000 65 */
ryought 0:8dccbeedd000 66 int putc(int c);
ryought 0:8dccbeedd000 67
ryought 0:8dccbeedd000 68 /** Write a formated string to the LCD
ryought 0:8dccbeedd000 69 *
ryought 0:8dccbeedd000 70 * @param format A printf-style format string, followed by the
ryought 0:8dccbeedd000 71 * variables to use in formating the string.
ryought 0:8dccbeedd000 72 */
ryought 0:8dccbeedd000 73 int printf(const char* format, ...);
ryought 0:8dccbeedd000 74 #endif
ryought 0:8dccbeedd000 75
ryought 0:8dccbeedd000 76 /** Locate to a screen column and row
ryought 0:8dccbeedd000 77 *
ryought 0:8dccbeedd000 78 * @param column The horizontal position from the left, indexed from 0
ryought 0:8dccbeedd000 79 * @param row The vertical position from the top, indexed from 0
ryought 0:8dccbeedd000 80 */
ryought 0:8dccbeedd000 81 void locate(int column, int row);
ryought 0:8dccbeedd000 82
ryought 0:8dccbeedd000 83 /** Clear the screen and locate to 0,0 */
ryought 0:8dccbeedd000 84 void cls();
ryought 0:8dccbeedd000 85
ryought 0:8dccbeedd000 86 /** Set a pixel on te screen
ryought 0:8dccbeedd000 87 *
ryought 0:8dccbeedd000 88 * @param x horizontal position from left
ryought 0:8dccbeedd000 89 * @param y vertical position from top
ryought 0:8dccbeedd000 90 * @param colour 24-bit colour in format 0x00RRGGBB
ryought 0:8dccbeedd000 91 */
ryought 0:8dccbeedd000 92 void pixel(int x, int y, int colour);
ryought 0:8dccbeedd000 93
ryought 0:8dccbeedd000 94 /** Fill an area of the screen
ryought 0:8dccbeedd000 95 *
ryought 0:8dccbeedd000 96 * @param x horizontal position from left
ryought 0:8dccbeedd000 97 * @param y vertical position from top
ryought 0:8dccbeedd000 98 * @param width width in pixels
ryought 0:8dccbeedd000 99 * @param height height in pixels
ryought 0:8dccbeedd000 100 * @param colour 24-bit colour in format 0x00RRGGBB
ryought 0:8dccbeedd000 101 */
ryought 0:8dccbeedd000 102 void fill(int x, int y, int width, int height, int colour);
ryought 0:8dccbeedd000 103
ryought 0:8dccbeedd000 104 void blit(int x, int y, int width, int height, const int* colour);
ryought 0:8dccbeedd000 105 void bitblit(int x, int y, int width, int height, const char* bitstream);
ryought 0:8dccbeedd000 106
ryought 0:8dccbeedd000 107 int width();
ryought 0:8dccbeedd000 108 int height();
ryought 0:8dccbeedd000 109 int columns();
ryought 0:8dccbeedd000 110 int rows();
ryought 0:8dccbeedd000 111
ryought 0:8dccbeedd000 112 void reset();
ryought 0:8dccbeedd000 113
ryought 0:8dccbeedd000 114 /** Set the foreground colour
ryought 0:8dccbeedd000 115 *
ryought 0:8dccbeedd000 116 * @param c 24-bit colour
ryought 0:8dccbeedd000 117 */
ryought 0:8dccbeedd000 118 void foreground(int c);
ryought 0:8dccbeedd000 119
ryought 0:8dccbeedd000 120 /** Set the background colour
ryought 0:8dccbeedd000 121 *
ryought 0:8dccbeedd000 122 * @param c 24-bit colour
ryought 0:8dccbeedd000 123 */
ryought 0:8dccbeedd000 124 void background(int c);
ryought 0:8dccbeedd000 125
ryought 0:8dccbeedd000 126 protected:
ryought 0:8dccbeedd000 127 virtual void _window(int x, int y, int width, int height);
ryought 0:8dccbeedd000 128 virtual void _putp(int colour);
ryought 0:8dccbeedd000 129
ryought 0:8dccbeedd000 130 void command(int value);
ryought 0:8dccbeedd000 131 void data(int value);
ryought 0:8dccbeedd000 132
ryought 0:8dccbeedd000 133 void newline();
ryought 0:8dccbeedd000 134 virtual int _putc(int c);
ryought 0:8dccbeedd000 135 virtual int _getc() {
ryought 0:8dccbeedd000 136 return 0;
ryought 0:8dccbeedd000 137 }
ryought 0:8dccbeedd000 138 void putp(int v);
ryought 0:8dccbeedd000 139 void window(int x, int y, int width, int height);
ryought 0:8dccbeedd000 140
ryought 0:8dccbeedd000 141 SPI _spi;
ryought 0:8dccbeedd000 142 DigitalOut _rst;
ryought 0:8dccbeedd000 143 DigitalOut _cs;
ryought 0:8dccbeedd000 144
ryought 0:8dccbeedd000 145 LCDType _type;
ryought 0:8dccbeedd000 146 int _row, _column, _rows, _columns, _foreground, _background, _width, _height;
ryought 0:8dccbeedd000 147 };
ryought 0:8dccbeedd000 148
ryought 0:8dccbeedd000 149 #endif
ryought 0:8dccbeedd000 150
ryought 0:8dccbeedd000 151