Mbed clock is set using NTP and UTC displayed on Nokia LCD. Seehttp://mbed.org/users/4180_1/notebook/internet-nokia-lcd-clock/

Dependencies:   EthernetNetIf NTPClient_NetServices mbed

Committer:
4180_1
Date:
Fri May 25 00:41:26 2012 +0000
Revision:
0:da7f4b6d2b7c

        

Who changed what in which revision?

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