Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1915 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
||
5 | * Copyright (C) 2011 Harald Bongartz * |
||
6 | * * |
||
7 | * This program is free software; you can redistribute it and/or modify * |
||
8 | * it under the terms of the GNU General Public License as published by * |
||
9 | * the Free Software Foundation; either version 2 of the License. * |
||
10 | * * |
||
11 | * This program is distributed in the hope that it will be useful, * |
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
14 | * GNU General Public License for more details. * |
||
15 | * * |
||
16 | * You should have received a copy of the GNU General Public License * |
||
17 | * along with this program; if not, write to the * |
||
18 | * Free Software Foundation, Inc., * |
||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
20 | * * |
||
21 | * * |
||
22 | * Credits to: * |
||
23 | * Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
||
24 | * http://www.mikrokopter.de * |
||
25 | * Gregor "killagreg" Stobrawa for his version of the MK code * |
||
26 | * Thomas Kaiser "thkais" for the original project. See * |
||
27 | * http://www.ft-fanpage.de/mikrokopter/ * |
||
28 | * http://forum.mikrokopter.de/topic-4061-1.html * |
||
29 | * Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
||
30 | * http://www.mylifesucks.de/oss/c-osd/ * |
||
31 | * Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
||
32 | *****************************************************************************/ |
||
33 | |||
34 | |||
35 | #include "../cpu.h" |
||
36 | #include <avr/io.h> |
||
37 | #include <avr/interrupt.h> |
||
38 | #include <avr/pgmspace.h> |
||
39 | |||
40 | #include "../lcd/lcd.h" |
||
41 | #include "../timer/timer.h" |
||
42 | #include "../tracking/servo.h" |
||
43 | #include "../messages.h" |
||
44 | |||
45 | #define SERVO_CORRECT 3.125 |
||
46 | |||
47 | |||
48 | //-------------------------------------------------------------- |
||
49 | // |
||
50 | void servo_test (void) |
||
51 | { |
||
52 | #ifdef HWVERSION3_9 |
||
53 | uint8_t chg = 0; |
||
54 | uint8_t Pos = 150; // 1,5mS |
||
55 | |||
56 | OCR1A = 150 * SERVO_CORRECT; // Servomitte |
||
57 | |||
58 | lcd_cls (); |
||
59 | |||
60 | lcd_printp (PSTR(" Servo Tester "), 2); |
||
61 | lcd_printp_at (7, 5, PSTR("%"), 0); |
||
62 | lcd_printp_at (16, 5, PSTR("mS"), 0); |
||
63 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
||
64 | lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
||
65 | lcd_printp_at (18, 7, PSTR("\x19O\x18"), 0); |
||
66 | |||
67 | lcd_rect(3, 23, 120, 8, 1); // +-150% Rahmen |
||
68 | lcd_line(23,23,23,31,1); // -100% |
||
69 | lcd_line(43,23,43,31,1); // -50% |
||
70 | lcd_frect(61, 23, 3, 8, 1); // 0% |
||
71 | lcd_line(83,23,83,31,1); // +50% |
||
72 | lcd_line(103,23,103,31,1); // +100% |
||
73 | |||
74 | write_ndigit_number_u (4, 5, 0, 3, 0,0); // Pulse width in % |
||
75 | write_ndigit_number_u_100th(12, 5, 150, 3, 0); // Pulse width in ms |
||
76 | |||
77 | do |
||
78 | { |
||
79 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Pos < 225)) |
||
80 | { |
||
81 | if (Pos < 150) |
||
82 | lcd_frect ((63 - ((150 - Pos) * 0.8)), 24, 1, 6, 0); |
||
83 | |||
84 | Pos++; |
||
85 | if (Pos == 75 || Pos == 100 || Pos == 125 || Pos == 150 || Pos == 175 || Pos == 200 || Pos == 225) |
||
86 | { |
||
87 | set_beep ( 200, 0x0080, BeepNormal); |
||
88 | } |
||
89 | |||
90 | if (Pos >= 225) |
||
91 | Pos = 225; |
||
92 | |||
93 | chg++; |
||
94 | } |
||
95 | else if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Pos > 75)) |
||
96 | { |
||
97 | if (Pos > 150) |
||
98 | lcd_frect ((((Pos - 150) * 0.8) + 63), 24, ((Pos - 150) * 0.8), 6, 0); |
||
99 | |||
100 | Pos--; |
||
101 | if (Pos == 75 || Pos == 100 || Pos == 125 || Pos == 150 || Pos == 175 || Pos == 200 || Pos == 225) |
||
102 | { |
||
103 | set_beep ( 200, 0x0080, BeepNormal); |
||
104 | } |
||
105 | |||
106 | if (Pos <= 75) |
||
107 | Pos = 75; |
||
108 | |||
109 | chg++; |
||
110 | } |
||
111 | else if (get_key_press (1 << KEY_ENTER)) |
||
112 | { |
||
113 | lcd_frect (4, 24, 118, 6, 0); // Balken löschen |
||
114 | lcd_frect(61, 23, 3, 8, 1); // 0% |
||
115 | Pos = 150; |
||
116 | set_beep ( 200, 0x0080, BeepNormal); |
||
117 | chg++; |
||
118 | } |
||
119 | |||
120 | if (chg) |
||
121 | { |
||
122 | chg = 0; |
||
123 | |||
124 | if (Pos >= 150) |
||
125 | { |
||
126 | lcd_frect (63, 24, ((Pos - 150) * 0.8), 6, 1); |
||
127 | write_ndigit_number_u (4, 5, ((Pos - 150) * 2), 3, 0,0); // Pulse width in % |
||
128 | lcd_frect(62, 23, 2, 8, 1); // 0% |
||
129 | } |
||
130 | else |
||
131 | { |
||
132 | lcd_frect (63 - ((150 - Pos) * 0.8), 24, ((150 - Pos) * 0.8), 6, 1); |
||
133 | write_ndigit_number_u (4, 5, ((150 - Pos) * 2), 3, 0,0); // Pulse width in % |
||
134 | lcd_frect(61, 23, 2, 8, 1); // 0% |
||
135 | } |
||
136 | write_ndigit_number_u_100th(12, 5, Pos, 3, 0); // Pulse width in ms |
||
137 | |||
138 | lcd_line(3, 23,3, 31,1); // -150% |
||
139 | lcd_line(23, 23,23, 31,1); // -100% |
||
140 | lcd_line(43, 23,43, 31,1); // -50% |
||
141 | lcd_line(83, 23,83, 31,1); // +50% |
||
142 | lcd_line(103,23,103,31,1); // +100% |
||
143 | lcd_line(123,23,123,31,1); // +150% |
||
144 | |||
145 | |||
146 | OCR1A = Pos * SERVO_CORRECT; // Servostellung |
||
147 | |||
148 | } |
||
149 | } |
||
150 | while (!get_key_press (1 << KEY_ESC)); |
||
151 | get_key_press(KEY_ALL); |
||
152 | #endif |
||
153 | } |