Rev 2598 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2598 | Rev 2601 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2009-2017 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009-2018 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 | #ifndef _MAX7456_SOFTWARE_SPI_H |
21 | #ifndef _MAX7456_SOFTWARE_SPI_H |
22 | #define _MAX7456_SOFTWARE_SPI_H |
22 | #define _MAX7456_SOFTWARE_SPI_H |
23 | 23 | ||
24 | 24 | ||
25 | /* ########################################################################## |
25 | /* ########################################################################## |
26 | * Software SPI to communicate with MAX7456 |
26 | * Software SPI to communicate with MAX7456 |
27 | * ##########################################################################*/ |
27 | * ##########################################################################*/ |
28 | #define MAX_CS_HIGH PORTA |= (1 << PA1); |
28 | #define MAX_CS_HIGH PORTA |= (1 << PA1); |
29 | #define MAX_CS_LOW PORTA &= ~(1 << PA1); |
29 | #define MAX_CS_LOW PORTA &= ~(1 << PA1); |
30 | #define MAX_SDIN_HIGH PORTA |= (1 << PA2); |
30 | #define MAX_SDIN_HIGH PORTA |= (1 << PA2); |
31 | #define MAX_SDIN_LOW PORTA &= ~(1 << PA2); |
31 | #define MAX_SDIN_LOW PORTA &= ~(1 << PA2); |
32 | #define MAX_SCLK_HIGH PORTA |= (1 << PA3); |
32 | #define MAX_SCLK_HIGH PORTA |= (1 << PA3); |
33 | #define MAX_SCLK_LOW PORTA &= ~(1 << PA3); |
33 | #define MAX_SCLK_LOW PORTA &= ~(1 << PA3); |
34 | #define MAX_RESET_HIGH PORTA |= (1 << PA5); |
34 | #define MAX_RESET_HIGH PORTA |= (1 << PA5); |
35 | #define MAX_RESET_LOW PORTA &= ~(1 << PA5); |
35 | #define MAX_RESET_LOW PORTA &= ~(1 << PA5); |
36 | 36 | ||
37 | /* ########################################################################## |
37 | /* ########################################################################## |
38 | * MAX7456 Register definitions |
38 | * MAX7456 Register definitions |
39 | * ##########################################################################*/ |
39 | * ##########################################################################*/ |
40 | 40 | ||
41 | #define MAX7456_REG_READ_OFFSET 0x80 |
41 | #define MAX7456_REG_READ_OFFSET 0x80 |
42 | 42 | ||
43 | #define MAX7456_VM0 0x00 |
43 | #define MAX7456_VM0 0x00 |
44 | #define MAX7456_VM1 0x01 |
44 | #define MAX7456_VM1 0x01 |
45 | #define MAX7456_HOS 0x02 |
45 | #define MAX7456_HOS 0x02 |
46 | #define MAX7456_VOS 0x03 |
46 | #define MAX7456_VOS 0x03 |
47 | #define MAX7456_DMM 0x04 |
47 | #define MAX7456_DMM 0x04 |
48 | #define MAX7456_DMAH 0x05 |
48 | #define MAX7456_DMAH 0x05 |
49 | #define MAX7456_DMAL 0x06 |
49 | #define MAX7456_DMAL 0x06 |
50 | #define MAX7456_DMDI 0x07 |
50 | #define MAX7456_DMDI 0x07 |
51 | #define MAX7456_CMM 0x08 |
51 | #define MAX7456_CMM 0x08 |
52 | #define MAX7456_CMAH 0x09 |
52 | #define MAX7456_CMAH 0x09 |
53 | #define MAX7456_CMAL 0x0A |
53 | #define MAX7456_CMAL 0x0A |
54 | #define MAX7456_CMDI 0x0B |
54 | #define MAX7456_CMDI 0x0B |
55 | #define MAX7456_OSDM 0x0C |
55 | #define MAX7456_OSDM 0x0C |
56 | #define MAX7456_RB0 0x10 |
56 | #define MAX7456_RB0 0x10 |
57 | #define MAX7456_RB1 0x11 |
57 | #define MAX7456_RB1 0x11 |
58 | #define MAX7456_RB2 0x12 |
58 | #define MAX7456_RB2 0x12 |
59 | #define MAX7456_RB3 0x13 |
59 | #define MAX7456_RB3 0x13 |
60 | #define MAX7456_RB4 0x14 |
60 | #define MAX7456_RB4 0x14 |
61 | #define MAX7456_RB5 0x15 |
61 | #define MAX7456_RB5 0x15 |
62 | #define MAX7456_RB6 0x16 |
62 | #define MAX7456_RB6 0x16 |
63 | #define MAX7456_RB7 0x17 |
63 | #define MAX7456_RB7 0x17 |
64 | #define MAX7456_RB8 0x18 |
64 | #define MAX7456_RB8 0x18 |
65 | #define MAX7456_RB9 0x19 |
65 | #define MAX7456_RB9 0x19 |
66 | #define MAX7456_RB10 0x1A |
66 | #define MAX7456_RB10 0x1A |
67 | #define MAX7456_RB11 0x1B |
67 | #define MAX7456_RB11 0x1B |
68 | #define MAX7456_RB12 0x1C |
68 | #define MAX7456_RB12 0x1C |
69 | #define MAX7456_RB13 0x1D |
69 | #define MAX7456_RB13 0x1D |
70 | #define MAX7456_RB14 0x1E |
70 | #define MAX7456_RB14 0x1E |
71 | #define MAX7456_RB15 0x1F |
71 | #define MAX7456_RB15 0x1F |
72 | #define MAX7456_OSDBL 0x6C |
72 | #define MAX7456_OSDBL 0x6C |
73 | 73 | ||
74 | // READ-ONLY REGs |
74 | // READ-ONLY REGs |
75 | 75 | ||
76 | #define MAX7456_STAT 0xA0 |
76 | #define MAX7456_STAT 0xA0 |
77 | #define MAX7456_DMDO 0xB0 |
77 | #define MAX7456_DMDO 0xB0 |
78 | #define MAX7456_CMDO 0xC0 |
78 | #define MAX7456_CMDO 0xC0 |
79 | 79 | ||
80 | 80 | ||
81 | /* ########################################################################## |
81 | /* ########################################################################## |
82 | * MAX7456 SPI & Display stuff |
82 | * MAX7456 SPI & Display stuff |
83 | * ##########################################################################*/ |
83 | * ##########################################################################*/ |
84 | 84 | ||
85 | /** |
85 | /** |
86 | * Send a byte through SPI |
86 | * Send a byte through SPI |
87 | */ |
87 | */ |
88 | void spi_send(uint8_t); |
88 | void spi_send(uint8_t); |
89 | 89 | ||
90 | /** |
90 | /** |
91 | * Send <byte> to <address> of MAX7456 |
91 | * Send <byte> to <address> of MAX7456 |
92 | */ |
92 | */ |
93 | void spi_send_byte(uint8_t, uint8_t); |
93 | void spi_send_byte(uint8_t, uint8_t); |
94 | 94 | ||
95 | /** |
95 | /** |
96 | * write a <character> to <address> of MAX7456 display memory |
96 | * write a <character> to <address> of MAX7456 display memory |
97 | */ |
97 | */ |
98 | void write_char(uint16_t, char); |
98 | void write_char(uint16_t, char); |
99 | 99 | ||
100 | /** |
100 | /** |
101 | * write a character <attribute> to <address> of MAX7456 display memory |
101 | * write a character <attribute> to <address> of MAX7456 display memory |
102 | */ |
102 | */ |
103 | void write_char_att(uint16_t, char); |
103 | void write_char_att(uint16_t, char); |
104 | /** |
104 | /** |
105 | * write a <character> at <x>/<y> to MAX7456 display memory |
105 | * write a <character> at <x>/<y> to MAX7456 display memory |
106 | */ |
106 | */ |
107 | void write_char_xy(uint8_t, uint8_t, char); |
107 | void write_char_xy(uint8_t, uint8_t, char); |
108 | /** |
108 | /** |
109 | * write a character <attribute> at <x>/<y> to MAX7456 display memory |
109 | * write a character <attribute> at <x>/<y> to MAX7456 display memory |
110 | */ |
110 | */ |
111 | void write_char_att_xy(uint8_t, uint8_t, char attribute); |
111 | void write_char_att_xy(uint8_t, uint8_t, char attribute); |
112 | 112 | ||
113 | /** |
113 | /** |
114 | * clear display memory |
114 | * clear display memory |
115 | * (also sets 8bit mode) |
115 | * (also sets 8bit mode) |
116 | */ |
116 | */ |
117 | void clear(void); |
117 | void clear(void); |
118 | 118 | ||
119 | /** |
119 | /** |
120 | * write an ascii <character> to <address> of MAX7456 display memory |
120 | * write an ascii <character> to <address> of MAX7456 display memory |
121 | */ |
121 | */ |
122 | void write_ascii_char(uint16_t, char); |
122 | void write_ascii_char(uint16_t, char); |
123 | 123 | ||
124 | /** |
124 | /** |
125 | * write an ascii <string> at <x>/<y> to MAX7456 display memory |
125 | * write an ascii <string> at <x>/<y> to MAX7456 display memory |
126 | */ |
126 | */ |
127 | void write_ascii_string(uint8_t, uint8_t, char*); |
127 | void write_ascii_string(uint8_t, uint8_t, char*); |
128 | 128 | ||
129 | /** |
129 | /** |
130 | * write an ascii <string> with lenght <len> at <x>/<y> to MAX7456 display memory |
130 | * write an ascii <string> with lenght <len> at <x>/<y> to MAX7456 display memory |
131 | */ |
131 | */ |
132 | void write_ascii_string_len(uint8_t x, uint8_t y, char *string, uint8_t len); |
132 | void write_ascii_string_len(uint8_t x, uint8_t y, char *string, uint8_t len); |
133 | 133 | ||
134 | /** |
134 | /** |
135 | * write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
135 | * write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
136 | */ |
136 | */ |
137 | void write_ascii_string_pgm(uint8_t, uint8_t, const char*); |
137 | void write_ascii_string_pgm(uint8_t, uint8_t, const char*); |
138 | 138 | ||
139 | /** |
139 | /** |
140 | * write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory |
140 | * write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory |
141 | */ |
141 | */ |
142 | void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t); |
142 | void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t); |
143 | 143 | ||
144 | /** |
144 | /** |
145 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory |
145 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory |
146 | * <length> represents the length to rightbound the number |
146 | * <length> represents the length to rightbound the number |
147 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
147 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
148 | */ |
148 | */ |
149 | void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
149 | void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
150 | 150 | ||
151 | /** |
151 | /** |
152 | * Write a signed <number> at <x>/<y> to MAX7456 display memory |
152 | * Write a signed <number> at <x>/<y> to MAX7456 display memory |
153 | * <length> represents the length to rightbound the number |
153 | * <length> represents the length to rightbound the number |
154 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
154 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
155 | */ |
155 | */ |
156 | void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
156 | void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
157 | 157 | ||
158 | /** |
158 | /** |
159 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value |
159 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value |
160 | * <length> represents the length to rightbound the number |
160 | * <length> represents the length to rightbound the number |
161 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
161 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
162 | */ |
162 | */ |
163 | void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
163 | void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
164 | 164 | ||
165 | /** |
165 | /** |
166 | * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value |
166 | * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value |
167 | * <length> represents the length to rightbound the number |
167 | * <length> represents the length to rightbound the number |
168 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
168 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
169 | */ |
169 | */ |
170 | void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
170 | void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
171 | 171 | ||
172 | /** |
172 | /** |
173 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
173 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
174 | */ |
174 | */ |
175 | void write_time(uint8_t, uint8_t, uint16_t); |
175 | void write_time(uint8_t, uint8_t, uint16_t); |
176 | 176 | ||
177 | #if (ALLCHARSDEBUG|(WRITECHARS != -1)) |
177 | #if (ALLCHARSDEBUG|(WRITECHARS != -1)) |
178 | /** |
178 | /** |
179 | * for testing write all chars to screen |
179 | * for testing write all chars to screen |
180 | */ |
180 | */ |
181 | void write_all_chars(); |
181 | void write_all_chars(); |
182 | 182 | ||
183 | /** |
183 | /** |
184 | * let the MAX7456 learn a new character at <number> |
184 | * let the MAX7456 learn a new character at <number> |
185 | * with <data>. |
185 | * with <data>. |
186 | */ |
186 | */ |
187 | void learn_char(uint8_t, unsigned char*); |
187 | void learn_char(uint8_t, unsigned char*); |
188 | #endif |
188 | #endif |
189 | 189 | ||
190 | /** |
190 | /** |
191 | * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
191 | * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
192 | */ |
192 | */ |
193 | void write_gps_pos(uint8_t, uint8_t, int32_t); |
193 | void write_gps_pos(uint8_t, uint8_t, int32_t); |
194 | 194 | ||
195 | #endif |
195 | #endif |
196 | 196 |