temp poti

Dependents:   2016-01-28_TINF_Temperatur_einlesen

Committer:
tauchi88
Date:
Thu Jan 28 19:53:13 2016 +0000
Revision:
0:4a09a5e0d6d8
temp

Who changed what in which revision?

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