mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
Badly displayed fields in Trainer Screen (thanks gbirkus!)
InstantTrim should work also in Telemetry View Trims2Offsets function ok with Flight Phases New Makefile option EEPROM_PROGRESS_BAR Many flash savings ...
This commit is contained in:
parent
c63c467182
commit
9c16acb445
14 changed files with 215 additions and 207 deletions
|
@ -95,6 +95,10 @@ SOMO = NO
|
||||||
# Values = en,
|
# Values = en,
|
||||||
TRANSLATIONS = EN
|
TRANSLATIONS = EN
|
||||||
|
|
||||||
|
# EEPROM_PROGRESS_BAR
|
||||||
|
# Values = YES, NO
|
||||||
|
EEPROM_PROGRESS_BAR = NO
|
||||||
|
|
||||||
# DEBUG mode
|
# DEBUG mode
|
||||||
DEBUG = NO
|
DEBUG = NO
|
||||||
|
|
||||||
|
@ -243,6 +247,10 @@ ifeq ($(DEBUG), YES)
|
||||||
CPPDEFS += -DDEBUG
|
CPPDEFS += -DDEBUG
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(EEPROM_PROGRESS_BAR), YES)
|
||||||
|
CPPDEFS += -DEEPROM_PROGRESS_BAR
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(PCB), ARM)
|
ifeq ($(PCB), ARM)
|
||||||
# V4 ARM, so ...
|
# V4 ARM, so ...
|
||||||
OPT = 2
|
OPT = 2
|
||||||
|
|
|
@ -144,7 +144,7 @@ void eeDeleteModel(uint8_t id)
|
||||||
{
|
{
|
||||||
eeCheck(true);
|
eeCheck(true);
|
||||||
|
|
||||||
memset(ModelNames[id], ' ', sizeof(g_model.name));
|
memset(ModelNames[id], 0, sizeof(g_model.name));
|
||||||
|
|
||||||
Eeprom32_source_address = (uint8_t *)&g_model ; // Get data from here
|
Eeprom32_source_address = (uint8_t *)&g_model ; // Get data from here
|
||||||
Eeprom32_data_size = 0 ; // This much
|
Eeprom32_data_size = 0 ; // This much
|
||||||
|
@ -160,7 +160,10 @@ bool eeCopyModel(uint8_t dst, uint8_t src)
|
||||||
uint16_t size = File_system[src+1].size ;
|
uint16_t size = File_system[src+1].size ;
|
||||||
read32_eeprom_data( (File_system[src+1].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&Eeprom_buffer.data.model_data, size, 0 ) ;
|
read32_eeprom_data( (File_system[src+1].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&Eeprom_buffer.data.model_data, size, 0 ) ;
|
||||||
|
|
||||||
|
if (size > sizeof(g_model.name))
|
||||||
memcpy(ModelNames[dst], Eeprom_buffer.data.model_data.name, sizeof(g_model.name));
|
memcpy(ModelNames[dst], Eeprom_buffer.data.model_data.name, sizeof(g_model.name));
|
||||||
|
else
|
||||||
|
memset(ModelNames[dst], 0, sizeof(g_model.name));
|
||||||
|
|
||||||
Eeprom32_source_address = (uint8_t *)&Eeprom_buffer.data.model_data; // Get data from here
|
Eeprom32_source_address = (uint8_t *)&Eeprom_buffer.data.model_data; // Get data from here
|
||||||
Eeprom32_data_size = sizeof(g_model) ; // This much
|
Eeprom32_data_size = sizeof(g_model) ; // This much
|
||||||
|
@ -173,18 +176,20 @@ bool eeCopyModel(uint8_t dst, uint8_t src)
|
||||||
void eeSwapModels(uint8_t id1, uint8_t id2)
|
void eeSwapModels(uint8_t id1, uint8_t id2)
|
||||||
{
|
{
|
||||||
// eeCheck(true) should have been called before entering here
|
// eeCheck(true) should have been called before entering here
|
||||||
// id2 must exist
|
|
||||||
|
|
||||||
uint16_t id1_size = File_system[id1+1].size;
|
uint16_t id1_size = File_system[id1+1].size;
|
||||||
uint32_t id1_block_no = File_system[id1+1].block_no;
|
uint32_t id1_block_no = File_system[id1+1].block_no;
|
||||||
|
|
||||||
eeCopyModel(id1, id2);
|
eeCopyModel(id1, id2);
|
||||||
|
|
||||||
// block_no has been shifted now, but we have the size
|
// block_no(id1) has been shifted now, but we have the size
|
||||||
read32_eeprom_data( (id1_block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&Eeprom_buffer.data.model_data, id1_size, 0 ) ;
|
read32_eeprom_data( (id1_block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&Eeprom_buffer.data.model_data, id1_size, 0 ) ;
|
||||||
|
|
||||||
// TODO flash saving with function above ...
|
// TODO flash saving with function above ...
|
||||||
|
if (id1_size > sizeof(g_model.name))
|
||||||
memcpy(ModelNames[id2], Eeprom_buffer.data.model_data.name, sizeof(g_model.name));
|
memcpy(ModelNames[id2], Eeprom_buffer.data.model_data.name, sizeof(g_model.name));
|
||||||
|
else
|
||||||
|
memset(ModelNames[id2], 0, sizeof(g_model.name));
|
||||||
|
|
||||||
Eeprom32_source_address = (uint8_t *)&Eeprom_buffer.data.model_data; // Get data from here
|
Eeprom32_source_address = (uint8_t *)&Eeprom_buffer.data.model_data; // Get data from here
|
||||||
Eeprom32_data_size = sizeof(g_model) ; // This much
|
Eeprom32_data_size = sizeof(g_model) ; // This much
|
||||||
|
@ -509,7 +514,7 @@ void ee32LoadModelName(uint8_t id, char *buf, uint8_t len)
|
||||||
{
|
{
|
||||||
if (id < MAX_MODELS) {
|
if (id < MAX_MODELS) {
|
||||||
id += 1;
|
id += 1;
|
||||||
memset(buf, ' ', len);
|
memset(buf, 0, len);
|
||||||
if (File_system[id].size > sizeof(g_model.name) ) {
|
if (File_system[id].size > sizeof(g_model.name) ) {
|
||||||
read32_eeprom_data( ( File_system[id].block_no << 12) + 8, ( uint8_t *)buf, sizeof(g_model.name), 0 ) ;
|
read32_eeprom_data( ( File_system[id].block_no << 12) + 8, ( uint8_t *)buf, sizeof(g_model.name), 0 ) ;
|
||||||
}
|
}
|
||||||
|
@ -518,29 +523,15 @@ void ee32LoadModelName(uint8_t id, char *buf, uint8_t len)
|
||||||
|
|
||||||
void eeReadAll()
|
void eeReadAll()
|
||||||
{
|
{
|
||||||
// txmit('a') ;
|
|
||||||
if (!ee32LoadGeneral() )
|
if (!ee32LoadGeneral() )
|
||||||
// !EeFsOpen() ||
|
|
||||||
// EeFsck() < 0 ||
|
|
||||||
// )
|
|
||||||
{
|
{
|
||||||
// txmit('b') ;
|
|
||||||
|
|
||||||
alert((char const *)"Bad EEprom Data", true);
|
|
||||||
g_eeGeneral.contrast = 25 ;
|
|
||||||
message(PSTR("EEPROM Formatting"));
|
|
||||||
// EeFsFormat();
|
|
||||||
//alert(PSTR("format ok"));
|
|
||||||
generalDefault();
|
generalDefault();
|
||||||
// alert(PSTR("default ok"));
|
|
||||||
|
|
||||||
// uint16_t sz = theFile.writeRlc(FILE_GENERAL,FILE_TYP_GENERAL,(uint8_t*)&g_eeGeneral,sizeof(EEGeneral),200);
|
alert(STR_BADEEPROMDATA);
|
||||||
// if(sz!=sizeof(EEGeneral)) alert(PSTR("genwrite error"));
|
message(STR_MESSAGE, STR_EEPROMFORMATTING, NULL, NULL);
|
||||||
|
|
||||||
modelDefault(0);
|
modelDefault(0);
|
||||||
//alert(PSTR("modef ok"));
|
|
||||||
// theFile.writeRlc(FILE_MODEL(0),FILE_TYP_MODEL,(uint8_t*)&g_model,sizeof(g_model),200);
|
|
||||||
//alert(PSTR("modwrite ok"));
|
|
||||||
STORE_GENERALVARS;
|
STORE_GENERALVARS;
|
||||||
STORE_MODELVARS;
|
STORE_MODELVARS;
|
||||||
}
|
}
|
||||||
|
@ -722,14 +713,17 @@ void ee32_process()
|
||||||
eeAddress = File_system[Eeprom32_file_index].block_no ^ 1 ;
|
eeAddress = File_system[Eeprom32_file_index].block_no ^ 1 ;
|
||||||
eeAddress <<= 12 ; // Block start address
|
eeAddress <<= 12 ; // Block start address
|
||||||
Eeprom32_address = eeAddress ; // Where to put new data
|
Eeprom32_address = eeAddress ; // Where to put new data
|
||||||
|
#if 0
|
||||||
x = Eeprom32_data_size + sizeof( struct t_eeprom_header ) ; // Size needing to be checked
|
x = Eeprom32_data_size + sizeof( struct t_eeprom_header ) ; // Size needing to be checked
|
||||||
p = (uint8_t *) &Eeprom_buffer ;
|
p = (uint8_t *) &Eeprom_buffer ;
|
||||||
read32_eeprom_data( eeAddress, p, x, 1 ) ;
|
read32_eeprom_data( eeAddress, p, x, 1 ) ;
|
||||||
|
#endif
|
||||||
Eeprom32_process_state = E32_READSENDING ;
|
Eeprom32_process_state = E32_READSENDING ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Eeprom32_process_state == E32_READSENDING )
|
if ( Eeprom32_process_state == E32_READSENDING )
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if ( Spi_complete )
|
if ( Spi_complete )
|
||||||
{
|
{
|
||||||
uint32_t blank = 1 ;
|
uint32_t blank = 1 ;
|
||||||
|
@ -747,11 +741,12 @@ void ee32_process()
|
||||||
// If not blank, sort erasing here
|
// If not blank, sort erasing here
|
||||||
if ( blank )
|
if ( blank )
|
||||||
{
|
{
|
||||||
Eeprom32_state_after_erase = E32_IDLE ;
|
Eeprom32_state_after_erase = E32_IDLE ; // TODO really needed?
|
||||||
Eeprom32_process_state = E32_WRITESTART ;
|
Eeprom32_process_state = E32_WRITESTART ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
eeAddress = Eeprom32_address ;
|
eeAddress = Eeprom32_address ;
|
||||||
eeprom_write_enable() ;
|
eeprom_write_enable() ;
|
||||||
p = Spi_tx_buf ;
|
p = Spi_tx_buf ;
|
||||||
|
@ -762,8 +757,8 @@ void ee32_process()
|
||||||
spi_PDC_action( p, 0, 0, 4, 0 ) ;
|
spi_PDC_action( p, 0, 0, 4, 0 ) ;
|
||||||
Eeprom32_process_state = E32_ERASESENDING ;
|
Eeprom32_process_state = E32_ERASESENDING ;
|
||||||
Eeprom32_state_after_erase = E32_WRITESTART ;
|
Eeprom32_state_after_erase = E32_WRITESTART ;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Eeprom32_process_state == E32_WRITESTART )
|
if ( Eeprom32_process_state == E32_WRITESTART )
|
||||||
|
@ -825,6 +820,7 @@ void ee32_process()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
// now erase the other block
|
// now erase the other block
|
||||||
File_system[Eeprom32_file_index].block_no ^= 1 ; // This is now the current block
|
File_system[Eeprom32_file_index].block_no ^= 1 ; // This is now the current block
|
||||||
eeAddress = Eeprom32_address ^ 0x00001000 ; // Address of block to erase
|
eeAddress = Eeprom32_address ^ 0x00001000 ; // Address of block to erase
|
||||||
|
@ -837,6 +833,8 @@ void ee32_process()
|
||||||
spi_PDC_action( p, 0, 0, 4, 0 ) ;
|
spi_PDC_action( p, 0, 0, 4, 0 ) ;
|
||||||
Eeprom32_process_state = E32_ERASESENDING ;
|
Eeprom32_process_state = E32_ERASESENDING ;
|
||||||
Eeprom32_state_after_erase = E32_IDLE ;
|
Eeprom32_state_after_erase = E32_IDLE ;
|
||||||
|
#endif
|
||||||
|
Eeprom32_process_state = E32_IDLE ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,19 +730,17 @@ void eeReadAll()
|
||||||
EeFsck() < 0 ||
|
EeFsck() < 0 ||
|
||||||
!eeLoadGeneral())
|
!eeLoadGeneral())
|
||||||
{
|
{
|
||||||
alert(STR_BADEEPROMDATA, true);
|
|
||||||
message(STR_EEPROMFORMATTING);
|
|
||||||
EeFsFormat();
|
|
||||||
//alert(PSTR("format ok"));
|
|
||||||
generalDefault();
|
generalDefault();
|
||||||
//alert(PSTR("default ok"));
|
|
||||||
|
alert(STR_BADEEPROMDATA);
|
||||||
|
message(STR_MESSAGE, STR_EEPROMFORMATTING, NULL, NULL);
|
||||||
|
|
||||||
|
EeFsFormat();
|
||||||
|
|
||||||
theFile.writeRlc(FILE_GENERAL, FILE_TYP_GENERAL,(uint8_t*)&g_eeGeneral,sizeof(EEGeneral), true);
|
theFile.writeRlc(FILE_GENERAL, FILE_TYP_GENERAL,(uint8_t*)&g_eeGeneral,sizeof(EEGeneral), true);
|
||||||
|
|
||||||
modelDefault(0);
|
modelDefault(0);
|
||||||
//alert(PSTR("modef ok"));
|
|
||||||
theFile.writeRlc(FILE_MODEL(0), FILE_TYP_MODEL, (uint8_t*)&g_model, sizeof(g_model), true);
|
theFile.writeRlc(FILE_MODEL(0), FILE_TYP_MODEL, (uint8_t*)&g_model, sizeof(g_model), true);
|
||||||
//alert(PSTR("modwrite ok"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stickMode = g_eeGeneral.stickMode;
|
stickMode = g_eeGeneral.stickMode;
|
||||||
|
|
|
@ -791,7 +791,6 @@ void putsTelemetryChannel(uint8_t x, uint8_t y, uint8_t channel, int16_t val, ui
|
||||||
channel -= MAX_TIMERS;
|
channel -= MAX_TIMERS;
|
||||||
// A1 and A2
|
// A1 and A2
|
||||||
{
|
{
|
||||||
// TODO optimize this, avoid int32_t
|
|
||||||
int16_t converted_value = ((int32_t)val+g_model.frsky.channels[channel].offset) * (g_model.frsky.channels[channel].ratio << g_model.frsky.channels[channel].multiplier) * 2 / 51;
|
int16_t converted_value = ((int32_t)val+g_model.frsky.channels[channel].offset) * (g_model.frsky.channels[channel].ratio << g_model.frsky.channels[channel].multiplier) * 2 / 51;
|
||||||
if (g_model.frsky.channels[channel].type >= UNIT_RAW) {
|
if (g_model.frsky.channels[channel].type >= UNIT_RAW) {
|
||||||
converted_value /= 10;
|
converted_value /= 10;
|
||||||
|
|
|
@ -507,7 +507,7 @@ void menuProcTrainer(uint8_t event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
y += FH;
|
y += FH;
|
||||||
|
}
|
||||||
|
|
||||||
edit = (m_posVert==5);
|
edit = (m_posVert==5);
|
||||||
lcd_puts(0*FW, 6*FH, STR_MULTIPLIER);
|
lcd_puts(0*FW, 6*FH, STR_MULTIPLIER);
|
||||||
|
@ -533,7 +533,6 @@ void menuProcTrainer(uint8_t event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void menuProcDiagVers(uint8_t event)
|
void menuProcDiagVers(uint8_t event)
|
||||||
|
|
|
@ -42,28 +42,28 @@ uint16_t anaIn(uint8_t chan)
|
||||||
TEST(trims, greaterTrimLink)
|
TEST(trims, greaterTrimLink)
|
||||||
{
|
{
|
||||||
memset(&g_model, 0, sizeof(g_model));
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
setTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim
|
setRawTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim
|
||||||
setTrimValue(3, 0, 32);
|
setRawTrimValue(3, 0, 32);
|
||||||
EXPECT_EQ(getTrimValue(getTrimFlightPhase(0, 1), 0), 32);
|
EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, 1), 0), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(trims, chainedTrims)
|
TEST(trims, chainedTrims)
|
||||||
{
|
{
|
||||||
memset(&g_model, 0, sizeof(g_model));
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
setTrimValue(0, 0, 32);
|
setRawTrimValue(0, 0, 32);
|
||||||
setTrimValue(1, 0, TRIM_EXTENDED_MAX+1); // link to FP0 trim
|
setRawTrimValue(1, 0, TRIM_EXTENDED_MAX+1); // link to FP0 trim
|
||||||
setTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim
|
setRawTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim
|
||||||
EXPECT_EQ(getTrimValue(getTrimFlightPhase(0, 2), 0), 32);
|
EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, 2), 0), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(trims, infiniteChainedTrims)
|
TEST(trims, infiniteChainedTrims)
|
||||||
{
|
{
|
||||||
memset(&g_model, 0, sizeof(g_model));
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
setTrimValue(0, 0, 32);
|
setRawTrimValue(0, 0, 32);
|
||||||
setTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim
|
setRawTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim
|
||||||
setTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim
|
setRawTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim
|
||||||
setTrimValue(3, 0, TRIM_EXTENDED_MAX+3); // link to FP2 trim
|
setRawTrimValue(3, 0, TRIM_EXTENDED_MAX+3); // link to FP2 trim
|
||||||
EXPECT_EQ(getTrimValue(getTrimFlightPhase(0, 2), 0), 32);
|
EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, 2), 0), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(outdezNAtt, test_unsigned) {
|
TEST(outdezNAtt, test_unsigned) {
|
||||||
|
|
25
src/lcd.cpp
25
src/lcd.cpp
|
@ -236,6 +236,7 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le
|
||||||
{
|
{
|
||||||
uint8_t fw = FWNUM;
|
uint8_t fw = FWNUM;
|
||||||
int8_t mode = MODE(flags);
|
int8_t mode = MODE(flags);
|
||||||
|
bool dblsize = flags & DBLSIZE;
|
||||||
|
|
||||||
bool neg = false;
|
bool neg = false;
|
||||||
if (flags & UNSIGN) { flags -= UNSIGN; }
|
if (flags & UNSIGN) { flags -= UNSIGN; }
|
||||||
|
@ -255,7 +256,7 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le
|
||||||
len = mode + 1;
|
len = mode + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DBLSIZE) {
|
if (dblsize) {
|
||||||
fw += FWNUM;
|
fw += FWNUM;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -268,7 +269,7 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le
|
||||||
if (flags & LEFT) {
|
if (flags & LEFT) {
|
||||||
x += len * fw;
|
x += len * fw;
|
||||||
if (neg)
|
if (neg)
|
||||||
x += (flags & DBLSIZE ? 7 : FWNUM);
|
x += (dblsize ? 7 : FWNUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_lastPos = x;
|
lcd_lastPos = x;
|
||||||
|
@ -277,14 +278,14 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le
|
||||||
for (uint8_t i=1; i<=len; i++) {
|
for (uint8_t i=1; i<=len; i++) {
|
||||||
char c = ((uint16_t)val % 10) + '0';
|
char c = ((uint16_t)val % 10) + '0';
|
||||||
uint8_t f = flags;
|
uint8_t f = flags;
|
||||||
if (flags & DBLSIZE) {
|
if (dblsize) {
|
||||||
if (c=='1' && i==len && xn>x+10) { x+=2; f|=CONDENSED; }
|
if (c=='1' && i==len && xn>x+10) { x+=2; f|=CONDENSED; }
|
||||||
if (val >= 1000) { x+=FWNUM; f&=~DBLSIZE; }
|
if (val >= 1000) { x+=FWNUM; f&=~DBLSIZE; }
|
||||||
}
|
}
|
||||||
lcd_putcAtt(x, y, c, f);
|
lcd_putcAtt(x, y, c, f);
|
||||||
if (mode==i) {
|
if (mode==i) {
|
||||||
flags &= ~PREC2; // TODO not needed but removes 64bytes, could be improved for sure, check asm
|
flags &= ~PREC2; // TODO not needed but removes 64bytes, could be improved for sure, check asm
|
||||||
if (flags & DBLSIZE) {
|
if (dblsize) {
|
||||||
xn = x;
|
xn = x;
|
||||||
if(c=='2' || c=='3' || c=='1') ln++;
|
if(c=='2' || c=='3' || c=='1') ln++;
|
||||||
uint8_t tn = ((uint16_t)val/10) % 10;
|
uint8_t tn = ((uint16_t)val/10) % 10;
|
||||||
|
@ -300,7 +301,7 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le
|
||||||
lcd_vline(x+1, y, 8);
|
lcd_vline(x+1, y, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((flags & DBLSIZE) && val >= 1000 && val < 10000) x-=2;
|
if (dblsize && val >= 1000 && val < 10000) x-=2;
|
||||||
val = ((uint16_t)val) / 10;
|
val = ((uint16_t)val) / 10;
|
||||||
x-=fw;
|
x-=fw;
|
||||||
}
|
}
|
||||||
|
@ -557,6 +558,20 @@ void putsTmrMode(uint8_t x, uint8_t y, int8_t mode, uint8_t att)
|
||||||
putsSwitches(x, y, mode-(TMR_VAROFS-1), att|SWONLY);
|
putsSwitches(x, y, mode-(TMR_VAROFS-1), att|SWONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void putsTrimMode(uint8_t x, uint8_t y, uint8_t phase, uint8_t idx, uint8_t att)
|
||||||
|
{
|
||||||
|
int16_t v = getRawTrimValue(phase, idx);
|
||||||
|
|
||||||
|
if (v > TRIM_EXTENDED_MAX) {
|
||||||
|
uint8_t p = v - TRIM_EXTENDED_MAX - 1;
|
||||||
|
if (p >= phase) p++;
|
||||||
|
lcd_putcAtt(x, y, '0'+p, att);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
putsChnLetter(x, y, idx+1, att);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PCBARM
|
#ifdef PCBARM
|
||||||
|
|
||||||
#include "AT91SAM3S2.h"
|
#include "AT91SAM3S2.h"
|
||||||
|
|
|
@ -105,6 +105,7 @@ extern void putsMixerSource(uint8_t x, uint8_t y, uint8_t idx, uint8_t att=0);
|
||||||
extern void putsFlightPhase(uint8_t x, uint8_t y, int8_t idx, uint8_t att=0);
|
extern void putsFlightPhase(uint8_t x, uint8_t y, int8_t idx, uint8_t att=0);
|
||||||
extern void putsCurve(uint8_t x, uint8_t y, int8_t idx, uint8_t att=0);
|
extern void putsCurve(uint8_t x, uint8_t y, int8_t idx, uint8_t att=0);
|
||||||
extern void putsTmrMode(uint8_t x, uint8_t y, int8_t mode, uint8_t att);
|
extern void putsTmrMode(uint8_t x, uint8_t y, int8_t mode, uint8_t att);
|
||||||
|
extern void putsTrimMode(uint8_t x, uint8_t y, uint8_t phase, uint8_t idx, uint8_t att);
|
||||||
|
|
||||||
extern void putsChnRaw(uint8_t x,uint8_t y,uint8_t idx1,uint8_t att);
|
extern void putsChnRaw(uint8_t x,uint8_t y,uint8_t idx1,uint8_t att);
|
||||||
extern void putsChn(uint8_t x,uint8_t y,uint8_t idx1,uint8_t att);
|
extern void putsChn(uint8_t x,uint8_t y,uint8_t idx1,uint8_t att);
|
||||||
|
|
|
@ -74,8 +74,6 @@ void doMainScreenGrphics()
|
||||||
|
|
||||||
void menuMainView(uint8_t event)
|
void menuMainView(uint8_t event)
|
||||||
{
|
{
|
||||||
static bool instantTrimSwLock;
|
|
||||||
|
|
||||||
uint8_t view = g_eeGeneral.view;
|
uint8_t view = g_eeGeneral.view;
|
||||||
uint8_t view_base = view & 0x0f;
|
uint8_t view_base = view & 0x0f;
|
||||||
|
|
||||||
|
@ -163,7 +161,6 @@ void menuMainView(uint8_t event)
|
||||||
killEvents(KEY_EXIT);
|
killEvents(KEY_EXIT);
|
||||||
killEvents(KEY_UP);
|
killEvents(KEY_UP);
|
||||||
killEvents(KEY_DOWN);
|
killEvents(KEY_DOWN);
|
||||||
instantTrimSwLock = true;
|
|
||||||
break;
|
break;
|
||||||
#ifdef NAVIGATION_RE1
|
#ifdef NAVIGATION_RE1
|
||||||
case EVT_KEY_LONG(BTN_RE1):
|
case EVT_KEY_LONG(BTN_RE1):
|
||||||
|
@ -180,10 +177,6 @@ void menuMainView(uint8_t event)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool trimSw = isFunctionActive(FUNC_INSTANT_TRIM);
|
|
||||||
if (!instantTrimSwLock && trimSw) instantTrim();
|
|
||||||
instantTrimSwLock = trimSw;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
uint8_t phase = getFlightPhase();
|
uint8_t phase = getFlightPhase();
|
||||||
lcd_putsnAtt(6*FW+2, 2*FH, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR);
|
lcd_putsnAtt(6*FW+2, 2*FH, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR);
|
||||||
|
@ -210,7 +203,7 @@ void menuMainView(uint8_t event)
|
||||||
xm = x[CONVERT_MODE(i+1)-1];
|
xm = x[CONVERT_MODE(i+1)-1];
|
||||||
|
|
||||||
uint8_t att = ROUND;
|
uint8_t att = ROUND;
|
||||||
int16_t val = getTrimValue(getTrimFlightPhase(i, phase), i);
|
int16_t val = getTrimValue(phase, i);
|
||||||
|
|
||||||
if (val < -125 || val > 125)
|
if (val < -125 || val > 125)
|
||||||
att = BLINK|INVERS|ROUND;
|
att = BLINK|INVERS|ROUND;
|
||||||
|
|
|
@ -661,21 +661,14 @@ void menuProcPhaseOne(uint8_t event)
|
||||||
case 2:
|
case 2:
|
||||||
lcd_putsLeft( y, STR_TRIMS);
|
lcd_putsLeft( y, STR_TRIMS);
|
||||||
for (uint8_t t=0; t<NUM_STICKS; t++) {
|
for (uint8_t t=0; t<NUM_STICKS; t++) {
|
||||||
int16_t v = getTrimValue(s_currIdx, t);
|
putsTrimMode((10+t)*FW, y, s_currIdx, t, (attr && m_posHorz==t) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||||
if (v > TRIM_EXTENDED_MAX) {
|
|
||||||
uint8_t p = v - TRIM_EXTENDED_MAX - 1;
|
|
||||||
if (p >= s_currIdx) p++;
|
|
||||||
lcd_putcAtt((10+t)*FW, y, '0'+p, (attr && m_posHorz==t) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
v = TRIM_EXTENDED_MAX;
|
|
||||||
putsChnLetter((10+t)*FW, y, t+1, (attr && m_posHorz==t) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
|
||||||
}
|
|
||||||
if (attr && m_posHorz==t && ((s_editMode>0) || p1valdiff)) {
|
if (attr && m_posHorz==t && ((s_editMode>0) || p1valdiff)) {
|
||||||
|
int16_t v = getRawTrimValue(s_currIdx, t);
|
||||||
|
if (v < TRIM_EXTENDED_MAX) v = TRIM_EXTENDED_MAX;
|
||||||
v = checkIncDec(event, v, TRIM_EXTENDED_MAX, TRIM_EXTENDED_MAX+MAX_PHASES-1, EE_MODEL);
|
v = checkIncDec(event, v, TRIM_EXTENDED_MAX, TRIM_EXTENDED_MAX+MAX_PHASES-1, EE_MODEL);
|
||||||
if (checkIncDec_Ret) {
|
if (checkIncDec_Ret) {
|
||||||
if (v == TRIM_EXTENDED_MAX) v = 0;
|
if (v == TRIM_EXTENDED_MAX) v = 0;
|
||||||
setTrimValue(s_currIdx, t, v);
|
setRawTrimValue(s_currIdx, t, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -731,16 +724,7 @@ void menuProcPhasesAll(uint8_t event)
|
||||||
else {
|
else {
|
||||||
putsSwitches(11*FW+FW/2, y, p->swtch, 0);
|
putsSwitches(11*FW+FW/2, y, p->swtch, 0);
|
||||||
for (uint8_t t=0; t<NUM_STICKS; t++) {
|
for (uint8_t t=0; t<NUM_STICKS; t++) {
|
||||||
// TODO duplicated code
|
putsTrimMode((16+t)*FW-FW/2, y, i, t, 0);
|
||||||
int16_t v = getTrimValue(i, t);
|
|
||||||
if (v > TRIM_EXTENDED_MAX) {
|
|
||||||
uint8_t c = v - TRIM_EXTENDED_MAX - 1;
|
|
||||||
if (c >= i) c++;
|
|
||||||
lcd_putc((16+t)*FW-FW/2, y, '0'+c);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
putsChnLetter((16+t)*FW-FW/2, y, t+1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p->fadeIn) lcd_putc(20*FW+2, y, 'I');
|
if (p->fadeIn) lcd_putc(20*FW+2, y, 'I');
|
||||||
|
@ -1215,7 +1199,7 @@ void menuProcMixOne(uint8_t event)
|
||||||
case 0:
|
case 0:
|
||||||
lcd_puts(2*FW, y, STR_SOURCE);
|
lcd_puts(2*FW, y, STR_SOURCE);
|
||||||
putsMixerSource(FW*10, y, md2->srcRaw, attr);
|
putsMixerSource(FW*10, y, md2->srcRaw, attr);
|
||||||
if(attr) CHECK_INCDEC_MODELVAR(event, md2->srcRaw, 1, NUM_XCHNMIX); // TODO use enum
|
if(attr) CHECK_INCDEC_MODELVAR(event, md2->srcRaw, 1, NUM_XCHNMIX);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
lcd_puts(2*FW, y, STR_WEIGHT);
|
lcd_puts(2*FW, y, STR_WEIGHT);
|
||||||
|
|
173
src/open9x.cpp
173
src/open9x.cpp
|
@ -131,7 +131,8 @@ LimitData *limitaddress(uint8_t idx)
|
||||||
|
|
||||||
void generalDefault()
|
void generalDefault()
|
||||||
{
|
{
|
||||||
memset(&g_eeGeneral,0,sizeof(g_eeGeneral));
|
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
|
||||||
|
g_eeGeneral.lightSw = SWITCH_ON;
|
||||||
g_eeGeneral.myVers = EEPROM_VER;
|
g_eeGeneral.myVers = EEPROM_VER;
|
||||||
g_eeGeneral.contrast = 25;
|
g_eeGeneral.contrast = 25;
|
||||||
g_eeGeneral.vBatWarn = 90;
|
g_eeGeneral.vBatWarn = 90;
|
||||||
|
@ -325,20 +326,23 @@ void applyExpos(int16_t *anas, uint8_t phase)
|
||||||
|
|
||||||
if (phase == 255)
|
if (phase == 255)
|
||||||
phase = getFlightPhase();
|
phase = getFlightPhase();
|
||||||
|
phase++;
|
||||||
|
|
||||||
int8_t cur_chn = -1;
|
int8_t cur_chn = -1;
|
||||||
|
|
||||||
for (uint8_t i=0; i<MAX_EXPOS; i++) {
|
for (uint8_t i=0; i<MAX_EXPOS; i++) {
|
||||||
ExpoData &ed = g_model.expoData[i];
|
ExpoData &ed = g_model.expoData[i];
|
||||||
|
uint8_t ed_phase = ed.phase;
|
||||||
if (ed.mode==0) break; // end of list
|
if (ed.mode==0) break; // end of list
|
||||||
if (ed.chn == cur_chn)
|
if (ed.chn == cur_chn)
|
||||||
continue;
|
continue;
|
||||||
if (ed.phase != 0) {
|
if (ed_phase != 0) {
|
||||||
if (ed.negPhase) {
|
if (ed.negPhase) {
|
||||||
if (phase+1 == -ed.phase)
|
if (phase == ed_phase)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (phase+1 != ed.phase)
|
if (phase != ed_phase)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +352,8 @@ void applyExpos(int16_t *anas, uint8_t phase)
|
||||||
cur_chn = ed.chn;
|
cur_chn = ed.chn;
|
||||||
int16_t k = ed.expo;
|
int16_t k = ed.expo;
|
||||||
v = expo(v, k);
|
v = expo(v, k);
|
||||||
if (ed.curve) v = applyCurve(v, ed.curve > 10 ? ed.curve + 4 : ed.curve);
|
uint8_t ed_curve = ed.curve;
|
||||||
|
if (ed_curve) v = applyCurve(v, ed_curve > 10 ? ed_curve + 4 : ed_curve);
|
||||||
v = ((int32_t)v * ed.weight) / 100;
|
v = ((int32_t)v * ed.weight) / 100;
|
||||||
anas[cur_chn] = v;
|
anas[cur_chn] = v;
|
||||||
}
|
}
|
||||||
|
@ -368,18 +373,19 @@ int16_t applyLimits(uint8_t channel, int32_t value)
|
||||||
(value > 0) ? value * ((int32_t) lim_p - ofs) / 100000 :
|
(value > 0) ? value * ((int32_t) lim_p - ofs) / 100000 :
|
||||||
-value * ((int32_t) lim_n - ofs) / 100000; //div by 100000 -> output = -1024..1024
|
-value * ((int32_t) lim_n - ofs) / 100000; //div by 100000 -> output = -1024..1024
|
||||||
|
|
||||||
// TODO work on an int16_t as soon as possible ...
|
|
||||||
value += calc1000toRESX(ofs);
|
value += calc1000toRESX(ofs);
|
||||||
lim_p = calc1000toRESX(lim_p);
|
lim_p = calc1000toRESX(lim_p);
|
||||||
lim_n = calc1000toRESX(lim_n);
|
lim_n = calc1000toRESX(lim_n);
|
||||||
if (value > lim_p) value = lim_p;
|
if (value > lim_p) value = lim_p;
|
||||||
if (value < lim_n) value = lim_n;
|
if (value < lim_n) value = lim_n;
|
||||||
if (g_model.limitData[channel].revert) value = -value; // finally do the reverse.
|
|
||||||
|
|
||||||
if (safetyCh[channel] != -128) // if safety channel available for channel check and replace val if needed
|
ofs = value; // we convert value to a 16bit value and reuse ofs
|
||||||
value = calc100toRESX(safetyCh[channel]);
|
if (g_model.limitData[channel].revert) ofs = -ofs; // finally do the reverse.
|
||||||
|
|
||||||
return value;
|
if (safetyCh[channel] != -128) // if safety channel available for channel check
|
||||||
|
ofs = calc100toRESX(safetyCh[channel]);
|
||||||
|
|
||||||
|
return ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMain
|
int16_t ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMain
|
||||||
|
@ -514,6 +520,7 @@ bool __getSwitch(int8_t swtch)
|
||||||
// case CS_ANEG:
|
// case CS_ANEG:
|
||||||
default:
|
default:
|
||||||
result = (abs(x)<y);
|
result = (abs(x)<y);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -538,6 +545,7 @@ bool __getSwitch(int8_t swtch)
|
||||||
// case CS_ELESS:
|
// case CS_ELESS:
|
||||||
default:
|
default:
|
||||||
result = (x<=y);
|
result = (x<=y);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,7 +571,7 @@ uint8_t getFlightPhase()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t getTrimValue(uint8_t phase, uint8_t idx)
|
int16_t getRawTrimValue(uint8_t phase, uint8_t idx)
|
||||||
{
|
{
|
||||||
int16_t result;
|
int16_t result;
|
||||||
if (s_trimPtr[idx]) {
|
if (s_trimPtr[idx]) {
|
||||||
|
@ -576,7 +584,12 @@ int16_t getTrimValue(uint8_t phase, uint8_t idx)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTrimValue(uint8_t phase, uint8_t idx, int16_t trim)
|
int16_t getTrimValue(uint8_t phase, uint8_t idx)
|
||||||
|
{
|
||||||
|
return getRawTrimValue(getTrimFlightPhase(phase, idx), idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRawTrimValue(uint8_t phase, uint8_t idx, int16_t trim)
|
||||||
{
|
{
|
||||||
if (s_trimPtr[idx]) {
|
if (s_trimPtr[idx]) {
|
||||||
*s_trimPtr[idx] = limit((int16_t)-125, trim, (int16_t)+125);
|
*s_trimPtr[idx] = limit((int16_t)-125, trim, (int16_t)+125);
|
||||||
|
@ -589,11 +602,11 @@ void setTrimValue(uint8_t phase, uint8_t idx, int16_t trim)
|
||||||
STORE_MODELVARS;
|
STORE_MODELVARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getTrimFlightPhase(uint8_t idx, uint8_t phase)
|
uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx)
|
||||||
{
|
{
|
||||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||||
if (phase == 0) return 0;
|
if (phase == 0) return 0;
|
||||||
int16_t trim = getTrimValue(phase, idx);
|
int16_t trim = getRawTrimValue(phase, idx);
|
||||||
if (trim <= TRIM_EXTENDED_MAX) return phase;
|
if (trim <= TRIM_EXTENDED_MAX) return phase;
|
||||||
uint8_t result = trim-TRIM_EXTENDED_MAX-1;
|
uint8_t result = trim-TRIM_EXTENDED_MAX-1;
|
||||||
if (result >= phase) result++;
|
if (result >= phase) result++;
|
||||||
|
@ -678,19 +691,6 @@ void checkLowEEPROM()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void alertMessages( const pm_char * s, const pm_char * t )
|
|
||||||
{
|
|
||||||
lcd_clear();
|
|
||||||
lcd_putsAtt(64-5*FW,0*FH,STR_ALERT,DBLSIZE);
|
|
||||||
lcd_putsLeft(4*FH,s);
|
|
||||||
lcd_putsLeft(5*FH,t);
|
|
||||||
lcd_putsLeft(6*FH, STR_PRESSANYKEYTOSKIP ) ;
|
|
||||||
refreshDisplay();
|
|
||||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
|
||||||
|
|
||||||
clearKeyEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkTHR()
|
void checkTHR()
|
||||||
{
|
{
|
||||||
if(g_eeGeneral.disableThrottleWarning) return;
|
if(g_eeGeneral.disableThrottleWarning) return;
|
||||||
|
@ -708,7 +708,7 @@ void checkTHR()
|
||||||
if(v<=lowLim) return;
|
if(v<=lowLim) return;
|
||||||
|
|
||||||
// first - display warning
|
// first - display warning
|
||||||
alertMessages( STR_THROTTLENOTIDLE, STR_RESETTHROTTLE ) ;
|
message(STR_ALERT, STR_THROTTLENOTIDLE, STR_RESETTHROTTLE, STR_PRESSANYKEYTOSKIP);
|
||||||
|
|
||||||
//loop until all switches are reset
|
//loop until all switches are reset
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -742,7 +742,7 @@ void checkSwitches()
|
||||||
if(!g_eeGeneral.switchWarning) return; // if warning is on
|
if(!g_eeGeneral.switchWarning) return; // if warning is on
|
||||||
|
|
||||||
// first - display warning
|
// first - display warning
|
||||||
alertMessages( STR_SWITCHESNOTOFF, STR_PLEASERESETTHEM ) ;
|
message(STR_ALERT, STR_SWITCHESNOTOFF, STR_RESETTHROTTLE, STR_PLEASERESETTHEM);
|
||||||
|
|
||||||
bool state = (g_eeGeneral.switchWarning > 0);
|
bool state = (g_eeGeneral.switchWarning > 0);
|
||||||
|
|
||||||
|
@ -766,25 +766,10 @@ void checkSwitches()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void message(const pm_char * s)
|
void alert(const pm_char * s)
|
||||||
{
|
{
|
||||||
lcd_clear();
|
message(STR_ALERT, s, 0, STR_PRESSANYKEY);
|
||||||
lcd_putsAtt(64-5*FW, 0*FH, STR_MESSAGE, DBLSIZE);
|
|
||||||
lcd_putsLeft(4*FW,s);
|
|
||||||
refreshDisplay();
|
|
||||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
|
||||||
}
|
|
||||||
|
|
||||||
void alert(const pm_char * s, bool defaults)
|
|
||||||
{
|
|
||||||
lcd_clear();
|
|
||||||
lcd_putsAtt(64-5*FW, 0*FH, STR_ALERT, DBLSIZE);
|
|
||||||
lcd_putsLeft(4*FH,s);
|
|
||||||
lcd_puts(64-LEN_PRESSANYKEY*FW/2, 7*FH, STR_PRESSANYKEY);
|
|
||||||
refreshDisplay();
|
|
||||||
lcdSetRefVolt(defaults ? 25 : g_eeGeneral.contrast);
|
|
||||||
AUDIO_ERROR();
|
|
||||||
clearKeyEvents();
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
#ifdef SIMU
|
#ifdef SIMU
|
||||||
|
@ -793,15 +778,28 @@ void alert(const pm_char * s, bool defaults)
|
||||||
#endif
|
#endif
|
||||||
if(keyDown()) return; //wait for key release
|
if(keyDown()) return; //wait for key release
|
||||||
|
|
||||||
if (getSwitch(g_eeGeneral.lightSw,0) || g_eeGeneral.lightAutoOff || defaults)
|
checkBacklight();
|
||||||
BACKLIGHT_ON;
|
|
||||||
else
|
|
||||||
BACKLIGHT_OFF;
|
|
||||||
|
|
||||||
wdt_reset();
|
wdt_reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void message(const pm_char *title, const pm_char *s, const pm_char *t, const char *last)
|
||||||
|
{
|
||||||
|
lcd_clear();
|
||||||
|
lcd_putsAtt(0, 0, title, DBLSIZE);
|
||||||
|
lcd_putsLeft(4*FH, s);
|
||||||
|
if (t)
|
||||||
|
lcd_putsLeft(5*FH, t);
|
||||||
|
if (last) {
|
||||||
|
lcd_putsLeft(7*FH, last);
|
||||||
|
AUDIO_ERROR();
|
||||||
|
clearKeyEvents();
|
||||||
|
}
|
||||||
|
refreshDisplay();
|
||||||
|
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||||
|
}
|
||||||
|
|
||||||
int8_t *s_trimPtr[NUM_STICKS] = { NULL, NULL, NULL, NULL };
|
int8_t *s_trimPtr[NUM_STICKS] = { NULL, NULL, NULL, NULL };
|
||||||
|
|
||||||
uint8_t checkTrim(uint8_t event)
|
uint8_t checkTrim(uint8_t event)
|
||||||
|
@ -812,8 +810,8 @@ uint8_t checkTrim(uint8_t event)
|
||||||
if (k>=0 && k<8) { // && (event & _MSK_KEY_REPT))
|
if (k>=0 && k<8) { // && (event & _MSK_KEY_REPT))
|
||||||
//LH_DWN LH_UP LV_DWN LV_UP RV_DWN RV_UP RH_DWN RH_UP
|
//LH_DWN LH_UP LV_DWN LV_UP RV_DWN RV_UP RH_DWN RH_UP
|
||||||
uint8_t idx = CONVERT_MODE(1+k/2) - 1;
|
uint8_t idx = CONVERT_MODE(1+k/2) - 1;
|
||||||
uint8_t phase = getTrimFlightPhase(idx, getFlightPhase());
|
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
|
||||||
int16_t before = getTrimValue(phase, idx);
|
int16_t before = getRawTrimValue(phase, idx);
|
||||||
int8_t v = (s==0) ? min(32, abs(before)/4+1) : 1 << (s-1); // 1=>1 2=>2 3=>4 4=>8
|
int8_t v = (s==0) ? min(32, abs(before)/4+1) : 1 << (s-1); // 1=>1 2=>2 3=>4 4=>8
|
||||||
bool thro = (idx==THR_STICK && g_model.thrTrim);
|
bool thro = (idx==THR_STICK && g_model.thrTrim);
|
||||||
if (thro) v = 4; // if throttle trim and trim trottle then step=4
|
if (thro) v = 4; // if throttle trim and trim trottle then step=4
|
||||||
|
@ -839,7 +837,7 @@ uint8_t checkTrim(uint8_t event)
|
||||||
after = TRIM_EXTENDED_MAX;
|
after = TRIM_EXTENDED_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTrimValue(phase, idx, after);
|
setRawTrimValue(phase, idx, after);
|
||||||
|
|
||||||
#if defined (AUDIO)
|
#if defined (AUDIO)
|
||||||
// toneFreq higher/lower according to trim position
|
// toneFreq higher/lower according to trim position
|
||||||
|
@ -1142,7 +1140,7 @@ FORCEINLINE void evalTrims(uint8_t phase)
|
||||||
// do trim -> throttle trim if applicable
|
// do trim -> throttle trim if applicable
|
||||||
// TODO avoid int32_t vv
|
// TODO avoid int32_t vv
|
||||||
int32_t vv = 2*RESX;
|
int32_t vv = 2*RESX;
|
||||||
int16_t trim = getTrimValue(getTrimFlightPhase(i, phase), i);
|
int16_t trim = getTrimValue(phase, i);
|
||||||
if (i==THR_STICK && g_model.thrTrim) {
|
if (i==THR_STICK && g_model.thrTrim) {
|
||||||
if (g_eeGeneral.throttleReversed)
|
if (g_eeGeneral.throttleReversed)
|
||||||
trim = -trim;
|
trim = -trim;
|
||||||
|
@ -1266,20 +1264,32 @@ void evalFunctions()
|
||||||
if (sd->func < FUNC_TRAINER && (g_menuStack[0] != menuProcFunctionSwitches || m_posVert != i+1 || m_posHorz > 1)) {
|
if (sd->func < FUNC_TRAINER && (g_menuStack[0] != menuProcFunctionSwitches || m_posVert != i+1 || m_posHorz > 1)) {
|
||||||
safetyCh[sd->func] = (int8_t)sd->param;
|
safetyCh[sd->func] = (int8_t)sd->param;
|
||||||
}
|
}
|
||||||
if (sd->func == FUNC_PLAY_SOUND) {
|
|
||||||
#if defined(AUDIO)
|
if (~active_functions & mask) {
|
||||||
audioDefevent(AU_FRSKY_FIRST+sd->param);
|
|
||||||
#else
|
if (sd->func == FUNC_INSTANT_TRIM) {
|
||||||
beep(3);
|
if (g_menuStack[0] == menuMainView
|
||||||
|
#if defined(FRSKY)
|
||||||
|
|| g_menuStack[0] == menuProcFrsky
|
||||||
#endif
|
#endif
|
||||||
|
)
|
||||||
|
instantTrim();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SOMO)
|
#if defined(SOMO)
|
||||||
if (sd->func == FUNC_PLAY_SOMO && (~active_functions & mask)) {
|
if (sd->func == FUNC_PLAY_SOMO) {
|
||||||
somoPushPrompt(sd->param);
|
somoPushPrompt(sd->param);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (sd->func == FUNC_RESET && (~active_functions & mask)) {
|
|
||||||
switch(sd->param) {
|
#if defined(DEBUG)
|
||||||
|
if (sd->func == FUNC_TEST) {
|
||||||
|
testFunc();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (sd->func == FUNC_RESET) {
|
||||||
|
switch (sd->param) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
resetTimer(sd->param);
|
resetTimer(sd->param);
|
||||||
|
@ -1294,11 +1304,15 @@ void evalFunctions()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(DEBUG)
|
|
||||||
if (sd->func == FUNC_TEST && (~active_functions & mask)) {
|
|
||||||
testFunc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sd->func == FUNC_PLAY_SOUND) {
|
||||||
|
#if defined(AUDIO)
|
||||||
|
audioDefevent(AU_FRSKY_FIRST+sd->param);
|
||||||
|
#else
|
||||||
|
beep(3);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
active_functions |= mask;
|
active_functions |= mask;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1519,15 +1533,14 @@ void perOut(uint8_t phase)
|
||||||
v = applyCurve(v, md->curve);
|
v = applyCurve(v, md->curve);
|
||||||
|
|
||||||
//========== TRIMS ===============
|
//========== TRIMS ===============
|
||||||
// TODO use k?
|
if (k < NUM_STICKS) {
|
||||||
if (md->srcRaw>0 && md->srcRaw<=NUM_STICKS) {
|
|
||||||
if (s_perout_mode < e_perout_mode_zeros && md->carryTrim == TRIM_ON) {
|
if (s_perout_mode < e_perout_mode_zeros && md->carryTrim == TRIM_ON) {
|
||||||
v += trims[md->srcRaw-1];
|
v += trims[k];
|
||||||
}
|
}
|
||||||
if (s_perout_mode == e_perout_mode_normal && md->carryTrim == TRIM_OFFSET) {
|
if (s_perout_mode == e_perout_mode_normal && md->carryTrim == TRIM_OFFSET) {
|
||||||
v = md->sOffset;
|
v = md->sOffset;
|
||||||
v = calc1000toRESX(v << 3);
|
v = calc1000toRESX(v << 3);
|
||||||
s_trimPtr[md->srcRaw-1] = &md->sOffset; // use the value stored here for the trim
|
s_trimPtr[k] = &md->sOffset; // use the value stored here for the trim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1835,6 +1848,8 @@ void perMain()
|
||||||
evalFunctions();
|
evalFunctions();
|
||||||
|
|
||||||
if (s_noHi) s_noHi--;
|
if (s_noHi) s_noHi--;
|
||||||
|
if (trimsCheckTimer) trimsCheckTimer --;
|
||||||
|
|
||||||
if (g_eeGeneral.inactivityTimer && g_vbat100mV>50) {
|
if (g_eeGeneral.inactivityTimer && g_vbat100mV>50) {
|
||||||
inacCounter++;
|
inacCounter++;
|
||||||
uint16_t tsum = 0;
|
uint16_t tsum = 0;
|
||||||
|
@ -1847,9 +1862,6 @@ void perMain()
|
||||||
if((inacCounter&0x3F)==10) AUDIO_INACTIVITY();
|
if((inacCounter&0x3F)==10) AUDIO_INACTIVITY();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trimsCheckTimer > 0)
|
|
||||||
trimsCheckTimer -= 1;
|
|
||||||
|
|
||||||
#if defined (LOGS)
|
#if defined (LOGS)
|
||||||
writeLogs();
|
writeLogs();
|
||||||
#endif
|
#endif
|
||||||
|
@ -2201,7 +2213,7 @@ void instantTrim()
|
||||||
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
||||||
if (i!=THR_STICK) {
|
if (i!=THR_STICK) {
|
||||||
// don't instant trim the throttle stick
|
// don't instant trim the throttle stick
|
||||||
uint8_t trim_phase = getTrimFlightPhase(i, phase);
|
uint8_t trim_phase = getTrimFlightPhase(phase, i);
|
||||||
s_perout_mode = e_instant_trim;
|
s_perout_mode = e_instant_trim;
|
||||||
evalSticks(phase);
|
evalSticks(phase);
|
||||||
s_perout_mode = e_perout_mode_normal;
|
s_perout_mode = e_perout_mode_normal;
|
||||||
|
@ -2212,7 +2224,7 @@ void instantTrim()
|
||||||
if (trim > TRIM_EXTENDED_MAX) {
|
if (trim > TRIM_EXTENDED_MAX) {
|
||||||
trim = TRIM_EXTENDED_MAX;
|
trim = TRIM_EXTENDED_MAX;
|
||||||
}
|
}
|
||||||
setTrimValue(trim_phase, i, trim);
|
setRawTrimValue(trim_phase, i, trim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2236,12 +2248,10 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||||
s_perout_mode = e_perout_mode_normal;
|
s_perout_mode = e_perout_mode_normal;
|
||||||
|
|
||||||
for (uint8_t i=0; i<NUM_CHNOUT; i++) {
|
for (uint8_t i=0; i<NUM_CHNOUT; i++) {
|
||||||
int16_t output = applyLimits(i, chans[i]);
|
int16_t output = applyLimits(i, chans[i]) - zeros[i];
|
||||||
int16_t v = g_model.limitData[i].offset;
|
int16_t v = g_model.limitData[i].offset;
|
||||||
// TODO flash saving?
|
if (g_model.limitData[i].revert) output = -output;
|
||||||
v += g_model.limitData[i].revert ?
|
v += output;
|
||||||
(zeros[i] - output) :
|
|
||||||
(output - zeros[i]);
|
|
||||||
// TODO * 125 / 128 ?
|
// TODO * 125 / 128 ?
|
||||||
g_model.limitData[i].offset = limit((int16_t)-1000, (int16_t)v, (int16_t)1000); // make sure the offset doesn't go haywire
|
g_model.limitData[i].offset = limit((int16_t)-1000, (int16_t)v, (int16_t)1000); // make sure the offset doesn't go haywire
|
||||||
}
|
}
|
||||||
|
@ -2249,10 +2259,11 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||||
// reset all trims, except throttle (if throttle trim)
|
// reset all trims, except throttle (if throttle trim)
|
||||||
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
for (uint8_t i=0; i<NUM_STICKS; i++) {
|
||||||
if (i!=THR_STICK || !g_model.thrTrim) {
|
if (i!=THR_STICK || !g_model.thrTrim) {
|
||||||
|
int16_t original_trim = getTrimValue(phase, i);
|
||||||
for (uint8_t phase=0; phase<MAX_PHASES; phase++) {
|
for (uint8_t phase=0; phase<MAX_PHASES; phase++) {
|
||||||
int16_t trim = getTrimValue(phase, i);
|
int16_t trim = getRawTrimValue(phase, i);
|
||||||
if (trim <= TRIM_EXTENDED_MAX)
|
if (trim <= TRIM_EXTENDED_MAX)
|
||||||
setTrimValue(phase, i, 0);
|
setRawTrimValue(phase, i, trim - original_trim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/open9x.h
12
src/open9x.h
|
@ -474,8 +474,9 @@ uint16_t evalChkSum();
|
||||||
|
|
||||||
/// Gibt Alarm Maske auf lcd aus.
|
/// Gibt Alarm Maske auf lcd aus.
|
||||||
/// Die Maske wird so lange angezeigt bis eine beliebige Taste gedrueckt wird.
|
/// Die Maske wird so lange angezeigt bis eine beliebige Taste gedrueckt wird.
|
||||||
void alert(const pm_char * s, bool defaults=false);
|
extern void alert(const pm_char * s);
|
||||||
void message(const pm_char * s);
|
extern void message(const pm_char *title, const pm_char *s, const pm_char *t, const char *last);
|
||||||
|
|
||||||
/// periodisches Hauptprogramm
|
/// periodisches Hauptprogramm
|
||||||
void perMain();
|
void perMain();
|
||||||
/// Bearbeitet alle zeitkritischen Jobs.
|
/// Bearbeitet alle zeitkritischen Jobs.
|
||||||
|
@ -485,10 +486,11 @@ void per10ms();
|
||||||
int16_t getValue(uint8_t i);
|
int16_t getValue(uint8_t i);
|
||||||
bool getSwitch(int8_t swtch, bool nc);
|
bool getSwitch(int8_t swtch, bool nc);
|
||||||
|
|
||||||
uint8_t getFlightPhase();
|
extern uint8_t getFlightPhase();
|
||||||
uint8_t getTrimFlightPhase(uint8_t idx, uint8_t phase);
|
extern uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx);
|
||||||
|
extern int16_t getRawTrimValue(uint8_t phase, uint8_t idx);
|
||||||
extern int16_t getTrimValue(uint8_t phase, uint8_t idx);
|
extern int16_t getTrimValue(uint8_t phase, uint8_t idx);
|
||||||
extern void setTrimValue(uint8_t phase, uint8_t idx, int16_t trim);
|
extern void setRawTrimValue(uint8_t phase, uint8_t idx, int16_t trim);
|
||||||
|
|
||||||
extern uint16_t s_timeCumTot;
|
extern uint16_t s_timeCumTot;
|
||||||
extern uint16_t s_timeCumThr; //gewichtete laufzeit in 1/16 sec
|
extern uint16_t s_timeCumThr; //gewichtete laufzeit in 1/16 sec
|
||||||
|
|
|
@ -269,15 +269,15 @@
|
||||||
#define TR_MODEL "MODEL"
|
#define TR_MODEL "MODEL"
|
||||||
#define TR_FP "FP"
|
#define TR_FP "FP"
|
||||||
#define TR_EEPROMLOWMEM "EEPROM low mem"
|
#define TR_EEPROMLOWMEM "EEPROM low mem"
|
||||||
#define TR_ALERT "ALERT"
|
#define TR_ALERT "\007ALERT"
|
||||||
#define TR_PRESSANYKEYTOSKIP "Press any key to skip"
|
#define TR_PRESSANYKEYTOSKIP "Press any key to skip"
|
||||||
#define TR_THROTTLENOTIDLE "Throttle not idle"
|
#define TR_THROTTLENOTIDLE "Throttle not idle"
|
||||||
#define TR_RESETTHROTTLE "Reset throttle"
|
#define TR_RESETTHROTTLE "Reset throttle"
|
||||||
#define TR_ALARMSDISABLED "Alarms Disabled"
|
#define TR_ALARMSDISABLED "Alarms Disabled"
|
||||||
#define TR_SWITCHESNOTOFF "Switches not off"
|
#define TR_SWITCHESNOTOFF "Switches not off"
|
||||||
#define TR_PLEASERESETTHEM "Please reset them"
|
#define TR_PLEASERESETTHEM "Please reset them"
|
||||||
#define TR_MESSAGE "MESSAGE"
|
#define TR_MESSAGE "\004MESSAGE"
|
||||||
#define TR_PRESSANYKEY "press any Key"
|
#define TR_PRESSANYKEY "\004Press any Key"
|
||||||
#define TR_BADEEPROMDATA "Bad EEprom Data"
|
#define TR_BADEEPROMDATA "Bad EEprom Data"
|
||||||
#define TR_EEPROMFORMATTING "EEPROM Formatting"
|
#define TR_EEPROMFORMATTING "EEPROM Formatting"
|
||||||
#define TR_EEPROMOVERFLOW "EEPROM overflow"
|
#define TR_EEPROMOVERFLOW "EEPROM overflow"
|
||||||
|
|
|
@ -270,7 +270,7 @@
|
||||||
#define TR_FP "PV"
|
#define TR_FP "PV"
|
||||||
#define TR_EEPROMLOWMEM "EEPROM low mem"
|
#define TR_EEPROMLOWMEM "EEPROM low mem"
|
||||||
#define TR_ALERT "ALERTE"
|
#define TR_ALERT "ALERTE"
|
||||||
#define TR_PRESSANYKEYTOSKIP "Appuyez sur touche"
|
#define TR_PRESSANYKEYTOSKIP "Touche pour ignorer"
|
||||||
#define TR_THROTTLENOTIDLE "Gaz pas a zero"
|
#define TR_THROTTLENOTIDLE "Gaz pas a zero"
|
||||||
#define TR_RESETTHROTTLE "Reinitialisez le"
|
#define TR_RESETTHROTTLE "Reinitialisez le"
|
||||||
#define TR_ALARMSDISABLED "Alarmes Desactivees"
|
#define TR_ALARMSDISABLED "Alarmes Desactivees"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue