-
Notifications
You must be signed in to change notification settings - Fork 32
/
lcd.c
70 lines (63 loc) · 1.38 KB
/
lcd.c
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
#include <avr/io.h>
#include <util/delay.h>
void LcdWrite(unsigned char dc, unsigned char data)
{
int i;
if( dc )
PORTD |= 0x20;
else
PORTD &= ~0x20;
PORTD &= ~0x80;
for( i = 0 ; i < 8 ; i++ ) {
if( (data >> (7 - i)) & 1 )
PORTD |= 16;
else
PORTD &= ~16;
PORTD |= 8;
PORTD &= ~8;
}
PORTD |= 0x80;
PORTB ^= 0x20;
}
#include "qrencode.h"
#include <string.h>
int main()
{
DDRB |= 0x20;
PORTB |= 0xf8;
DDRD |= 0xf8;
PORTD &= ~8;
PORTD &= ~0x40;
PORTD |= 0x40;
unsigned char b = 0x55;
unsigned i, k, t;
LcdWrite(0, 0x22);
LcdWrite(0, 0x0C);
for ( k = 0; k < 84 ; k++, b ^= 0xff )
for ( i = 0; i < 6 ; i++)
LcdWrite(1, b);
strcpy((char *)strinbuf, "http://harleyhacking.blogspot.com");
qrencode();
LcdWrite(0, 0x22);
LcdWrite(0, 0x0C);
for ( k = 0; k < 84 ; k++ )
for ( i = 0; i < 6 ; i++)
LcdWrite(1, 0);
PORTB &= ~0x20;
t = 0;
b = 0;
for ( k = 0; k < 84 ; k++) {
for ( i = 0; i < 48 ; i++) {
b >>= 1;
if( i < WD && k < WD )
if( QRBIT(WD-i-1,k) )
b |= 0x80;
if( ++t > 7 ) {
t = 0;
LcdWrite(1, b);
b = 0;
}
}
}
for(;;);
}