/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/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_puts_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/branch/test2/GPL_PKT_V3_6_7f_FC090b/stick/stick.c_f |
---|
0,0 → 1,392 |
/***************************************************************************** |
* 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" |
#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" |
#include "../eeprom/eeprom.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 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 |
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); |
//CB LIMIT_MIN_MAX (Poti_Neutral[Stick_Nr],108,148); |
LIMIT_MIN_MAX (Poti_Neutral[Stick_Nr],stick_min[Stick_Nr],stick_max[Stick_Nr]); |
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); |
//CB LIMIT_MIN_MAX (Poti_Neutral[Stick_Nr],108,148); |
LIMIT_MIN_MAX (Poti_Neutral[Stick_Nr],stick_min[Stick_Nr],stick_max[Stick_Nr]); |
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_puts_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); |
//CB if (serialChannelRichtung & (1<<Stick_Nr)) |
if (stick_dir[Stick_Nr] & (1<<Stick_Nr)) |
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); |
LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],stick_min[Stick_Nr],stick_max[Stick_Nr]); |
if ((Stick_Nr==0) || (Stick_Nr==2)) // nur die Potis 1,2 sind 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],stick_min[Stick_Nr],stick_max[Stick_Nr]); // war 75 , 225 |
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 |
//CB if (Stick_Nr==3) // Taster |
if (stick_typ[Stick_Nr]==1) // Taster |
{ |
// if (get_key_press (1 << KEY_EXT)) Pos_Stick[Stick_Nr] = 225; |
//CB if (serialChannelRichtung & (1<<Stick_Nr)) |
if (stick_dir[Stick_Nr] & (1<<Stick_Nr)) |
{ |
if (PINA & (1 << KEY_EXT)) Pos_Stick[Stick_Nr] = 30; |
else Pos_Stick[Stick_Nr] = 270; |
} |
else |
{ |
if (PINA & (1 << KEY_EXT)) Pos_Stick[Stick_Nr] = 270; |
else Pos_Stick[Stick_Nr] = 30; |
} |
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)) && (Pos_Stick[4] < 271)) |
{ |
Pos_Stick[4] ++ ; |
//LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],30,270); // war 75 , 225 |
chg |= (1<<4) ; |
} |
else if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Pos_Stick[4] > 29)) |
{ |
Pos_Stick[4] -- ; |
//LIMIT_MIN_MAX (Pos_Stick[Stick_Nr],30,270); // war 75 , 225 |
chg |= (1<<4) ; |
} |
else 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 |
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 |
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% |
} |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/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/branch/test2/GPL_PKT_V3_6_7f_FC090b/stick/stick.h_f |
---|
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 |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/stick/stick_setup.c |
---|
0,0 → 1,311 |
/****************************************************************/ |
/* Setup für die Sticks */ |
/* 2013 Cebra */ |
/****************************************************************/ |
#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 "../menu.h" |
#include "../messages.h" |
#include "../mk-data-structs.h" |
#include "../eeprom/eeprom.h" |
#include "../setup/setup.h" |
//-------------------------------------------------------------- |
#define ITEMS_STICKS 7 |
const prog_char stick_menuitems[ITEMS_STICKS][NUM_LANG][18]= // Zeilen,Zeichen+1 |
{ |
{"Übersicht ","summary ","summary "}, |
{"Stick 1 \x1d","stick 1 \x1d","stick 1 \x1d"}, |
{"Stick 2 \x1d","stick 2 \x1d","stick 2 \x1d"}, |
{"Stick 3 \x1d","stick 3 \x1d","stick 3 \x1d"}, |
{"Stick 4 \x1d","stick 4 \x1d","stick 4 \x1d"}, |
{"Stick 5 \x1d","stick 5 \x1d","stick 5 \x1d"}, |
{"PKT Lipomessung ","PKT Lipo measure.","PKT Lipo measure."}, |
}; |
//-------------------------------------------------------------- |
#define ITEMS_STICK 5 |
const prog_char sticks_menuitems[ITEMS_STICK][NUM_LANG][18]= // Zeilen,Zeichen+1 |
{ |
{"Minimal Wert ","minimal value ","minimal value "}, |
{"Maximal Wert ","maximal value ","maximal value "}, |
{"Type ","type ","type "}, |
{"Richtung ","direction ","direction "}, |
{"Neutralisiered","neutralizing ","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))); |
} |
//-------------------------------------------------------------- |
void Joysticks_Setup(void) |
{ |
size = ITEMS_STICKS; |
// uint8_t ii = 0; |
// uint8_t Offset = 0; |
// uint8_t dmode = 0; |
uint8_t target_pos = 1; |
// uint8_t val = 0; |
edit =0; |
while(1) |
{ |
size = ITEMS_STICKS; |
lcd_cls (); |
lcd_printpns_at(0, 0, PSTR(" Joystick Setup "), 2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
// while(2) |
// { |
// ii = 0; |
// if(Offset > 0) |
// { |
// lcd_printp_at(1,1, PSTR("\x12"), 0); |
// } |
// for(ii = 0;ii < 6 ; ii++) |
// { |
// if((ii+Offset) < size) |
// { |
// lcd_printp_at(3,ii+1,stick_menuitems[ii+Offset][Config.DisplayLanguage], 0); |
// } |
// if((ii == 5)&&(ii+Offset < (size-1))) |
// { |
// lcd_printp_at(1,6, PSTR("\x13"), 0); |
// } |
// } |
// if(dmode == 0) |
// { |
// if(Offset == 0) |
// { |
// if(size > 6) |
// { |
// val = menu_choose2 (1, 5, target_pos,0,1); |
// } |
// else |
// { |
// val = menu_choose2 (1, size, target_pos,0,0); |
// } |
// } |
// else |
// { |
// val = menu_choose2 (2, 5, target_pos,1,1); |
// } |
// } |
// if(dmode == 1) |
// { |
// if(Offset+7 > size) |
// { |
// val = menu_choose2 (2, 6, target_pos,1,0); |
// } |
// else |
// { |
// val = menu_choose2 (2, 5, target_pos,1,1); |
// } |
// } |
// if(val == 254) |
// { |
// Offset++; |
// dmode = 1; |
// target_pos = 5; |
// } |
// else if(val == 253) |
// { |
// Offset--; |
// dmode = 0; |
// target_pos = 2; |
// } |
// else if(val == 255) |
// { |
// if (edit == 1) |
// { |
// WriteParameter(); |
// edit = 0; |
// return; |
// } |
// return; |
// } |
// else |
// { |
// break; |
// } |
// } |
val = menu_select(stick_menuitems,size,target_pos); |
if (val==255) break; |
target_pos = val; |
if((val + offset)== 1 ) Joysticks_Uebersicht(); |
if((val + offset)== 2 ) stick_menu(0); //Stick 1 |
if((val + offset)== 3 ) { |
if (Config.Lipomessung == true) { |
lcd_cls (); |
lcd_puts_at(0, 3, strGet(LIPO_MESSUNG), 2); |
_delay_ms(1000); |
} |
else stick_menu(1); //Stick 2 |
} |
if((val + offset)== 4 ) stick_menu(2); //Stick 3 |
if((val + offset)== 5 ) stick_menu(3); //Stick 4 |
if((val + offset)== 6 ) stick_menu(4); //Stick 5 |
if((val + offset)== 7 ) Config.Lipomessung = Edit_generic(Config.Lipomessung,0,1,LIPO_MESSUNG,YesNo); |
} |
} |
//-------------------------------------------------------------- |
void stick_menu(uint8_t stick) |
{ |
// uint8_t ii = 0; |
// uint8_t Offset = 0; |
// uint8_t dmode = 0; |
uint8_t target_pos = 1; |
// uint8_t val = 0; |
edit =0; |
while(1) |
{ |
size = ITEMS_STICK; |
lcd_cls (); |
lcd_printpns_at(0, 0, PSTR("Joystick "), 2); |
write_ndigit_number_u (9, 0,stick+1, 1, 0,2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
// while(2) |
// { |
// ii = 0; |
// if(Offset > 0) |
// { |
// lcd_printp_at(1,1, PSTR("\x12"), 0); |
// } |
// for(ii = 0;ii < 6 ; ii++) |
// { |
// if((ii+Offset) < size) |
// { |
// lcd_printp_at(3,ii+1,sticks_menuitems[ii+Offset][Config.DisplayLanguage], 0); |
// } |
// if((ii == 5)&&(ii+Offset < (size-1))) |
// { |
// lcd_printp_at(1,6, PSTR("\x13"), 0); |
// } |
// } |
// if(dmode == 0) |
// { |
// if(Offset == 0) |
// { |
// if(size > 6) |
// { |
// val = menu_choose2 (1, 5, target_pos,0,1); |
// } |
// else |
// { |
// val = menu_choose2 (1, size, target_pos,0,0); |
// } |
// } |
// else |
// { |
// val = menu_choose2 (2, 5, target_pos,1,1); |
// } |
// } |
// if(dmode == 1) |
// { |
// if(Offset+7 > size) |
// { |
// val = menu_choose2 (2, 6, target_pos,1,0); |
// } |
// else |
// { |
// val = menu_choose2 (2, 5, target_pos,1,1); |
// } |
// } |
// if(val == 254) |
// { |
// Offset++; |
// dmode = 1; |
// target_pos = 5; |
// } |
// else if(val == 253) |
// { |
// Offset--; |
// dmode = 0; |
// target_pos = 2; |
// } |
// else if(val == 255) |
// { |
// if (edit == 1) |
// { |
// WriteParameter(); |
// edit = 0; |
// return; |
// } |
// return; |
// } |
// else |
// { |
// break; |
// } |
// } |
val = menu_select(sticks_menuitems,size,target_pos); |
if (val==255) break; |
target_pos = val; |
if((val + offset) == 1 ) Config.stick_min[stick]= Edit_generic(Config.stick_min[stick],0,300,STICK_MIN,Show_uint3); |
if((val + offset) == 2 ) Config.stick_max[stick]= Edit_generic(Config.stick_max[stick],0,300,STICK_MAX,Show_uint3); |
if((val + offset) == 3 ) Config.stick_typ[stick]= Edit_generic(Config.stick_typ[stick],0,1,STICK_TYPE,Sticktype); |
if((val + offset) == 4 ) Config.stick_dir[stick]= Edit_generic(Config.stick_dir[stick],0,1,STICK_DIR,NormRev); |
if((val + offset) == 5 ) Config.stick_neutral[stick]= Edit_generic(Config.stick_neutral[stick],0,1,STICK_NEUTRAL,YesNo); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/test2/GPL_PKT_V3_6_7f_FC090b/stick/stick_setup.h |
---|
0,0 → 1,7 |
#ifndef _STICK_SETUP_H_ |
#define _STICK_SETUP_ |
void Joysticks_Setup(void); |
void stick_menu(uint8_t stick); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |