matrixdisplaydriver.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by David Saxton                                    *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #include "libraryitem.h"
00012 #include "logic.h"
00013 #include "matrixdisplaydriver.h"
00014 
00015 #include <klocale.h>
00016 #include <qpainter.h>
00017 #include <qstring.h>
00018 
00019 #include <cassert>
00020 
00021 // Thank you Scott Dattalo!
00022 // http://www.dattalo.com/gnupic/lcdfont.inc
00023 
00024 //  code; decimal; hex; codepage 437
00025 // not all codes implemented
00026 // After further investigation, the higher codes correspond to japanese katakana
00027 // letters. this is getting intesting.
00028 
00029 // TODO: identify the code page that is actually implemented then make sure it is
00030 // correct or fill it in with page 437 codes.
00031 // Otherwise, implement multiple codepages and let user select at runtime. 
00032 
00033 static char characterMap[256][5] = {
00034 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //0   0x00    NULL
00035 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //1   0x01  [white happy face]
00036 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //2   0x02  [black happy face]
00037 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //3   0x03  [heart]
00038 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //4   0x04  [daimond] 
00039 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //5   0x05  [club]
00040 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //6   0x06  [spade] 
00041 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //7   0x07  [dot]
00042 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //8   0x08  [inverted dot]
00043 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //9   0x09  [circle] 
00044 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //10  0x0A  [inverted circle]
00045 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //11  0x0B  [mars symbol]
00046 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //12  0x0C  [venus symbol]
00047 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //13  0x0D  [note]
00048 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //14  0x0E  [double note]
00049 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //15  0x0F  [sun]
00050 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //16  0x10  [play/ right pointing triangle]
00051 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //17  0x11  [left pointing triangle]
00052 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //18  0x12  [up-down arrow]
00053 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //19  0x13    !!
00054 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //20  0x14  [paragraph symbol]
00055 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //21  0x15  [chapter symbol]
00056 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //22  0x16  [bar]
00057 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //23  0x17  [up-down arrow with underline]
00058 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //24  0x18  [up arrow]
00059 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //25  0x19  [down arrow]
00060 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //26  0x1A  [right arrow]     
00061 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //27  0x1B  [left arrow]
00062 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //28  0x1C
00063 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //29  0x1D  [left-right arrow]
00064 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //30  0x1E  [up triangle]     
00065 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //31  0x1F  [down triangle]
00066 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //32  0x20  [space]
00067 { 0x00, 0x00, 0x7d, 0x00, 0x00 }, //33  0x21    !
00068 { 0x00, 0x70, 0x00, 0x70, 0x00 }, //34  0x22    "
00069 { 0x14, 0x7f, 0x14, 0x7f, 0x14 }, //35  0x23    #
00070 { 0x12, 0x2a, 0x7f, 0x2a, 0x24 }, //36  0x24    $
00071 { 0x62, 0x64, 0x08, 0x13, 0x23 }, //37  0x25    %
00072 { 0x36, 0x49, 0x55, 0x22, 0x05 }, //38  0x26    &
00073 { 0x00, 0x50, 0x60, 0x00, 0x00 }, //39  0x27    '
00074 { 0x00, 0x1c, 0x22, 0x41, 0x00 }, //40  0x28    (
00075 { 0x00, 0x41, 0x22, 0x1c, 0x00 }, //41  0x29    )
00076 { 0x14, 0x08, 0x3e, 0x08, 0x14 }, //42  0x2A    *
00077 { 0x08, 0x08, 0x3e, 0x08, 0x08 }, //43  0x2B    +
00078 { 0x00, 0x05, 0x06, 0x00, 0x00 }, //44  0x2C    ,
00079 { 0x08, 0x08, 0x08, 0x08, 0x08 }, //45  0x2D    -
00080 { 0x00, 0x03, 0x03, 0x00, 0x00 }, //46  0x2E    .
00081 { 0x02, 0x04, 0x08, 0x10, 0x20 }, //47  0x2F    /
00082 { 0x3e, 0x45, 0x49, 0x51, 0x3e }, //48  0x30    0
00083 { 0x00, 0x21, 0x7f, 0x01, 0x00 }, //49  0x31    1
00084 { 0x21, 0x43, 0x45, 0x49, 0x31 }, //50  0x32    2
00085 { 0x42, 0x41, 0x51, 0x69, 0x46 }, //51  0x33    3
00086 { 0x0c, 0x14, 0x24, 0x7f, 0x04 }, //52  0x34    4
00087 { 0x72, 0x51, 0x51, 0x51, 0x4e }, //53  0x35    5
00088 { 0x1e, 0x29, 0x49, 0x49, 0x06 }, //54  0x36    6
00089 { 0x40, 0x47, 0x48, 0x50, 0x60 }, //55  0x37    7
00090 { 0x36, 0x49, 0x49, 0x49, 0x36 }, //56  0x38    8
00091 { 0x30, 0x49, 0x49, 0x4a, 0x3c }, //57  0x39    9
00092 { 0x00, 0x36, 0x36, 0x00, 0x00 }, //58  0x3A    :
00093 { 0x00, 0x35, 0x36, 0x00, 0x00 }, //59  0x3B    ;
00094 { 0x08, 0x14, 0x22, 0x41, 0x00 }, //60  0x3C    <
00095 { 0x14, 0x14, 0x14, 0x14, 0x14 }, //61  0x3D    =
00096 { 0x41, 0x22, 0x14, 0x08, 0x00 }, //62  0x3E    >
00097 { 0x20, 0x40, 0x45, 0x48, 0x30 }, //63  0x3F    ?
00098 { 0x26, 0x49, 0x4f, 0x41, 0x3e }, //64  0x40    @
00099 { 0x3f, 0x44, 0x44, 0x44, 0x3f }, //65  0x41    A
00100 { 0x7f, 0x49, 0x49, 0x49, 0x36 }, //66  0x42    B
00101 { 0x3e, 0x41, 0x41, 0x41, 0x22 }, //67  0x43    C
00102 { 0x7f, 0x41, 0x41, 0x41, 0x3e }, //68  0x44    D
00103 { 0x7f, 0x49, 0x49, 0x49, 0x41 }, //69  0x45    E
00104 { 0x7f, 0x48, 0x48, 0x48, 0x40 }, //70  0x46    F
00105 { 0x3e, 0x41, 0x49, 0x49, 0x2f }, //71  0x47    G
00106 { 0x7f, 0x08, 0x08, 0x08, 0x7f }, //72  0x48    H
00107 { 0x00, 0x41, 0x7f, 0x41, 0x00 }, //73  0x49    I
00108 { 0x02, 0x01, 0x41, 0x7e, 0x40 }, //74  0x4A    J
00109 { 0x7f, 0x08, 0x14, 0x22, 0x41 }, //75  0x4B    K
00110 { 0x7f, 0x01, 0x01, 0x01, 0x01 }, //76  0x4C    L
00111 { 0x7f, 0x40, 0x20, 0x40, 0x7f }, //77  0x4D    M
00112 { 0x7f, 0x10, 0x08, 0x04, 0x7f }, //78  0x4E    N
00113 { 0x3e, 0x41, 0x41, 0x41, 0x3e }, //79  0x4F    O
00114 { 0x7f, 0x48, 0x48, 0x48, 0x30 }, //80  0x50    P
00115 { 0x3e, 0x41, 0x45, 0x42, 0x3d }, //81  0x51    Q
00116 { 0x7f, 0x48, 0x4c, 0x4a, 0x31 }, //82  0x52    R
00117 { 0x31, 0x49, 0x49, 0x49, 0x46 }, //83  0x53    S
00118 { 0x40, 0x40, 0x7f, 0x40, 0x40 }, //84  0x54    T
00119 { 0x7e, 0x01, 0x01, 0x01, 0x7e }, //85  0x55    U
00120 { 0x7c, 0x02, 0x01, 0x02, 0x7c }, //86  0x56    V
00121 { 0x7e, 0x01, 0x0e, 0x01, 0x7e }, //87  0x57    W
00122 { 0x63, 0x14, 0x08, 0x14, 0x63 }, //88  0x58    X
00123 { 0x70, 0x08, 0x07, 0x08, 0x70 }, //89  0x59    Y
00124 { 0x43, 0x45, 0x49, 0x51, 0x61 }, //90  0x5A    Z
00125 { 0x00, 0x7f, 0x41, 0x41, 0x00 }, //91  0x5B    [
00126 { 0x54, 0x34, 0x1f, 0x34, 0x54 }, //92  0x5C    \
00127 { 0x00, 0x41, 0x41, 0x7f, 0x00 }, //93  0x5D    ]
00128 { 0x10, 0x20, 0x40, 0x20, 0x10 }, //94  0x5E    ^
00129 { 0x01, 0x01, 0x01, 0x01, 0x01 }, //95  0x5F    `
00130 { 0x00, 0x40, 0x20, 0x10, 0x00 }, //96  0x60    a
00131 { 0x02, 0x15, 0x15, 0x15, 0x0f }, //97  0x61    b
00132 { 0x7f, 0x09, 0x11, 0x11, 0x0e }, //98  0x62    c
00133 { 0x0e, 0x11, 0x11, 0x11, 0x02 }, //99  0x63    d
00134 { 0x0e, 0x11, 0x11, 0x09, 0x7f }, //100 0x64    e
00135 { 0x0e, 0x15, 0x15, 0x15, 0x0c }, //101 0x65    f
00136 { 0x08, 0x3f, 0x48, 0x40, 0x20 }, //102 0x66    g
00137 { 0x30, 0x49, 0x49, 0x49, 0x7e }, //103 0x67    h
00138 { 0x7f, 0x08, 0x10, 0x10, 0x0f }, //104 0x68    i
00139 { 0x00, 0x11, 0x5f, 0x01, 0x00 }, //105 0x69    j
00140 { 0x02, 0x01, 0x21, 0x7e, 0x00 }, //106 0x6A    k
00141 { 0x7f, 0x04, 0x0a, 0x11, 0x00 }, //107 0x6B    l
00142 { 0x00, 0x41, 0x7f, 0x01, 0x00 }, //108 0x6C    m
00143 { 0x1f, 0x10, 0x0c, 0x10, 0x0f }, //109 0x6D    n
00144 { 0x1f, 0x08, 0x10, 0x10, 0x0f }, //110 0x6E    o
00145 { 0x0e, 0x11, 0x11, 0x11, 0x0e }, //111 0x6F    p
00146 { 0x1f, 0x14, 0x14, 0x14, 0x08 }, //112 0x70    q
00147 { 0x08, 0x14, 0x14, 0x0c, 0x1f }, //113 0x71    r
00148 { 0x1f, 0x08, 0x10, 0x10, 0x08 }, //114 0x72    s
00149 { 0x09, 0x15, 0x15, 0x15, 0x12 }, //115 0x73    t
00150 { 0x20, 0x7e, 0x21, 0x01, 0x02 }, //116 0x74    u
00151 { 0x1e, 0x01, 0x01, 0x02, 0x1f }, //117 0x75    v
00152 { 0x1c, 0x02, 0x01, 0x02, 0x1c }, //118 0x76    w
00153 { 0x1e, 0x01, 0x06, 0x01, 0x1e }, //119 0x77    x
00154 { 0x11, 0x0a, 0x04, 0x0a, 0x11 }, //120 0x78    y
00155 { 0x18, 0x05, 0x05, 0x05, 0x1e }, //121 0x79    z
00156 { 0x11, 0x13, 0x15, 0x19, 0x11 }, //122 0x7A    {
00157 { 0x00, 0x08, 0x36, 0x41, 0x00 }, //123 0x7B    |
00158 { 0x00, 0x00, 0x7f, 0x00, 0x00 }, //124 0x7C    }
00159 { 0x00, 0x41, 0x36, 0x08, 0x00 }, //125 0x7D    ~
00160 { 0x08, 0x08, 0x2a, 0x1c, 0x08 }, //126 0x7E
00161 { 0x08, 0x1c, 0x2a, 0x08, 0x08 }, //127 0x7F
00162 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //128 0x80
00163 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //129 0x81
00164 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //130 0x82
00165 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //131 0x83
00166 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //132 0x84
00167 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //133 0x85
00168 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //134 0x86
00169 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //135 0x87
00170 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //136 0x88
00171 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //137 0x89
00172 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //138 0x8A
00173 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //139 0x8B
00174 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //140 0x8C
00175 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //141 0x8D
00176 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //142 0x8E
00177 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //143 0x8F
00178 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //144 0x90
00179 { 0x07, 0x05, 0x07, 0x00, 0x00 }, //145 0x91    ae
00180 { 0x00, 0x00, 0x78, 0x40, 0x40 }, //146 0x92    AE
00181 { 0x01, 0x01, 0x0f, 0x00, 0x00 }, //147 0x93
00182 { 0x04, 0x02, 0x01, 0x00, 0x00 }, //148 0x94
00183 { 0x00, 0x0c, 0x0c, 0x00, 0x00 }, //149 0x95
00184 { 0x28, 0x28, 0x29, 0x2a, 0x3c }, //150 0x96
00185 { 0x10, 0x11, 0x16, 0x14, 0x18 }, //151 0x97
00186 { 0x02, 0x04, 0x0f, 0x10, 0x00 }, //152 0x98
00187 { 0x0c, 0x08, 0x19, 0x09, 0x0e }, //153 0x99
00188 { 0x09, 0x09, 0x0f, 0x09, 0x09 }, //154 0x9A
00189 { 0x09, 0x0a, 0x0c, 0x1f, 0x08 }, //155 0x9B    [cents]
00190 { 0x08, 0x1f, 0x08, 0x0a, 0x0c }, //156 0x9C    [pounds]
00191 { 0x01, 0x09, 0x09, 0x0f, 0x01 }, //157 0x9D    [yen]
00192 { 0x15, 0x15, 0x15, 0x1f, 0x00 }, //158 0x9E    
00193 { 0x0c, 0x00, 0x0d, 0x01, 0x0e }, //159 0x9F    [function]
00194 { 0x04, 0x04, 0x04, 0x04, 0x04 }, //160 0xA0    
00195 { 0x40, 0x41, 0x5e, 0x48, 0x70 }, //161 0xA1
00196 { 0x04, 0x08, 0x1f, 0x20, 0x40 }, //162 0xA2
00197 { 0x38, 0x20, 0x61, 0x22, 0x3c }, //163 0xA3
00198 { 0x11, 0x11, 0x1f, 0x11, 0x11 }, //164 0xA4
00199 { 0x22, 0x24, 0x28, 0x7f, 0x20 }, //165 0xA5
00200 { 0x21, 0x7e, 0x20, 0x21, 0x3e }, //166 0xA6
00201 { 0x28, 0x28, 0x7f, 0x28, 0x28 }, //167 0xA7
00202 { 0x08, 0x31, 0x21, 0x22, 0x3c }, //168 0xA8    upside down ?
00203 { 0x10, 0x60, 0x21, 0x3e, 0x20 }, //169 0xA9
00204 { 0x21, 0x21, 0x21, 0x21, 0x3f }, //170 0xAA
00205 { 0x20, 0x79, 0x22, 0x7c, 0x20 }, //171 0xAB    1/2
00206 { 0x29, 0x29, 0x01, 0x02, 0x1c }, //172 0xAC    1/4
00207 { 0x21, 0x22, 0x24, 0x2a, 0x31 }, //173 0xAD    
00208 { 0x20, 0x7e, 0x21, 0x29, 0x31 }, //174 0xAE    <<
00209 { 0x30, 0x09, 0x01, 0x02, 0x3c }, //175 0xAF    >>
00210 { 0x08, 0x31, 0x29, 0x26, 0x3c }, //176 0xB0
00211 { 0x28, 0x29, 0x3e, 0x48, 0x08 }, //177 0xB1
00212 { 0x30, 0x00, 0x31, 0x02, 0x3c }, //178 0xB2
00213 { 0x10, 0x51, 0x5e, 0x50, 0x10 }, //179 0xB3
00214 { 0x00, 0x7f, 0x08, 0x04, 0x00 }, //180 0xB4
00215 { 0x11, 0x12, 0x7c, 0x10, 0x10 }, //181 0xB5
00216 { 0x01, 0x21, 0x21, 0x21, 0x01 }, //182 0xB6
00217 { 0x21, 0x2a, 0x24, 0x2a, 0x30 }, //183 0xB7
00218 { 0x22, 0x24, 0x6f, 0x34, 0x22 }, //184 0xB8
00219 { 0x00, 0x01, 0x02, 0x7c, 0x00 }, //185 0xB9
00220 { 0x0f, 0x00, 0x20, 0x10, 0x0f }, //186 0xBA
00221 { 0x7e, 0x11, 0x11, 0x11, 0x11 }, //187 0xBB
00222 { 0x20, 0x21, 0x21, 0x22, 0x3c }, //188 0xBC
00223 { 0x10, 0x20, 0x10, 0x08, 0x06 }, //189 0xBD
00224 { 0x26, 0x20, 0x7f, 0x20, 0x26 }, //190 0xBE
00225 { 0x20, 0x24, 0x22, 0x25, 0x38 }, //191 0xBF
00226 { 0x00, 0x2a, 0x2a, 0x2a, 0x01 }, //192 0xC0
00227 { 0x0e, 0x12, 0x22, 0x02, 0x07 }, //193 0xC1
00228 { 0x01, 0x0a, 0x04, 0x0a, 0x30 }, //194 0xC2
00229 { 0x28, 0x3e, 0x29, 0x29, 0x29 }, //195 0xC3
00230 { 0x10, 0x7f, 0x10, 0x14, 0x18 }, //196 0xC4
00231 { 0x01, 0x21, 0x21, 0x3f, 0x01 }, //197 0xC5
00232 { 0x29, 0x29, 0x29, 0x29, 0x3f }, //198 0xC6
00233 { 0x10, 0x50, 0x51, 0x52, 0x1c }, //199 0xC7
00234 { 0x78, 0x01, 0x02, 0x7c, 0x00 }, //200 0xC8
00235 { 0x1f, 0x00, 0x3f, 0x01, 0x06 }, //201 0xC9
00236 { 0x3f, 0x01, 0x02, 0x04, 0x08 }, //202 0xCA
00237 { 0x3f, 0x21, 0x21, 0x21, 0x3f }, //203 0xCB
00238 { 0x38, 0x20, 0x21, 0x22, 0x3c }, //204 0xCC
00239 { 0x21, 0x21, 0x01, 0x02, 0x0c }, //205 0xCD
00240 { 0x20, 0x10, 0x40, 0x20, 0x00 }, //206 0xCE
00241 { 0x70, 0x50, 0x70, 0x00, 0x00 }, //207 0xCF
00242 { 0x0e, 0x11, 0x09, 0x06, 0x19 }, //208 0xD0
00243 { 0x02, 0x55, 0x15, 0x55, 0x0f }, //209 0xD1
00244 { 0x1f, 0x2a, 0x2a, 0x2a, 0x14 }, //210 0xD2
00245 { 0x0a, 0x15, 0x15, 0x11, 0x02 }, //211 0xD3
00246 { 0x3f, 0x02, 0x02, 0x04, 0x3e }, //212 0xD4
00247 { 0x0e, 0x11, 0x19, 0x15, 0x12 }, //213 0xD5
00248 { 0x0f, 0x12, 0x22, 0x22, 0x1c }, //214 0xD6
00249 { 0x1c, 0x22, 0x22, 0x22, 0x3f }, //215 0xD7
00250 { 0x02, 0x01, 0x1e, 0x10, 0x10 }, //216 0xD8
00251 { 0x20, 0x20, 0x00, 0x70, 0x00 }, //217 0xD9
00252 { 0x00, 0x00, 0x10, 0x5f, 0x00 }, //218 0xDA
00253 { 0x28, 0x10, 0x28, 0x00, 0x00 }, //219 0xDB
00254 { 0x18, 0x24, 0x7e, 0x24, 0x08 }, //220 0xDC
00255 { 0x14, 0x7f, 0x15, 0x01, 0x01 }, //221 0xDD
00256 { 0x1f, 0x48, 0x50, 0x50, 0x0f }, //222 0xDE
00257 { 0x0e, 0x51, 0x11, 0x51, 0x0e }, //223 0xDF
00258 { 0x3f, 0x12, 0x22, 0x22, 0x1c }, //224 0xE0
00259 { 0x1c, 0x22, 0x22, 0x12, 0x3f }, //225 0xE1    [calculus beta]
00260 { 0x3c, 0x52, 0x52, 0x52, 0x3c }, //226 0xE2    [upper case gamma]
00261 { 0x03, 0x05, 0x02, 0x05, 0x06 }, //227 0xE3    [pi]
00262 { 0x1a, 0x26, 0x20, 0x26, 0x1a }, //228 0xE4    [upper case sigma]
00263 { 0x1e, 0x41, 0x01, 0x42, 0x1f }, //229 0xE5    [lower case sigma]
00264 { 0x63, 0x55, 0x49, 0x41, 0x41 }, //230 0xE6    [mu]
00265 { 0x22, 0x3c, 0x20, 0x3e, 0x22 }, //231 0xE7    [lower case gamma]
00266 { 0x51, 0x4a, 0x44, 0x4a, 0x51 }, //232 0xE8    [phi]
00267 { 0x3c, 0x02, 0x02, 0x02, 0x3f }, //233 0xE9    [theta]
00268 { 0x28, 0x28, 0x3e, 0x28, 0x48 }, //234 0xEA    [omega]
00269 { 0x22, 0x3c, 0x28, 0x28, 0x2e }, //235 0xEB    [delta]
00270 { 0x3e, 0x28, 0x38, 0x28, 0x3e }, //236 0xEC    [infinity]
00271 { 0x04, 0x04, 0x15, 0x04, 0x04 }, //237 0xED    [null]
00272 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //238 0xEE    [set member of]
00273 { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f }, //239 0xEF    [set intersection]
00274 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //240 0xF0    [equivalent]
00275 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //241 0xF1    [pluss minus]
00276 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //242 0xF2    >_
00277 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //243 0xF3    <_
00278 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //244 0xF4    upper part of integral sign.
00279 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //245 0xF5    lower part of integral sign.
00280 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //246 0xF6    [divide by sign] 
00281 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //247 0xF7    [similar to]
00282 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //248 0xF8    [degrees]
00283 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //249 0xF9    [sqrt]
00284 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //250 0xFA    [superscript n]
00285 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //251 0xFB    [squared]
00286 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //252 0xFC    
00287 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //253 0xFD
00288 { 0x00, 0x00, 0x00, 0x00, 0x00 }, //254 0xFE
00289 { 0x00, 0x00, 0x00, 0x00, 0x00 } //255  0xFF
00290 };
00291 
00292 inline static bool displayBit(unsigned value, unsigned row, unsigned column ) {
00293         assert( value < 256 );
00294         assert( row < 7 );
00295         assert( column < 5 );
00296         return characterMap[value][column] & (1 << row);
00297 }
00298 
00299 Item* MatrixDisplayDriver::construct(ItemDocument *itemDocument, bool newItem, const char *id )
00300 {
00301         return new MatrixDisplayDriver( (ICNDocument*)itemDocument, newItem, id );
00302 }
00303 
00304 LibraryItem *MatrixDisplayDriver::libraryItem()
00305 {
00306         return new LibraryItem(
00307                 "ec/matrix_display_driver",
00308                 i18n("Matrix Display Driver"),
00309                 i18n("Integrated Circuits"),
00310                 "ic2.png",
00311                 LibraryItem::lit_component,
00312                 MatrixDisplayDriver::construct );
00313 }
00314 
00315 MatrixDisplayDriver::MatrixDisplayDriver( ICNDocument *icnDocument, bool newItem, const char *id )
00316         : Component( icnDocument, newItem, id ? id : "Matrix Display Driver" )
00317 {
00318         m_name = i18n("Matrix Display Driver");
00319 
00320         m_prevCol = 0;
00321         m_nextCol = 0;
00322         m_scanCount = 2;
00323 
00324         createProperty( "diode-configuration", Variant::Type::Select );
00325         property("diode-configuration")->setCaption( i18n("Configuration") );
00326         property("diode-configuration")->setAllowed( QStringList::split(',',"Row Cathode,Column Cathode") );
00327         property("diode-configuration")->setValue("Row Cathode");
00328         property("diode-configuration")->setAdvanced(true);
00329 
00330         QStringList pins = QStringList::split( ',', "D0,D1,D2,D3,D4,D5,D6,D7,,,,,,C4,C3,C2,C1,C0,,R0,R1,R2,R3,R4,R5,R6", true );
00331         initDIPSymbol( pins, 64 );
00332         initDIP(pins);
00333 
00334         m_pValueLogic.resize(8, 0);
00335         for ( unsigned i = 0; i < 8; ++i )
00336                 m_pValueLogic[i] = createLogicIn( ecNodeWithID("D"+QString::number(i)) );
00337 
00338         m_pRowLogic.resize(7, 0);
00339         for ( unsigned i = 0; i < 7; ++i ) {
00340                 m_pRowLogic[i] = createLogicOut( ecNodeWithID("R"+QString::number(i)), false );
00341                 m_pRowLogic[i]->setOutputLowConductance( 1.0 );
00342                 m_pRowLogic[i]->setOutputHighVoltage(5.0);
00343         }
00344 
00345         m_pColLogic.resize(5, 0);
00346         for ( unsigned i = 0; i < 5; ++i ) {
00347                 m_pColLogic[i] = createLogicOut( ecNodeWithID("C"+QString::number(i)), false );
00348                 m_pColLogic[i]->setOutputHighVoltage(5.0);
00349         }
00350 }
00351 
00352 MatrixDisplayDriver::~MatrixDisplayDriver()
00353 {
00354 }
00355 
00356 void MatrixDisplayDriver::stepNonLogic()
00357 {
00358         if(++m_scanCount < 5 ) return;
00359 
00360         m_scanCount = 0;
00361 
00362         m_pColLogic[m_prevCol]->setHigh(false);
00363         m_pColLogic[m_nextCol]->setHigh(true);
00364 
00365         unsigned value = 0;
00366         for(unsigned i = 0; i < 8; ++i )
00367                 value |= ( m_pValueLogic[i]->isHigh() ) ? (1 << i) : 0;
00368 
00369         for(unsigned row = 0; row < 7; row++ ) {
00370                 m_pRowLogic[row]->setHigh(!displayBit(value, row, m_nextCol));
00371         }
00372 
00373         m_prevCol = m_nextCol;
00374 
00375         m_nextCol++;
00376         if(m_nextCol >= 5 ) m_nextCol = 0;
00377 }
00378 

Generated on Tue May 8 17:05:31 2007 for KTechLab by  doxygen 1.5.1