A simple yet powerful library for controlling graphical displays. Multiple display controllers are supported using inheritance.
Dependents: mbed_rifletool Hexi_Bubble_Game Hexi_Catch-the-dot_Game Hexi_Acceleromagnetic_Synth
NOTE: This library is in beta right now. As far as I know, everything here works, but there are many features that are lacking so far. Most notably containers, button handling, and display drivers other than the SSD1306.
Abstracts/Display.h@1:f7003ec66a51, 2014-03-14 (annotated)
- Committer:
- neilt6
- Date:
- Fri Mar 14 19:17:44 2014 +0000
- Revision:
- 1:f7003ec66a51
- Parent:
- 0:b876cf091464
- Child:
- 2:bbfc18022ee5
Added rudimentary ILI9341 support, and SPI support for SSD1306
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
neilt6 | 0:b876cf091464 | 1 | /* NeatGUI Library |
neilt6 | 0:b876cf091464 | 2 | * Copyright (c) 2013 Neil Thiessen |
neilt6 | 0:b876cf091464 | 3 | * |
neilt6 | 0:b876cf091464 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
neilt6 | 0:b876cf091464 | 5 | * you may not use this file except in compliance with the License. |
neilt6 | 0:b876cf091464 | 6 | * You may obtain a copy of the License at |
neilt6 | 0:b876cf091464 | 7 | * |
neilt6 | 0:b876cf091464 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
neilt6 | 0:b876cf091464 | 9 | * |
neilt6 | 0:b876cf091464 | 10 | * Unless required by applicable law or agreed to in writing, software |
neilt6 | 0:b876cf091464 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
neilt6 | 0:b876cf091464 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
neilt6 | 0:b876cf091464 | 13 | * See the License for the specific language governing permissions and |
neilt6 | 0:b876cf091464 | 14 | * limitations under the License. |
neilt6 | 0:b876cf091464 | 15 | */ |
neilt6 | 0:b876cf091464 | 16 | |
neilt6 | 0:b876cf091464 | 17 | #ifndef DISPLAY_H |
neilt6 | 0:b876cf091464 | 18 | #define DISPLAY_H |
neilt6 | 0:b876cf091464 | 19 | |
neilt6 | 0:b876cf091464 | 20 | #include "mbed.h" |
neilt6 | 0:b876cf091464 | 21 | #include "Canvas.h" |
neilt6 | 0:b876cf091464 | 22 | |
neilt6 | 0:b876cf091464 | 23 | /** Display abstract class. |
neilt6 | 0:b876cf091464 | 24 | * Used as a base class for Display objects with 2D drawing capabilites. |
neilt6 | 0:b876cf091464 | 25 | */ |
neilt6 | 0:b876cf091464 | 26 | class Display : public Canvas |
neilt6 | 0:b876cf091464 | 27 | { |
neilt6 | 0:b876cf091464 | 28 | public: |
neilt6 | 0:b876cf091464 | 29 | /** Represents the state of the Display |
neilt6 | 0:b876cf091464 | 30 | */ |
neilt6 | 0:b876cf091464 | 31 | enum State { |
neilt6 | 0:b876cf091464 | 32 | NOT_INITIALIZED, /**< Display has not been initialized yet */ |
neilt6 | 0:b876cf091464 | 33 | DISPLAY_OFF, /**< Display is initialized and turned off */ |
neilt6 | 0:b876cf091464 | 34 | DISPLAY_ON /**< Display is initialized and turned on */ |
neilt6 | 0:b876cf091464 | 35 | }; |
neilt6 | 0:b876cf091464 | 36 | |
neilt6 | 0:b876cf091464 | 37 | /** Create a Display object with the specified width and height |
neilt6 | 0:b876cf091464 | 38 | * |
neilt6 | 0:b876cf091464 | 39 | * @param w The display width. |
neilt6 | 0:b876cf091464 | 40 | * @param h The display height. |
neilt6 | 0:b876cf091464 | 41 | */ |
neilt6 | 0:b876cf091464 | 42 | Display(int w, int h); |
neilt6 | 0:b876cf091464 | 43 | |
neilt6 | 0:b876cf091464 | 44 | /** Probe for the display controller and initialize it if present |
neilt6 | 0:b876cf091464 | 45 | * |
neilt6 | 0:b876cf091464 | 46 | * @returns |
neilt6 | 0:b876cf091464 | 47 | * 'true' if the device exists on the bus, |
neilt6 | 0:b876cf091464 | 48 | * 'false' if the device doesn't exist on the bus. |
neilt6 | 0:b876cf091464 | 49 | */ |
neilt6 | 1:f7003ec66a51 | 50 | virtual bool open() = 0; |
neilt6 | 0:b876cf091464 | 51 | |
neilt6 | 0:b876cf091464 | 52 | /** Finalize any writes to the Display |
neilt6 | 0:b876cf091464 | 53 | */ |
neilt6 | 1:f7003ec66a51 | 54 | virtual void finalize(); |
neilt6 | 0:b876cf091464 | 55 | |
neilt6 | 0:b876cf091464 | 56 | /** Get the current state of the Display |
neilt6 | 0:b876cf091464 | 57 | * |
neilt6 | 0:b876cf091464 | 58 | * @returns The current state as a State enum. |
neilt6 | 0:b876cf091464 | 59 | */ |
neilt6 | 1:f7003ec66a51 | 60 | virtual Display::State state(); |
neilt6 | 0:b876cf091464 | 61 | |
neilt6 | 0:b876cf091464 | 62 | /** Set the state of the Display |
neilt6 | 0:b876cf091464 | 63 | * |
neilt6 | 0:b876cf091464 | 64 | * @param mode The new state as a State enum. |
neilt6 | 0:b876cf091464 | 65 | */ |
neilt6 | 0:b876cf091464 | 66 | virtual void state(State s); |
neilt6 | 0:b876cf091464 | 67 | |
neilt6 | 0:b876cf091464 | 68 | protected: |
neilt6 | 0:b876cf091464 | 69 | Display::State m_State; |
neilt6 | 0:b876cf091464 | 70 | }; |
neilt6 | 0:b876cf091464 | 71 | |
neilt6 | 0:b876cf091464 | 72 | #endif |