Arduino style GUI

Committer:
jonebuckman
Date:
Wed Feb 27 22:34:06 2019 +0000
Revision:
4:d353b314d244
Parent:
3:b5409826d05f
Updated writeCommand and writeData.

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 SEPS525_SPI_H
jonebuckman 3:b5409826d05f 19 #define SEPS525_SPI_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 /** SEPS525_SPI class.
jonebuckman 3:b5409826d05f 25 * Used for controlling an SEPS525-based OLED display connected to SPI.
jonebuckman 3:b5409826d05f 26 */
jonebuckman 3:b5409826d05f 27 class SEPS525_SPI : public Display
jonebuckman 3:b5409826d05f 28 {
jonebuckman 3:b5409826d05f 29 public:
jonebuckman 3:b5409826d05f 30
jonebuckman 3:b5409826d05f 31 /** Create an SEPS525 object connected to the specified SPI pins with the specified /CS and DC pins
jonebuckman 3:b5409826d05f 32 *
jonebuckman 3:b5409826d05f 33 * @param mosi The SPI data out pin.
jonebuckman 3:b5409826d05f 34 * @param miso The SPI data in pin.
jonebuckman 3:b5409826d05f 35 * @param sclk The SPI clock pin.
jonebuckman 3:b5409826d05f 36 * @param cs The SPI chip select pin.
jonebuckman 3:b5409826d05f 37 * @param dc The data/command pin.
jonebuckman 3:b5409826d05f 38 */
jonebuckman 3:b5409826d05f 39 SEPS525_SPI(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName dc, PinName res);
jonebuckman 3:b5409826d05f 40
jonebuckman 3:b5409826d05f 41 /** Probe for the SEPS525 and initialize it if present
jonebuckman 3:b5409826d05f 42 *
jonebuckman 3:b5409826d05f 43 * @returns
jonebuckman 3:b5409826d05f 44 * 'true' if the device exists on the bus,
jonebuckman 3:b5409826d05f 45 * 'false' if the device doesn't exist on the bus.
jonebuckman 3:b5409826d05f 46 */
jonebuckman 3:b5409826d05f 47 virtual bool open();
jonebuckman 3:b5409826d05f 48
jonebuckman 3:b5409826d05f 49 /** Send the buffer to the SEPS525
jonebuckman 3:b5409826d05f 50 */
jonebuckman 3:b5409826d05f 51 virtual void flush();
jonebuckman 3:b5409826d05f 52
jonebuckman 3:b5409826d05f 53 /** Get the current state of the SEPS525
jonebuckman 3:b5409826d05f 54 *
jonebuckman 3:b5409826d05f 55 * @returns The current state as a Display::State enum.
jonebuckman 3:b5409826d05f 56 */
jonebuckman 3:b5409826d05f 57 virtual Display::State state();
jonebuckman 3:b5409826d05f 58
jonebuckman 3:b5409826d05f 59 /** Set the state of the SEPS525
jonebuckman 3:b5409826d05f 60 *
jonebuckman 3:b5409826d05f 61 * @param mode The new state as a Display::State enum.
jonebuckman 3:b5409826d05f 62 */
jonebuckman 3:b5409826d05f 63 virtual void state(State s);
jonebuckman 3:b5409826d05f 64
jonebuckman 3:b5409826d05f 65 /** Set the master current
jonebuckman 3:b5409826d05f 66 *
jonebuckman 3:b5409826d05f 67 * @param current The master current value.
jonebuckman 3:b5409826d05f 68 */
jonebuckman 3:b5409826d05f 69 virtual void masterCurrent(int current);
jonebuckman 3:b5409826d05f 70
jonebuckman 3:b5409826d05f 71 /** Draw a single pixel at the specified coordinates
jonebuckman 3:b5409826d05f 72 *
jonebuckman 3:b5409826d05f 73 * @param x The X coordinate.
jonebuckman 3:b5409826d05f 74 * @param y The Y coordinate.
jonebuckman 3:b5409826d05f 75 * @param c The color of the pixel as a 32-bit ARGB value.
jonebuckman 3:b5409826d05f 76 */
jonebuckman 3:b5409826d05f 77 virtual void drawPixel(int x, int y, unsigned int c);
jonebuckman 3:b5409826d05f 78
jonebuckman 3:b5409826d05f 79 private:
jonebuckman 3:b5409826d05f 80 //Commands
jonebuckman 3:b5409826d05f 81 enum Command {
jonebuckman 3:b5409826d05f 82 CMD_INDEX = 0x00,
jonebuckman 3:b5409826d05f 83 CMD_STATUS_RD = 0x01,
jonebuckman 3:b5409826d05f 84 CMD_OSC_CTL = 0x02,
jonebuckman 3:b5409826d05f 85 CMD_IREF = 0x80,
jonebuckman 3:b5409826d05f 86 CMD_CLOCK_DIV = 0x03,
jonebuckman 3:b5409826d05f 87 CMD_REDUCE_CURRENT = 0x04,
jonebuckman 3:b5409826d05f 88 CMD_SOFT_RST = 0x05,
jonebuckman 3:b5409826d05f 89 CMD_DISP_ON_OFF = 0x06,
jonebuckman 3:b5409826d05f 90 CMD_PRECHARGE_TIME_R = 0x08,
jonebuckman 3:b5409826d05f 91 CMD_PRECHARGE_TIME_G = 0x09,
jonebuckman 3:b5409826d05f 92 CMD_PRECHARGE_TIME_B = 0x0A,
jonebuckman 3:b5409826d05f 93 CMD_PRECHARGE_CURRENT_R = 0x0B,
jonebuckman 3:b5409826d05f 94 CMD_PRECHARGE_CURRENT_G = 0x0C,
jonebuckman 3:b5409826d05f 95 CMD_PRECHARGE_CURRENT_B = 0x0D,
jonebuckman 3:b5409826d05f 96 CMD_DRIVING_CURRENT_R = 0x10,
jonebuckman 3:b5409826d05f 97 CMD_DRIVING_CURRENT_G = 0x11,
jonebuckman 3:b5409826d05f 98 CMD_DRIVING_CURRENT_B = 0x12,
jonebuckman 3:b5409826d05f 99 CMD_DISPLAY_MODE_SET = 0x13,
jonebuckman 3:b5409826d05f 100 CMD_RGB_IF = 0x14,
jonebuckman 3:b5409826d05f 101 CMD_RGB_POL = 0x15,
jonebuckman 3:b5409826d05f 102 CMD_MEMORY_WRITE_MODE = 0x16,
jonebuckman 3:b5409826d05f 103 CMD_MX1_ADDR = 0x17,
jonebuckman 3:b5409826d05f 104 CMD_MX2_ADDR = 0x18,
jonebuckman 3:b5409826d05f 105 CMD_MY1_ADDR = 0x19,
jonebuckman 3:b5409826d05f 106 CMD_MY2_ADDR = 0x1A,
jonebuckman 3:b5409826d05f 107 CMD_MEMORY_ACCESS_POINTER_X = 0x20,
jonebuckman 3:b5409826d05f 108 CMD_MEMORY_ACCESS_POINTER_Y = 0x21,
jonebuckman 3:b5409826d05f 109 CMD_DDRAM_DATA_ACCESS_PORT = 0x22,
jonebuckman 3:b5409826d05f 110 CMD_GRAY_SCALE_TABLE_INDEX = 0x50,
jonebuckman 3:b5409826d05f 111 CMD_GRAY_SCALE_TABLE_DATA = 0x51,
jonebuckman 3:b5409826d05f 112 CMD_DUTY = 0x28,
jonebuckman 3:b5409826d05f 113 CMD_DSL = 0x29,
jonebuckman 3:b5409826d05f 114 CMD_D1_DDRAM_FAC = 0x2E,
jonebuckman 3:b5409826d05f 115 CMD_D1_DDRAM_FAR = 0x2F,
jonebuckman 3:b5409826d05f 116 CMD_D2_DDRAM_SAC = 0x31,
jonebuckman 3:b5409826d05f 117 CMD_D2_DDRAM_SAR = 0x32,
jonebuckman 3:b5409826d05f 118 CMD_SCR1_FX1 = 0x33,
jonebuckman 3:b5409826d05f 119 CMD_SCR1_FX2 = 0x34,
jonebuckman 3:b5409826d05f 120 CMD_SCR1_FY1 = 0x35,
jonebuckman 3:b5409826d05f 121 CMD_SCR1_FY2 = 0x36,
jonebuckman 3:b5409826d05f 122 CMD_SCR2_SX1 = 0x37,
jonebuckman 3:b5409826d05f 123 CMD_SCR2_SX2 = 0x38,
jonebuckman 3:b5409826d05f 124 CMD_SCR2_SY1 = 0x39,
jonebuckman 3:b5409826d05f 125 CMD_SCR2_SY2 = 0x3A,
jonebuckman 3:b5409826d05f 126 CMD_SCREEN_SAVER_CONTEROL = 0x3B,
jonebuckman 3:b5409826d05f 127 CMD_SS_SLEEP_TIMER = 0x3C,
jonebuckman 3:b5409826d05f 128 CMD_SCREEN_SAVER_MODE = 0x3D,
jonebuckman 3:b5409826d05f 129 CMD_SS_SCR1_FU = 0x3E,
jonebuckman 3:b5409826d05f 130 CMD_SS_SCR1_MXY = 0x3F,
jonebuckman 3:b5409826d05f 131 CMD_SS_SCR2_FU = 0x40,
jonebuckman 3:b5409826d05f 132 CMD_SS_SCR2_MXY = 0x41,
jonebuckman 3:b5409826d05f 133 CMD_MOVING_DIRECTION = 0x42,
jonebuckman 3:b5409826d05f 134 CMD_SS_SCR2_SX1 = 0x47,
jonebuckman 3:b5409826d05f 135 CMD_SS_SCR2_SX2 = 0x48,
jonebuckman 3:b5409826d05f 136 CMD_SS_SCR2_SY1 = 0x49,
jonebuckman 3:b5409826d05f 137 CMD_SS_SCR2_SY2 = 0x4A,
jonebuckman 3:b5409826d05f 138 };
jonebuckman 3:b5409826d05f 139
jonebuckman 3:b5409826d05f 140 //SPI interface variables
jonebuckman 3:b5409826d05f 141 SPI m_SPI;
jonebuckman 3:b5409826d05f 142 DigitalOut m_CS;
jonebuckman 3:b5409826d05f 143 DigitalOut m_DC;
jonebuckman 3:b5409826d05f 144 DigitalOut m_RES;
jonebuckman 3:b5409826d05f 145
jonebuckman 3:b5409826d05f 146 //Command and data helpers
jonebuckman 3:b5409826d05f 147 void writeCommand(char command);
jonebuckman 3:b5409826d05f 148 void writeData(char data);
jonebuckman 3:b5409826d05f 149 };
jonebuckman 3:b5409826d05f 150
jonebuckman 3:b5409826d05f 151 #endif