mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 23:35:17 +03:00
Backup before 10bits trims function merge (instead of 8bits + subtrims)
This commit is contained in:
parent
f0fca34b7e
commit
af73d05bbd
21 changed files with 560 additions and 122 deletions
17
src/Makefile
17
src/Makefile
|
@ -29,7 +29,8 @@
|
||||||
|
|
||||||
#gruvin: PCB version -- OVERRIDES the following settings if not STD
|
#gruvin: PCB version -- OVERRIDES the following settings if not STD
|
||||||
# Values: STD, V3, V4
|
# Values: STD, V3, V4
|
||||||
PCB = V3
|
PCB = V4
|
||||||
|
#NOTE!: V4 adds to V3, such that both PCBV3 and PCBV4 get defined
|
||||||
|
|
||||||
# Following options for PCB=STD only (ignored otherwise) ...
|
# Following options for PCB=STD only (ignored otherwise) ...
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ TARGET = gruvin9x
|
||||||
OBJDIR = obj
|
OBJDIR = obj
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC = gruvin9x.cpp stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp pers.cpp file.cpp lcd.cpp drivers.cpp templates.cpp
|
CPPSRC = gruvin9x.cpp stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp pers.cpp file.cpp lcd.cpp drivers.cpp
|
||||||
|
|
||||||
ifeq ($(EXT), JETI)
|
ifeq ($(EXT), JETI)
|
||||||
CPPSRC += jeti.cpp
|
CPPSRC += jeti.cpp
|
||||||
|
@ -168,6 +169,11 @@ ifeq ($(PCB), STD)
|
||||||
# STD PCB, so ...
|
# STD PCB, so ...
|
||||||
|
|
||||||
CPPDEFS += -DPCBSTD
|
CPPDEFS += -DPCBSTD
|
||||||
|
# If Hardware PPM mode ( PB0<->BP7) switch the Backlight output with the original PPM to use hardware facility to generate precise PPM (hardware mods)
|
||||||
|
# G: TODO This prevents HARDPPM being used with FRSKY. HARDPPM needs its own option XXX
|
||||||
|
ifeq ($(EXT), HARDPPM)
|
||||||
|
CPPDEFS += -DPPMPB7_HARDWARE
|
||||||
|
endif
|
||||||
|
|
||||||
# If JETI-Support is enabled
|
# If JETI-Support is enabled
|
||||||
ifeq ($(EXT), JETI)
|
ifeq ($(EXT), JETI)
|
||||||
|
@ -210,7 +216,7 @@ else
|
||||||
CPPDEFS += -DPCBV3 -DFRSKY -DBEEPSPKR
|
CPPDEFS += -DPCBV3 -DFRSKY -DBEEPSPKR
|
||||||
endif
|
endif
|
||||||
ifeq ($(PCB), V4)
|
ifeq ($(PCB), V4)
|
||||||
CPPDEFS += -DPCBV4 -DFRSKY -DBEEPSPKR
|
CPPDEFS += -DPCBV3 -DPCBV4 -DFRSKY -DBEEPSPKR
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -231,6 +237,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(TEMPLATES), YES)
|
ifeq ($(TEMPLATES), YES)
|
||||||
CPPDEFS += -DTEMPLATES
|
CPPDEFS += -DTEMPLATES
|
||||||
|
CPPSRC += templates.cpp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -845,6 +852,6 @@ gtest_main.a : gtest-all.o gtest_main.o
|
||||||
# gtest_main.a, depending on whether it defines its own main()
|
# gtest_main.a, depending on whether it defines its own main()
|
||||||
# function.
|
# function.
|
||||||
|
|
||||||
gtests: $(CPPSRC) gtests.cpp simpgmspace.cpp gtest_main.a
|
gtests: $(CPPSRC) gtests.cpp simpgmspace.cpp *.h gtest_main.a
|
||||||
g++ $(CPPSRC) gtests.cpp simpgmspace.cpp $(CPPFLAGS) -I$(GTEST_DIR) $(ARCH) -o gtests -lpthread -MD -DSIMU gtest_main.a
|
g++ $(CPPSRC) gtests.cpp simpgmspace.cpp $(CPPFLAGS) -I$(GTEST_DIR) $(ARCH) -o gtests -lpthread -MD -DSIMU gtest_main.a
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,31 @@ void Key::input(bool val, EnumKeys enuk)
|
||||||
bool keyState(EnumKeys enuk)
|
bool keyState(EnumKeys enuk)
|
||||||
{
|
{
|
||||||
if(enuk < (int)DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
if(enuk < (int)DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
||||||
|
|
||||||
|
#if defined (PCBV4)
|
||||||
|
switch(enuk){
|
||||||
|
case SW_ElevDR : return PINC & (1<<INP_C_ElevDR);
|
||||||
|
|
||||||
|
case SW_AileDR : return PINC & (1<<INP_C_AileDR);
|
||||||
|
|
||||||
|
case SW_RuddDR : return PING & (1<<INP_G_RuddDR);
|
||||||
|
// INP_G_ID1 INP_B_ID2
|
||||||
|
// id0 0 1
|
||||||
|
// id1 1 1
|
||||||
|
// id2 1 0
|
||||||
|
case SW_ID0 : return !(PING & (1<<INP_G_ID1));
|
||||||
|
case SW_ID1 : return (PING & (1<<INP_G_ID1))&& (PINB & (1<<INP_B_ID2));
|
||||||
|
case SW_ID2 : return !(PINB & (1<<INP_B_ID2));
|
||||||
|
|
||||||
|
case SW_Gear : return PING & (1<<INP_G_Gear);
|
||||||
|
|
||||||
|
case SW_ThrCt : return PING & (1<<INP_G_ThrCt);
|
||||||
|
|
||||||
|
case SW_Trainer: return PINB & (1<<INP_B_Trainer);
|
||||||
|
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
#else
|
||||||
switch(enuk){
|
switch(enuk){
|
||||||
case SW_ElevDR : return PINE & (1<<INP_E_ElevDR);
|
case SW_ElevDR : return PINE & (1<<INP_E_ElevDR);
|
||||||
|
|
||||||
|
@ -260,6 +285,7 @@ bool keyState(EnumKeys enuk)
|
||||||
case SW_Trainer: return PINE & (1<<INP_E_Trainer);
|
case SW_Trainer: return PINE & (1<<INP_E_Trainer);
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
#endif // defined (PCBV4)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +320,7 @@ void per10ms()
|
||||||
g_tmr10ms++;
|
g_tmr10ms++;
|
||||||
g_blinkTmr10ms++;
|
g_blinkTmr10ms++;
|
||||||
|
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3) && !defined (PCBV4)
|
||||||
/* Update gloabal Date/Time every 100 per10ms cycles */
|
/* Update gloabal Date/Time every 100 per10ms cycles */
|
||||||
if (++g_ms100 == 100)
|
if (++g_ms100 == 100)
|
||||||
{
|
{
|
||||||
|
@ -306,8 +332,8 @@ void per10ms()
|
||||||
/**** BEGIN KEY STATE READ ****/
|
/**** BEGIN KEY STATE READ ****/
|
||||||
uint8_t enuk = KEY_MENU;
|
uint8_t enuk = KEY_MENU;
|
||||||
|
|
||||||
|
// User buttons ...
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
|
|
||||||
/* Original keys were connected to PORTB as follows:
|
/* Original keys were connected to PORTB as follows:
|
||||||
|
|
||||||
Bit Key
|
Bit Key
|
||||||
|
@ -321,6 +347,15 @@ void per10ms()
|
||||||
0 other use
|
0 other use
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
# if defined (PCBV4)
|
||||||
|
uint8_t tin = ~PINL;
|
||||||
|
uint8_t in;
|
||||||
|
in = (tin & 0x0f) << 3;
|
||||||
|
in |= (tin & 0x30) >> 3;
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
|
// Gruvin's PCBv2.14/v3 key scanning ...
|
||||||
#define KEY_Y0 1 // EXIT / MENU
|
#define KEY_Y0 1 // EXIT / MENU
|
||||||
#define KEY_Y1 2 // LEFT / RIGHT / UP / DOWN
|
#define KEY_Y1 2 // LEFT / RIGHT / UP / DOWN
|
||||||
#define KEY_Y2 4 // LV_Trim_Up / Down / LH_Trim_Up / Down
|
#define KEY_Y2 4 // LV_Trim_Up / Down / LH_Trim_Up / Down
|
||||||
|
@ -338,6 +373,8 @@ void per10ms()
|
||||||
|
|
||||||
in = keyDown(); // in gruvin9x.cpp
|
in = keyDown(); // in gruvin9x.cpp
|
||||||
|
|
||||||
|
# endif // PCBV4
|
||||||
|
|
||||||
#else
|
#else
|
||||||
uint8_t in = ~PINB;
|
uint8_t in = ~PINB;
|
||||||
#endif
|
#endif
|
||||||
|
@ -348,8 +385,22 @@ void per10ms()
|
||||||
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
|
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
|
||||||
++enuk;
|
++enuk;
|
||||||
}
|
}
|
||||||
|
// End User buttons
|
||||||
|
|
||||||
|
// Trim switches ...
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
|
# if defined (PCBV4)
|
||||||
|
static prog_uchar APM crossTrim[]={
|
||||||
|
1<<INP_J_TRM_LH_DWN,
|
||||||
|
1<<INP_J_TRM_LH_UP,
|
||||||
|
1<<INP_J_TRM_LV_DWN,
|
||||||
|
1<<INP_J_TRM_LV_UP,
|
||||||
|
1<<INP_J_TRM_RV_DWN,
|
||||||
|
1<<INP_J_TRM_RV_UP,
|
||||||
|
1<<INP_J_TRM_RH_DWN,
|
||||||
|
1<<INP_J_TRM_RH_UP
|
||||||
|
};
|
||||||
|
# else
|
||||||
static prog_uchar APM crossTrim[]={
|
static prog_uchar APM crossTrim[]={
|
||||||
1<<TRIM_M_RV_DWN,
|
1<<TRIM_M_RV_DWN,
|
||||||
1<<TRIM_M_RV_UP,
|
1<<TRIM_M_RV_UP,
|
||||||
|
@ -360,7 +411,10 @@ void per10ms()
|
||||||
1<<TRIM_M_LV_DWN,
|
1<<TRIM_M_LV_DWN,
|
||||||
1<<TRIM_M_LV_UP
|
1<<TRIM_M_LV_UP
|
||||||
};
|
};
|
||||||
#else
|
# endif
|
||||||
|
|
||||||
|
#else // stock original board ...
|
||||||
|
|
||||||
static prog_uchar APM crossTrim[]={
|
static prog_uchar APM crossTrim[]={
|
||||||
1<<INP_D_TRM_LH_DWN, // bit 7
|
1<<INP_D_TRM_LH_DWN, // bit 7
|
||||||
1<<INP_D_TRM_LH_UP,
|
1<<INP_D_TRM_LH_UP,
|
||||||
|
@ -375,6 +429,9 @@ void per10ms()
|
||||||
|
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
|
|
||||||
|
# if defined (PCBV4)
|
||||||
|
in = ~PINJ;
|
||||||
|
# else
|
||||||
PORTD = ~KEY_Y2; // select Y2 row. (Bits 3:0 LVD / LVU / LHU / LHD)
|
PORTD = ~KEY_Y2; // select Y2 row. (Bits 3:0 LVD / LVU / LHU / LHD)
|
||||||
_delay_us(1);
|
_delay_us(1);
|
||||||
in = ~PIND & 0xf0; // mask out outputs
|
in = ~PIND & 0xf0; // mask out outputs
|
||||||
|
@ -384,20 +441,21 @@ void per10ms()
|
||||||
in |= ((~PIND & 0xf0) >> 4);
|
in |= ((~PIND & 0xf0) >> 4);
|
||||||
|
|
||||||
PORTD = 0xFF;
|
PORTD = 0xFF;
|
||||||
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
in = ~PIND;
|
in = ~PIND;
|
||||||
|
|
||||||
// Legacy support for USART1 free hardware mod [DEPRECATED]
|
// Legacy support for USART1 free hardware mod [DEPRECATED]
|
||||||
#if defined(USART1FREED)
|
# if defined(USART1FREED)
|
||||||
// mask out original INP_D_TRM_LV_UP and INP_D_TRM_LV_DWN bits
|
// mask out original INP_D_TRM_LV_UP and INP_D_TRM_LV_DWN bits
|
||||||
in &= ~((1<<INP_D_TRM_LV_UP) | (1<<INP_D_TRM_LV_DWN));
|
in &= ~((1<<INP_D_TRM_LV_UP) | (1<<INP_D_TRM_LV_DWN));
|
||||||
|
|
||||||
// merge in the two new switch port values
|
// merge in the two new switch port values
|
||||||
in |= (~PINC & (1<<INP_C_TRM_LV_UP)) ? (1<<INP_D_TRM_LV_UP) : 0;
|
in |= (~PINC & (1<<INP_C_TRM_LV_UP)) ? (1<<INP_D_TRM_LV_UP) : 0;
|
||||||
in |= (~PING & (1<<INP_G_TRM_LV_DWN)) ? (1<<INP_D_TRM_LV_DWN) : 0;
|
in |= (~PING & (1<<INP_G_TRM_LV_DWN)) ? (1<<INP_D_TRM_LV_DWN) : 0;
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(int i=0; i<8; i++)
|
for(int i=0; i<8; i++)
|
||||||
|
@ -406,14 +464,20 @@ void per10ms()
|
||||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i),(EnumKeys)enuk);
|
keys[enuk].input(in & pgm_read_byte(crossTrim+i),(EnumKeys)enuk);
|
||||||
++enuk;
|
++enuk;
|
||||||
}
|
}
|
||||||
|
// End Trim Switches
|
||||||
|
|
||||||
/**** END KEY STATE READ ****/
|
/**** END KEY STATE READ ****/
|
||||||
|
|
||||||
#if defined (FRSKY)
|
#if defined (FRSKY)
|
||||||
// Used to detect presence of valid FrSky telemetry packets inside the
|
|
||||||
// last <FRSKY_TIMEOUT10ms> 10ms intervals
|
// TODO why sending only every 50ms
|
||||||
if ( FrskyAlarmSendState )
|
// Attempt to transmit any waiting Fr-Sky alarm set packets every 50ms (subject to packet buffer availability)
|
||||||
FRSKY10mspoll() ;
|
static uint8_t FrskyDelay = 5;
|
||||||
|
if (FrskyAlarmSendState && (--FrskyDelay == 0))
|
||||||
|
{
|
||||||
|
FrskyDelay = 5; // 50ms
|
||||||
|
FRSKY10mspoll();
|
||||||
|
}
|
||||||
|
|
||||||
if (frskyStreaming > 0)
|
if (frskyStreaming > 0)
|
||||||
frskyStreaming--;
|
frskyStreaming--;
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef eepromv3_h
|
#ifndef eepromv3_h
|
||||||
#define eepromv3_h
|
#define eepromv3_h
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef eepromv4_h
|
#ifndef eepromv4_h
|
||||||
#define eepromv4_h
|
#define eepromv4_h
|
||||||
|
|
||||||
|
|
49
src/ff.cpp
49
src/ff.cpp
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - FAT file system module R0.08a (C)ChaN, 2010
|
/ FatFs - FAT file system module R0.08a (C)ChaN, 2010
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
|
@ -3518,6 +3539,34 @@ FRESULT f_mkfs (
|
||||||
|
|
||||||
#endif /* _USE_MKFS && !_FS_READONLY */
|
#endif /* _USE_MKFS && !_FS_READONLY */
|
||||||
|
|
||||||
|
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Allocate a memory block */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
||||||
|
UINT size /* Number of bytes to allocate */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Free a memory block */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void ff_memfree(
|
||||||
|
void* mblock /* Pointer to the memory block to free */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
free(mblock);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
21
src/ff.h
21
src/ff.h
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ FatFs - FAT file system module include file R0.08a (C)ChaN, 2010
|
/ FatFs - FAT file system module include file R0.08a (C)ChaN, 2010
|
||||||
/----------------------------------------------------------------------------/
|
/----------------------------------------------------------------------------/
|
||||||
|
|
21
src/ffconf.h
21
src/ffconf.h
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ FatFs - FAT file system module configuration file R0.08a (C)ChaN, 2010
|
/ FatFs - FAT file system module configuration file R0.08a (C)ChaN, 2010
|
||||||
/----------------------------------------------------------------------------/
|
/----------------------------------------------------------------------------/
|
||||||
|
|
122
src/gruvin9x.cpp
122
src/gruvin9x.cpp
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Authors (alphabetical order)
|
* Authors (alphabetical order)
|
||||||
* - Bertrand Songis <bsongis@gmail.com>
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
*
|
*
|
||||||
* gruvin9x is based on code named er9x by
|
* gruvin9x is based on code named er9x by
|
||||||
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
* was based on the original (and ongoing) project by Thomas Husterer,
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
* th9x -- http://code.google.com/p/th9x/
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -442,7 +442,7 @@ bool getSwitch(int8_t swtch, bool nc, uint8_t level)
|
||||||
//#define CS_EGREATER 12
|
//#define CS_EGREATER 12
|
||||||
//#define CS_ELESS 13
|
//#define CS_ELESS 13
|
||||||
|
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3) && !defined (PCBV4)
|
||||||
// The ugly scanned keys thing should be gone for PCBV4+. In the meantime ...
|
// The ugly scanned keys thing should be gone for PCBV4+. In the meantime ...
|
||||||
uint8_t keyDown()
|
uint8_t keyDown()
|
||||||
{
|
{
|
||||||
|
@ -459,7 +459,11 @@ uint8_t keyDown()
|
||||||
#else
|
#else
|
||||||
inline uint8_t keyDown()
|
inline uint8_t keyDown()
|
||||||
{
|
{
|
||||||
|
#if defined (PCBV4)
|
||||||
|
return (~PINL) & 0x3F;
|
||||||
|
#else
|
||||||
return (~PINB) & 0x7E;
|
return (~PINB) & 0x7E;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -831,9 +835,10 @@ void getADC_filt()
|
||||||
void getADC_osmp()
|
void getADC_osmp()
|
||||||
{
|
{
|
||||||
uint16_t temp_ana[8] = {0};
|
uint16_t temp_ana[8] = {0};
|
||||||
for (uint8_t adc_input=0;adc_input<8;adc_input++){
|
for (uint8_t adc_input=0;adc_input<8;adc_input++)
|
||||||
|
{
|
||||||
|
ADMUX=adc_input|ADC_VREF_TYPE; // TODO now it is done only one time before the loop, is it good?
|
||||||
for (uint8_t i=0; i<4;i++) { // Going from 10bits to 11 bits. Addition = n. Loop 4^n times
|
for (uint8_t i=0; i<4;i++) { // Going from 10bits to 11 bits. Addition = n. Loop 4^n times
|
||||||
ADMUX=adc_input|ADC_VREF_TYPE;
|
|
||||||
// Start the AD conversion
|
// Start the AD conversion
|
||||||
ADCSRA|=0x40;
|
ADCSRA|=0x40;
|
||||||
// Wait for the AD conversion to complete
|
// Wait for the AD conversion to complete
|
||||||
|
@ -847,7 +852,8 @@ void getADC_osmp()
|
||||||
|
|
||||||
void getADC_single()
|
void getADC_single()
|
||||||
{
|
{
|
||||||
for (uint8_t adc_input=0;adc_input<8;adc_input++){
|
for (uint8_t adc_input=0;adc_input<8;adc_input++)
|
||||||
|
{
|
||||||
ADMUX=adc_input|ADC_VREF_TYPE;
|
ADMUX=adc_input|ADC_VREF_TYPE;
|
||||||
// Start the AD conversion
|
// Start the AD conversion
|
||||||
ADCSRA|=0x40;
|
ADCSRA|=0x40;
|
||||||
|
@ -871,11 +877,16 @@ void getADC_bandgap()
|
||||||
// See http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=847208#847208
|
// See http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=847208#847208
|
||||||
// In the end, simply using a longer delay (presumably to account for the higher
|
// In the end, simply using a longer delay (presumably to account for the higher
|
||||||
// impedance Vbg internal source) solved the problem. NOTE: Does NOT adversely affect PPM_out latency.
|
// impedance Vbg internal source) solved the problem. NOTE: Does NOT adversely affect PPM_out latency.
|
||||||
|
#if defined (PCBV4)
|
||||||
|
ADCSRB &= ~(1<<MUX5);
|
||||||
|
#endif
|
||||||
ADMUX=0x1E|ADC_VREF_TYPE; // Switch MUX to internal 1.1V reference
|
ADMUX=0x1E|ADC_VREF_TYPE; // Switch MUX to internal 1.1V reference
|
||||||
_delay_us(300); // this somewhat costly delay is the only remedy for stable results on the Atmega2560/1 chips
|
_delay_us(300); // this somewhat costly delay is the only remedy for stable results on the Atmega2560/1 chips
|
||||||
ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; // again becasue first one is usually inaccurate
|
ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; // again becasue first one is usually inaccurate
|
||||||
BandGap=ADCW;
|
BandGap=ADCW;
|
||||||
|
#if defined (PCBV4)
|
||||||
|
ADCSRB |= (1<<MUX5);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1460,7 +1471,7 @@ void perOut(int16_t *chanOut)
|
||||||
} */
|
} */
|
||||||
|
|
||||||
//========== LIMITS ===============
|
//========== LIMITS ===============
|
||||||
for(uint8_t i=0;i<NUM_CHNOUT;i++) {
|
for (uint8_t i=0;i<NUM_CHNOUT;i++) {
|
||||||
// chans[i] holds data from mixer. chans[i] = v*weight => 1024*100
|
// chans[i] holds data from mixer. chans[i] = v*weight => 1024*100
|
||||||
// later we multiply by the limit (up to 100) and then we need to normalize
|
// later we multiply by the limit (up to 100) and then we need to normalize
|
||||||
// at the end chans[i] = chans[i]/100 => -1024..1024
|
// at the end chans[i] = chans[i]/100 => -1024..1024
|
||||||
|
@ -1577,6 +1588,9 @@ void perMain()
|
||||||
else
|
else
|
||||||
BACKLIGHT_OFF;
|
BACKLIGHT_OFF;
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
// G: TODO This shouldn't be in perMain(). It should be in the same place
|
||||||
|
// all the other ADC samples happen
|
||||||
static int16_t p1valprev;
|
static int16_t p1valprev;
|
||||||
p1valdiff = (p1val-calibratedStick[6])/32;
|
p1valdiff = (p1val-calibratedStick[6])/32;
|
||||||
if(p1valdiff) {
|
if(p1valdiff) {
|
||||||
|
@ -1584,6 +1598,7 @@ void perMain()
|
||||||
p1val = calibratedStick[6];
|
p1val = calibratedStick[6];
|
||||||
}
|
}
|
||||||
p1valprev = calibratedStick[6];
|
p1valprev = calibratedStick[6];
|
||||||
|
/////////////////
|
||||||
|
|
||||||
g_menuStack[g_menuStackPtr](evt);
|
g_menuStack[g_menuStackPtr](evt);
|
||||||
refreshDiplay();
|
refreshDiplay();
|
||||||
|
@ -1630,8 +1645,8 @@ Gruvin:
|
||||||
|
|
||||||
g_vbat100mV = (ab*16 + (ab*g_eeGeneral.vBatCalib)/8)/BandGap;
|
g_vbat100mV = (ab*16 + (ab*g_eeGeneral.vBatCalib)/8)/BandGap;
|
||||||
#else
|
#else
|
||||||
int32_t instant_vbat = anaIn(7);
|
int32_t instant_vbat = anaIn(7);
|
||||||
instant_vbat = (instant_vbat*16 + instant_vbat*g_eeGeneral.vBatCalib/8) / BandGap;
|
instant_vbat = (instant_vbat*16 + instant_vbat*g_eeGeneral.vBatCalib/8) / BandGap;
|
||||||
if (g_vbat100mV == 0 || g_menuStack[0] != menuMainView) g_vbat100mV = instant_vbat;
|
if (g_vbat100mV == 0 || g_menuStack[0] != menuMainView) g_vbat100mV = instant_vbat;
|
||||||
g_vbat100mV = (instant_vbat + g_vbat100mV*7) / 8;
|
g_vbat100mV = (instant_vbat + g_vbat100mV*7) / 8;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1647,7 +1662,6 @@ Gruvin:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
// The various "beep" tone lengths
|
// The various "beep" tone lengths
|
||||||
|
@ -1676,7 +1690,7 @@ uint8_t ppmInState = 0; //0=unsync 1..8= wait for value i-1
|
||||||
|
|
||||||
uint8_t heartbeat;
|
uint8_t heartbeat;
|
||||||
|
|
||||||
|
|
||||||
ISR(TIMER1_COMPA_vect) //2MHz pulse generation
|
ISR(TIMER1_COMPA_vect) //2MHz pulse generation
|
||||||
{
|
{
|
||||||
static uint8_t pulsePol;
|
static uint8_t pulsePol;
|
||||||
|
@ -1688,19 +1702,27 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation
|
||||||
;
|
;
|
||||||
uint16_t dt=TCNT1;//-OCR1A;
|
uint16_t dt=TCNT1;//-OCR1A;
|
||||||
|
|
||||||
|
//vinceofdrink@gmail harwared ppm
|
||||||
|
//Orginal bitbang for PPM
|
||||||
|
#ifndef DPPMPB7_HARDWARE
|
||||||
if(pulsePol)
|
if(pulsePol)
|
||||||
{
|
{
|
||||||
PORTB |= (1<<OUT_B_PPM); // GCC optimisation should result in a single SBI instruction
|
PORTB |= (1<<OUT_B_PPM); // GCC optimisation should result in a single SBI instruction
|
||||||
pulsePol = 0;
|
pulsePol = 0;
|
||||||
}else{
|
}else{
|
||||||
PORTB &= ~(1<<OUT_B_PPM); // GCC optimisation should result in a single CLI instruction
|
PORTB &= ~(1<<OUT_B_PPM); // GCC optimisation should result in a single CBI instruction
|
||||||
pulsePol = 1;
|
pulsePol = 1;
|
||||||
}
|
}
|
||||||
g_tmr1Latency_max = max(dt,g_tmr1Latency_max); // max has leap, therefore vary in length
|
g_tmr1Latency_max = max(dt,g_tmr1Latency_max); // max has leap, therefore vary in length
|
||||||
g_tmr1Latency_min = min(dt,g_tmr1Latency_min); // min has leap, therefore vary in length
|
g_tmr1Latency_min = min(dt,g_tmr1Latency_min); // min has leap, therefore vary in length
|
||||||
|
#endif
|
||||||
OCR1A = *pulsePtr++;
|
OCR1A = *pulsePtr++;
|
||||||
|
|
||||||
|
//vinceofdrink@gmail harwared ppm
|
||||||
|
#if defined (DPPMPB7_HARDWARE)
|
||||||
|
OCR1C=OCR1A; //just copy the value of the OCR1A to OCR1C to test PPM out without to much change in the code not optimum but will not alter ppm precision
|
||||||
|
#endif
|
||||||
|
|
||||||
if( *pulsePtr == 0) {
|
if( *pulsePtr == 0) {
|
||||||
//currpulse=0;
|
//currpulse=0;
|
||||||
pulsePtr = pulses2MHz;
|
pulsePtr = pulses2MHz;
|
||||||
|
@ -1713,7 +1735,9 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation
|
||||||
TIMSK &= ~(1<<OCIE1A); //stop reentrance
|
TIMSK &= ~(1<<OCIE1A); //stop reentrance
|
||||||
#endif
|
#endif
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
setupPulses();
|
setupPulses();
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
TIMSK1 |= (1<<OCIE1A);
|
TIMSK1 |= (1<<OCIE1A);
|
||||||
|
@ -1761,7 +1785,7 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
static uint8_t accuracyWarble = 4; // becasue 16M / 1024 / 100 = 156.25. So bump every 4.
|
static uint8_t accuracyWarble = 4; // becasue 16M / 1024 / 100 = 156.25. So bump every 4.
|
||||||
uint8_t bump = (!(accuracyWarble++ & 0x03)) ? 157 : 156;
|
uint8_t bump = (!(accuracyWarble++ & 0x03)) ? 157 : 156;
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
TIMSK2 &= ~(1<<OCIE2A); //stop reentrance
|
TIMSK2 &= ~(1<<OCIE2A); //stop reentrance
|
||||||
OCR2A += bump;
|
OCR2A += bump;
|
||||||
|
@ -1775,7 +1799,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||||
#endif
|
#endif
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
|
|
||||||
#if defined (PCBSTD) && defined (BEEPSPKR)
|
#if defined (PCBSTD) && defined (BEEPSPKR)
|
||||||
// gruvin: Begin Tone Generator
|
// gruvin: Begin Tone Generator
|
||||||
static uint8_t toneCounter;
|
static uint8_t toneCounter;
|
||||||
|
@ -2005,10 +2028,10 @@ extern uint16_t g_timeMain;
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
uint16_t DEBUG1 = 0;
|
uint16_t DEBUG1 = 0;
|
||||||
uint16_t DEBUG2 = 0;
|
uint16_t DEBUG2 = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern unsigned char __bss_end ;
|
extern unsigned char __bss_end ;
|
||||||
|
|
||||||
|
@ -2085,34 +2108,42 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||||
#ifndef SIMU
|
#ifndef SIMU
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Set up I/O port data diretions and initial states
|
// Set up I/O port data directions and initial states
|
||||||
|
DDRA = 0xff; PORTA = 0x00; // LCD data
|
||||||
|
|
||||||
DDRA = 0xff; PORTA = 0x00;
|
#if defined (PCBV4)
|
||||||
#if defined (PCBV3)
|
DDRB = 0b10010111; PORTB = 0b01101000; // 7:SPKR, 6:IDL2_S|PPM, 5:TrainSW, SDCARD[4:CS 3:MISO 2:MOSI 1:SCK], 0:PPM_OUT|IDL2_SW
|
||||||
|
DDRC = 0x3f; PORTC = 0xc0; // 7:AilDR, 6:EleDR, LCD[5,4,3,2,1[, 0:BackLight
|
||||||
|
DDRD = 0x01; PORTD = 0xfe; // 7/6:Spare3/4, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL
|
||||||
|
DDRE = 0b00001010; PORTE = 0b11110101; // 7:PPM_IN, 6: RENC1_B, 5:RENC1_A, 4:USB_DNEG, 3:BUZZER, 2:USB_DPOS, 1:TELEM_TX, 0:TELEM_RX
|
||||||
|
DDRF = 0x00; PORTF = 0x00; // 7-4:JTAG, 3:ADC_REF_1.2V input, 2-0:ADC_SPARE_2-0
|
||||||
|
DDRG = 0b00010000; PORTG = 0xff; // 7-6:N/A, 5:GearSW, 4: Sim_Ctrl[out], 3:IDL1_Sw, 2:TCut_Sw, 1:RF_Power[in], 0: RudDr_Sw
|
||||||
|
DDRH = 0x00; PORTH = 0xff; // 7:0 Spare port -- all inputer for now [Bit 2:VIB_OPTION -- setting to input for now]
|
||||||
|
DDRJ = 0x00; PORTJ = 0xff; // 7-0:Trim switch inputs
|
||||||
|
DDRK = 0x00; PORTK = 0x00; // anain. No pull-ups!
|
||||||
|
DDRL = 0x00; PORTL = 0xff; // 7-6:Spare6/5 (inputs), 5-0: User Button inputs
|
||||||
|
#else
|
||||||
|
# if defined (PCBV3)
|
||||||
DDRB = 0x97; PORTB = 0x1e; // 7:AUDIO, SD_CARD[6:SDA 5:SCL 4:CS 3:MISO 2:MOSI 1:SCK], 0:PPM_OUT
|
DDRB = 0x97; PORTB = 0x1e; // 7:AUDIO, SD_CARD[6:SDA 5:SCL 4:CS 3:MISO 2:MOSI 1:SCK], 0:PPM_OUT
|
||||||
DDRC = 0x3f; PORTC = 0xc0; // PC0 used for LCD back light control
|
DDRC = 0x3f; PORTC = 0xc0; // PC0 used for LCD back light control
|
||||||
DDRD = 0x0F; PORTD = 0xff; // 7:4=inputs (keys/trims, pull-ups on), 3:0=outputs (keyscan row select)
|
DDRD = 0x0F; PORTD = 0xff; // 7:4=inputs (keys/trims, pull-ups on), 3:0=outputs (keyscan row select)
|
||||||
#else
|
# else
|
||||||
DDRB = 0x81; PORTB = 0x7e; //pullups keys+nc
|
DDRB = 0x81; PORTB = 0x7e; //pullups keys+nc
|
||||||
DDRC = 0x3e; PORTC = 0xc1; //pullups nc
|
DDRC = 0x3e; PORTC = 0xc1; //pullups nc
|
||||||
DDRD = 0x00; PORTD = 0xff; //pullups keys
|
DDRD = 0x00; PORTD = 0xff; //pullups keys
|
||||||
#endif
|
# endif
|
||||||
DDRE = (1<<OUT_E_BUZZER); PORTE = 0xff-(1<<OUT_E_BUZZER); //pullups + buzzer 0
|
DDRE = (1<<OUT_E_BUZZER); PORTE = 0xff-(1<<OUT_E_BUZZER); //pullups + buzzer 0
|
||||||
DDRF = 0x00; PORTF = 0x00; //anain
|
DDRF = 0x00; PORTF = 0x00; //anain
|
||||||
DDRG = 0x10; PORTG = 0xff; //pullups + SIM_CTL=1 = phonejack = ppm_in
|
DDRG = 0x10; PORTG = 0xff; //pullups + SIM_CTL=1 = phonejack = ppm_in
|
||||||
|
#endif
|
||||||
|
|
||||||
lcd_init();
|
lcd_init();
|
||||||
|
|
||||||
#ifdef JETI
|
|
||||||
JETI_Init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (FRSKY)
|
|
||||||
FRSKY_Init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ADMUX=ADC_VREF_TYPE;
|
ADMUX=ADC_VREF_TYPE;
|
||||||
ADCSRA=0x85; // ADC enabled, pre-scaler division=32 (no interrupt, no auto-triggering)
|
ADCSRA=0x85; // ADC enabled, pre-scaler division=32 (no interrupt, no auto-triggering)
|
||||||
|
#if defined (PCBV4)
|
||||||
|
ADCSRB=(1<<MUX5);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**** Set up timer/counter 0 ****/
|
/**** Set up timer/counter 0 ****/
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
|
@ -2177,6 +2208,15 @@ int main(void)
|
||||||
g_menuStack[1] = menuProcModelSelect;
|
g_menuStack[1] = menuProcModelSelect;
|
||||||
|
|
||||||
lcdSetRefVolt(25);
|
lcdSetRefVolt(25);
|
||||||
|
|
||||||
|
#if defined (FRSKY)
|
||||||
|
FRSKY_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETI
|
||||||
|
JETI_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
eeReadAll();
|
eeReadAll();
|
||||||
|
|
||||||
uint8_t cModel = g_eeGeneral.currModel;
|
uint8_t cModel = g_eeGeneral.currModel;
|
||||||
|
@ -2193,6 +2233,11 @@ int main(void)
|
||||||
|
|
||||||
clearKeyEvents(); //make sure no keys are down before proceeding
|
clearKeyEvents(); //make sure no keys are down before proceeding
|
||||||
|
|
||||||
|
//addon Vinceofdrink@gmail (hardware ppm)
|
||||||
|
#if defined (DPPMPB7_HARDWARE)
|
||||||
|
TCCR1A |=(1<<COM1C0); // (COM1C1=0 and COM1C0=1 in TCCR1A) toogle the state of PB7 on each TCNT1=OCR1C
|
||||||
|
#endif
|
||||||
|
|
||||||
setupPulses();
|
setupPulses();
|
||||||
|
|
||||||
wdt_enable(WDTO_500MS);
|
wdt_enable(WDTO_500MS);
|
||||||
|
@ -2204,6 +2249,8 @@ int main(void)
|
||||||
|
|
||||||
if(cModel!=g_eeGeneral.currModel) eeDirty(EE_GENERAL); // if model was quick-selected, make sure it sticks
|
if(cModel!=g_eeGeneral.currModel) eeDirty(EE_GENERAL); // if model was quick-selected, make sure it sticks
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined (PCBV3)
|
#if defined (PCBV3)
|
||||||
TIMSK1 |= (1<<OCIE1A); // Pulse generator enable immediately before mainloop
|
TIMSK1 |= (1<<OCIE1A); // Pulse generator enable immediately before mainloop
|
||||||
#else
|
#else
|
||||||
|
@ -2225,7 +2272,7 @@ int main(void)
|
||||||
g_unixTime = mktime(&utm);
|
g_unixTime = mktime(&utm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while(1) {
|
while(1){
|
||||||
uint16_t t0 = getTmr16KHz();
|
uint16_t t0 = getTmr16KHz();
|
||||||
getADC[g_eeGeneral.filterInput]();
|
getADC[g_eeGeneral.filterInput]();
|
||||||
getADC_bandgap() ;
|
getADC_bandgap() ;
|
||||||
|
@ -2241,3 +2288,4 @@ int main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
180
src/gruvin9x.h
180
src/gruvin9x.h
|
@ -74,6 +74,7 @@
|
||||||
|
|
||||||
extern RlcFile theFile; //used for any file operation
|
extern RlcFile theFile; //used for any file operation
|
||||||
|
|
||||||
|
// G: The following comments relate to the original stock PCB only
|
||||||
//
|
//
|
||||||
// elev thr
|
// elev thr
|
||||||
// LV RV
|
// LV RV
|
||||||
|
@ -85,8 +86,6 @@ extern RlcFile theFile; //used for any file operation
|
||||||
// | |
|
// | |
|
||||||
// 3 v 5 v
|
// 3 v 5 v
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
//PORTA 7 6 5 4 3 2 1 0
|
//PORTA 7 6 5 4 3 2 1 0
|
||||||
// O O O O O O O O
|
// O O O O O O O O
|
||||||
// ------------------------ LCD_DAT -----------------------
|
// ------------------------ LCD_DAT -----------------------
|
||||||
|
@ -116,20 +115,6 @@ extern RlcFile theFile; //used for any file operation
|
||||||
// SIM_CTL ID1 NC RF_POW RuddDR
|
// SIM_CTL ID1 NC RF_POW RuddDR
|
||||||
|
|
||||||
#define PORTA_LCD_DAT PORTA
|
#define PORTA_LCD_DAT PORTA
|
||||||
|
|
||||||
#if defined (PCBV3)
|
|
||||||
#define OUT_C_LIGHT 0
|
|
||||||
#else
|
|
||||||
#define OUT_B_LIGHT 7
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define INP_B_KEY_LFT 6
|
|
||||||
#define INP_B_KEY_RGT 5
|
|
||||||
#define INP_B_KEY_UP 4
|
|
||||||
#define INP_B_KEY_DWN 3
|
|
||||||
#define INP_B_KEY_EXT 2
|
|
||||||
#define INP_B_KEY_MEN 1
|
|
||||||
#define OUT_B_PPM 0
|
|
||||||
#define PORTC_LCD_CTRL PORTC
|
#define PORTC_LCD_CTRL PORTC
|
||||||
#define OUT_C_LCD_E 5
|
#define OUT_C_LCD_E 5
|
||||||
#define OUT_C_LCD_RnW 4
|
#define OUT_C_LCD_RnW 4
|
||||||
|
@ -137,39 +122,137 @@ extern RlcFile theFile; //used for any file operation
|
||||||
#define OUT_C_LCD_RES 2
|
#define OUT_C_LCD_RES 2
|
||||||
#define OUT_C_LCD_CS1 1
|
#define OUT_C_LCD_CS1 1
|
||||||
|
|
||||||
#define INP_D_TRM_LH_UP 7
|
extern uint16_t DEBUG1;
|
||||||
#define INP_D_TRM_LH_DWN 6
|
extern uint16_t DEBUG2;
|
||||||
#define INP_D_TRM_RV_DWN 5
|
|
||||||
#define INP_D_TRM_RV_UP 4
|
#if defined (PCBV4)
|
||||||
#define INP_D_TRM_LV_DWN 3
|
# define INP_P_KEY_DWN 0
|
||||||
#define INP_D_TRM_LV_UP 2
|
# define INP_P_KEY_UP 1
|
||||||
#define INP_D_TRM_RH_DWN 1
|
# define INP_P_KEY_RGT 2
|
||||||
#define INP_D_TRM_RH_UP 0
|
# define INP_P_KEY_LFT 3
|
||||||
|
# define INP_P_KEY_MEN 4
|
||||||
|
# define INP_P_KEY_EXT 5
|
||||||
|
// v4.1 will have hardware PPM. Won't make code change until v4.0 beta board is hardware patched
|
||||||
|
|
||||||
|
# define INP_J_TRM_LH_DWN 0
|
||||||
|
# define INP_J_TRM_LH_UP 1
|
||||||
|
# define INP_J_TRM_LV_DWN 2
|
||||||
|
# define INP_J_TRM_LV_UP 3
|
||||||
|
# define INP_J_TRM_RV_DWN 4
|
||||||
|
# define INP_J_TRM_RV_UP 5
|
||||||
|
# define INP_J_TRM_RH_DWN 6
|
||||||
|
# define INP_J_TRM_RH_UP 7
|
||||||
|
|
||||||
|
# define INP_E_PPM_IN 7
|
||||||
|
# define INP_E_ROT_ENC_1_B 6
|
||||||
|
# define INP_E_ROT_ENC_1_A 5
|
||||||
|
# define INP_E_USB_D_PLS 4
|
||||||
|
# define OUT_E_BUZZER 3
|
||||||
|
# define INP_E_USB_D_NEG 2
|
||||||
|
# define INP_E_TELEM_RX 1
|
||||||
|
# define OUT_E_TELEM_TX 0
|
||||||
|
|
||||||
|
# define INP_D_SPARE3 7
|
||||||
|
# define INP_D_SPARE4 6
|
||||||
|
# define INP_D_ROT_ENC_2_PUSH 5
|
||||||
|
# define INP_D_ROT_ENC_1_PUSH 4
|
||||||
|
# define OUT_D_ROT_ENC_2_B 3
|
||||||
|
# define INP_D_ROT_ENC_2_A 2
|
||||||
|
# define INP_D_I2C_SCL 1
|
||||||
|
# define INP_D_I2C_SDA 0
|
||||||
|
|
||||||
|
# define INP_G_Gear 5
|
||||||
|
# define INP_G_ThrCt 2
|
||||||
|
# define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
|
||||||
|
# define INP_G_ID1 3
|
||||||
|
# define INP_G_RF_POW 1
|
||||||
|
# define INP_G_RuddDR 0
|
||||||
|
|
||||||
|
# define INP_C_AileDR 7
|
||||||
|
# define INP_C_ElevDR 6
|
||||||
|
# define OUT_C_LIGHT 0
|
||||||
|
|
||||||
|
# define OUT_B_Speaker 7
|
||||||
|
# define INP_B_Trainer 5
|
||||||
|
|
||||||
|
//vinceofdrink@gmail hardwared ppm
|
||||||
|
//Orginal bitbang port for PPM
|
||||||
|
//G: The v4.1 board will have H/W PPM as standard. All v4.0 beta boards must be hacked likewise, but not yet.
|
||||||
|
# ifndef DPPMPB7_HARDWARE
|
||||||
|
# define INP_B_ID2 6
|
||||||
|
# define OUT_B_PPM 0
|
||||||
|
# else
|
||||||
|
# define OUT_B_PPM 6 // will be switched via internal MCU Timer/PWM hardware
|
||||||
|
# define INP_B_ID2 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
#else // boards prior to v4 ...
|
||||||
|
|
||||||
|
|
||||||
|
# define INP_B_KEY_LFT 6
|
||||||
|
# define INP_B_KEY_RGT 5
|
||||||
|
# define INP_B_KEY_UP 4
|
||||||
|
# define INP_B_KEY_DWN 3
|
||||||
|
# define INP_B_KEY_EXT 2
|
||||||
|
# define INP_B_KEY_MEN 1
|
||||||
|
//vinceofdrink@gmail harwared ppm
|
||||||
|
//Orginal bitbang port for PPM
|
||||||
|
# ifndef DPPMPB7_HARDWARE
|
||||||
|
# define OUT_B_PPM 0
|
||||||
|
# else
|
||||||
|
# define OUT_B_PPM 7 // will not be used
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define INP_D_TRM_LH_UP 7
|
||||||
|
# define INP_D_TRM_LH_DWN 6
|
||||||
|
# define INP_D_TRM_RV_DWN 5
|
||||||
|
# define INP_D_TRM_RV_UP 4
|
||||||
|
# define INP_D_TRM_LV_DWN 3
|
||||||
|
# define INP_D_TRM_LV_UP 2
|
||||||
|
# define INP_D_TRM_RH_DWN 1
|
||||||
|
# define INP_D_TRM_RH_UP 0
|
||||||
|
|
||||||
|
# if defined (PCBV3)
|
||||||
|
# define OUT_C_LIGHT 0
|
||||||
|
# else
|
||||||
|
# ifndef DPPMPB7_HARDWARE
|
||||||
|
# define OUT_B_LIGHT 7
|
||||||
|
# else
|
||||||
|
# define OUT_B_LIGHT 0
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define INP_E_PPM_IN 7
|
||||||
|
# define INP_E_ID2 6
|
||||||
|
# define INP_E_Trainer 5
|
||||||
|
# define INP_E_Gear 4
|
||||||
|
# define OUT_E_BUZZER 3
|
||||||
|
# define INP_E_ElevDR 2
|
||||||
|
# define INP_E_AileDR 1
|
||||||
|
# define INP_E_ThrCt 0
|
||||||
|
|
||||||
|
# if defined(JETI) || defined(FRSKY)
|
||||||
|
# undef INP_E_ThrCt
|
||||||
|
# undef INP_E_AileDR
|
||||||
|
# define INP_C_ThrCt 6
|
||||||
|
# define INP_C_AileDR 7
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
|
||||||
|
# define INP_G_ID1 3
|
||||||
|
# define INP_G_RF_POW 1
|
||||||
|
# define INP_G_RuddDR 0
|
||||||
|
|
||||||
// Legacy support for USART1 hardware mod [DEPRECATED]
|
// Legacy support for USART1 hardware mod [DEPRECATED]
|
||||||
|
// G: This board will be retired before much longer. But I still need it for now.
|
||||||
#if defined(USART1FREED)
|
#if defined(USART1FREED)
|
||||||
// do not undef the original INP_D_TRM_LV_DWN/UP as we need them later
|
// do not undef the original INP_D_TRM_LV_DWN/UP as we need them later
|
||||||
#define INP_C_TRM_LV_UP 0
|
#define INP_C_TRM_LV_UP 0
|
||||||
#define INP_G_TRM_LV_DWN 2
|
#define INP_G_TRM_LV_DWN 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INP_E_PPM_IN 7
|
#endif // defined (PCBV4)
|
||||||
#define INP_E_ID2 6
|
|
||||||
#define INP_E_Trainer 5
|
|
||||||
#define INP_E_Gear 4
|
|
||||||
#define OUT_E_BUZZER 3
|
|
||||||
#define INP_E_ElevDR 2
|
|
||||||
|
|
||||||
|
|
||||||
#define INP_E_AileDR 1
|
|
||||||
#define INP_E_ThrCt 0
|
|
||||||
|
|
||||||
#if defined(JETI) || defined(FRSKY)
|
|
||||||
#undef INP_E_ThrCt
|
|
||||||
#undef INP_E_AileDR
|
|
||||||
#define INP_C_ThrCt 6
|
|
||||||
#define INP_C_AileDR 7
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (BEEPSPKR)
|
#if defined (BEEPSPKR)
|
||||||
#define BEEP_KEY_TIME 5
|
#define BEEP_KEY_TIME 5
|
||||||
|
@ -178,11 +261,6 @@ extern RlcFile theFile; //used for any file operation
|
||||||
#define BEEP_KEY_DOWN_FREQ 45
|
#define BEEP_KEY_DOWN_FREQ 45
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
|
|
||||||
#define INP_G_ID1 3
|
|
||||||
#define INP_G_RF_POW 1
|
|
||||||
#define INP_G_RuddDR 0
|
|
||||||
|
|
||||||
#define SLAVE_MODE (PING & (1<<INP_G_RF_POW))
|
#define SLAVE_MODE (PING & (1<<INP_G_RF_POW))
|
||||||
|
|
||||||
const uint8_t modn12x3[4][4]= {
|
const uint8_t modn12x3[4][4]= {
|
||||||
|
@ -247,7 +325,7 @@ enum EnumKeys {
|
||||||
#define CSWITCH_STR "---- v>ofs v<ofs |v|>ofs|v|<ofsAND OR XOR ""v1==v2 ""v1!=v2 ""v1>v2 ""v1<v2 ""v1>=v2 ""v1<=v2 "
|
#define CSWITCH_STR "---- v>ofs v<ofs |v|>ofs|v|<ofsAND OR XOR ""v1==v2 ""v1!=v2 ""v1>v2 ""v1<v2 ""v1>=v2 ""v1<=v2 "
|
||||||
#define CSW_LEN_FUNC 7
|
#define CSW_LEN_FUNC 7
|
||||||
|
|
||||||
#define FSWITCH_STR "---- ""Trainer ""Instant Trim ""Trims2Offsets ""Telemetry View"
|
#define FSWITCH_STR "---- ""Trainer ""Instant Trim ""Telemetry View"
|
||||||
#define FSW_LEN_FUNC 14
|
#define FSW_LEN_FUNC 14
|
||||||
|
|
||||||
#define SWASH_TYPE_STR "--- ""120 ""120X ""140 ""90 "
|
#define SWASH_TYPE_STR "--- ""120 ""120X ""140 ""90 "
|
||||||
|
@ -673,6 +751,12 @@ inline bool isFunctionActive(uint8_t func)
|
||||||
return active_functions & (1 << (func-1));
|
return active_functions & (1 << (func-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (PCBV3)
|
||||||
|
extern char g_logFilename[21]; // pers.cpp::resetTelemetry()
|
||||||
|
extern FATFS FATFS_Obj; // pers.cpp::resetTelemetry()
|
||||||
|
extern FIL g_oLogFile; // pers.cpp::resetTelemetry()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // gruvin9x_h
|
#endif // gruvin9x_h
|
||||||
/*eof*/
|
/*eof*/
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*-------------------------------------------*/
|
/*-------------------------------------------*/
|
||||||
/* Integer type definitions for FatFs module */
|
/* Integer type definitions for FatFs module */
|
||||||
/*-------------------------------------------*/
|
/*-------------------------------------------*/
|
||||||
|
|
|
@ -48,7 +48,6 @@ void menuMainView(uint8_t event)
|
||||||
{
|
{
|
||||||
static uint8_t switchView = 255;
|
static uint8_t switchView = 255;
|
||||||
static bool instantTrimSwLock;
|
static bool instantTrimSwLock;
|
||||||
static bool trim2OfsSwLock;
|
|
||||||
|
|
||||||
uint8_t view = (switchView == 255 ? g_eeGeneral.view : switchView);
|
uint8_t view = (switchView == 255 ? g_eeGeneral.view : switchView);
|
||||||
|
|
||||||
|
@ -146,7 +145,6 @@ void menuMainView(uint8_t event)
|
||||||
killEvents(KEY_UP);
|
killEvents(KEY_UP);
|
||||||
killEvents(KEY_DOWN);
|
killEvents(KEY_DOWN);
|
||||||
instantTrimSwLock = true;
|
instantTrimSwLock = true;
|
||||||
trim2OfsSwLock = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,10 +152,6 @@ void menuMainView(uint8_t event)
|
||||||
if (!instantTrimSwLock && trimSw) instantTrim();
|
if (!instantTrimSwLock && trimSw) instantTrim();
|
||||||
instantTrimSwLock = trimSw;
|
instantTrimSwLock = trimSw;
|
||||||
|
|
||||||
trimSw = isFunctionActive(FUNC_TRIMS_2_OFS);
|
|
||||||
if (!trim2OfsSwLock && trimSw) moveTrimsToOffsets();
|
|
||||||
trim2OfsSwLock = trimSw;
|
|
||||||
|
|
||||||
if (view == e_telemetry+ALTERNATE) {
|
if (view == e_telemetry+ALTERNATE) {
|
||||||
putsModelName(0, 0, g_model.name, g_eeGeneral.currModel, 0);
|
putsModelName(0, 0, g_model.name, g_eeGeneral.currModel, 0);
|
||||||
uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0);
|
uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0);
|
||||||
|
|
|
@ -323,6 +323,13 @@ void setupPulses()
|
||||||
setupPulsesTracerCtp1009();
|
setupPulsesTracerCtp1009();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if defined (DPPMPB7_HARDWARE)
|
||||||
|
|
||||||
|
//Don't know if its usefull for the other encoding type or if they have polarity option cannot test those
|
||||||
|
//Force an ouput compare to match the ppm polarity
|
||||||
|
if(PINB&(1<<7) && g_model.pulsePol)
|
||||||
|
TCCR1C |=(1<<FOC1C);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//inline int16_t reduceRange(int16_t x) // for in case we want to have room for subtrims
|
//inline int16_t reduceRange(int16_t x) // for in case we want to have room for subtrims
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Author - Erez Raviv <erezraviv@gmail.com>
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
*
|
*
|
||||||
* Based on th9x -> http://code.google.com/p/th9x/
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -13,6 +18,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef eeprom_h
|
#ifndef eeprom_h
|
||||||
#define eeprom_h
|
#define eeprom_h
|
||||||
|
|
||||||
|
@ -35,7 +41,7 @@
|
||||||
|
|
||||||
#define EEPROM_VER_r584 3
|
#define EEPROM_VER_r584 3
|
||||||
#define EEPROM_VER_r751 5
|
#define EEPROM_VER_r751 5
|
||||||
#define EEPROM_VER 105
|
#define EEPROM_VER 105 // TODO make it 201
|
||||||
|
|
||||||
typedef struct t_TrainerMix {
|
typedef struct t_TrainerMix {
|
||||||
uint8_t srcChn:6; // 0-7 = ch1-8
|
uint8_t srcChn:6; // 0-7 = ch1-8
|
||||||
|
@ -148,9 +154,8 @@ typedef struct t_SafetySwData { // Safety Switches data
|
||||||
|
|
||||||
#define FUNC_TRAINER 1
|
#define FUNC_TRAINER 1
|
||||||
#define FUNC_INSTANT_TRIM 2
|
#define FUNC_INSTANT_TRIM 2
|
||||||
#define FUNC_TRIMS_2_OFS 3
|
#define FUNC_VIEW_TELEMETRY 3
|
||||||
#define FUNC_VIEW_TELEMETRY 4
|
#define FUNC_LAST 3
|
||||||
#define FUNC_LAST 4
|
|
||||||
|
|
||||||
typedef struct t_FuncSwData { // Function Switches data
|
typedef struct t_FuncSwData { // Function Switches data
|
||||||
int8_t swtch; //input
|
int8_t swtch; //input
|
||||||
|
|
18
src/pers.cpp
18
src/pers.cpp
|
@ -191,8 +191,6 @@ uint8_t Translate()
|
||||||
if (trimSw) {
|
if (trimSw) {
|
||||||
g_model.funcSw[0].swtch = trimSw;
|
g_model.funcSw[0].swtch = trimSw;
|
||||||
g_model.funcSw[0].func = FUNC_INSTANT_TRIM;
|
g_model.funcSw[0].func = FUNC_INSTANT_TRIM;
|
||||||
g_model.funcSw[1].swtch = trimSw;
|
|
||||||
g_model.funcSw[1].func = FUNC_TRIMS_2_OFS;
|
|
||||||
}
|
}
|
||||||
memcpy(&g_model.phaseData[0].trim[0], &trims[0], 4);
|
memcpy(&g_model.phaseData[0].trim[0], &trims[0], 4);
|
||||||
theFile.writeRlc(FILE_MODEL(id), FILE_TYP_MODEL, (uint8_t*)&g_model, sizeof(g_model), true);
|
theFile.writeRlc(FILE_MODEL(id), FILE_TYP_MODEL, (uint8_t*)&g_model, sizeof(g_model), true);
|
||||||
|
@ -233,10 +231,24 @@ bool eeLoadGeneral()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TEMPLATES
|
||||||
|
inline void applyDefaultTemplate()
|
||||||
|
{
|
||||||
|
for (int i=0; i<NUM_STICKS; i++) {
|
||||||
|
MixData *md = mixaddress(i);
|
||||||
|
md->destCh = i+1;
|
||||||
|
md->weight = 100;
|
||||||
|
md->srcRaw = i+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
STORE_MODELVARS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void modelDefault(uint8_t id)
|
void modelDefault(uint8_t id)
|
||||||
{
|
{
|
||||||
memset(&g_model, 0, sizeof(g_model));
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
applyTemplate(0); //default 4 channel template
|
applyDefaultTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t eeLoadModelName(uint8_t id, char *name)
|
uint16_t eeLoadModelName(uint8_t id, char *name)
|
||||||
|
|
21
src/rtc.cpp
21
src/rtc.cpp
|
@ -1,3 +1,24 @@
|
||||||
|
/*
|
||||||
|
* gruvin9x Author Bryan J.Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* based on th9x -> http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* rtc.cpp code take from (TODO. Re-locate and fix this credit.)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
/* RTC controls */
|
/* RTC controls */
|
||||||
|
|
||||||
|
|
20
src/rtc.h
20
src/rtc.h
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* gruvin9x Author Bryan J.Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* based on th9x -> http://code.google.com/p/th9x/
|
||||||
|
*
|
||||||
|
* rtc.cpp code take from (TODO. Re-locate and fix this credit.)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef RTC_H
|
#ifndef RTC_H
|
||||||
#define RTC_H
|
#define RTC_H
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ void eeprom_read_block (void *pointer_ram,
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy(pointer_ram, &eeprom[(int)pointer_eeprom], size);
|
memcpy(pointer_ram, &eeprom[(uint64_t)pointer_eeprom], size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,5 +81,6 @@ void eeprom_read_block (void *pointer_ram,
|
||||||
const void *pointer_eeprom,
|
const void *pointer_eeprom,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
|
#undef offsetof
|
||||||
#define offsetof(st, m) ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))
|
#define offsetof(st, m) ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))
|
||||||
#define wdt_reset()
|
#define wdt_reset()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//Automatically generated file (Makefile) - do not edit
|
//Automatically generated file (Makefile) - do not edit
|
||||||
#define DATE_STR "2011-09-13"
|
#define DATE_STR "2011-09-14"
|
||||||
#define TIME_STR "19:07:15"
|
#define TIME_STR "11:11:34"
|
||||||
#define TAG_VERS 2-bsongis
|
#define TAG_VERS 2-bsongis
|
||||||
#define SVN_VERS "gruvin9x-dev-r819"
|
#define SVN_VERS "open9x-r3"
|
||||||
#define BUILD_NUM 827
|
#define BUILD_NUM 841
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* gruvin9x Author Bryan J.Rentoul (Gruvin) <gruvin@gmail.com>
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
*
|
*
|
||||||
* templates.cpp original author - Erez Raviv <erezraviv@gmail.com>
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -12,6 +17,8 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
* ============================================================
|
* ============================================================
|
||||||
* Templates file
|
* Templates file
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Author - Erez Raviv <erezraviv@gmail.com>
|
* Authors (alphabetical order)
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
*
|
||||||
|
* gruvin9x is based on code named er9x by
|
||||||
|
* Author - Erez Raviv <erezraviv@gmail.com>, which is in turn
|
||||||
|
* was based on the original (and ongoing) project by Thomas Husterer,
|
||||||
|
* th9x -- http://code.google.com/p/th9x/
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -10,6 +17,7 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* ============================================================
|
* ============================================================
|
||||||
* Templates file
|
* Templates file
|
||||||
*
|
*
|
||||||
|
@ -82,6 +90,12 @@ void clearMixes();
|
||||||
void clearCurves();
|
void clearCurves();
|
||||||
void applyTemplate(uint8_t idx);
|
void applyTemplate(uint8_t idx);
|
||||||
|
|
||||||
|
#ifdef TEMPLATES
|
||||||
|
inline void applyDefaultTemplate()
|
||||||
|
{
|
||||||
|
applyTemplate(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //TEMPLATES_H
|
#endif //TEMPLATES_H
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue