Rev 349 | Rev 404 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 349 | Rev 379 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje * |
3 | * admiralcascade@gmail.com * |
3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
5 | * * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ****************************************************************************/ |
19 | ****************************************************************************/ |
20 | 20 | ||
21 | /* ########################################################################## |
21 | /* ########################################################################## |
22 | * Software SPI to communicate with MAX7456 |
22 | * Software SPI to communicate with MAX7456 |
23 | * ##########################################################################*/ |
23 | * ##########################################################################*/ |
24 | #define MAX_CS_HIGH PORTA |= (1 << PA1); |
24 | #define MAX_CS_HIGH PORTA |= (1 << PA1); |
25 | #define MAX_CS_LOW PORTA &= ~(1 << PA1); |
25 | #define MAX_CS_LOW PORTA &= ~(1 << PA1); |
26 | #define MAX_SDIN_HIGH PORTA |= (1 << PA2); |
26 | #define MAX_SDIN_HIGH PORTA |= (1 << PA2); |
27 | #define MAX_SDIN_LOW PORTA &= ~(1 << PA2); |
27 | #define MAX_SDIN_LOW PORTA &= ~(1 << PA2); |
28 | #define MAX_SCLK_HIGH PORTA |= (1 << PA3); |
28 | #define MAX_SCLK_HIGH PORTA |= (1 << PA3); |
29 | #define MAX_SCLK_LOW PORTA &= ~(1 << PA3); |
29 | #define MAX_SCLK_LOW PORTA &= ~(1 << PA3); |
30 | #define MAX_RESET_HIGH PORTA |= (1 << PA5); |
30 | #define MAX_RESET_HIGH PORTA |= (1 << PA5); |
31 | #define MAX_RESET_LOW PORTA &= ~(1 << PA5); |
31 | #define MAX_RESET_LOW PORTA &= ~(1 << PA5); |
32 | 32 | ||
33 | 33 | ||
34 | /* ########################################################################## |
34 | /* ########################################################################## |
35 | * MAX7456 SPI & Display stuff |
35 | * MAX7456 SPI & Display stuff |
36 | * ##########################################################################*/ |
36 | * ##########################################################################*/ |
37 | 37 | ||
38 | /** |
38 | /** |
39 | * Send a byte through SPI |
39 | * Send a byte through SPI |
40 | */ |
40 | */ |
41 | void spi_send(uint8_t); |
41 | void spi_send(uint8_t); |
42 | 42 | ||
43 | /** |
43 | /** |
44 | * Send <byte> to <address> of MAX7456 |
44 | * Send <byte> to <address> of MAX7456 |
45 | */ |
45 | */ |
46 | void spi_send_byte(uint8_t, uint8_t); |
46 | void spi_send_byte(uint8_t, uint8_t); |
47 | 47 | ||
48 | /** |
48 | /** |
49 | * write a <character> to <address> of MAX7456 display memory |
49 | * write a <character> to <address> of MAX7456 display memory |
50 | */ |
50 | */ |
51 | void write_char(uint16_t, char); |
51 | void write_char(uint16_t, char); |
52 | 52 | ||
53 | /** |
53 | /** |
54 | * write a character <attribute> to <address> of MAX7456 display memory |
54 | * write a character <attribute> to <address> of MAX7456 display memory |
55 | */ |
55 | */ |
56 | void write_char_att(uint16_t, char); |
56 | void write_char_att(uint16_t, char); |
57 | /** |
57 | /** |
58 | * write a <character> at <x>/<y> to MAX7456 display memory |
58 | * write a <character> at <x>/<y> to MAX7456 display memory |
59 | */ |
59 | */ |
60 | void write_char_xy(uint8_t, uint8_t, char); |
60 | void write_char_xy(uint8_t, uint8_t, char); |
61 | /** |
61 | /** |
62 | * write a character <attribute> at <x>/<y> to MAX7456 display memory |
62 | * write a character <attribute> at <x>/<y> to MAX7456 display memory |
63 | */ |
63 | */ |
64 | void write_char_att_xy(uint8_t, uint8_t, char attribute); |
64 | void write_char_att_xy(uint8_t, uint8_t, char attribute); |
65 | 65 | ||
66 | /** |
66 | /** |
67 | * clear display by writing blank characters all over it |
67 | * clear display by writing blank characters all over it |
68 | */ |
68 | */ |
69 | void clear(void); |
69 | void clear(void); |
70 | 70 | ||
71 | /** |
71 | /** |
72 | * write an ascii <character> to <address> of MAX7456 display memory |
72 | * write an ascii <character> to <address> of MAX7456 display memory |
73 | */ |
73 | */ |
74 | void write_ascii_char(uint16_t, char); |
74 | void write_ascii_char(uint16_t, char); |
75 | 75 | ||
76 | /** |
76 | /** |
77 | * write an ascii <string> at <x>/<y> to MAX7456 display memory |
77 | * write an ascii <string> at <x>/<y> to MAX7456 display memory |
78 | */ |
78 | */ |
79 | void write_ascii_string(uint8_t, uint8_t, char*); |
79 | void write_ascii_string(uint8_t, uint8_t, char*); |
80 | 80 | ||
81 | /** |
81 | /** |
82 | * write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
82 | * write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
83 | */ |
83 | */ |
84 | void write_ascii_string_pgm(uint8_t, uint8_t, char*); |
84 | void write_ascii_string_pgm(uint8_t, uint8_t, char*); |
85 | 85 | ||
86 | /** |
86 | /** |
- | 87 | * write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory |
|
- | 88 | */ |
|
- | 89 | void write_string_pgm_down(uint8_t, uint8_t, char*, uint8_t); |
|
- | 90 | ||
- | 91 | /** |
|
87 | * Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
92 | * Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
88 | * <num> represents the largest multiple of 10 that will still be displayable as |
93 | * <num> represents the largest multiple of 10 that will still be displayable as |
89 | * the first digit, so num = 10 will be 0-99 and so on |
94 | * the first digit, so num = 10 will be 0-99 and so on |
90 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
95 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
91 | */ |
96 | */ |
92 | void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
97 | void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
93 | 98 | ||
94 | /** |
99 | /** |
95 | * Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
100 | * Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
96 | * <num> represents the largest multiple of 10 that will still be displayable as |
101 | * <num> represents the largest multiple of 10 that will still be displayable as |
97 | * the first digit, so num = 10 will be 0-99 and so on |
102 | * the first digit, so num = 10 will be 0-99 and so on |
98 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
103 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
99 | */ |
104 | */ |
100 | void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
105 | void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
101 | 106 | ||
102 | /** |
107 | /** |
103 | * Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
108 | * Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
104 | * as /10th of the value |
109 | * as /10th of the value |
105 | * <num> represents the largest multiple of 10 that will still be displayable as |
110 | * <num> represents the largest multiple of 10 that will still be displayable as |
106 | * the first digit, so num = 10 will be 0-99 and so on |
111 | * the first digit, so num = 10 will be 0-99 and so on |
107 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
112 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
108 | */ |
113 | */ |
109 | void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
114 | void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
110 | 115 | ||
111 | /** |
116 | /** |
112 | * Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
117 | * Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
113 | * as /10th of the value |
118 | * as /10th of the value |
114 | * <num> represents the largest multiple of 10 that will still be displayable as |
119 | * <num> represents the largest multiple of 10 that will still be displayable as |
115 | * the first digit, so num = 10 will be 0-99 and so on |
120 | * the first digit, so num = 10 will be 0-99 and so on |
116 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
121 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
117 | */ |
122 | */ |
118 | void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
123 | void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
119 | 124 | ||
120 | /** |
125 | /** |
121 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
126 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
122 | */ |
127 | */ |
123 | void write_time(uint8_t, uint8_t, uint16_t); |
128 | void write_time(uint8_t, uint8_t, uint16_t); |
124 | 129 | ||
125 | /** |
130 | /** |
126 | * for testing write all chars to screen |
131 | * for testing write all chars to screen |
127 | */ |
132 | */ |
128 | void write_all_chars(); |
133 | void write_all_chars(); |
129 | 134 | ||
130 | /** |
135 | /** |
131 | * let the MAX7456 learn a new character at <number> |
136 | * let the MAX7456 learn a new character at <number> |
132 | * with <data>. |
137 | * with <data>. |
133 | */ |
138 | */ |
134 | void learn_char(uint8_t, unsigned char*); |
139 | void learn_char(uint8_t, unsigned char*); |
135 | 140 |