This is a code which generates the various zoomed versions of an image stored in an SD card and displays it on a Nokia LCD based on the keys pressed on a capacitive touch pad.

Dependencies:   FatFileSystem mbed

Fork of Lab3 by Martin Sturm

Committer:
abarve9
Date:
Thu Oct 11 06:10:31 2012 +0000
Revision:
1:6048138606a0
Parent:
0:c546b51ecf0b
This is an image zooming program which reads an image stored in an SD card and displays the various zoomed versions of the image based on the key pressed in the capacitive touch sensor.

Who changed what in which revision?

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