A basic graphics package for the LPC4088 Display Module.

Dependents:   lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more

Fork of DMBasicGUI by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Mon Mar 09 10:50:17 2015 +0100
Revision:
14:647b1896ed84
Parent:
13:bff2288c2c61
Child:
15:a68bb30ab95e
Updated code documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 13:bff2288c2c61 1 /*
embeddedartists 13:bff2288c2c61 2 * Copyright 2014 Embedded Artists AB
embeddedartists 13:bff2288c2c61 3 *
embeddedartists 13:bff2288c2c61 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 13:bff2288c2c61 5 * you may not use this file except in compliance with the License.
embeddedartists 13:bff2288c2c61 6 * You may obtain a copy of the License at
embeddedartists 13:bff2288c2c61 7 *
embeddedartists 13:bff2288c2c61 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 13:bff2288c2c61 9 *
embeddedartists 13:bff2288c2c61 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 13:bff2288c2c61 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 13:bff2288c2c61 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 13:bff2288c2c61 13 * See the License for the specific language governing permissions and
embeddedartists 13:bff2288c2c61 14 * limitations under the License.
embeddedartists 13:bff2288c2c61 15 */
embeddedartists 13:bff2288c2c61 16
embeddedartists 5:f4de114c31c3 17 #ifndef RENDERER_H
embeddedartists 5:f4de114c31c3 18 #define RENDERER_H
embeddedartists 5:f4de114c31c3 19
embeddedartists 5:f4de114c31c3 20 #include "rtos.h"
embeddedartists 5:f4de114c31c3 21 #include "Display.h"
embeddedartists 5:f4de114c31c3 22
embeddedartists 14:647b1896ed84 23 /**
embeddedartists 14:647b1896ed84 24 * Renderer for the SlideShow engine.
embeddedartists 14:647b1896ed84 25 *
embeddedartists 14:647b1896ed84 26 * The renderer handles all (if more than one) running slideshows and
embeddedartists 14:647b1896ed84 27 * the layer(s) they are drawn on.
embeddedartists 14:647b1896ed84 28 *
embeddedartists 14:647b1896ed84 29 * For information on how to use the SlideShow and some examples see
embeddedartists 14:647b1896ed84 30 * https://developer.mbed.org/teams/Embedded-Artists/wiki/LPC4088DM-Using-the-SlideShow-Engine
embeddedartists 14:647b1896ed84 31 */
embeddedartists 5:f4de114c31c3 32 class Renderer {
embeddedartists 5:f4de114c31c3 33 public:
embeddedartists 5:f4de114c31c3 34
embeddedartists 13:bff2288c2c61 35 Renderer();
embeddedartists 5:f4de114c31c3 36 ~Renderer();
embeddedartists 5:f4de114c31c3 37
embeddedartists 5:f4de114c31c3 38 /** Specifies a part of a layer
embeddedartists 5:f4de114c31c3 39 *
embeddedartists 5:f4de114c31c3 40 * Returns a handle to pass when updating the framebuffer.
embeddedartists 5:f4de114c31c3 41 *
embeddedartists 5:f4de114c31c3 42 * @param layer 0 is the bottom of the stack, higher number is on top
embeddedartists 5:f4de114c31c3 43 * @param xoff top left corner of the drawing rectangle
embeddedartists 5:f4de114c31c3 44 * @param yoff top left corner of the drawing rectangle
embeddedartists 5:f4de114c31c3 45 * @param width width of the drawing rectangle
embeddedartists 5:f4de114c31c3 46 * @param height height of the drawing rectangle
embeddedartists 5:f4de114c31c3 47 *
embeddedartists 5:f4de114c31c3 48 * @returns
embeddedartists 5:f4de114c31c3 49 * handle to pass to setFrameBuffer function
embeddedartists 5:f4de114c31c3 50 * 0 on failure
embeddedartists 5:f4de114c31c3 51 */
embeddedartists 5:f4de114c31c3 52 uint32_t registerUser(int layer, int xoff, int yoff, int width, int height);
embeddedartists 5:f4de114c31c3 53 uint32_t registerFullscreenUser(int layer);
embeddedartists 5:f4de114c31c3 54
embeddedartists 5:f4de114c31c3 55 /** Removes the item from the renderer
embeddedartists 5:f4de114c31c3 56 *
embeddedartists 5:f4de114c31c3 57 * @param handle the handle returned in the registerUser() call
embeddedartists 5:f4de114c31c3 58 */
embeddedartists 5:f4de114c31c3 59 void unregisterUser(uint32_t handle);
embeddedartists 5:f4de114c31c3 60
embeddedartists 5:f4de114c31c3 61 /** Informs the renderer that there is new data to use
embeddedartists 5:f4de114c31c3 62 *
embeddedartists 5:f4de114c31c3 63 * Blocks until the data has been register. After that point the
embeddedartists 5:f4de114c31c3 64 * data must not be modified until another call to setFramebuffer.
embeddedartists 5:f4de114c31c3 65 *
embeddedartists 5:f4de114c31c3 66 * @param handle the handle returned in the registerUser() call
embeddedartists 5:f4de114c31c3 67 * @param data the image data
embeddedartists 5:f4de114c31c3 68 */
embeddedartists 5:f4de114c31c3 69 void setFramebuffer(uint32_t handle, const uint16_t* data);
embeddedartists 5:f4de114c31c3 70
embeddedartists 5:f4de114c31c3 71 void setRenderThread(Thread* renderThread) { t = renderThread; }
embeddedartists 5:f4de114c31c3 72
embeddedartists 5:f4de114c31c3 73 /** Run the renderer
embeddedartists 5:f4de114c31c3 74 *
embeddedartists 5:f4de114c31c3 75 * Should be called from a high priority thread.
embeddedartists 5:f4de114c31c3 76 */
embeddedartists 5:f4de114c31c3 77 void render();
embeddedartists 5:f4de114c31c3 78
embeddedartists 5:f4de114c31c3 79 private:
embeddedartists 5:f4de114c31c3 80
embeddedartists 5:f4de114c31c3 81 enum Constants {
embeddedartists 5:f4de114c31c3 82 MaxNumLayers = 10,
embeddedartists 5:f4de114c31c3 83 };
embeddedartists 5:f4de114c31c3 84
embeddedartists 5:f4de114c31c3 85 typedef uint16_t* image_t;
embeddedartists 5:f4de114c31c3 86
embeddedartists 5:f4de114c31c3 87 typedef struct {
embeddedartists 5:f4de114c31c3 88 bool used;
embeddedartists 5:f4de114c31c3 89 int x0;
embeddedartists 5:f4de114c31c3 90 int y0;
embeddedartists 5:f4de114c31c3 91 int x1;
embeddedartists 5:f4de114c31c3 92 int y1;
embeddedartists 5:f4de114c31c3 93 int width;
embeddedartists 5:f4de114c31c3 94 int clippedHeight;
embeddedartists 5:f4de114c31c3 95 int zorder;
embeddedartists 5:f4de114c31c3 96 int signalId;
embeddedartists 5:f4de114c31c3 97 bool fullscreen;
embeddedartists 5:f4de114c31c3 98 const uint16_t* newData;
embeddedartists 5:f4de114c31c3 99 const uint16_t* activeData;
embeddedartists 5:f4de114c31c3 100 uint16_t* tmp;
embeddedartists 5:f4de114c31c3 101 Mutex* lock;
embeddedartists 5:f4de114c31c3 102 } layerinfo_t;
embeddedartists 5:f4de114c31c3 103
embeddedartists 5:f4de114c31c3 104 layerinfo_t layers[MaxNumLayers];
embeddedartists 5:f4de114c31c3 105 layerinfo_t* order[MaxNumLayers];
embeddedartists 5:f4de114c31c3 106
embeddedartists 5:f4de114c31c3 107 int numRegisteredLayers;
embeddedartists 5:f4de114c31c3 108
embeddedartists 5:f4de114c31c3 109 Thread* t;
embeddedartists 5:f4de114c31c3 110 Mutex setupMutex;
embeddedartists 5:f4de114c31c3 111
embeddedartists 5:f4de114c31c3 112 int screenWidth;
embeddedartists 5:f4de114c31c3 113 int screenHeight;
embeddedartists 5:f4de114c31c3 114 int screenPixels;
embeddedartists 5:f4de114c31c3 115 int screenBytes;
embeddedartists 5:f4de114c31c3 116 int activeBackBuffer;
embeddedartists 5:f4de114c31c3 117
embeddedartists 5:f4de114c31c3 118 image_t ImageBackBuffer[2];
embeddedartists 5:f4de114c31c3 119
embeddedartists 5:f4de114c31c3 120 Display* display;
embeddedartists 5:f4de114c31c3 121 };
embeddedartists 5:f4de114c31c3 122
embeddedartists 5:f4de114c31c3 123 #endif
embeddedartists 5:f4de114c31c3 124
embeddedartists 5:f4de114c31c3 125
embeddedartists 5:f4de114c31c3 126