Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2136 - 1
 
2
/****************************************************************/
3
/* Setup für die Sticks                                         */
4
/* 2013 Cebra                                                   */
5
/****************************************************************/
6
 
7
//############################################################################
8
//# HISTORY  stick_setup.c
9
//#
10
//# 28.05.2014 OG
11
//# - chg: Setup's auf das neue Edit_generic() umgestellt
12
//#
13
//# 11.05.2014 OG
14
//# - chg: einge Setup-Menues umgestellt auf MenuCtrl_SetTitleFromParentItem()
15
//#        -> die Menues 'erben' damit ihren Titel vom aufrufenden Menuepunkt
16
//#
17
//# 30.03.2014 OG
18
//# - chg: ein paar englische Texte auf DE gemappt weil der Unterschied unerheblich war
19
//# - chg: Sprache Hollaendisch vollstaendig entfernt
20
//# - chg: MenuCtrl_PushML_P() umgestellt auf MenuCtrl_PushML2_P()
21
//#
22
//# 31.05.2013 OG
23
//# - chg: einige redundante Menuetitel auf define umgestellt
24
//#
25
//# 24.05.2013 OG
26
//# - chg: Aufrufe von MenuCtrl_Push() umgestellt auf MenuCtrl_PushML_P()
27
//#
28
//# 22.05.2013 OG
29
//# - umgestellt auf menuctrl
30
//# - del: include utils/menuold.h
31
//#
32
//# 17.05.2013 OG
33
//# - chg: umgestellt auf utils/menuold.h
34
//#
35
//# 16.04.2013 Cebra
36
//# - chg: PROGMEM angepasst auf neue avr-libc und GCC, prog_char depreciated
37
//#
38
//# 04.04.2013 Cebra
39
//# - chg: Texttuning
40
//#
41
//# 03.04.2013 Cebra
42
//# - chg: Holländische Menütexte
43
//#
44
//# 27.03.2013 Cebra
45
//# - chg: Fehler bei der Menüsteuerung behoben
46
//############################################################################
47
 
48
#include <stdio.h>
49
#include <stdlib.h>
50
#include <string.h>
51
#include <math.h>
52
#include "../cpu.h"
53
#include <util/delay.h>
54
#include <avr/pgmspace.h>
55
#include <avr/interrupt.h>
56
#include "../main.h"
57
#include "../timer/timer.h"
58
#include "stick_setup.h"
59
#include "../lcd/lcd.h"
60
#include "../timer/timer.h"
61
#include "../messages.h"
62
#include "../mk-data-structs.h"
63
#include "../eeprom/eeprom.h"
64
#include "../setup/setup.h"
65
#include "../utils/menuctrl.h"
66
 
67
 
68
//############################################################################
69
#ifdef USE_JOYSTICK
70
//############################################################################
71
 
72
//-----------------------------
73
// Setup_Joysticks()
74
//-----------------------------
75
#define JSTICKS_OVERVIEW    1
76
#define JSTICKS_STICK1      2
77
#define JSTICKS_STICK2      3
78
#define JSTICKS_STICK3      4
79
#define JSTICKS_STICK4      5
80
#define JSTICKS_STICK5      6
81
#define JSTICKS_LIPO        7
82
 
83
static const char JSTICKS_OVERVIEW_de[]     PROGMEM = "Übersicht";
84
static const char JSTICKS_OVERVIEW_en[]     PROGMEM = "summary";
85
 
86
static const char JSTICKS_STICK1_de[]       PROGMEM = "Stick 1";
87
#define           JSTICKS_STICK1_en         JSTICKS_STICK1_de
88
 
89
static const char JSTICKS_STICK2_de[]       PROGMEM = "Stick 2";
90
#define           JSTICKS_STICK2_en         JSTICKS_STICK2_de
91
 
92
static const char JSTICKS_STICK3_de[]       PROGMEM = "Stick 3";
93
#define           JSTICKS_STICK3_en         JSTICKS_STICK3_de
94
 
95
static const char JSTICKS_STICK4_de[]       PROGMEM = "Stick 4";
96
#define           JSTICKS_STICK4_en         JSTICKS_STICK4_de
97
 
98
static const char JSTICKS_STICK5_de[]       PROGMEM = "Stick 5";
99
#define           JSTICKS_STICK5_en         JSTICKS_STICK5_de
100
 
101
static const char JSTICKS_LIPO_de[]         PROGMEM = "PKT Lipomessung";
102
static const char JSTICKS_LIPO_en[]         PROGMEM = "PKT Lipo measure.";
103
 
104
 
105
//############################################################################
106
 
107
//-----------------------------
108
// Setup_Stick()
109
//-----------------------------
110
#define MSTICK_MIN      1
111
#define MSTICK_MAX      2
112
#define MSTICK_TYPE     3
113
#define MSTICK_DIR      4
114
#define MSTICK_NEUT     5
115
 
116
static const char MSTICK_MIN_de[]           PROGMEM = "Minimal Wert";
117
static const char MSTICK_MIN_en[]           PROGMEM = "minimal value";
118
 
119
static const char MSTICK_MAX_de[]           PROGMEM = "Maximal Wert";
120
static const char MSTICK_MAX_en[]           PROGMEM = "maximal value";
121
 
122
static const char MSTICK_TYPE_de[]          PROGMEM = "Type";
123
static const char MSTICK_TYPE_en[]          PROGMEM = "type";
124
 
125
static const char MSTICK_DIR_de[]           PROGMEM = "Richtung";
126
static const char MSTICK_DIR_en[]           PROGMEM = "direction";
127
 
128
static const char MSTICK_NEUT_de[]          PROGMEM = "Neutralisiered";
129
static const char MSTICK_NEUT_en[]          PROGMEM = "neutralizing";
130
 
131
//############################################################################
132
 
133
 
134
//--------------------------------------------------------------
135
//--------------------------------------------------------------
136
void Joysticks_Uebersicht(void)
137
{
138
    lcd_cls ();
139
    lcd_printpns_at(0, 0, PSTR("   Joystick Setup    "), 2);
140
    lcd_printpns_at(0, 1, PSTR("S Min Max Typ  Dir  N"), 0);
141
 
142
    for (uint8_t i = 0; i < 5; i++) {
143
 
144
        write_ndigit_number_u (0, 2+i,i+1, 1, 0,0);
145
        write_ndigit_number_u (2, 2+i,Config.stick_min[i], 3, 0,0);
146
        write_ndigit_number_u (6, 2+i,Config.stick_max[i], 3, 0,0);
147
        if (Config.stick_typ[i] == 0) lcd_printpns_at(10, 2+i, PSTR("Poti"), 0); else lcd_printpns_at(10, 2+i, PSTR("Tast"), 0);
148
          //if (Config.stick_typ[i] == 0) // MartinR: geändert
149
            //{
150
            if (Config.stick_dir[i] == 0) lcd_printpns_at(15, 2+i, PSTR("Norm"), 0); else lcd_printpns_at(15, 2+i, PSTR("Rev"), 0);
151
            if (Config.stick_neutral[i] == 0) lcd_printpns_at(20, 2+i, PSTR("N"), 0); else lcd_printpns_at(20, 2+i, PSTR("Y"), 0);
152
            //}
153
        if (i == 1) if (Config.Lipomessung == true) lcd_printpns_at(3, 2+i, PSTR("PKT Lipomessung   "), 0);
154
 
155
      }
156
 
157
 
158
    lcd_printp_at (18, 7, PSTR("OK"), 0);
159
 
160
    do{}
161
      while (!(get_key_press (1 << KEY_ENTER)));
162
}
163
 
164
 
165
 
166
//--------------------------------------------------------------
167
// Setup_Stick()
168
//--------------------------------------------------------------
169
void Setup_Stick( uint8_t stick )
170
{
171
    uint8_t itemid;
172
 
173
    //---------------
174
    // Create
175
    //---------------
176
    MenuCtrl_Create();
177
    MenuCtrl_SetTitleFromParentItem();      // "Stick n"
178
  //MenuCtrl_SetTitle_P( PSTR("Joystick") );
179
 
180
    //---------------
181
    // Menuitems
182
    //---------------
183
    MenuCtrl_PushML2_P( MSTICK_MIN  , MENU_ITEM, NOFUNC , MSTICK_MIN_de  , MSTICK_MIN_en  );
184
    MenuCtrl_PushML2_P( MSTICK_MAX  , MENU_ITEM, NOFUNC , MSTICK_MAX_de  , MSTICK_MAX_en  );
185
    MenuCtrl_PushML2_P( MSTICK_TYPE , MENU_ITEM, NOFUNC , MSTICK_TYPE_de , MSTICK_TYPE_en );
186
    MenuCtrl_PushML2_P( MSTICK_DIR  , MENU_ITEM, NOFUNC , MSTICK_DIR_de  , MSTICK_DIR_en  );
187
    MenuCtrl_PushML2_P( MSTICK_NEUT , MENU_ITEM, NOFUNC , MSTICK_NEUT_de , MSTICK_NEUT_en );
188
 
189
    //---------------
190
    // Control
191
    //---------------
192
    while( true )
193
    {
194
        MenuCtrl_Control( MENUCTRL_EVENT );
195
 
196
        if( MenuCtrl_GetKey() == KEY_ESC )  break;      // ENDE
197
 
198
        itemid = MenuCtrl_GetItemId();                  // welcher Menu-Punkt (ID)
199
 
200
        if( itemid == MSTICK_MIN  ) { Config.stick_min[stick]    = Edit_generic( Config.stick_min[stick]     ,0,300,Show_uint3,1  ,NULL,NULL);  }
201
        if( itemid == MSTICK_MAX  ) { Config.stick_max[stick]    = Edit_generic( Config.stick_max[stick]     ,0,300,Show_uint3,1  ,NULL,NULL);  }
202
        if( itemid == MSTICK_TYPE ) { Config.stick_typ[stick]    = Edit_generic( Config.stick_typ[stick]     ,0,  1,Sticktype,1   ,NULL,NULL);  }
203
        if( itemid == MSTICK_DIR  ) { Config.stick_dir[stick]    = Edit_generic( Config.stick_dir[stick]     ,0,  1,NormRev,1     ,NULL,NULL);  }
204
        if( itemid == MSTICK_NEUT ) { Config.stick_neutral[stick]= Edit_generic( Config.stick_neutral[stick] ,0,  1,YesNo,1       ,NULL,NULL);  }
205
 
206
    }
207
 
208
    //---------------
209
    // Destroy
210
    //---------------
211
    MenuCtrl_Destroy();
212
}
213
 
214
 
215
 
216
//--------------------------------------------------------------
217
// Setup_Joysticks()
218
//--------------------------------------------------------------
219
void Setup_Joysticks( void )
220
{
221
    uint8_t itemid;
222
 
223
    //---------------
224
    // Create
225
    //---------------
226
    MenuCtrl_Create();
227
    MenuCtrl_SetTitleFromParentItem();      // "Joystick"
228
    //MenuCtrl_SetTitle_P( PSTR("Joystick Setup") );
229
 
230
    //---------------
231
    // Menuitems
232
    //---------------
233
    MenuCtrl_PushML2_P( JSTICKS_OVERVIEW  , MENU_ITEM, NOFUNC , JSTICKS_OVERVIEW_de , JSTICKS_OVERVIEW_en );
234
    MenuCtrl_PushML2_P( JSTICKS_STICK1    , MENU_SUB , NOFUNC , JSTICKS_STICK1_de   , JSTICKS_STICK1_en   );
235
    MenuCtrl_PushML2_P( JSTICKS_STICK2    , MENU_SUB , NOFUNC , JSTICKS_STICK2_de   , JSTICKS_STICK2_en   );
236
    MenuCtrl_PushML2_P( JSTICKS_STICK3    , MENU_SUB , NOFUNC , JSTICKS_STICK3_de   , JSTICKS_STICK3_en   );
237
    MenuCtrl_PushML2_P( JSTICKS_STICK4    , MENU_SUB , NOFUNC , JSTICKS_STICK4_de   , JSTICKS_STICK4_en   );
238
    MenuCtrl_PushML2_P( JSTICKS_STICK5    , MENU_SUB , NOFUNC , JSTICKS_STICK5_de   , JSTICKS_STICK5_en   );
239
    MenuCtrl_PushML2_P( JSTICKS_LIPO      , MENU_ITEM, NOFUNC , JSTICKS_LIPO_de     , JSTICKS_LIPO_en     );
240
 
241
 
242
    //---------------
243
    // Control
244
    //---------------
245
    while( true )
246
    {
247
        MenuCtrl_Control( MENUCTRL_EVENT );
248
 
249
        if( MenuCtrl_GetKey() == KEY_ESC )  break;      // ENDE
250
 
251
        itemid = MenuCtrl_GetItemId();                  // welcher Menu-Punkt (ID)
252
 
253
        if( itemid == JSTICKS_OVERVIEW  ) { Joysticks_Uebersicht(); }
254
        if( itemid == JSTICKS_STICK1    ) { Setup_Stick(0);          }
255
        if( itemid == JSTICKS_STICK2    ) { if (Config.Lipomessung == true)
256
                                            {
257
                                                lcd_cls ();
258
                                                lcd_printp_at(0, 3, PSTR("LiPo measure!"), MNORMAL);
259
                                                _delay_ms(1000);
260
                                            }
261
                                            else  Setup_Stick(1);           //Stick 2
262
                                          }
263
        if( itemid == JSTICKS_STICK3    ) { Setup_Stick(2);  }
264
        if( itemid == JSTICKS_STICK4    ) { Setup_Stick(3);  }
265
        if( itemid == JSTICKS_STICK5    ) { Setup_Stick(4);  }
266
        if( itemid == JSTICKS_LIPO      ) { Config.Lipomessung = Edit_generic( Config.Lipomessung ,0,1,YesNo,1  ,NULL,NULL);  }
267
 
268
    }
269
 
270
    //---------------
271
    // Destroy
272
    //---------------
273
    MenuCtrl_Destroy();
274
}
275
 
276
 
277
//############################################################################
278
#endif // USE_JOYSTICK
279
//############################################################################