Arduino style GUI

Committer:
jonebuckman
Date:
Fri May 06 16:51:15 2016 +0000
Revision:
0:90962b684403
Updated drivers.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jonebuckman 0:90962b684403 1 /* NeatGUI Library
jonebuckman 0:90962b684403 2 * Copyright (c) 2013 Neil Thiessen
jonebuckman 0:90962b684403 3 *
jonebuckman 0:90962b684403 4 * Licensed under the Apache License, Version 2.0 (the "License");
jonebuckman 0:90962b684403 5 * you may not use this file except in compliance with the License.
jonebuckman 0:90962b684403 6 * You may obtain a copy of the License at
jonebuckman 0:90962b684403 7 *
jonebuckman 0:90962b684403 8 * http://www.apache.org/licenses/LICENSE-2.0
jonebuckman 0:90962b684403 9 *
jonebuckman 0:90962b684403 10 * Unless required by applicable law or agreed to in writing, software
jonebuckman 0:90962b684403 11 * distributed under the License is distributed on an "AS IS" BASIS,
jonebuckman 0:90962b684403 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jonebuckman 0:90962b684403 13 * See the License for the specific language governing permissions and
jonebuckman 0:90962b684403 14 * limitations under the License.
jonebuckman 0:90962b684403 15 */
jonebuckman 0:90962b684403 16
jonebuckman 0:90962b684403 17 #ifndef ILI9341_H
jonebuckman 0:90962b684403 18 #define ILI9241_H
jonebuckman 0:90962b684403 19
jonebuckman 0:90962b684403 20 #include "mbed.h"
jonebuckman 0:90962b684403 21 #include "Display.h"
jonebuckman 0:90962b684403 22
jonebuckman 0:90962b684403 23 /** ILI9341 class.
jonebuckman 0:90962b684403 24 * Used for controlling an ILI9341-based TFT display.
jonebuckman 0:90962b684403 25 */
jonebuckman 0:90962b684403 26 class ILI9341 : public Display
jonebuckman 0:90962b684403 27 {
jonebuckman 0:90962b684403 28 public:
jonebuckman 0:90962b684403 29 /** Create an ILI9341 object connected to the specified SPI pins with the specified /CS and DC pins
jonebuckman 0:90962b684403 30 *
jonebuckman 0:90962b684403 31 * @param mosi The SPI data out pin.
jonebuckman 0:90962b684403 32 * @param miso The SPI data in pin.
jonebuckman 0:90962b684403 33 * @param sclk The SPI clock pin.
jonebuckman 0:90962b684403 34 * @param sclk The SPI chip select pin.
jonebuckman 0:90962b684403 35 * @param sclk The data/command pin.
jonebuckman 0:90962b684403 36 */
jonebuckman 0:90962b684403 37 ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName dc);
jonebuckman 0:90962b684403 38
jonebuckman 0:90962b684403 39 /** Probe for the ILI9341 and initialize it if present
jonebuckman 0:90962b684403 40 *
jonebuckman 0:90962b684403 41 * @returns
jonebuckman 0:90962b684403 42 * 'true' if the device exists on the bus,
jonebuckman 0:90962b684403 43 * 'false' if the device doesn't exist on the bus.
jonebuckman 0:90962b684403 44 */
jonebuckman 0:90962b684403 45 virtual bool open();
jonebuckman 0:90962b684403 46
jonebuckman 0:90962b684403 47 /** Send the buffer to the ILI9341
jonebuckman 0:90962b684403 48 */
jonebuckman 0:90962b684403 49 virtual void flush();
jonebuckman 0:90962b684403 50
jonebuckman 0:90962b684403 51 /** Get the current state of the ILI9341
jonebuckman 0:90962b684403 52 *
jonebuckman 0:90962b684403 53 * @returns The current state as a Display::State enum.
jonebuckman 0:90962b684403 54 */
jonebuckman 0:90962b684403 55 virtual Display::State state();
jonebuckman 0:90962b684403 56
jonebuckman 0:90962b684403 57 /** Set the state of the ILI9341
jonebuckman 0:90962b684403 58 *
jonebuckman 0:90962b684403 59 * @param mode The new state as a Display::State enum.
jonebuckman 0:90962b684403 60 */
jonebuckman 0:90962b684403 61 virtual void state(State s);
jonebuckman 0:90962b684403 62
jonebuckman 0:90962b684403 63 //void display();
jonebuckman 0:90962b684403 64
jonebuckman 0:90962b684403 65 /** Draw a single pixel at the specified coordinates
jonebuckman 0:90962b684403 66 *
jonebuckman 0:90962b684403 67 * @param x The X coordinate.
jonebuckman 0:90962b684403 68 * @param y The Y coordinate.
jonebuckman 0:90962b684403 69 * @param c The color of the pixel as a 32-bit ARGB value.
jonebuckman 0:90962b684403 70 */
jonebuckman 0:90962b684403 71 virtual void drawPixel(int x, int y, unsigned int c);
jonebuckman 0:90962b684403 72
jonebuckman 0:90962b684403 73 private:
jonebuckman 0:90962b684403 74 //Commands
jonebuckman 0:90962b684403 75 /*enum Command {
jonebuckman 0:90962b684403 76 CMD_SETCONTRAST = 0x81,
jonebuckman 0:90962b684403 77 CMD_DISPLAYALLON_RESUME = 0xA4,
jonebuckman 0:90962b684403 78 CMD_DISPLAYALLON = 0xA5,
jonebuckman 0:90962b684403 79 CMD_NORMALDISPLAY = 0xA6,
jonebuckman 0:90962b684403 80 CMD_INVERTDISPLAY = 0xA7,
jonebuckman 0:90962b684403 81 CMD_DISPLAYOFF = 0xAE,
jonebuckman 0:90962b684403 82 CMD_DISPLAYON = 0xAF,
jonebuckman 0:90962b684403 83 CMD_SETDISPLAYOFFSET = 0xD3,
jonebuckman 0:90962b684403 84 CMD_SETCOMPINS = 0xDA,
jonebuckman 0:90962b684403 85 CMD_SETVCOMDETECT = 0xDB,
jonebuckman 0:90962b684403 86 CMD_SETDISPLAYCLOCKDIV = 0xD5,
jonebuckman 0:90962b684403 87 CMD_SETPRECHARGE = 0xD9,
jonebuckman 0:90962b684403 88 CMD_SETMULTIPLEX = 0xA8,
jonebuckman 0:90962b684403 89 CMD_SETLOWCOLUMN = 0x00,
jonebuckman 0:90962b684403 90 CMD_SETHIGHCOLUMN = 0x10,
jonebuckman 0:90962b684403 91 CMD_SETSTARTLINE = 0x40,
jonebuckman 0:90962b684403 92 CMD_MEMORYMODE = 0x20,
jonebuckman 0:90962b684403 93 CMD_COMSCANINC = 0xC0,
jonebuckman 0:90962b684403 94 CMD_COMSCANDEC = 0xC8,
jonebuckman 0:90962b684403 95 CMD_SEGREMAP = 0xA0,
jonebuckman 0:90962b684403 96 CMD_CHARGEPUMP = 0x8D,
jonebuckman 0:90962b684403 97 CMD_CHARGEPUMPON = 0x14,
jonebuckman 0:90962b684403 98 CMD_CHARGEPUMPOFF = 0x10,
jonebuckman 0:90962b684403 99 CMD_ACTIVATE_SCROLL = 0x2F,
jonebuckman 0:90962b684403 100 CMD_DEACTIVATE_SCROLL = 0x2E,
jonebuckman 0:90962b684403 101 CMD_SET_VERTICAL_SCROLL_AREA = 0xA3,
jonebuckman 0:90962b684403 102 CMD_RIGHT_HORIZONTAL_SCROLL = 0x26,
jonebuckman 0:90962b684403 103 CMD_LEFT_HORIZONTAL_SCROLL = 0x27,
jonebuckman 0:90962b684403 104 CMD_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29,
jonebuckman 0:90962b684403 105 CMD_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
jonebuckman 0:90962b684403 106 };*/
jonebuckman 0:90962b684403 107
jonebuckman 0:90962b684403 108 //Interface variables
jonebuckman 0:90962b684403 109 SPI m_SPI;
jonebuckman 0:90962b684403 110 DigitalOut m_CS;
jonebuckman 0:90962b684403 111 DigitalOut m_DC;
jonebuckman 0:90962b684403 112
jonebuckman 0:90962b684403 113 //Command and data helpers
jonebuckman 0:90962b684403 114 void writeCommand(char command);
jonebuckman 0:90962b684403 115 void writeData8(char data);
jonebuckman 0:90962b684403 116 void writeData16(unsigned short data);
jonebuckman 0:90962b684403 117 };
jonebuckman 0:90962b684403 118
jonebuckman 0:90962b684403 119 #endif