Arduino style GUI

Committer:
jonebuckman
Date:
Wed Feb 27 22:23:34 2019 +0000
Revision:
3:b5409826d05f
Added ILI9163 driver.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jonebuckman 3:b5409826d05f 1 /* NeatGUI Library
jonebuckman 3:b5409826d05f 2 * Copyright (c) 2013 Neil Thiessen
jonebuckman 3:b5409826d05f 3 * Copyright (c) 2017 Jon Buckman
jonebuckman 3:b5409826d05f 4 *
jonebuckman 3:b5409826d05f 5 * Licensed under the Apache License, Version 2.0 (the "License");
jonebuckman 3:b5409826d05f 6 * you may not use this file except in compliance with the License.
jonebuckman 3:b5409826d05f 7 * You may obtain a copy of the License at
jonebuckman 3:b5409826d05f 8 *
jonebuckman 3:b5409826d05f 9 * http://www.apache.org/licenses/LICENSE-2.0
jonebuckman 3:b5409826d05f 10 *
jonebuckman 3:b5409826d05f 11 * Unless required by applicable law or agreed to in writing, software
jonebuckman 3:b5409826d05f 12 * distributed under the License is distributed on an "AS IS" BASIS,
jonebuckman 3:b5409826d05f 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jonebuckman 3:b5409826d05f 14 * See the License for the specific language governing permissions and
jonebuckman 3:b5409826d05f 15 * limitations under the License.
jonebuckman 3:b5409826d05f 16 */
jonebuckman 3:b5409826d05f 17
jonebuckman 3:b5409826d05f 18 #ifndef ILI9163_H
jonebuckman 3:b5409826d05f 19 #define ILI9163_H
jonebuckman 3:b5409826d05f 20
jonebuckman 3:b5409826d05f 21 #include "mbed.h"
jonebuckman 3:b5409826d05f 22 #include "Display.h"
jonebuckman 3:b5409826d05f 23
jonebuckman 3:b5409826d05f 24 /** ILI9163 class.
jonebuckman 3:b5409826d05f 25 * Used for controlling an ILI9163-based TFT display.
jonebuckman 3:b5409826d05f 26 */
jonebuckman 3:b5409826d05f 27 class ILI9163 : public Display
jonebuckman 3:b5409826d05f 28 {
jonebuckman 3:b5409826d05f 29 public:
jonebuckman 3:b5409826d05f 30 /** Create an ILI9163 object connected to the specified SPI pins with the specified /CS and DC pins
jonebuckman 3:b5409826d05f 31 *
jonebuckman 3:b5409826d05f 32 * @param mosi The SPI data out pin.
jonebuckman 3:b5409826d05f 33 * @param miso The SPI data in pin.
jonebuckman 3:b5409826d05f 34 * @param sclk The SPI clock pin.
jonebuckman 3:b5409826d05f 35 * @param sclk The SPI chip select pin.
jonebuckman 3:b5409826d05f 36 * @param sclk The data/command pin.
jonebuckman 3:b5409826d05f 37 */
jonebuckman 3:b5409826d05f 38 ILI9163(PinName D0, PinName D1, PinName D2, PinName D3, PinName D4, PinName D5, PinName D6, PinName D7, PinName cs, PinName dc, PinName wr, PinName rst);
jonebuckman 3:b5409826d05f 39
jonebuckman 3:b5409826d05f 40 /** Probe for the ILI9163 and initialize it if present
jonebuckman 3:b5409826d05f 41 *
jonebuckman 3:b5409826d05f 42 * @returns
jonebuckman 3:b5409826d05f 43 * 'true' if the device exists on the bus,
jonebuckman 3:b5409826d05f 44 * 'false' if the device doesn't exist on the bus.
jonebuckman 3:b5409826d05f 45 */
jonebuckman 3:b5409826d05f 46 virtual bool open();
jonebuckman 3:b5409826d05f 47
jonebuckman 3:b5409826d05f 48 /** Send the buffer to the ILI9163
jonebuckman 3:b5409826d05f 49 */
jonebuckman 3:b5409826d05f 50 virtual void flush();
jonebuckman 3:b5409826d05f 51
jonebuckman 3:b5409826d05f 52 /** Get the current state of the ILI9163
jonebuckman 3:b5409826d05f 53 *
jonebuckman 3:b5409826d05f 54 * @returns The current state as a Display::State enum.
jonebuckman 3:b5409826d05f 55 */
jonebuckman 3:b5409826d05f 56 virtual Display::State state();
jonebuckman 3:b5409826d05f 57
jonebuckman 3:b5409826d05f 58 /** Set the state of the ILI9163
jonebuckman 3:b5409826d05f 59 *
jonebuckman 3:b5409826d05f 60 * @param mode The new state as a Display::State enum.
jonebuckman 3:b5409826d05f 61 */
jonebuckman 3:b5409826d05f 62 virtual void state(State s);
jonebuckman 3:b5409826d05f 63
jonebuckman 3:b5409826d05f 64 //void display();
jonebuckman 3:b5409826d05f 65
jonebuckman 3:b5409826d05f 66 /** Draw a single pixel at the specified coordinates
jonebuckman 3:b5409826d05f 67 *
jonebuckman 3:b5409826d05f 68 * @param x The X coordinate.
jonebuckman 3:b5409826d05f 69 * @param y The Y coordinate.
jonebuckman 3:b5409826d05f 70 * @param c The color of the pixel as a 32-bit ARGB value.
jonebuckman 3:b5409826d05f 71 */
jonebuckman 3:b5409826d05f 72 virtual void drawPixel(int x, int y, unsigned int c);
jonebuckman 3:b5409826d05f 73
jonebuckman 3:b5409826d05f 74 private:
jonebuckman 3:b5409826d05f 75 //Interface variables
jonebuckman 3:b5409826d05f 76 BusOut bus;
jonebuckman 3:b5409826d05f 77 DigitalOut m_CS;
jonebuckman 3:b5409826d05f 78 DigitalOut m_DC;
jonebuckman 3:b5409826d05f 79 DigitalOut m_WR;
jonebuckman 3:b5409826d05f 80 DigitalOut m_RST;
jonebuckman 3:b5409826d05f 81
jonebuckman 3:b5409826d05f 82 //Command and data helpers
jonebuckman 3:b5409826d05f 83 void writeCommand(char command);
jonebuckman 3:b5409826d05f 84 void writeData8(char data);
jonebuckman 3:b5409826d05f 85 void writeData16(unsigned short data);
jonebuckman 3:b5409826d05f 86 };
jonebuckman 3:b5409826d05f 87
jonebuckman 3:b5409826d05f 88 #endif