-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplay.cpp
142 lines (112 loc) · 3.27 KB
/
display.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
@file
@see display.h for details
@version 1.0
@author Arco van Geest <arco@appeltaart.mine.nu>
@copyright 2013 Arco van Geest <arco@appeltaart.mine.nu> All right reserved.
This file is part of PinDA.
PinDA is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PinDA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PinDA. If not, see <http://www.gnu.org/licenses/>.
@date 20130520 Initial documented version
@brief control displays
*/
#include "display.h"
#include "lcdchars.h"
DISPLAY_WIL11A::DISPLAY_WIL11A ( MC6821 * _piaalfa, MC6821 * _pia7seg, MC6821 * _piawidget ) {
piaalfa = _piaalfa;
pia7seg = _pia7seg;
piawidget = _piawidget;
index=0;
blink=false;
blinktime=100;
blinkcounter=0;
for (int i=0;i<16;i++){
stext1[i]=' ';
stext1a[i]=' ';
}
pia7seg->write_ddra(255); // A output
pia7seg->write_ddrb(255); //B uitgang
pia7seg->write_pdra(0x00);
pia7seg->write_pdrb(0x00);
//cra2/crb2
piaalfa->write_ddra(255); // A output
piaalfa->write_ddrb(255); //B uitgang
piaalfa->write_pdra(0x00);
piaalfa->write_pdrb(0x00);
//piawidget->write_ddra(255); // A output
//piawidget->write_pdra(0x00);
pinda.AddInterrupt ( this , 1);
}
void DISPLAY_WIL11A::interrupt ( void ) {
pia7seg->write_pdrb(0x00 );
piaalfa->write_pdra(0x00);
piaalfa->write_pdrb(0x00);
uint8_t state=pia7seg->read_pdra();
pia7seg->write_pdra( ( state & 0xf0) | index );
// set alphanumeric data
uint8_t c = stext1[ index ];
uint16_t val= lcd14Char( c ) ;
if ( ( stext1[ index ] >= '0' ) & ( stext1[ index ] <= '9') ) {
switch(index) {
case 1 :
case 4 :
case 9 :
case 12 :
val |= 0x8080;
default:
;;
}
}
piaalfa->write_pdra(val >> 8);
piaalfa->write_pdrb(val & 0x00ff);
// set 7seg data
uint8_t val7= lcd7Char( stext2[ index ] ) ;
pia7seg->write_pdrb( val7 );
//pia7seg->write_pdrb(0xff );
index++;
if ( index>16) index=0;
}
void DISPLAY_WIL11A::setScore1( String _txt) {
_txt += " ";
for (int i=0;i<8;i++){
stext1[i+1]=_txt.charAt( i );
}
}
void DISPLAY_WIL11A::setScore2( String _txt) {
_txt += " ";
for (int i=0;i<8;i++){
stext1[i+9]=_txt.charAt( i );
}
}
void DISPLAY_WIL11A::setScore3( String _txt) {
_txt += " ";
for (int i=0;i<8;i++){
stext2[i+1]=_txt.charAt( i );
}
}
void DISPLAY_WIL11A::setScore4( String _txt) {
_txt += " ";
for (int i=0;i<8;i++){
stext2[i+9]=_txt.charAt( i );
}
}
void DISPLAY_WIL11A::text1( String _text1) {
_text1 += " ";
for (int i=0;i<16;i++){
stext1[i]=_text1.charAt( i );
}
}
void DISPLAY_WIL11A::text2( String _text2) {
_text2 += " ";
for (int i=0;i<16;i++){
stext2[i]=_text2.charAt( i );
}
}