Christian Weiß
/
TINF_Testvorbereitung2_copy
TINF_Testvorbereitung2_copy
C12832/GraphicsDisplay.cpp@0:028eb27f452d, 2018-11-15 (annotated)
- Committer:
- Wizo
- Date:
- Thu Nov 15 18:10:55 2018 +0000
- Revision:
- 0:028eb27f452d
TINF_Testvorbereitung2_copy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wizo | 0:028eb27f452d | 1 | /* mbed GraphicsDisplay Display Library Base Class |
Wizo | 0:028eb27f452d | 2 | * Copyright (c) 2007-2009 sford |
Wizo | 0:028eb27f452d | 3 | * Released under the MIT License: http://mbed.org/license/mit |
Wizo | 0:028eb27f452d | 4 | */ |
Wizo | 0:028eb27f452d | 5 | |
Wizo | 0:028eb27f452d | 6 | #include "GraphicsDisplay.h" |
Wizo | 0:028eb27f452d | 7 | |
Wizo | 0:028eb27f452d | 8 | const unsigned char FONT8x8[97][8] = { |
Wizo | 0:028eb27f452d | 9 | 0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per_char |
Wizo | 0:028eb27f452d | 10 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20 |
Wizo | 0:028eb27f452d | 11 | 0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // ! |
Wizo | 0:028eb27f452d | 12 | 0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // " |
Wizo | 0:028eb27f452d | 13 | 0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // # |
Wizo | 0:028eb27f452d | 14 | 0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $ |
Wizo | 0:028eb27f452d | 15 | 0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // % |
Wizo | 0:028eb27f452d | 16 | 0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // & |
Wizo | 0:028eb27f452d | 17 | 0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // ' |
Wizo | 0:028eb27f452d | 18 | 0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // ( |
Wizo | 0:028eb27f452d | 19 | 0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // ) |
Wizo | 0:028eb27f452d | 20 | 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // * |
Wizo | 0:028eb27f452d | 21 | 0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // + |
Wizo | 0:028eb27f452d | 22 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // , |
Wizo | 0:028eb27f452d | 23 | 0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // - |
Wizo | 0:028eb27f452d | 24 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // . |
Wizo | 0:028eb27f452d | 25 | 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash) |
Wizo | 0:028eb27f452d | 26 | 0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30 |
Wizo | 0:028eb27f452d | 27 | 0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1 |
Wizo | 0:028eb27f452d | 28 | 0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2 |
Wizo | 0:028eb27f452d | 29 | 0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3 |
Wizo | 0:028eb27f452d | 30 | 0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4 |
Wizo | 0:028eb27f452d | 31 | 0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5 |
Wizo | 0:028eb27f452d | 32 | 0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6 |
Wizo | 0:028eb27f452d | 33 | 0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7 |
Wizo | 0:028eb27f452d | 34 | 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8 |
Wizo | 0:028eb27f452d | 35 | 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9 |
Wizo | 0:028eb27f452d | 36 | 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // : |
Wizo | 0:028eb27f452d | 37 | 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ; |
Wizo | 0:028eb27f452d | 38 | 0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // < |
Wizo | 0:028eb27f452d | 39 | 0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // = |
Wizo | 0:028eb27f452d | 40 | 0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // > |
Wizo | 0:028eb27f452d | 41 | 0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ? |
Wizo | 0:028eb27f452d | 42 | 0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40 |
Wizo | 0:028eb27f452d | 43 | 0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A |
Wizo | 0:028eb27f452d | 44 | 0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B |
Wizo | 0:028eb27f452d | 45 | 0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C |
Wizo | 0:028eb27f452d | 46 | 0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D |
Wizo | 0:028eb27f452d | 47 | 0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E |
Wizo | 0:028eb27f452d | 48 | 0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F |
Wizo | 0:028eb27f452d | 49 | 0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G |
Wizo | 0:028eb27f452d | 50 | 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H |
Wizo | 0:028eb27f452d | 51 | 0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I |
Wizo | 0:028eb27f452d | 52 | 0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J |
Wizo | 0:028eb27f452d | 53 | 0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K |
Wizo | 0:028eb27f452d | 54 | 0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L |
Wizo | 0:028eb27f452d | 55 | 0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M |
Wizo | 0:028eb27f452d | 56 | 0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N |
Wizo | 0:028eb27f452d | 57 | 0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O |
Wizo | 0:028eb27f452d | 58 | 0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50 |
Wizo | 0:028eb27f452d | 59 | 0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q |
Wizo | 0:028eb27f452d | 60 | 0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R |
Wizo | 0:028eb27f452d | 61 | 0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S |
Wizo | 0:028eb27f452d | 62 | 0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T |
Wizo | 0:028eb27f452d | 63 | 0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U |
Wizo | 0:028eb27f452d | 64 | 0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V |
Wizo | 0:028eb27f452d | 65 | 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W |
Wizo | 0:028eb27f452d | 66 | 0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X |
Wizo | 0:028eb27f452d | 67 | 0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y |
Wizo | 0:028eb27f452d | 68 | 0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z |
Wizo | 0:028eb27f452d | 69 | 0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [ |
Wizo | 0:028eb27f452d | 70 | 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash) |
Wizo | 0:028eb27f452d | 71 | 0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ] |
Wizo | 0:028eb27f452d | 72 | 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^ |
Wizo | 0:028eb27f452d | 73 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _ |
Wizo | 0:028eb27f452d | 74 | 0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60 |
Wizo | 0:028eb27f452d | 75 | 0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a |
Wizo | 0:028eb27f452d | 76 | 0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b |
Wizo | 0:028eb27f452d | 77 | 0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c |
Wizo | 0:028eb27f452d | 78 | 0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d |
Wizo | 0:028eb27f452d | 79 | 0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e |
Wizo | 0:028eb27f452d | 80 | 0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f |
Wizo | 0:028eb27f452d | 81 | 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g |
Wizo | 0:028eb27f452d | 82 | 0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h |
Wizo | 0:028eb27f452d | 83 | 0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i |
Wizo | 0:028eb27f452d | 84 | 0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j |
Wizo | 0:028eb27f452d | 85 | 0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k |
Wizo | 0:028eb27f452d | 86 | 0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l |
Wizo | 0:028eb27f452d | 87 | 0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m |
Wizo | 0:028eb27f452d | 88 | 0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n |
Wizo | 0:028eb27f452d | 89 | 0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o |
Wizo | 0:028eb27f452d | 90 | 0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p |
Wizo | 0:028eb27f452d | 91 | 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q |
Wizo | 0:028eb27f452d | 92 | 0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r |
Wizo | 0:028eb27f452d | 93 | 0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s |
Wizo | 0:028eb27f452d | 94 | 0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t |
Wizo | 0:028eb27f452d | 95 | 0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u |
Wizo | 0:028eb27f452d | 96 | 0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v |
Wizo | 0:028eb27f452d | 97 | 0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w |
Wizo | 0:028eb27f452d | 98 | 0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x |
Wizo | 0:028eb27f452d | 99 | 0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y |
Wizo | 0:028eb27f452d | 100 | 0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z |
Wizo | 0:028eb27f452d | 101 | 0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // { |
Wizo | 0:028eb27f452d | 102 | 0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // | |
Wizo | 0:028eb27f452d | 103 | 0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // } |
Wizo | 0:028eb27f452d | 104 | 0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~ |
Wizo | 0:028eb27f452d | 105 | 0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00}; // DEL |
Wizo | 0:028eb27f452d | 106 | |
Wizo | 0:028eb27f452d | 107 | GraphicsDisplay::GraphicsDisplay(const char *name):TextDisplay(name) { |
Wizo | 0:028eb27f452d | 108 | foreground(0xFFFF); |
Wizo | 0:028eb27f452d | 109 | background(0x0000); |
Wizo | 0:028eb27f452d | 110 | } |
Wizo | 0:028eb27f452d | 111 | |
Wizo | 0:028eb27f452d | 112 | void GraphicsDisplay::character(int column, int row, int value) { |
Wizo | 0:028eb27f452d | 113 | blitbit(column * 8, row * 8, 8, 8, (char*)&(FONT8x8[value - 0x1F][0])); |
Wizo | 0:028eb27f452d | 114 | } |
Wizo | 0:028eb27f452d | 115 | |
Wizo | 0:028eb27f452d | 116 | void GraphicsDisplay::window(int x, int y, int w, int h) { |
Wizo | 0:028eb27f452d | 117 | // current pixel location |
Wizo | 0:028eb27f452d | 118 | _x = x; |
Wizo | 0:028eb27f452d | 119 | _y = y; |
Wizo | 0:028eb27f452d | 120 | // window settings |
Wizo | 0:028eb27f452d | 121 | _x1 = x; |
Wizo | 0:028eb27f452d | 122 | _x2 = x + w - 1; |
Wizo | 0:028eb27f452d | 123 | _y1 = y; |
Wizo | 0:028eb27f452d | 124 | _y2 = y + h - 1; |
Wizo | 0:028eb27f452d | 125 | } |
Wizo | 0:028eb27f452d | 126 | |
Wizo | 0:028eb27f452d | 127 | void GraphicsDisplay::putp(int colour) { |
Wizo | 0:028eb27f452d | 128 | // put pixel at current pixel location |
Wizo | 0:028eb27f452d | 129 | pixel(_x, _y, colour); |
Wizo | 0:028eb27f452d | 130 | // update pixel location based on window settings |
Wizo | 0:028eb27f452d | 131 | _x++; |
Wizo | 0:028eb27f452d | 132 | if(_x > _x2) { |
Wizo | 0:028eb27f452d | 133 | _x = _x1; |
Wizo | 0:028eb27f452d | 134 | _y++; |
Wizo | 0:028eb27f452d | 135 | if(_y > _y2) { |
Wizo | 0:028eb27f452d | 136 | _y = _y1; |
Wizo | 0:028eb27f452d | 137 | } |
Wizo | 0:028eb27f452d | 138 | } |
Wizo | 0:028eb27f452d | 139 | } |
Wizo | 0:028eb27f452d | 140 | |
Wizo | 0:028eb27f452d | 141 | void GraphicsDisplay::fill(int x, int y, int w, int h, int colour) { |
Wizo | 0:028eb27f452d | 142 | window(x, y, w, h); |
Wizo | 0:028eb27f452d | 143 | for(int i=0; i<w*h; i++) { |
Wizo | 0:028eb27f452d | 144 | putp(colour); |
Wizo | 0:028eb27f452d | 145 | } |
Wizo | 0:028eb27f452d | 146 | } |
Wizo | 0:028eb27f452d | 147 | |
Wizo | 0:028eb27f452d | 148 | void GraphicsDisplay::cls() { |
Wizo | 0:028eb27f452d | 149 | fill(0, 0, width(), height(), _background); |
Wizo | 0:028eb27f452d | 150 | } |
Wizo | 0:028eb27f452d | 151 | |
Wizo | 0:028eb27f452d | 152 | void GraphicsDisplay::blit(int x, int y, int w, int h, const int *colour) { |
Wizo | 0:028eb27f452d | 153 | window(x, y, w, h); |
Wizo | 0:028eb27f452d | 154 | for(int i=0; i<w*h; i++) { |
Wizo | 0:028eb27f452d | 155 | putp(colour[i]); |
Wizo | 0:028eb27f452d | 156 | } |
Wizo | 0:028eb27f452d | 157 | } |
Wizo | 0:028eb27f452d | 158 | |
Wizo | 0:028eb27f452d | 159 | void GraphicsDisplay::blitbit(int x, int y, int w, int h, const char* colour) { |
Wizo | 0:028eb27f452d | 160 | window(x, y, w, h); |
Wizo | 0:028eb27f452d | 161 | for(int i = 0; i < w*h; i++) { |
Wizo | 0:028eb27f452d | 162 | char byte = colour[i >> 3]; |
Wizo | 0:028eb27f452d | 163 | int offset = i & 0x7; |
Wizo | 0:028eb27f452d | 164 | int c = ((byte << offset) & 0x80) ? _foreground : _background; |
Wizo | 0:028eb27f452d | 165 | putp(c); |
Wizo | 0:028eb27f452d | 166 | } |
Wizo | 0:028eb27f452d | 167 | } |
Wizo | 0:028eb27f452d | 168 | |
Wizo | 0:028eb27f452d | 169 | int GraphicsDisplay::columns() { |
Wizo | 0:028eb27f452d | 170 | return width() / 8; |
Wizo | 0:028eb27f452d | 171 | } |
Wizo | 0:028eb27f452d | 172 | |
Wizo | 0:028eb27f452d | 173 | int GraphicsDisplay::rows() { |
Wizo | 0:028eb27f452d | 174 | return height() / 8; |
Wizo | 0:028eb27f452d | 175 | } |
Wizo | 0:028eb27f452d | 176 |