Subversion Repositories Projects

Rev

Rev 736 | Rev 783 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 736 Rev 762
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009-2010 by Claas Anders "CaScAdE" Rathje               *
2
 *   Copyright (C) 2009-2010 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
 
-
 
21
#ifndef _MAX7456_SOFTWARE_SPI_H
-
 
22
#define _MAX7456_SOFTWARE_SPI_H
-
 
23
 
20
 
24
 
21
/* ##########################################################################
25
/* ##########################################################################
22
 * Software SPI to communicate with MAX7456
26
 * Software SPI to communicate with MAX7456
23
 * ##########################################################################*/
27
 * ##########################################################################*/
24
#define MAX_CS_HIGH             PORTA |=  (1 << PA1);
28
#define MAX_CS_HIGH             PORTA |=  (1 << PA1);
25
#define MAX_CS_LOW              PORTA &= ~(1 << PA1);
29
#define MAX_CS_LOW              PORTA &= ~(1 << PA1);
26
#define MAX_SDIN_HIGH           PORTA |=  (1 << PA2);
30
#define MAX_SDIN_HIGH           PORTA |=  (1 << PA2);
27
#define MAX_SDIN_LOW            PORTA &= ~(1 << PA2);
31
#define MAX_SDIN_LOW            PORTA &= ~(1 << PA2);
28
#define MAX_SCLK_HIGH           PORTA |=  (1 << PA3);
32
#define MAX_SCLK_HIGH           PORTA |=  (1 << PA3);
29
#define MAX_SCLK_LOW            PORTA &= ~(1 << PA3);
33
#define MAX_SCLK_LOW            PORTA &= ~(1 << PA3);
30
#define MAX_RESET_HIGH          PORTA |=  (1 << PA5);
34
#define MAX_RESET_HIGH          PORTA |=  (1 << PA5);
31
#define MAX_RESET_LOW           PORTA &= ~(1 << PA5);
35
#define MAX_RESET_LOW           PORTA &= ~(1 << PA5);
32
 
36
 
33
 
37
 
34
/* ##########################################################################
38
/* ##########################################################################
35
 * MAX7456 SPI & Display stuff
39
 * MAX7456 SPI & Display stuff
36
 * ##########################################################################*/
40
 * ##########################################################################*/
37
 
41
 
38
/**
42
/**
39
 * Send a byte through SPI
43
 * Send a byte through SPI
40
 */
44
 */
41
void spi_send(uint8_t);
45
void spi_send(uint8_t);
42
 
46
 
43
/**
47
/**
44
 *  Send <byte> to <address> of MAX7456
48
 *  Send <byte> to <address> of MAX7456
45
 */
49
 */
46
void spi_send_byte(uint8_t, uint8_t);
50
void spi_send_byte(uint8_t, uint8_t);
47
 
51
 
48
/**
52
/**
49
 *  write a <character> to <address> of MAX7456 display memory
53
 *  write a <character> to <address> of MAX7456 display memory
50
 */
54
 */
51
void write_char(uint16_t, char);
55
void write_char(uint16_t, char);
52
 
56
 
53
/**
57
/**
54
 *  write a character <attribute> to <address> of MAX7456 display memory
58
 *  write a character <attribute> to <address> of MAX7456 display memory
55
 */
59
 */
56
void write_char_att(uint16_t, char);
60
void write_char_att(uint16_t, char);
57
/**
61
/**
58
 *  write a <character> at <x>/<y> to MAX7456 display memory
62
 *  write a <character> at <x>/<y> to MAX7456 display memory
59
 */
63
 */
60
void write_char_xy(uint8_t, uint8_t, char);
64
void write_char_xy(uint8_t, uint8_t, char);
61
/**
65
/**
62
 *  write a  character <attribute> at <x>/<y> to MAX7456 display memory
66
 *  write a  character <attribute> at <x>/<y> to MAX7456 display memory
63
 */
67
 */
64
void write_char_att_xy(uint8_t, uint8_t, char attribute);
68
void write_char_att_xy(uint8_t, uint8_t, char attribute);
65
 
69
 
66
/**
70
/**
67
 *  clear display memory
71
 *  clear display memory
68
 *  (also sets 8bit mode)
72
 *  (also sets 8bit mode)
69
 */
73
 */
70
void clear(void);
74
void clear(void);
71
 
75
 
72
/**
76
/**
73
 *  write an ascii <character> to <address> of MAX7456 display memory
77
 *  write an ascii <character> to <address> of MAX7456 display memory
74
 */
78
 */
75
void write_ascii_char(uint16_t, char);
79
void write_ascii_char(uint16_t, char);
76
 
80
 
77
/**
81
/**
78
 *  write an ascii <string> at <x>/<y> to MAX7456 display memory
82
 *  write an ascii <string> at <x>/<y> to MAX7456 display memory
79
 */
83
 */
80
void write_ascii_string(uint8_t, uint8_t, char*);
84
void write_ascii_string(uint8_t, uint8_t, char*);
81
 
85
 
82
/**
86
/**
83
 *  write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory
87
 *  write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory
84
 */
88
 */
85
void write_ascii_string_pgm(uint8_t, uint8_t, const char*);
89
void write_ascii_string_pgm(uint8_t, uint8_t, const char*);
86
 
90
 
87
/**
91
/**
88
 *  write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory
92
 *  write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory
89
 */
93
 */
90
void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t);
94
void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t);
91
 
95
 
92
/**
96
/**
93
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory
97
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory
94
 * <length> represents the length to rightbound the number
98
 * <length> represents the length to rightbound the number
95
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
99
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
96
 */
100
 */
97
void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);
101
void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);
98
 
102
 
99
/**
103
/**
100
 * Write a signed <number> at <x>/<y> to MAX7456 display memory
104
 * Write a signed <number> at <x>/<y> to MAX7456 display memory
101
 * <length> represents the length to rightbound the number
105
 * <length> represents the length to rightbound the number
102
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
106
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
103
 */
107
 */
104
void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t);
108
void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t);
105
 
109
 
106
/**
110
/**
107
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value
111
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value
108
 * <length> represents the length to rightbound the number
112
 * <length> represents the length to rightbound the number
109
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
113
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
110
 */
114
 */
111
void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);
115
void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);
112
 
116
 
113
/**
117
/**
114
 * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value
118
 * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value
115
 * <length> represents the length to rightbound the number
119
 * <length> represents the length to rightbound the number
116
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
120
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
117
 */
121
 */
118
void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t);
122
void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t);
119
 
123
 
120
/**
124
/**
121
 *  write <seconds> as human readable time at <x>/<y> to MAX7456 display mem
125
 *  write <seconds> as human readable time at <x>/<y> to MAX7456 display mem
122
 */
126
 */
123
void write_time(uint8_t, uint8_t, uint16_t);
127
void write_time(uint8_t, uint8_t, uint16_t);
124
 
128
 
125
#if (ALLCHARSDEBUG|(WRITECHARS != -1))
129
#if (ALLCHARSDEBUG|(WRITECHARS != -1))
126
/**
130
/**
127
 * for testing write all chars to screen
131
 * for testing write all chars to screen
128
 */
132
 */
129
void write_all_chars();
133
void write_all_chars();
130
 
134
 
131
/**
135
/**
132
 * let the MAX7456 learn a new character at <number>
136
 * let the MAX7456 learn a new character at <number>
133
 * with <data>.
137
 * with <data>.
134
 */
138
 */
135
void learn_char(uint8_t, unsigned char*);
139
void learn_char(uint8_t, unsigned char*);
136
#endif
140
#endif
137
 
141
 
138
/**
142
/**
139
 * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude
143
 * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude
140
 */
144
 */
141
void write_gps_pos(uint8_t, uint8_t, int32_t);
145
void write_gps_pos(uint8_t, uint8_t, int32_t);
-
 
146
 
-
 
147
#endif
142
 
148