13,7 → 13,15 |
volatile int16_t ServoNickValue = 0; |
volatile int16_t ServoRollValue = 0; |
|
// Arthur P: Added two variables for control of the shutter servo cycle. |
// 091114 Inserted same changes into v.0.76g code. |
// 091114 Inactivated the following two lines as the shutter interval funtion is not |
// used at the moment. |
// volatile static unsigned int CameraShutterCycleCounter = 0; |
// volatile static unsigned int CameraShutterCycle = 0; |
|
|
|
enum { |
STOP = 0, |
CK = 1, |
28,66 → 36,90 |
|
SIGNAL (SIG_OVERFLOW0) // 9,7kHz |
{ |
static unsigned char cnt_1ms = 1,cnt = 0; |
static unsigned char cnt_1ms = 1,cnt = 0; |
unsigned char pieper_ein = 0; |
if(SendSPI) SendSPI--; |
if(SpektrumTimer) SpektrumTimer--; |
if(SendSPI) SendSPI--; |
if(SpektrumTimer) SpektrumTimer--; |
|
if(!cnt--) |
if(!cnt--) |
{ |
cnt = 9; |
cnt_1ms++; |
cnt_1ms %= 2; |
if(!cnt_1ms) UpdateMotor = 1; |
CountMilliseconds++; |
cnt = 9; |
cnt_1ms++; |
cnt_1ms %= 2; |
if(!cnt_1ms) UpdateMotor = 1; |
CountMilliseconds++; |
} |
|
if(beeptime >= 1) |
{ |
beeptime--; |
if(beeptime >= 1) |
{ |
beeptime--; |
if(beeptime & BeepMuster) |
{ |
pieper_ein = 1; |
} |
else pieper_ein = 0; |
{ |
pieper_ein = 1; |
} |
else |
{ |
pieper_ein = 0; |
BeepMuster = 0xffff; |
} |
else |
{ |
pieper_ein = 0; |
} |
} |
else |
{ |
pieper_ein = 0; |
BeepMuster = 0xffff; |
} |
|
if(pieper_ein) |
{ |
if(PlatinenVersion == 10) PORTD |= (1<<2); // Speaker an PORTD.2 |
else PORTC |= (1<<7); // Speaker an PORTC.7 |
if(pieper_ein) |
{ |
if(PlatinenVersion == 10) |
{ |
PORTD |= (1<<2); // Speaker an PORTD.2 |
} |
else |
{ |
if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
else PORTC &= ~(1<<7); |
else |
{ |
PORTC |= (1<<7); // Speaker an PORTC.7 |
} |
|
if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
{ |
if(PINC & 0x10) |
{ |
cntKompass++; |
} |
else |
{ |
if((cntKompass) && (cntKompass < 362)) |
} |
else |
{ |
cntKompass += cntKompass / 41; |
if(cntKompass > 10) KompassValue = cntKompass - 10; else KompassValue = 0; |
if(PlatinenVersion == 10) |
{ |
PORTD &= ~(1<<2); |
} |
else |
{ |
PORTC &= ~(1<<7); |
} |
} |
// if(cntKompass < 10) cntKompass =r 10; |
// KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
cntKompass = 0; |
} |
} |
|
if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
{ |
if(PINC & 0x10) |
{ |
cntKompass++; |
} |
else |
{ |
if((cntKompass) && (cntKompass < 362)) |
{ |
cntKompass += cntKompass / 41; |
if(cntKompass > 10) |
{ |
KompassValue = cntKompass - 10; |
} |
else |
{ |
KompassValue = 0; |
} |
} |
|
// if(cntKompass < 10) cntKompass =r 10; |
// KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
|
KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
cntKompass = 0; |
} |
} |
|
} |
|
|
216,7 → 248,18 |
static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
|
// replace below line with if(PlatinenVersion < 20) to revert to original (WKN-change) |
// Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only |
// called once. This retains all code changes in timer0.c. If parameter 6 > 0 then the user |
// has set a value for the cycle. CameraShuytterCycle == 5x Para6 to get approx 0.1sec increments. |
// 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
// CameraShutterCycle = 5 * Parameter_UserParam6; |
// CameraShutterCycle = Parameter_UserParam6; |
|
// Arthur P: Modified the code to scheck the value of parameter 8. If 128 or higher then a HEF4017 is |
// expected and will be used. Else J7 and J9 are seen as separate normal outputs. |
// if((PlatinenVersion < 20) |
// 091114. Inserted same changes into v.0.76g code. |
|
if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
{ |
//--------------------------- |
315,7 → 358,7 |
RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
ServoNickValue /= MULTIPLYER; |
break; |
case 2: // Roll Compensation Servo |
case 2: // Roll Compensation Servo |
ServoRollOffset = (ServoRollOffset * 3 + (int16_t) Parameter_ServoRollControl * MULTIPLYER) / 4; // lowpass offset |
ServoRollValue = ServoRollOffset; // offset (Range from 0 to 255 * 3 = 765) |
if(EE_Parameter.ServoCompInvert & 0x02) |
340,11 → 383,27 |
ServoRollValue /= MULTIPLYER; |
//DebugOut.Analog[20] = ServoRollValue; |
break; |
case 3: // Arthur P: Shutter Servo including interval control over parameter 5 and 6. |
// 091114 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
|
if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32) |
{ |
// Set servo to null position, turning camera off. |
RemainingPulse = MINSERVOPULSE; |
} |
else |
{ |
RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
} |
break; |
|
default: // other servo channels |
RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
break; |
// 090807 Arthur P: Removed the output of the remaining channels as this just eats time and probably |
// does not have much of a function. Better to add specific outputs as needed. |
// default: // other servo channels |
// RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
// break; |
} |
|
// range servo pulse width |
if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |