Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2146 → Rev 2147

/Transportables_Koptertool/PKT/trunk/stick/stick.c
0,0 → 1,507
/*****************************************************************************
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de *
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net *
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
* Copyright (C) 2011 Harald Bongartz *
* Copyright (C) 2012 Martin Runkel *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* *
* Credits to: *
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN *
* http://www.mikrokopter.de *
* Gregor "killagreg" Stobrawa for his version of the MK code *
* Thomas Kaiser "thkais" for the original project. See *
* http://www.ft-fanpage.de/mikrokopter/ *
* http://forum.mikrokopter.de/topic-4061-1.html *
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
* http://www.mylifesucks.de/oss/c-osd/ *
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
*****************************************************************************/
 
 
#include "../cpu.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
 
#include <string.h>
#include <stdlib.h>
 
#include "../lcd/lcd.h"
#include "../timer/timer.h"
//#include "../tracking/servo.h"
#include "../messages.h"
#include "../lipo/lipo.h"
#include "stick.h"
#include "stick_setup.h"
#include "../eeprom/eeprom.h"
#include "../setup/setup.h"
 
#define SERVO_CORRECT 3.125
 
 
#include <util/delay.h>
#include <inttypes.h>
#include <stdlib.h>
 
#include "../main.h"
#include "../uart/uart1.h"
#include "../uart/usart.h"
 
 
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
 
int16_t Pos_Stick[12]; // 1,5mS
int16_t Pos_alt[5]; //
 
uint8_t BalkenPos = 0;
uint8_t Stick_Display = 0;
//uint8_t serialChannelRichtung = 0;
//uint8_t serialChannelNeutral = 0;
//uint8_t serialChannelConfig = 2;
 
 
//--------------------------------------------------------------
//
void joystick (void)
{
// uint8_t chg = 0;
// uint8_t Pos_Stick = 150; // 1,5mS
// uint8_t Pos_alt = 150; //
//int16_t Pos_Stick[12]; // 1,5mS
uint8_t chg = 0;
//uint8_t BalkenPos = 0;
uint8_t Stick_Nr = 0;
//uint8_t Stick_Display = 0;
uint8_t i = 0;
 
memset (Pos_Stick, 150, 3); // füllt 3+1 Byte vom Pos_Stick[12] mit 150
//int16_t Pos_alt[5]; //
int16_t Poti_Summe[5]; //
memset (Poti_Summe, 0, 5); // füllt 3+1 Byte mit 0
int16_t Poti_Neutral[5]; //
 
 
// ADC- init
//if (Config.Lipomessung == true)
//{
 
//}
//for (uint8_t i = 0; i < 4; i++)
 
if (Config.stick_typ[0] == 0) // Poti
{
PORTA &= ~(1<<PORTA0);
DDRA &= ~(1<<DDA0);
}
else // Taster
{
PORTA |= (1<<PORTA0);
DDRA |= (1<<DDA0);
}
if (Config.Lipomessung == false)
{
if (Config.stick_typ[1] == 0) // Poti
{
PORTA &= ~(1<<PORTA1);
DDRA &= ~(1<<DDA1);
}
else // Taster
{
PORTA |= (1<<PORTA1);
DDRA |= (1<<DDA1);
}
}
if (Config.stick_typ[2] == 0)
{
PORTA &= ~(1<<PORTA2);
DDRA &= ~(1<<DDA2);
}
else
{
PORTA |= (1<<PORTA2);
DDRA |= (1<<DDA2);
}
if (Config.stick_typ[3] == 0)
{
PORTA &= ~(1<<PORTA3);
DDRA &= ~(1<<DDA3);
}
else
{
PORTA |= (1<<PORTA3);
DDRA |= (1<<DDA3);
}
 
//if (Config.stick_dir[i] == 0) serialChannelRichtung &= ~(1<<i); else serialChannelRichtung |= (1<<i);
//if (Config.stick_neutral[i] == 0) serialChannelNeutral &= ~(1<<i); else serialChannelNeutral |= (1<<i);
 
//if (Config.Lipomessung == true)
 
//serialChannelConfig
 
 
// Ermittlung der Neutralposition
for (uint8_t i = 0; i < 4; i++)
{
ADMUX = (1<<REFS0)|(0<<MUX0); // Multiplexer selection Register: AVCC with external capacitor at AREF pin , ADC1
ADMUX = (ADMUX & ~(0x1F)) | (i & 0x1F); // ADC[i] verwenden
 
timer = 50;
while (timer > 0);
 
ADCSRA = (1<<ADEN)|(1<<ADSC)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); // ADC Enable, ADC Start, Prescaler 128
 
 
while (ADCSRA & (1<<ADSC)); // wenn ADC fertig
 
Poti_Neutral[i] = ((ADCW>>2)&0xff);
LIMIT_MIN_MAX (Poti_Neutral[i],108,148);
 
ADMUX = (ADMUX & ~(0x1F)) | (i & 0x1F); // ADC[i] verwenden
// Stick_Nr 1,2,3 = Potis, Stick_Nr 1= Lipo
ADCSRA |= (1<<ADSC); // ADC Start
 
while (ADCSRA & (1<<ADSC)); // wenn ADC fertig
 
Poti_Neutral[i] = ((ADCW>>2)&0xff);
LIMIT_MIN_MAX (Poti_Neutral[i],108,148);
}
Stick_Nr = 0;
ADMUX = (ADMUX & ~(0x1F)) | (Stick_Nr & 0x1F); // ADC[i] verwenden
ADCSRA |= (1<<ADSC); // ADC Start
 
/*
Stick_Nr = 0;
ADMUX = (1<<REFS0)|(0<<MUX0); // Multiplexer selection Register: AVCC with external capacitor at AREF pin , ADC1
ADMUX = (ADMUX & ~(0x1F)) | (Stick_Nr & 0x1F); // ADC[Stick_Nr] verwenden
timer = 50;
while (timer > 0);
ADCSRA = (1<<ADEN)|(1<<ADSC)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); // ADC Enable, ADC Start, Prescaler 128
 
// Stick-Neutralposition bestimmen
 
while (ADCSRA & (1<<ADSC)); // wenn ADC fertig
Poti_Neutral[Stick_Nr] = ((ADCW>>2)&0xff);
LIMIT_MIN_MAX (Poti_Neutral[Stick_Nr],108,148);
Stick_Nr = 2 ;
ADMUX = (ADMUX & ~(0x1F)) | (Stick_Nr & 0x1F); // ADC[i] verwenden
// Stick_Nr 1,2,3 = Potis, Stick_Nr 1= Lipo
ADCSRA |= (1<<ADSC); // ADC Start
while (ADCSRA & (1<<ADSC)); // wenn ADC fertig
Poti_Neutral[Stick_Nr] = ((ADCW>>2)&0xff);
LIMIT_MIN_MAX (Poti_Neutral[Stick_Nr],108,148);
Stick_Nr = 0;
ADMUX = (ADMUX & ~(0x1F)) | (Stick_Nr & 0x1F); // ADC[i] verwenden
// Stick_Nr 1,2,3 = Potis, Stick_Nr 1= Lipo
ADCSRA |= (1<<ADSC); // ADC Start
*/
 
 
 
//OCR1A = 150 * SERVO_CORRECT; // Servomitte
 
lcd_cls ();
// Kopfzeile und Rahmen zeichnen
lcd_printp (PSTR(" serielle Potis 1-5 "), 2);
//lcd_printp_at (7, 5, PSTR("%"), 0);
//lcd_printp_at (16, 5, PSTR("mS"), 0);
 
lcd_printp_at(0, 7, strGet(KEYLINE3), 0);
lcd_printp_at (18, 7, PSTR("\x19O\x18"), 0);
for (i=0 ; i< 5 ; i++)
{
BalkenPos = 12 + (i*8) ;
 
lcd_rect(3,BalkenPos, 120, 6, 1); // +-150% Rahmen
lcd_line(23,BalkenPos,23,(BalkenPos+6),1); // -100%
lcd_line(43,BalkenPos,43,(BalkenPos+6),1); // -50%
lcd_frect(62,BalkenPos, 2, 6, 1); // 0%
lcd_line(83,BalkenPos,83,(BalkenPos+6),1); // +50%
lcd_line(103,BalkenPos,103,(BalkenPos+6),1); // +100%
}
// Reset auf Mittelstellung
Pos_Stick[0] = 150;
Poti_Summe[0] = 0;
Pos_Stick[2] = 150;
Poti_Summe[2] = 0;
Pos_Stick[4] = 150;
Poti_Summe[4] = 0;
chg = 255;
 
do
{
if (!(ADCSRA & (1<<ADSC))) // wenn ADC fertig
{
//Pos_Stick[Stick_Nr] = 150 + 128 - ((ADCW>>2)&0xff);
//if (serialChannelRichtung & (1<<Stick_Nr))
if (Config.stick_dir[Stick_Nr] > 0)
Pos_Stick[Stick_Nr] = Poti_Neutral[Stick_Nr] - ((ADCW>>2)&0xff);
else
Pos_Stick[Stick_Nr] = ((ADCW>>2)&0xff) - Poti_Neutral[Stick_Nr];
 
 
LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],-120,120);
//if ((Stick_Nr==0) || (Stick_Nr==2)) // nur die Potis 1,2 sind nicht neutralisierend
if (Config.stick_neutral[Stick_Nr]==0) // nicht neutralisierend
{
Poti_Summe[Stick_Nr] += (Pos_Stick[Stick_Nr]/8) * abs(Pos_Stick[Stick_Nr]/8);
LIMIT_MIN_MAX (Poti_Summe[Stick_Nr],-(120*128),(120*128));
Pos_Stick[Stick_Nr]= Poti_Summe[Stick_Nr] / 128; // nicht neutralisierend
}
Pos_Stick[Stick_Nr] += 150;
//LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],30,270); // war 75 , 225
LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],Config.stick_min[Stick_Nr],Config.stick_max[Stick_Nr]); // war 30, 270
if (Pos_Stick[Stick_Nr] != Pos_alt[Stick_Nr]) // nur bei Änderung
{
chg |= (1<<Stick_Nr) ;
//Pos_alt=Pos_Stick ; // verschoben
}
Stick_Nr ++ ;
//if (Stick_Nr==1) Stick_Nr=2; // Lipo überspringen
if (Stick_Nr==3) // Taster
{
if (Config.stick_dir[Stick_Nr] > 0)
{
if (PINA & (1 << KEY_EXT)) Pos_Stick[Stick_Nr] = Config.stick_min[Stick_Nr];
else Pos_Stick[Stick_Nr] = Config.stick_max[Stick_Nr];
}
else
{
if (PINA & (1 << KEY_EXT)) Pos_Stick[Stick_Nr] = Config.stick_max[Stick_Nr];
else Pos_Stick[Stick_Nr] = Config.stick_min[Stick_Nr];
}
if (Pos_Stick[Stick_Nr] != Pos_alt[Stick_Nr])
{
chg |= (1<<Stick_Nr) ;
}
Stick_Nr=0;
}
/*
#ifndef ohne_Lipo // MartinR
Stick_Nr = 1; // MartinR AD-Kanal 1 überspringen wegen Lipo Überwachung
#endif
*/
 
ADMUX = (ADMUX & ~(0x1F)) | (Stick_Nr & 0x1F); // ADC[i] verwenden
// Stick_Nr 1,2,3 = Potis, Stick_Nr 0= Lipo
ADCSRA |= (1<<ADSC); // ADC Start
//serialPotis ();
}
 
if ((get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3)))
//if (get_key_press (1 << KEY_PLUS))
//if (PINA & (1 << KEY_PLUS))
{
if (Config.stick_neutral[4]==0) // nicht neutralisierend
{
if (Config.stick_dir[4] == 0) Pos_Stick[4] ++ ; else Pos_Stick[4] -- ;
LIMIT_MIN_MAX (Pos_Stick[4],Config.stick_min[4],Config.stick_max[4]); // war 30, 270
}
else
{
if (Config.stick_dir[4] == 0) Pos_Stick[4] = Config.stick_max[4] ; else Pos_Stick[4] = Config.stick_min[4] ;
}
chg |= (1<<4) ;
}
else if ((get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 3)))
{
if (Config.stick_neutral[4]==0) // nicht neutralisierend
{
if (Config.stick_dir[4] == 0) Pos_Stick[4] -- ; else Pos_Stick[4] ++ ;
LIMIT_MIN_MAX (Pos_Stick[4],Config.stick_min[4],Config.stick_max[4]); // war 30, 270
//LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],30,270); // war 75 , 225
}
else
{
if (Config.stick_dir[4] == 0) Pos_Stick[4] = Config.stick_min[4] ; else Pos_Stick[4] = Config.stick_max[4] ;
}
chg |= (1<<4) ;
}
 
if (Config.stick_neutral[4]!= 0 && Pos_Stick[4]!= 150 && (PINA &(1 << KEY_PLUS)) && (PINA &(1 << KEY_MINUS)))
{
Pos_Stick[4] = 150 ;
chg |= (1<<4) ;
}
 
if (get_key_press (1 << KEY_ENTER))
{
/*
for (i=0 ; i< 4 ; i++)
{
BalkenPos = 12 + (i*8) ;
lcd_frect (4, (BalkenPos+1), 118, 4, 0); // Balken löschen
lcd_frect(62, BalkenPos, 2, 6, 1); // 0%
}
*/
Pos_Stick[0] = 150;
Poti_Summe[0] = 0;
Pos_Stick[2] = 150;
Poti_Summe[2] = 0;
Pos_Stick[4] = 150;
Poti_Summe[4] = 0;
BeepTime = 200;
BeepMuster = 0x0080;
chg = 255;
}
 
if (chg)
{
if (chg & (1<<0)); // Stick 1
{
BalkenPos = 12 + (0*8) ;
Stick_Display = 0;
Balken_Zeichnen () ;
Pos_alt[Stick_Display]=Pos_Stick[Stick_Display];
}
// Stick 2 = Lipo
if (chg & (1<<1)); // Stick 2
{
BalkenPos = 12 + (1*8) ;
Stick_Display = 1;
//if (serialChannelConfig & (0<<1)) Balken_Zeichnen () ; // nur wenn keine Lipo-Spannung
if (Config.Lipomessung == false) Balken_Zeichnen () ; // nur wenn keine Lipo-Spannung
Pos_alt[Stick_Display]=Pos_Stick[Stick_Display];
}
if (chg & (1<<2)); // Stick 3
{
BalkenPos = 12 + (2*8) ;
Stick_Display = 2;
Balken_Zeichnen () ;
Pos_alt[Stick_Display]=Pos_Stick[Stick_Display];
}
if (chg & (1<<3)); // Stick 4 = Taster
{
BalkenPos = 12 + (3*8) ;
Stick_Display = 3;
Balken_Zeichnen () ;
Pos_alt[Stick_Display]=Pos_Stick[Stick_Display];
}
if (chg & (1<<4)); // Stick 5 = Taster vom PKT
{
BalkenPos = 12 + (4*8) ;
Stick_Display = 4;
Balken_Zeichnen () ;
//OCR1A = (((Pos_Stick[Stick_Display]-150)/1.6)+150) * SERVO_CORRECT; // Servostellung , 1.6=0.8*0.5
Pos_alt[Stick_Display]=Pos_Stick[Stick_Display];
}
chg = 0;
serialPotis ();
}
}
while (!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
//#ifdef HWVERSION3_9
//#ifndef ohne_Lipo // MartinR
if (Config.Lipomessung == true) // MartinR: geändert
{
//DDRA &= ~(1<<DDA1); // Eingang: PKT Lipo Messung
//PORTA &= ~(1<<PORTA1);
ADC_Init(); // ADC für Lipomessung wieder aktivieren
}
 
//ADC_Init(); // ADC für Lipomessung wieder aktivieren
//#endif
//#endif
 
}
 
//--------------------------------------------------------------
//
void serialPotis (void)
{
uint8_t i = 0;
memset (buffer, 0, 12); // füllt die 12+1 Byte vom buffer mit 0
 
for (i=0 ; i< 5 ; i++)
{
buffer[i] = Pos_Stick[i]-150 ;
}
SendOutData('y', ADDRESS_FC, 1, buffer, 12);
}
//--------------------------------------------------------------
//
void Balken_Zeichnen (void)
{
// Balken löschen
if ((Pos_Stick[Stick_Display] > Pos_alt[Stick_Display])&&(Pos_alt[Stick_Display] < 150)) // Balken links löschen
lcd_frect ((63-((150 -Pos_alt[Stick_Display]) * 0.5)), (BalkenPos+1), (63-((150- Pos_Stick[Stick_Display]) * 0.5)), 4, 0);
if ((Pos_Stick[Stick_Display] < Pos_alt[Stick_Display])&&(Pos_alt[Stick_Display] > 150)) // Balken rechts löschen
lcd_frect ((63+((Pos_Stick[Stick_Display] - 150) * 0.5)), (BalkenPos+1), (63+((Pos_alt[Stick_Display] - 150) * 0.5)), 4, 0);
// Balken zeichnen
if (Pos_Stick[Stick_Display] >= 150)
{
lcd_frect (63, (BalkenPos+1), ((Pos_Stick[Stick_Display] - 150) * 0.5), 4, 1);
//write_ndigit_number_u (4, 5, ((Pos_Stick[Stick_Display] - 150) * 1.25), 3, 0, 0); // Pulse width in %
lcd_frect(62, (BalkenPos), 2, 6, 1); // 0%
}
else
{
lcd_frect (63 - ((150 - Pos_Stick[Stick_Display]) * 0.5), (BalkenPos+1), ((150 - Pos_Stick[Stick_Display]) * 0.5), 4, 1);
//write_ndigit_number_u (4, 5, ((150 - Pos_Stick[Stick_Display]) * 1.25), 3, 0, 0); // Pulse width in %
lcd_frect(62, (BalkenPos), 2, 6, 1); // 0%
}
// Raster zeichnen
lcd_line(3, BalkenPos,3, (BalkenPos+6),1); // -150%
lcd_line(23, BalkenPos,23, (BalkenPos+6),1); // -100%
lcd_line(43, BalkenPos,43, (BalkenPos+6),1); // -50%
lcd_line(83, BalkenPos,83, (BalkenPos+6),1); // +50%
lcd_line(103,BalkenPos,103,(BalkenPos+6),1); // +100%
lcd_line(123,BalkenPos,123,(BalkenPos+6),1); // +150%
}
 
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/Transportables_Koptertool/PKT/trunk/stick/stick.h
0,0 → 1,42
/*****************************************************************************
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de *
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net *
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
* Copyright (C) 2011 Harald Bongartz *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* *
* Credits to: *
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN *
* http://www.mikrokopter.de *
* Gregor "killagreg" Stobrawa for his version of the MK code *
* Thomas Kaiser "thkais" for the original project. See *
* http://www.ft-fanpage.de/mikrokopter/ *
* http://forum.mikrokopter.de/topic-4061-1.html *
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
* http://www.mylifesucks.de/oss/c-osd/ *
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
*****************************************************************************/
 
 
#ifndef _STICK_H
#define _STICK_H
 
void joystick (void);
void serialPotis (void);
void Balken_Zeichnen (void);
 
#endif
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/Transportables_Koptertool/PKT/trunk/stick/stick_setup.c
0,0 → 1,279
 
/****************************************************************/
/* Setup für die Sticks */
/* 2013 Cebra */
/****************************************************************/
 
//############################################################################
//# HISTORY stick_setup.c
//#
//# 28.05.2014 OG
//# - chg: Setup's auf das neue Edit_generic() umgestellt
//#
//# 11.05.2014 OG
//# - chg: einge Setup-Menues umgestellt auf MenuCtrl_SetTitleFromParentItem()
//# -> die Menues 'erben' damit ihren Titel vom aufrufenden Menuepunkt
//#
//# 30.03.2014 OG
//# - chg: ein paar englische Texte auf DE gemappt weil der Unterschied unerheblich war
//# - chg: Sprache Hollaendisch vollstaendig entfernt
//# - chg: MenuCtrl_PushML_P() umgestellt auf MenuCtrl_PushML2_P()
//#
//# 31.05.2013 OG
//# - chg: einige redundante Menuetitel auf define umgestellt
//#
//# 24.05.2013 OG
//# - chg: Aufrufe von MenuCtrl_Push() umgestellt auf MenuCtrl_PushML_P()
//#
//# 22.05.2013 OG
//# - umgestellt auf menuctrl
//# - del: include utils/menuold.h
//#
//# 17.05.2013 OG
//# - chg: umgestellt auf utils/menuold.h
//#
//# 16.04.2013 Cebra
//# - chg: PROGMEM angepasst auf neue avr-libc und GCC, prog_char depreciated
//#
//# 04.04.2013 Cebra
//# - chg: Texttuning
//#
//# 03.04.2013 Cebra
//# - chg: Holländische Menütexte
//#
//# 27.03.2013 Cebra
//# - chg: Fehler bei der Menüsteuerung behoben
//############################################################################
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../cpu.h"
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "../main.h"
#include "../timer/timer.h"
#include "stick_setup.h"
#include "../lcd/lcd.h"
#include "../timer/timer.h"
#include "../messages.h"
#include "../mk-data-structs.h"
#include "../eeprom/eeprom.h"
#include "../setup/setup.h"
#include "../utils/menuctrl.h"
 
 
//############################################################################
#ifdef USE_JOYSTICK
//############################################################################
 
//-----------------------------
// Setup_Joysticks()
//-----------------------------
#define JSTICKS_OVERVIEW 1
#define JSTICKS_STICK1 2
#define JSTICKS_STICK2 3
#define JSTICKS_STICK3 4
#define JSTICKS_STICK4 5
#define JSTICKS_STICK5 6
#define JSTICKS_LIPO 7
 
static const char JSTICKS_OVERVIEW_de[] PROGMEM = "Übersicht";
static const char JSTICKS_OVERVIEW_en[] PROGMEM = "summary";
 
static const char JSTICKS_STICK1_de[] PROGMEM = "Stick 1";
#define JSTICKS_STICK1_en JSTICKS_STICK1_de
 
static const char JSTICKS_STICK2_de[] PROGMEM = "Stick 2";
#define JSTICKS_STICK2_en JSTICKS_STICK2_de
 
static const char JSTICKS_STICK3_de[] PROGMEM = "Stick 3";
#define JSTICKS_STICK3_en JSTICKS_STICK3_de
 
static const char JSTICKS_STICK4_de[] PROGMEM = "Stick 4";
#define JSTICKS_STICK4_en JSTICKS_STICK4_de
 
static const char JSTICKS_STICK5_de[] PROGMEM = "Stick 5";
#define JSTICKS_STICK5_en JSTICKS_STICK5_de
 
static const char JSTICKS_LIPO_de[] PROGMEM = "PKT Lipomessung";
static const char JSTICKS_LIPO_en[] PROGMEM = "PKT Lipo measure.";
 
 
//############################################################################
 
//-----------------------------
// Setup_Stick()
//-----------------------------
#define MSTICK_MIN 1
#define MSTICK_MAX 2
#define MSTICK_TYPE 3
#define MSTICK_DIR 4
#define MSTICK_NEUT 5
 
static const char MSTICK_MIN_de[] PROGMEM = "Minimal Wert";
static const char MSTICK_MIN_en[] PROGMEM = "minimal value";
 
static const char MSTICK_MAX_de[] PROGMEM = "Maximal Wert";
static const char MSTICK_MAX_en[] PROGMEM = "maximal value";
 
static const char MSTICK_TYPE_de[] PROGMEM = "Type";
static const char MSTICK_TYPE_en[] PROGMEM = "type";
 
static const char MSTICK_DIR_de[] PROGMEM = "Richtung";
static const char MSTICK_DIR_en[] PROGMEM = "direction";
 
static const char MSTICK_NEUT_de[] PROGMEM = "Neutralisiered";
static const char MSTICK_NEUT_en[] PROGMEM = "neutralizing";
 
//############################################################################
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
void Joysticks_Uebersicht(void)
{
lcd_cls ();
lcd_printpns_at(0, 0, PSTR(" Joystick Setup "), 2);
lcd_printpns_at(0, 1, PSTR("S Min Max Typ Dir N"), 0);
 
for (uint8_t i = 0; i < 5; i++) {
 
write_ndigit_number_u (0, 2+i,i+1, 1, 0,0);
write_ndigit_number_u (2, 2+i,Config.stick_min[i], 3, 0,0);
write_ndigit_number_u (6, 2+i,Config.stick_max[i], 3, 0,0);
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);
//if (Config.stick_typ[i] == 0) // MartinR: geändert
//{
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);
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);
//}
if (i == 1) if (Config.Lipomessung == true) lcd_printpns_at(3, 2+i, PSTR("PKT Lipomessung "), 0);
 
}
 
 
lcd_printp_at (18, 7, PSTR("OK"), 0);
 
do{}
while (!(get_key_press (1 << KEY_ENTER)));
}
 
 
 
//--------------------------------------------------------------
// Setup_Stick()
//--------------------------------------------------------------
void Setup_Stick( uint8_t stick )
{
uint8_t itemid;
 
//---------------
// Create
//---------------
MenuCtrl_Create();
MenuCtrl_SetTitleFromParentItem(); // "Stick n"
//MenuCtrl_SetTitle_P( PSTR("Joystick") );
 
//---------------
// Menuitems
//---------------
MenuCtrl_PushML2_P( MSTICK_MIN , MENU_ITEM, NOFUNC , MSTICK_MIN_de , MSTICK_MIN_en );
MenuCtrl_PushML2_P( MSTICK_MAX , MENU_ITEM, NOFUNC , MSTICK_MAX_de , MSTICK_MAX_en );
MenuCtrl_PushML2_P( MSTICK_TYPE , MENU_ITEM, NOFUNC , MSTICK_TYPE_de , MSTICK_TYPE_en );
MenuCtrl_PushML2_P( MSTICK_DIR , MENU_ITEM, NOFUNC , MSTICK_DIR_de , MSTICK_DIR_en );
MenuCtrl_PushML2_P( MSTICK_NEUT , MENU_ITEM, NOFUNC , MSTICK_NEUT_de , MSTICK_NEUT_en );
 
//---------------
// Control
//---------------
while( true )
{
MenuCtrl_Control( MENUCTRL_EVENT );
 
if( MenuCtrl_GetKey() == KEY_ESC ) break; // ENDE
 
itemid = MenuCtrl_GetItemId(); // welcher Menu-Punkt (ID)
 
if( itemid == MSTICK_MIN ) { Config.stick_min[stick] = Edit_generic( Config.stick_min[stick] ,0,300,Show_uint3,1 ,NULL,NULL); }
if( itemid == MSTICK_MAX ) { Config.stick_max[stick] = Edit_generic( Config.stick_max[stick] ,0,300,Show_uint3,1 ,NULL,NULL); }
if( itemid == MSTICK_TYPE ) { Config.stick_typ[stick] = Edit_generic( Config.stick_typ[stick] ,0, 1,Sticktype,1 ,NULL,NULL); }
if( itemid == MSTICK_DIR ) { Config.stick_dir[stick] = Edit_generic( Config.stick_dir[stick] ,0, 1,NormRev,1 ,NULL,NULL); }
if( itemid == MSTICK_NEUT ) { Config.stick_neutral[stick]= Edit_generic( Config.stick_neutral[stick] ,0, 1,YesNo,1 ,NULL,NULL); }
 
}
 
//---------------
// Destroy
//---------------
MenuCtrl_Destroy();
}
 
 
 
//--------------------------------------------------------------
// Setup_Joysticks()
//--------------------------------------------------------------
void Setup_Joysticks( void )
{
uint8_t itemid;
 
//---------------
// Create
//---------------
MenuCtrl_Create();
MenuCtrl_SetTitleFromParentItem(); // "Joystick"
//MenuCtrl_SetTitle_P( PSTR("Joystick Setup") );
 
//---------------
// Menuitems
//---------------
MenuCtrl_PushML2_P( JSTICKS_OVERVIEW , MENU_ITEM, NOFUNC , JSTICKS_OVERVIEW_de , JSTICKS_OVERVIEW_en );
MenuCtrl_PushML2_P( JSTICKS_STICK1 , MENU_SUB , NOFUNC , JSTICKS_STICK1_de , JSTICKS_STICK1_en );
MenuCtrl_PushML2_P( JSTICKS_STICK2 , MENU_SUB , NOFUNC , JSTICKS_STICK2_de , JSTICKS_STICK2_en );
MenuCtrl_PushML2_P( JSTICKS_STICK3 , MENU_SUB , NOFUNC , JSTICKS_STICK3_de , JSTICKS_STICK3_en );
MenuCtrl_PushML2_P( JSTICKS_STICK4 , MENU_SUB , NOFUNC , JSTICKS_STICK4_de , JSTICKS_STICK4_en );
MenuCtrl_PushML2_P( JSTICKS_STICK5 , MENU_SUB , NOFUNC , JSTICKS_STICK5_de , JSTICKS_STICK5_en );
MenuCtrl_PushML2_P( JSTICKS_LIPO , MENU_ITEM, NOFUNC , JSTICKS_LIPO_de , JSTICKS_LIPO_en );
 
 
//---------------
// Control
//---------------
while( true )
{
MenuCtrl_Control( MENUCTRL_EVENT );
 
if( MenuCtrl_GetKey() == KEY_ESC ) break; // ENDE
 
itemid = MenuCtrl_GetItemId(); // welcher Menu-Punkt (ID)
 
if( itemid == JSTICKS_OVERVIEW ) { Joysticks_Uebersicht(); }
if( itemid == JSTICKS_STICK1 ) { Setup_Stick(0); }
if( itemid == JSTICKS_STICK2 ) { if (Config.Lipomessung == true)
{
lcd_cls ();
lcd_printp_at(0, 3, PSTR("LiPo measure!"), MNORMAL);
_delay_ms(1000);
}
else Setup_Stick(1); //Stick 2
}
if( itemid == JSTICKS_STICK3 ) { Setup_Stick(2); }
if( itemid == JSTICKS_STICK4 ) { Setup_Stick(3); }
if( itemid == JSTICKS_STICK5 ) { Setup_Stick(4); }
if( itemid == JSTICKS_LIPO ) { Config.Lipomessung = Edit_generic( Config.Lipomessung ,0,1,YesNo,1 ,NULL,NULL); }
 
}
 
//---------------
// Destroy
//---------------
MenuCtrl_Destroy();
}
 
 
//############################################################################
#endif // USE_JOYSTICK
//############################################################################
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/Transportables_Koptertool/PKT/trunk/stick/stick_setup.h
0,0 → 1,13
//############################################################################
//# HISTORY stick_setup.h
//#
//# 22.05.2013 OG
//# - umgestellt auf menuctrl
//############################################################################
 
#ifndef _STICK_SETUP_H_
#define _STICK_SETUP_
 
void Setup_Joysticks(void);
 
#endif
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/Transportables_Koptertool/PKT/trunk/stick/.
Property changes:
Added: svn:ignore
+_old_source