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