Commit e6bcc513 authored by Pavel Semerad's avatar Pavel Semerad
Browse files

add globally settable PPM options (frame/sync length)

parent b31918c2
task.o: task.c task.h stm8.h
main.o: main.c gt3b.h stm8.h task.h
ppm.o: ppm.c ppm.h gt3b.h stm8.h task.h calc.h
ppm.o: ppm.c ppm.h gt3b.h stm8.h task.h calc.h \
config.h eeprom.h
lcd.o: lcd.c lcd.h gt3b.h stm8.h task.h
input.o: input.c input.h gt3b.h stm8.h task.h menu.h \
config.h eeprom.h calc.h lcd.h timer.h
......
......@@ -9,6 +9,8 @@
2-char option identification instead of various symbols
added global option rotate_reverse to switch direction of rotate
endoder at GT3C
added globally settable PPM constant sync/constant frame + selection
of length
*0.4.2 (13 Apr 2012)
added global setting to disable center/reset value beep
......
......@@ -305,7 +305,10 @@ Global setup menu:
poweron not-centered warn C_N/C_Y
d long press key delay 100...1000 miliseconds
H setting of hardware features
reverse rotate encoder E_N/E_Y (No/Yes) - for GT3C
reverse rotate encoder E_N/E_R (Normal/Reverse) - for GT3C
select ppm sync/frame PTS/PTF (constant SYNC/frame length)
select ppm length Lxx - 3-18ms for constant SYNC length
9-24ms for constant frame length
r global or all models reset
all configs (global+model) G_N/G_Y (No/Yes)
all models M_N/M_Y (No/Yes
......
selectable frame length with constant frame/constant sync
- global option to choose constant frame/constant sync (9ms..)
- global option to set frame/sync length (3ms..)
- add code to ppm_calc_sync() to use global options
CH3-8 position settable from menu
linear CH3 with potentiometer
- global option to choose CH3 is a pot
......
......@@ -66,6 +66,10 @@ u8 config_global_set_default(void) {
cg.timer1_alarm = 0; // OFF
cg.timer2_alarm = 0;
cg.ppm_sync_frame = 0; // to constant SYNC length
cg.ppm_length = 1; // 4ms constant SYNC length
cg.unused1 = 0;
cg.unused2 = 0;
cg.unused3 = 0;
cg.unused4 = 0;
......
......@@ -60,7 +60,11 @@ typedef struct {
u8 rotate_reverse:1; // reverse rotate encoder sense
u8 timer1_alarm; // alarm of timer
u8 timer2_alarm;
u16 unused2; // reserve
u8 ppm_length:4; // length of PPM sync signal (3..) or frame length (9..)
u8 ppm_sync_frame:1; // 0 = constant SYNC length, 1 = constant frame length
u8 unused1:3; // reserve
u8 unused2;
u16 unused3;
u16 unused4;
u16 unused5;
......
......@@ -278,22 +278,50 @@ static void gs_hardware(u8 action) {
case 0:
cg.rotate_reverse ^= 1;
break;
case 1:
if (cg.ppm_sync_frame) {
cg.ppm_sync_frame = 0;
cg.ppm_length = 1; // 4ms SYNC
}
else {
cg.ppm_sync_frame = 1;
cg.ppm_length = 11; // 20ms frame
}
break;
case 2:
if (cg.ppm_sync_frame)
// constant frame length
cg.ppm_length =
(u8)(menu_change_val(cg.ppm_length + 9, 9, 24, 1, 0) - 9);
else
// constant SYNC length
cg.ppm_length =
(u8)(menu_change_val(cg.ppm_length + 3, 3, 18, 1, 0) - 3);
break;
}
}
// select next value
else if (action == MLA_NEXT) {
if (++menu_set > 0) menu_set = 0;
if (++menu_set > 2) menu_set = 0;
}
// show values
lcd_7seg(L7_H);
lcd_char(LCHR2, ' ');
menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2); // only last char will blink
switch (menu_set) {
case 0:
lcd_char(LCHR1, 'E');
lcd_char(LCHR3, (u8)(cg.rotate_reverse ? 'Y' : 'N'));
lcd_chars("E ");
lcd_char(LCHR3, (u8)(cg.rotate_reverse ? 'R' : 'N'));
break;
case 1:
lcd_chars("PT");
lcd_char(LCHR3, (u8)(cg.ppm_sync_frame ? 'F' : 'S'));
break;
case 2:
lcd_char_num3(cg.ppm_length + (u8)(cg.ppm_sync_frame ? 9 : 3));
lcd_char(LCHR1, 'L');
menu_blink |= MCB_CHR2; // blink char2 too
break;
}
}
......
......@@ -32,15 +32,14 @@
#include <string.h>
#include "ppm.h"
#include "calc.h"
#include "config.h"
// length of whole frame (frame will actually be shorter, this is safe value
// to not stop generating PPM signal if something goes wrong)
#define PPM_SAFE_FRAME_LENGTH 25000
// constant sync length in ms
#define PPM_SYNC_LENGTH 4
// constant frame length in ms
#define PPM_FRAME_LENGTH (MAX_CHANNELS * 2 + PPM_SYNC_LENGTH)
#define PPM_SYNC_LENGTH_MIN 3
......@@ -72,7 +71,7 @@ void ppm_set_channels(u8 n) {
BSET(PD_ODR, 0); // set PPM pin to 1
// set values for timer wakeups
ppm_start = ppm_timer; // not now, CALC will compute new one
ppm_calc_awake = (u8)(ppm_start + PPM_SYNC_LENGTH); // SYNC signal min length
ppm_calc_awake = (u8)(ppm_start + PPM_SYNC_LENGTH_MIN); // SYNC signal min length
ppm_end = ppm_calc_awake;
ppm_enabled = 1;
......@@ -174,11 +173,17 @@ void ppm_calc_sync(void) {
ppm_calc_len++;
// calculate new ppm_end
ppm_end = (u8)((u8)((ppm_microsecs01 + 9999) / 10000) + PPM_SYNC_LENGTH);
#if 0
// constant frame length, assign only when it is longer than minimum
if (ppm_end < PPM_FRAME_LENGTH) ppm_end = PPM_FRAME_LENGTH;
#endif
ppm_end = (u8)((ppm_microsecs01 + 9999) / 10000);
if (cg.ppm_sync_frame) {
// constant frame length
u8 fl = (u8)(cg.ppm_length + 9);
ppm_end += PPM_SYNC_LENGTH_MIN; // minimal frame with SYNC signal
if (ppm_end < fl) ppm_end = fl;
}
else {
// constant sync length
ppm_end += (u8)(cg.ppm_length + 3);
}
ppm_end += ppm_start;
ppm_microsecs01 = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment