Library for Nuelectronics Nokia 3310/5110 LCD Display and joystick.
Fork of N3310LCD by
Library for Nuelectronics Nokia 3310/5110 LCD Display and joystick.
N3310LCD.h@5:1fd7af32e521, 2013-03-27 (annotated)
- Committer:
- SomeRandomBloke
- Date:
- Wed Mar 27 21:09:58 2013 +0000
- Revision:
- 5:1fd7af32e521
- Parent:
- 4:90dce6032a37
- Child:
- 6:46bcc4e584c4
Used Stream class for printf output
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SomeRandomBloke | 0:7efa6655d94b | 1 | /* |
SomeRandomBloke | 0:7efa6655d94b | 2 | * N3310LCD. A program to interface mbed with the nuelectronics |
SomeRandomBloke | 0:7efa6655d94b | 3 | * Nokia 3310 LCD shield from www.nuelectronics.com. Ported from |
SomeRandomBloke | 0:7efa6655d94b | 4 | * the nuelectronics Arduino code. |
SomeRandomBloke | 0:7efa6655d94b | 5 | * |
SomeRandomBloke | 0:7efa6655d94b | 6 | * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk> |
SomeRandomBloke | 0:7efa6655d94b | 7 | * |
SomeRandomBloke | 0:7efa6655d94b | 8 | * Converted to a mbed library by Andrew D. Lindsay |
SomeRandomBloke | 0:7efa6655d94b | 9 | * |
SomeRandomBloke | 0:7efa6655d94b | 10 | * This file is part of N3310LCD. |
SomeRandomBloke | 0:7efa6655d94b | 11 | * |
SomeRandomBloke | 0:7efa6655d94b | 12 | * N3310LCD is free software: you can redistribute it and/or modify |
SomeRandomBloke | 0:7efa6655d94b | 13 | * it under the terms of the GNU General Public License as published by |
SomeRandomBloke | 0:7efa6655d94b | 14 | * the Free Software Foundation, either version 3 of the License, or |
SomeRandomBloke | 0:7efa6655d94b | 15 | * (at your option) any later version. |
SomeRandomBloke | 1:51961974fe55 | 16 | * |
SomeRandomBloke | 0:7efa6655d94b | 17 | * N3310LCD is distributed in the hope that it will be useful, |
SomeRandomBloke | 0:7efa6655d94b | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
SomeRandomBloke | 0:7efa6655d94b | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
SomeRandomBloke | 0:7efa6655d94b | 20 | * GNU General Public License for more details. |
SomeRandomBloke | 0:7efa6655d94b | 21 | * |
SomeRandomBloke | 0:7efa6655d94b | 22 | * You should have received a copy of the GNU General Public License |
SomeRandomBloke | 0:7efa6655d94b | 23 | * along with N3310LCD. If not, see <http://www.gnu.org/licenses/>. |
SomeRandomBloke | 0:7efa6655d94b | 24 | */ |
SomeRandomBloke | 0:7efa6655d94b | 25 | |
SomeRandomBloke | 0:7efa6655d94b | 26 | #ifndef SNATCH59_N3310LCD_H |
SomeRandomBloke | 0:7efa6655d94b | 27 | #define SNATCH59_N3310LCD_H |
SomeRandomBloke | 0:7efa6655d94b | 28 | |
SomeRandomBloke | 0:7efa6655d94b | 29 | #include <mbed.h> |
SomeRandomBloke | 0:7efa6655d94b | 30 | #include "N3310LCDDefs.h" |
SomeRandomBloke | 0:7efa6655d94b | 31 | |
SomeRandomBloke | 0:7efa6655d94b | 32 | #define LCDCOLMAX 84 |
SomeRandomBloke | 0:7efa6655d94b | 33 | #define LCDROWMAX 6 |
SomeRandomBloke | 0:7efa6655d94b | 34 | #define LCDPIXELROWMAX 48 |
SomeRandomBloke | 0:7efa6655d94b | 35 | #define PIXEL_OFF 0 |
SomeRandomBloke | 0:7efa6655d94b | 36 | #define PIXEL_ON 1 |
SomeRandomBloke | 0:7efa6655d94b | 37 | #define PIXEL_XOR 2 |
SomeRandomBloke | 3:9808f63fd2fe | 38 | #define FONT_5x7 0 |
SomeRandomBloke | 3:9808f63fd2fe | 39 | #define FONT_6x8 1 |
SomeRandomBloke | 4:90dce6032a37 | 40 | #define FONT_ALPHA_17x17 2 |
SomeRandomBloke | 4:90dce6032a37 | 41 | |
SomeRandomBloke | 0:7efa6655d94b | 42 | |
SomeRandomBloke | 5:1fd7af32e521 | 43 | class N3310LCD : public Stream |
SomeRandomBloke | 0:7efa6655d94b | 44 | { |
SomeRandomBloke | 0:7efa6655d94b | 45 | public: |
SomeRandomBloke | 1:51961974fe55 | 46 | N3310LCD(PinName mosi, PinName miso, PinName sck, |
SomeRandomBloke | 0:7efa6655d94b | 47 | PinName ce, PinName dat_cmd, PinName lcd_rst, PinName bl_on); |
SomeRandomBloke | 1:51961974fe55 | 48 | |
SomeRandomBloke | 0:7efa6655d94b | 49 | void init(); |
SomeRandomBloke | 0:7efa6655d94b | 50 | void cls(); |
SomeRandomBloke | 0:7efa6655d94b | 51 | void backlight(eBacklight state); |
SomeRandomBloke | 3:9808f63fd2fe | 52 | void writeCommand(BYTE data); |
SomeRandomBloke | 3:9808f63fd2fe | 53 | void writeData(BYTE data); |
SomeRandomBloke | 0:7efa6655d94b | 54 | void locate(BYTE xPos, BYTE yPos); |
SomeRandomBloke | 1:51961974fe55 | 55 | |
SomeRandomBloke | 0:7efa6655d94b | 56 | void drawBitmap(BYTE xPos, BYTE yPos, BYTE* bitmap, BYTE bmpXSize, BYTE bmpYSize); |
SomeRandomBloke | 0:7efa6655d94b | 57 | void clearBitmap(BYTE xPos,BYTE yPos, BYTE size_x, BYTE size_y); |
SomeRandomBloke | 3:9808f63fd2fe | 58 | void setFont(BYTE font ); |
SomeRandomBloke | 1:51961974fe55 | 59 | void writeString(BYTE xPos, BYTE yPos, char* string, eDisplayMode mode); |
SomeRandomBloke | 0:7efa6655d94b | 60 | void writeStringBig(BYTE xPos, BYTE yPos, char* string, eDisplayMode mode); |
SomeRandomBloke | 0:7efa6655d94b | 61 | void writeChar(BYTE ch, eDisplayMode mode); |
SomeRandomBloke | 0:7efa6655d94b | 62 | void writeCharBig(BYTE xPos, BYTE yPos, BYTE ch, eDisplayMode mode); |
SomeRandomBloke | 1:51961974fe55 | 63 | |
SomeRandomBloke | 1:51961974fe55 | 64 | void setPixel( BYTE x, BYTE y, BYTE c ); |
SomeRandomBloke | 0:7efa6655d94b | 65 | void drawLine(BYTE x1, BYTE y1, BYTE x2, BYTE y2, BYTE c); |
SomeRandomBloke | 0:7efa6655d94b | 66 | void drawRectangle(BYTE x1, BYTE y1,BYTE x2, BYTE y2, BYTE c); |
SomeRandomBloke | 0:7efa6655d94b | 67 | void drawFilledRectangle(BYTE x1, BYTE y1, BYTE x2, BYTE y2, BYTE c); |
SomeRandomBloke | 0:7efa6655d94b | 68 | void drawCircle(BYTE xc, BYTE yc, BYTE r, BYTE c); |
SomeRandomBloke | 1:51961974fe55 | 69 | |
SomeRandomBloke | 5:1fd7af32e521 | 70 | protected: |
SomeRandomBloke | 5:1fd7af32e521 | 71 | virtual int _putc(int value); |
SomeRandomBloke | 5:1fd7af32e521 | 72 | virtual int _getc(); |
SomeRandomBloke | 5:1fd7af32e521 | 73 | |
SomeRandomBloke | 0:7efa6655d94b | 74 | private: |
SomeRandomBloke | 0:7efa6655d94b | 75 | // I/O |
SomeRandomBloke | 0:7efa6655d94b | 76 | SPI lcdPort; // does SPI MOSI, MISO and SCK |
SomeRandomBloke | 0:7efa6655d94b | 77 | DigitalOut ceWire; // does SPI CE |
SomeRandomBloke | 0:7efa6655d94b | 78 | DigitalOut dcWire; // does 3310 DAT_CMD |
SomeRandomBloke | 0:7efa6655d94b | 79 | DigitalOut rstWire; // does 3310 LCD_RST |
SomeRandomBloke | 1:51961974fe55 | 80 | DigitalOut blWire; // does 3310 BL_ON (backlight) |
SomeRandomBloke | 0:7efa6655d94b | 81 | }; |
SomeRandomBloke | 0:7efa6655d94b | 82 | |
SomeRandomBloke | 0:7efa6655d94b | 83 | #endif |