Poker code for Secondary Mbed

Dependencies:   NokiaLCD mbed

Committer:
wjenkins7
Date:
Wed Dec 11 07:07:19 2013 +0000
Revision:
0:1324145f6904
Mbed Poker Secondary

Who changed what in which revision?

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