Test program for FF1705.

Dependencies:   libxDot-dev-mbed5-deprecated ISL29011

Committer:
jernej_vrscaj
Date:
Tue Nov 07 11:18:57 2017 +0000
Revision:
0:d96e7e513c16
Testing program for production purposes (v1.0).

Who changed what in which revision?

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