This builds on TCPSocket_HelloWorld and others to read an in-coming buffer and then build and send a buffer. Very much work in progress

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Committer:
acodd
Date:
Sat Feb 09 22:29:18 2013 +0000
Revision:
12:cce8fa67de18
First main release

Who changed what in which revision?

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