Jonne Valola / PokittoLib Featured

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Wed Oct 11 20:35:52 2017 +0000
Revision:
6:72f87b7c7400
Fixed PokittoLib to fully working. Includes mbed-src

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 6:72f87b7c7400 1 /**************************************************************************/
Pokitto 6:72f87b7c7400 2 /*!
Pokitto 6:72f87b7c7400 3 @file PokittoDisplay.h
Pokitto 6:72f87b7c7400 4 @author Jonne Valola
Pokitto 6:72f87b7c7400 5
Pokitto 6:72f87b7c7400 6 @section LICENSE
Pokitto 6:72f87b7c7400 7
Pokitto 6:72f87b7c7400 8 Software License Agreement (BSD License)
Pokitto 6:72f87b7c7400 9
Pokitto 6:72f87b7c7400 10 Copyright (c) 2016, Jonne Valola
Pokitto 6:72f87b7c7400 11 All rights reserved.
Pokitto 6:72f87b7c7400 12
Pokitto 6:72f87b7c7400 13 Redistribution and use in source and binary forms, with or without
Pokitto 6:72f87b7c7400 14 modification, are permitted provided that the following conditions are met:
Pokitto 6:72f87b7c7400 15 1. Redistributions of source code must retain the above copyright
Pokitto 6:72f87b7c7400 16 notice, this list of conditions and the following disclaimer.
Pokitto 6:72f87b7c7400 17 2. Redistributions in binary form must reproduce the above copyright
Pokitto 6:72f87b7c7400 18 notice, this list of conditions and the following disclaimer in the
Pokitto 6:72f87b7c7400 19 documentation and/or other materials provided with the distribution.
Pokitto 6:72f87b7c7400 20 3. Neither the name of the copyright holders nor the
Pokitto 6:72f87b7c7400 21 names of its contributors may be used to endorse or promote products
Pokitto 6:72f87b7c7400 22 derived from this software without specific prior written permission.
Pokitto 6:72f87b7c7400 23
Pokitto 6:72f87b7c7400 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Pokitto 6:72f87b7c7400 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Pokitto 6:72f87b7c7400 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Pokitto 6:72f87b7c7400 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Pokitto 6:72f87b7c7400 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Pokitto 6:72f87b7c7400 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Pokitto 6:72f87b7c7400 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Pokitto 6:72f87b7c7400 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Pokitto 6:72f87b7c7400 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Pokitto 6:72f87b7c7400 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pokitto 6:72f87b7c7400 34 */
Pokitto 6:72f87b7c7400 35 /**************************************************************************/
Pokitto 6:72f87b7c7400 36
Pokitto 6:72f87b7c7400 37
Pokitto 6:72f87b7c7400 38
Pokitto 6:72f87b7c7400 39 /* THE SEGMENT BELOW PERTAINS TO CIRCLE DRAWING FUNCTIONS ONLY
Pokitto 6:72f87b7c7400 40 *
Pokitto 6:72f87b7c7400 41 This is the core graphics library for all our displays, providing a common
Pokitto 6:72f87b7c7400 42 set of graphics primitives (points, lines, circles, etc.). It needs to be
Pokitto 6:72f87b7c7400 43 paired with a hardware-specific library for each display device we carry
Pokitto 6:72f87b7c7400 44 (to handle the lower-level functions).
Pokitto 6:72f87b7c7400 45 Adafruit invests time and resources providing this open source code, please
Pokitto 6:72f87b7c7400 46 support Adafruit & open-source hardware by purchasing products from Adafruit!
Pokitto 6:72f87b7c7400 47 Copyright (c) 2013 Adafruit Industries. All rights reserved.
Pokitto 6:72f87b7c7400 48 Redistribution and use in source and binary forms, with or without
Pokitto 6:72f87b7c7400 49 modification, are permitted provided that the following conditions are met:
Pokitto 6:72f87b7c7400 50 - Redistributions of source code must retain the above copyright notice,
Pokitto 6:72f87b7c7400 51 this list of conditions and the following disclaimer.
Pokitto 6:72f87b7c7400 52 - Redistributions in binary form must reproduce the above copyright notice,
Pokitto 6:72f87b7c7400 53 this list of conditions and the following disclaimer in the documentation
Pokitto 6:72f87b7c7400 54 and/or other materials provided with the distribution.
Pokitto 6:72f87b7c7400 55 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Pokitto 6:72f87b7c7400 56 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Pokitto 6:72f87b7c7400 57 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Pokitto 6:72f87b7c7400 58 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
Pokitto 6:72f87b7c7400 59 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Pokitto 6:72f87b7c7400 60 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Pokitto 6:72f87b7c7400 61 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Pokitto 6:72f87b7c7400 62 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Pokitto 6:72f87b7c7400 63 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Pokitto 6:72f87b7c7400 64 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Pokitto 6:72f87b7c7400 65 POSSIBILITY OF SUCH DAMAGE.
Pokitto 6:72f87b7c7400 66 */
Pokitto 6:72f87b7c7400 67
Pokitto 6:72f87b7c7400 68 #ifndef POKITTODISPLAY_H
Pokitto 6:72f87b7c7400 69 #define POKITTODISPLAY_H
Pokitto 6:72f87b7c7400 70
Pokitto 6:72f87b7c7400 71 #include <stdint.h>
Pokitto 6:72f87b7c7400 72 #include "Pokitto_settings.h"
Pokitto 6:72f87b7c7400 73 #include "PokittoGlobs.h"
Pokitto 6:72f87b7c7400 74 #include "PokittoFonts.h"
Pokitto 6:72f87b7c7400 75 #include "PokittoPalettes.h"
Pokitto 6:72f87b7c7400 76
Pokitto 6:72f87b7c7400 77 // Basic Color definitions
Pokitto 6:72f87b7c7400 78 #define COLOR_BLACK (uint16_t)(0x0000)
Pokitto 6:72f87b7c7400 79 #define COLOR_BLUE (uint16_t)(0x001F)
Pokitto 6:72f87b7c7400 80 #define COLOR_RED (uint16_t)(0xF800)
Pokitto 6:72f87b7c7400 81 #define COLOR_GREEN (uint16_t)(0x07E0)
Pokitto 6:72f87b7c7400 82 #define COLOR_CYAN (uint16_t)(0x07FF)
Pokitto 6:72f87b7c7400 83 #define COLOR_MAGENTA (uint16_t)(0xF81F)
Pokitto 6:72f87b7c7400 84 #define COLOR_YELLOW (uint16_t)(0xFFE0)
Pokitto 6:72f87b7c7400 85 #define COLOR_WHITE (uint16_t)(0xFFFF)
Pokitto 6:72f87b7c7400 86
Pokitto 6:72f87b7c7400 87 // Grayscale Values
Pokitto 6:72f87b7c7400 88 #define COLOR_GRAY_15 (uint16_t)(0x0861) // 15 15 15
Pokitto 6:72f87b7c7400 89 #define COLOR_GRAY_30 (uint16_t)(0x18E3) // 30 30 30
Pokitto 6:72f87b7c7400 90 #define COLOR_GRAY_50 (uint16_t)(0x3186) // 50 50 50
Pokitto 6:72f87b7c7400 91 #define COLOR_GRAY_80 (uint16_t)(0x528A) // 80 80 80
Pokitto 6:72f87b7c7400 92 #define COLOR_GRAY_128 (uint16_t)(0x8410) // 128 128 128
Pokitto 6:72f87b7c7400 93 #define COLOR_GRAY_200 (uint16_t)(0xCE59) // 200 200 200
Pokitto 6:72f87b7c7400 94 #define COLOR_GRAY_225 (uint16_t)(0xE71C) // 225 225 225
Pokitto 6:72f87b7c7400 95
Pokitto 6:72f87b7c7400 96 /** The tables below are palettes, that resemble the Pico 8 palette*/
Pokitto 6:72f87b7c7400 97
Pokitto 6:72f87b7c7400 98 enum defcolors {
Pokitto 6:72f87b7c7400 99 C_BLACK,
Pokitto 6:72f87b7c7400 100 C_DARKBLUE,
Pokitto 6:72f87b7c7400 101 C_PURPLE,
Pokitto 6:72f87b7c7400 102 C_DARKGREEN,
Pokitto 6:72f87b7c7400 103
Pokitto 6:72f87b7c7400 104 C_BROWN,
Pokitto 6:72f87b7c7400 105 C_DARKBROWN,
Pokitto 6:72f87b7c7400 106 C_LIGHTGRAY,
Pokitto 6:72f87b7c7400 107 C_WHITE,
Pokitto 6:72f87b7c7400 108
Pokitto 6:72f87b7c7400 109 C_RED,
Pokitto 6:72f87b7c7400 110 C_ORANGE,
Pokitto 6:72f87b7c7400 111 C_YELLOW,
Pokitto 6:72f87b7c7400 112 C_GREEN,
Pokitto 6:72f87b7c7400 113
Pokitto 6:72f87b7c7400 114 C_BLUE,
Pokitto 6:72f87b7c7400 115 C_DARKGRAY,
Pokitto 6:72f87b7c7400 116 C_PINK,
Pokitto 6:72f87b7c7400 117 C_PEACH
Pokitto 6:72f87b7c7400 118 };
Pokitto 6:72f87b7c7400 119
Pokitto 6:72f87b7c7400 120 const uint16_t def565palette[16] = {
Pokitto 6:72f87b7c7400 121 //kind of like pico8 palette
Pokitto 6:72f87b7c7400 122 0,0x194a,0x792a,0x42a,
Pokitto 6:72f87b7c7400 123 0xaa86,0x5aa9,0xc618,0xff9d,
Pokitto 6:72f87b7c7400 124 0xf809,0xfd00,0xff84,0x72a,
Pokitto 6:72f87b7c7400 125 0x2d7f,0x83b3,0xfbb5,0xfe75
Pokitto 6:72f87b7c7400 126 };
Pokitto 6:72f87b7c7400 127
Pokitto 6:72f87b7c7400 128 #define PALETTE_SIZE 16
Pokitto 6:72f87b7c7400 129 #include <stdint.h>
Pokitto 6:72f87b7c7400 130 #include <stdlib.h>
Pokitto 6:72f87b7c7400 131 #include <string.h>
Pokitto 6:72f87b7c7400 132
Pokitto 6:72f87b7c7400 133
Pokitto 6:72f87b7c7400 134 namespace Pokitto {
Pokitto 6:72f87b7c7400 135
Pokitto 6:72f87b7c7400 136 class Display {
Pokitto 6:72f87b7c7400 137 public:
Pokitto 6:72f87b7c7400 138 Display();
Pokitto 6:72f87b7c7400 139
Pokitto 6:72f87b7c7400 140 // PROPERTIES
Pokitto 6:72f87b7c7400 141 private:
Pokitto 6:72f87b7c7400 142 static uint8_t* canvas;
Pokitto 6:72f87b7c7400 143 static uint8_t bpp;
Pokitto 6:72f87b7c7400 144 static uint8_t m_colordepth;
Pokitto 6:72f87b7c7400 145 public:
Pokitto 6:72f87b7c7400 146 static uint8_t width;
Pokitto 6:72f87b7c7400 147 static uint8_t height;
Pokitto 6:72f87b7c7400 148 static uint8_t screenbuffer[];
Pokitto 6:72f87b7c7400 149
Pokitto 6:72f87b7c7400 150 // PROPERTIES
Pokitto 6:72f87b7c7400 151 static void setColorDepth(uint8_t);
Pokitto 6:72f87b7c7400 152 static uint8_t getColorDepth();
Pokitto 6:72f87b7c7400 153 static uint8_t getBitsPerPixel();
Pokitto 6:72f87b7c7400 154 static uint16_t getWidth();
Pokitto 6:72f87b7c7400 155 static uint16_t getHeight();
Pokitto 6:72f87b7c7400 156 static uint8_t getNumberOfColors();
Pokitto 6:72f87b7c7400 157
Pokitto 6:72f87b7c7400 158 // IMPORTANT PUBLIC STATE MEMBERS
Pokitto 6:72f87b7c7400 159 /** Selected font */
Pokitto 6:72f87b7c7400 160 static const unsigned char * font;
Pokitto 6:72f87b7c7400 161 /** Set if screen is cleared between updates or not*/
Pokitto 6:72f87b7c7400 162 static uint8_t persistence;
Pokitto 6:72f87b7c7400 163 /** Selected drawing color */
Pokitto 6:72f87b7c7400 164 static uint16_t color;
Pokitto 6:72f87b7c7400 165 /** Selected background color */
Pokitto 6:72f87b7c7400 166 static uint16_t bgcolor;
Pokitto 6:72f87b7c7400 167 /** Selected invisible color */
Pokitto 6:72f87b7c7400 168 static uint16_t invisiblecolor;
Pokitto 6:72f87b7c7400 169 /** Direct unbuffered color */
Pokitto 6:72f87b7c7400 170 static uint16_t directcolor;
Pokitto 6:72f87b7c7400 171 /** Direct unbuffered background color */
Pokitto 6:72f87b7c7400 172 static uint16_t directbgcolor;
Pokitto 6:72f87b7c7400 173 /** set color with a command */
Pokitto 6:72f87b7c7400 174 static void setColor(uint8_t);
Pokitto 6:72f87b7c7400 175 /** set color and bgcolor with a command */
Pokitto 6:72f87b7c7400 176 static void setColor(uint8_t,uint8_t);
Pokitto 6:72f87b7c7400 177 /** set invisiblecolor with a command */
Pokitto 6:72f87b7c7400 178 static void setInvisibleColor(uint16_t);
Pokitto 6:72f87b7c7400 179 /** get color */
Pokitto 6:72f87b7c7400 180 static uint8_t getColor();
Pokitto 6:72f87b7c7400 181 /** get background color */
Pokitto 6:72f87b7c7400 182 static uint8_t getBgColor();
Pokitto 6:72f87b7c7400 183 /** get invisible color */
Pokitto 6:72f87b7c7400 184 static uint16_t getInvisibleColor();
Pokitto 6:72f87b7c7400 185
Pokitto 6:72f87b7c7400 186
Pokitto 6:72f87b7c7400 187 /** Initialize display */
Pokitto 6:72f87b7c7400 188 static void begin();
Pokitto 6:72f87b7c7400 189 /** Clear display buffer */
Pokitto 6:72f87b7c7400 190 static void clear();
Pokitto 6:72f87b7c7400 191 /** Scroll by x lines */
Pokitto 6:72f87b7c7400 192 static void scroll(int16_t);
Pokitto 6:72f87b7c7400 193 /** Fill display buffer */
Pokitto 6:72f87b7c7400 194 static void fillScreen(uint16_t);
Pokitto 6:72f87b7c7400 195 /** Send display buffer to display hardware */
Pokitto 6:72f87b7c7400 196 static void update();
Pokitto 6:72f87b7c7400 197 /** Forced update of LCD display memory with a given pixel buffer */
Pokitto 6:72f87b7c7400 198 static void lcdRefresh(unsigned char*);
Pokitto 6:72f87b7c7400 199 /** Clear LCD hardware memory */
Pokitto 6:72f87b7c7400 200 static void clearLCD();
Pokitto 6:72f87b7c7400 201 /** Fill LCD hardware memory */
Pokitto 6:72f87b7c7400 202 static void fillLCD(uint16_t);
Pokitto 6:72f87b7c7400 203 /** Show Pokitto logo at startup*/
Pokitto 6:72f87b7c7400 204 static void showLogo();
Pokitto 6:72f87b7c7400 205 /** Point to another screenbuffer instead of the default one */
Pokitto 6:72f87b7c7400 206 static void setFrameBufferTo(uint8_t*);
Pokitto 6:72f87b7c7400 207
Pokitto 6:72f87b7c7400 208 // COLORS AND PALETTE
Pokitto 6:72f87b7c7400 209 public:
Pokitto 6:72f87b7c7400 210 /** set default palette */
Pokitto 6:72f87b7c7400 211 static void setDefaultPalette();
Pokitto 6:72f87b7c7400 212 /** master palette */
Pokitto 6:72f87b7c7400 213 static uint16_t palette[PALETTE_SIZE];
Pokitto 6:72f87b7c7400 214 /** runtime palette pointer */
Pokitto 6:72f87b7c7400 215 static uint16_t *paletteptr;
Pokitto 6:72f87b7c7400 216 /** convert RGB to 565 color value */
Pokitto 6:72f87b7c7400 217 static uint16_t RGBto565(uint8_t,uint8_t,uint8_t);
Pokitto 6:72f87b7c7400 218 /** linear interpolation between colors */
Pokitto 6:72f87b7c7400 219 static uint16_t interpolateColor(uint16_t, uint16_t, uint8_t);
Pokitto 6:72f87b7c7400 220 /** load an R,G,B triplet palette */
Pokitto 6:72f87b7c7400 221 static void loadRGBPalette(const unsigned char*);
Pokitto 6:72f87b7c7400 222 /** load a ready-made 565 palette */
Pokitto 6:72f87b7c7400 223 static void load565Palette(const uint16_t*);
Pokitto 6:72f87b7c7400 224 /** rotate palette by step */
Pokitto 6:72f87b7c7400 225 static void rotatePalette(int8_t);
Pokitto 6:72f87b7c7400 226 /** tween between two palettes **/
Pokitto 6:72f87b7c7400 227 static void tweenPalette(uint16_t*, const uint16_t*, const uint16_t*, uint8_t);
Pokitto 6:72f87b7c7400 228
Pokitto 6:72f87b7c7400 229 // DIRECT DRAWING (NO BUFFERING)
Pokitto 6:72f87b7c7400 230 /** Direct pixel (not through display buffer) */
Pokitto 6:72f87b7c7400 231 static void directPixel(int16_t,int16_t,uint16_t);
Pokitto 6:72f87b7c7400 232 /** Direct rectangle (not through display buffer) */
Pokitto 6:72f87b7c7400 233 static void directRectangle(int16_t, int16_t,int16_t, int16_t, uint16_t);
Pokitto 6:72f87b7c7400 234 /** Set the cursor for printing to a certain screen position */
Pokitto 6:72f87b7c7400 235 static void setCursor(int16_t,int16_t);
Pokitto 6:72f87b7c7400 236 /** direct bitmap to screen (no buffering) */
Pokitto 6:72f87b7c7400 237 static void directBitmap(int16_t,int16_t,const uint8_t*, uint8_t,uint8_t);
Pokitto 6:72f87b7c7400 238
Pokitto 6:72f87b7c7400 239
Pokitto 6:72f87b7c7400 240 // DRAWING METHODS
Pokitto 6:72f87b7c7400 241 /** Draw pixel at various bit depths */
Pokitto 6:72f87b7c7400 242 static void drawPixel(int16_t,int16_t);
Pokitto 6:72f87b7c7400 243 /** Draw pixel with specific color index at various bit depths */
Pokitto 6:72f87b7c7400 244 static void drawPixel(int16_t x,int16_t y, uint8_t col);
Pokitto 6:72f87b7c7400 245 /** Get pixel at various bit depths */
Pokitto 6:72f87b7c7400 246 static uint8_t getPixel(int16_t,int16_t);
Pokitto 6:72f87b7c7400 247 /** Draw line **/
Pokitto 6:72f87b7c7400 248 static void drawLine(int16_t,int16_t,int16_t,int16_t);
Pokitto 6:72f87b7c7400 249 /** Clip line with screen boundaries, returns 0 if whole line is out of bounds */
Pokitto 6:72f87b7c7400 250 static uint8_t clipLine(int16_t*, int16_t*, int16_t*, int16_t*);
Pokitto 6:72f87b7c7400 251 /** Draw a column real fast */
Pokitto 6:72f87b7c7400 252 static void drawColumn(int16_t, int16_t, int16_t);
Pokitto 6:72f87b7c7400 253 /** Map a 1-bit column real fast */
Pokitto 6:72f87b7c7400 254 static void map1BitColumn(int16_t, int16_t, int16_t, const uint8_t*, uint16_t);
Pokitto 6:72f87b7c7400 255 /** Draw a row real fast */
Pokitto 6:72f87b7c7400 256 static void drawRow(int16_t, int16_t, int16_t);
Pokitto 6:72f87b7c7400 257 /** Legacy drawColumn name, for compatibility - macros are not OK because of scope problems */
Pokitto 6:72f87b7c7400 258 static void drawFastVLine(int16_t, int16_t, int16_t);
Pokitto 6:72f87b7c7400 259 /** Legacy drawRow name, for compatibility - macros are not OK because of scope problems */
Pokitto 6:72f87b7c7400 260 static void drawFastHLine(int16_t, int16_t, int16_t);
Pokitto 6:72f87b7c7400 261 /** Draw rectangle (edges only) */
Pokitto 6:72f87b7c7400 262 static void drawRectangle(int16_t,int16_t,int16_t,int16_t);
Pokitto 6:72f87b7c7400 263 /** Fill rectangle */
Pokitto 6:72f87b7c7400 264 static void fillRectangle(int16_t,int16_t,int16_t,int16_t);
Pokitto 6:72f87b7c7400 265 /** GB compatibility fillRect */
Pokitto 6:72f87b7c7400 266 static void fillRect(int16_t x, int16_t y, int16_t w, int16_t h);
Pokitto 6:72f87b7c7400 267 /** GB compatibility drawRect */
Pokitto 6:72f87b7c7400 268 static void drawRect(int16_t x, int16_t y, int16_t w, int16_t h);
Pokitto 6:72f87b7c7400 269
Pokitto 6:72f87b7c7400 270 // Functions lifted from Adafruit GFX library (see PokittoDisplay.h for license //
Pokitto 6:72f87b7c7400 271 /** Draw circle */
Pokitto 6:72f87b7c7400 272 static void drawCircle(int16_t x0, int16_t y0, int16_t r);
Pokitto 6:72f87b7c7400 273 /** Draw circle helper */
Pokitto 6:72f87b7c7400 274 static void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t cornername);
Pokitto 6:72f87b7c7400 275 /** Fill circle */
Pokitto 6:72f87b7c7400 276 static void fillCircle(int16_t x0, int16_t y0, int16_t r);
Pokitto 6:72f87b7c7400 277 /** Fill circle helper*/
Pokitto 6:72f87b7c7400 278 static void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t cornername, int16_t delta);
Pokitto 6:72f87b7c7400 279 /** draw triangle */
Pokitto 6:72f87b7c7400 280 static void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
Pokitto 6:72f87b7c7400 281 /** Fill triangle*/
Pokitto 6:72f87b7c7400 282 static void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
Pokitto 6:72f87b7c7400 283 /** Draw rounded rectangle */
Pokitto 6:72f87b7c7400 284 static void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius);
Pokitto 6:72f87b7c7400 285 /** Fill rounded rectangle */
Pokitto 6:72f87b7c7400 286 static void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius);
Pokitto 6:72f87b7c7400 287
Pokitto 6:72f87b7c7400 288 // BITMAPS !
Pokitto 6:72f87b7c7400 289 /** Draw monochromatic bitmap. Used in font rendering */
Pokitto 6:72f87b7c7400 290 static void drawMonoBitmap(int16_t x, int16_t y, const uint8_t* bitmap, uint8_t index);
Pokitto 6:72f87b7c7400 291 /** Draw bitmap */
Pokitto 6:72f87b7c7400 292 static void drawBitmap(int16_t x, int16_t y, const uint8_t* bitmap);
Pokitto 6:72f87b7c7400 293 /** Draw RLE bitmap */
Pokitto 6:72f87b7c7400 294 static void drawRleBitmap(int16_t x, int16_t y, const uint8_t* bitmap);
Pokitto 6:72f87b7c7400 295 /** Draw animated bitmap frame */
Pokitto 6:72f87b7c7400 296 static void drawBitmap(int16_t x, int16_t y, const uint8_t* bitmap, uint8_t frame);
Pokitto 6:72f87b7c7400 297 /** Draw bitmap flipped on x-axis*/
Pokitto 6:72f87b7c7400 298 static void drawBitmapXFlipped(int16_t x, int16_t y, const uint8_t* bitmap);
Pokitto 6:72f87b7c7400 299 /** Draw bitmap with options */
Pokitto 6:72f87b7c7400 300 static void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t rotation, uint8_t flip);
Pokitto 6:72f87b7c7400 301 /** Get pointer to the screen buffer - GB compatibility */
Pokitto 6:72f87b7c7400 302 static uint8_t* getBuffer();
Pokitto 6:72f87b7c7400 303 /** Get pixel in a monochromatic bitmap - GB compatibility */
Pokitto 6:72f87b7c7400 304 static uint8_t getBitmapPixel(const uint8_t*, uint16_t, uint16_t);
Pokitto 6:72f87b7c7400 305 /** Optimized functions for drawing bit columns - used in raytracing */
Pokitto 6:72f87b7c7400 306 static void draw4BitColumn(int16_t x, int16_t y, uint8_t h, uint8_t* bitmap);
Pokitto 6:72f87b7c7400 307
Pokitto 6:72f87b7c7400 308 // PRINTING
Pokitto 6:72f87b7c7400 309 /** direct character to screen (no buffering) */
Pokitto 6:72f87b7c7400 310 static int directChar(int16_t, int16_t, uint16_t);
Pokitto 6:72f87b7c7400 311 /** character to screenbuffer */
Pokitto 6:72f87b7c7400 312 static int bufferChar(int16_t, int16_t, uint16_t);
Pokitto 6:72f87b7c7400 313 /** set the active font */
Pokitto 6:72f87b7c7400 314 static void setFont(const unsigned char * f);
Pokitto 6:72f87b7c7400 315 /** font dimensions */
Pokitto 6:72f87b7c7400 316 static uint8_t fontWidth, fontHeight;
Pokitto 6:72f87b7c7400 317 /** text wrapping */
Pokitto 6:72f87b7c7400 318 static bool textWrap;
Pokitto 6:72f87b7c7400 319 /** GB compatibility drawChar */
Pokitto 6:72f87b7c7400 320 static void drawChar(int8_t x, int8_t y, unsigned char c, uint8_t size);
Pokitto 6:72f87b7c7400 321
Pokitto 6:72f87b7c7400 322 static void enableDirectPrinting(uint8_t m);
Pokitto 6:72f87b7c7400 323 static bool isDirectPrintingEnabled();
Pokitto 6:72f87b7c7400 324 static int print_char(uint8_t x, uint8_t y, unsigned char c);
Pokitto 6:72f87b7c7400 325 static void set_cursor(uint8_t, uint8_t);
Pokitto 6:72f87b7c7400 326 static void write(uint8_t);
Pokitto 6:72f87b7c7400 327 static void write(const char *str);
Pokitto 6:72f87b7c7400 328 static void write(const uint8_t *buffer, uint8_t size);
Pokitto 6:72f87b7c7400 329 static void print(const char[]);
Pokitto 6:72f87b7c7400 330 static void print(char, int base = 0);
Pokitto 6:72f87b7c7400 331 static void print(unsigned char, int base = 0);
Pokitto 6:72f87b7c7400 332 static void print(int, int base = 10);
Pokitto 6:72f87b7c7400 333 static void print(unsigned int, int base = 10);
Pokitto 6:72f87b7c7400 334 static void print(long, int base = 10);
Pokitto 6:72f87b7c7400 335 static void print(unsigned long, int base = 10);
Pokitto 6:72f87b7c7400 336 static void print(double, int base = 2);
Pokitto 6:72f87b7c7400 337 static void print(uint8_t, uint8_t, const char[]);
Pokitto 6:72f87b7c7400 338 static void print(uint8_t, uint8_t, char, int = 0);
Pokitto 6:72f87b7c7400 339 static void print(uint8_t, uint8_t, unsigned char, int = 0);
Pokitto 6:72f87b7c7400 340 static void print(uint8_t, uint8_t, int, int = 10);
Pokitto 6:72f87b7c7400 341 static void print(uint8_t, uint8_t, unsigned int, int = 10);
Pokitto 6:72f87b7c7400 342 static void print(uint8_t, uint8_t, long, int = 10);
Pokitto 6:72f87b7c7400 343 static void print(uint8_t, uint8_t, unsigned long, int = 10);
Pokitto 6:72f87b7c7400 344 static void print(uint8_t, uint8_t, double, int = 2);
Pokitto 6:72f87b7c7400 345 static void println(uint8_t, uint8_t, const char[]);
Pokitto 6:72f87b7c7400 346 static void println(uint8_t, uint8_t, char, int = 0);
Pokitto 6:72f87b7c7400 347 static void println(uint8_t, uint8_t, unsigned char, int = 0);
Pokitto 6:72f87b7c7400 348 static void println(uint8_t, uint8_t, int, int = 10);
Pokitto 6:72f87b7c7400 349 static void println(uint8_t, uint8_t, unsigned int, int = 10);
Pokitto 6:72f87b7c7400 350 static void println(uint8_t, uint8_t, long, int = 10);
Pokitto 6:72f87b7c7400 351 static void println(uint8_t, uint8_t, unsigned long, int = 10);
Pokitto 6:72f87b7c7400 352 static void println(uint8_t, uint8_t, double, int = 2);
Pokitto 6:72f87b7c7400 353 static void println(uint8_t, uint8_t);
Pokitto 6:72f87b7c7400 354 static void println(const char[]);
Pokitto 6:72f87b7c7400 355 static void println(char, int = 0);
Pokitto 6:72f87b7c7400 356 static void println(unsigned char, int = 0);
Pokitto 6:72f87b7c7400 357 static void println(int, int = 10);
Pokitto 6:72f87b7c7400 358 static void println(unsigned int, int = 10);
Pokitto 6:72f87b7c7400 359 static void println(long, int = 10 );
Pokitto 6:72f87b7c7400 360 static void println(unsigned long, int = 10);
Pokitto 6:72f87b7c7400 361 static void println(double, int = 2);
Pokitto 6:72f87b7c7400 362 static void println(void);
Pokitto 6:72f87b7c7400 363
Pokitto 6:72f87b7c7400 364 static int16_t cursorX,cursorY;
Pokitto 6:72f87b7c7400 365 static uint8_t fontSize;
Pokitto 6:72f87b7c7400 366 static int8_t adjustCharStep, adjustLineStep;
Pokitto 6:72f87b7c7400 367 static bool fixedWidthFont;
Pokitto 6:72f87b7c7400 368
Pokitto 6:72f87b7c7400 369 static void inc_txtline();
Pokitto 6:72f87b7c7400 370 static void printNumber(unsigned long, uint8_t);
Pokitto 6:72f87b7c7400 371 static void printFloat(double, uint8_t);
Pokitto 6:72f87b7c7400 372
Pokitto 6:72f87b7c7400 373 /** Tiled mode functions **/
Pokitto 6:72f87b7c7400 374
Pokitto 6:72f87b7c7400 375 static void loadTileset(const uint8_t*);
Pokitto 6:72f87b7c7400 376
Pokitto 6:72f87b7c7400 377 static void setTileBufferTo(uint8_t*);
Pokitto 6:72f87b7c7400 378 static void clearTileBuffer();
Pokitto 6:72f87b7c7400 379 static void shiftTileBuffer(int8_t,int8_t);
Pokitto 6:72f87b7c7400 380
Pokitto 6:72f87b7c7400 381 static void setTile(uint16_t,uint8_t);
Pokitto 6:72f87b7c7400 382 static uint8_t getTile(uint16_t);
Pokitto 6:72f87b7c7400 383 static uint8_t getTile(uint8_t,uint8_t);
Pokitto 6:72f87b7c7400 384
Pokitto 6:72f87b7c7400 385
Pokitto 6:72f87b7c7400 386
Pokitto 6:72f87b7c7400 387 private:
Pokitto 6:72f87b7c7400 388 static uint8_t m_mode;
Pokitto 6:72f87b7c7400 389 static uint16_t m_w,m_h; // store these for faster access when switching printing modes
Pokitto 6:72f87b7c7400 390 /** Pointer to screen buffer */
Pokitto 6:72f87b7c7400 391 static uint8_t* m_scrbuf;
Pokitto 6:72f87b7c7400 392 /** Pointer to tileset */
Pokitto 6:72f87b7c7400 393 static uint8_t* m_tileset;
Pokitto 6:72f87b7c7400 394 /** Pointer to tilebuffer */
Pokitto 6:72f87b7c7400 395 static uint8_t* m_tilebuf;
Pokitto 6:72f87b7c7400 396 /** Pointer to tilecolorbuffer */
Pokitto 6:72f87b7c7400 397 static uint8_t* m_tilecolorbuf;
Pokitto 6:72f87b7c7400 398
Pokitto 6:72f87b7c7400 399 };
Pokitto 6:72f87b7c7400 400
Pokitto 6:72f87b7c7400 401 }
Pokitto 6:72f87b7c7400 402
Pokitto 6:72f87b7c7400 403 #endif // POKITTODISPLAY_H
Pokitto 6:72f87b7c7400 404
Pokitto 6:72f87b7c7400 405
Pokitto 6:72f87b7c7400 406
Pokitto 6:72f87b7c7400 407