Backlight function switch

No batt volts averaging during calib
Flight phase in bold in Phase One when enabled
Flash savings
[ersky9x] Delay / Duration in custom switches
This commit is contained in:
bsongis
2012-07-18 08:12:26 +00:00
parent 50d21a4c72
commit 3d737e3eb1
18 changed files with 796 additions and 167 deletions
+2 -2
View File
@@ -17,7 +17,6 @@
#include <stdint.h>
#include "open9x.h"
#include "stdio.h"
#include "inttypes.h"
#include "string.h"
@@ -924,7 +923,8 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
strcpy(buf, STR_MODELS_PATH);
FRESULT result = f_opendir(&archiveFolder, buf);
if (result != FR_OK) {
result = f_mkdir(buf);
if (result == FR_NO_PATH)
result = f_mkdir(buf);
if (result != FR_OK)
return SDCARD_ERROR(result);
}
+1 -3
View File
@@ -539,7 +539,6 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
// check and create folder here
strcpy_P(buf, STR_MODELS_PATH);
#ifndef SIMU
FRESULT result = f_opendir(&archiveFolder, buf);
if (result != FR_OK) {
if (result == FR_NO_PATH)
@@ -547,7 +546,6 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
if (result != FR_OK)
return SDCARD_ERROR(result);
}
#endif
buf[sizeof(MODELS_PATH)-1] = '/';
eeLoadModelName(i_fileSrc, &buf[sizeof(MODELS_PATH)]);
@@ -582,7 +580,7 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
FRESULT
#endif
result = f_open(&archiveFile, buf, FA_OPEN_ALWAYS | FA_WRITE);
result = f_open(&archiveFile, buf, FA_CREATE_ALWAYS | FA_WRITE);
if (result != FR_OK) {
return SDCARD_ERROR(result);
}
+38 -16
View File
@@ -3082,9 +3082,15 @@ typedef struct {
#define CKGR_PLLAR_MULA (0x7ff << 16) /**< \brief (CKGR_PLLAR) PLLA Multiplier */
#define CKGR_PLLAR_STUCKTO1 (0x1 << 29) /**< \brief (CKGR_PLLAR) */
/* -------- CKGR_PLLBR : (PMC Offset: 0x002C) PLLB Register -------- */
#define CKGR_PLLBR_DIVB (0xff << 0) /**< \brief (CKGR_PLLBR) Divider */
#define CKGR_PLLBR_PLLBCOUNT (0x3f << 8) /**< \brief (CKGR_PLLBR) PLLB Counter */
#define CKGR_PLLBR_MULB (0x7ff << 16) /**< \brief (CKGR_PLLBR) PLLB Multiplier */
#define CKGR_PLLBR_DIVB_Pos 0
#define CKGR_PLLBR_DIVB_Msk (0xffu << CKGR_PLLBR_DIVB_Pos) /**< \brief (CKGR_PLLBR) Divider */
#define CKGR_PLLBR_DIVB(value) ((CKGR_PLLBR_DIVB_Msk & ((value) << CKGR_PLLBR_DIVB_Pos)))
#define CKGR_PLLBR_PLLBCOUNT_Pos 8
#define CKGR_PLLBR_PLLBCOUNT_Msk (0x3fu << CKGR_PLLBR_PLLBCOUNT_Pos) /**< \brief (CKGR_PLLBR) PLLB Counter */
#define CKGR_PLLBR_PLLBCOUNT(value) ((CKGR_PLLBR_PLLBCOUNT_Msk & ((value) << CKGR_PLLBR_PLLBCOUNT_Pos)))
#define CKGR_PLLBR_MULB_Pos 16
#define CKGR_PLLBR_MULB_Msk (0x7ffu << CKGR_PLLBR_MULB_Pos) /**< \brief (CKGR_PLLBR) PLLB Multiplier */
#define CKGR_PLLBR_MULB(value) ((CKGR_PLLBR_MULB_Msk & ((value) << CKGR_PLLBR_MULB_Pos)))
/* -------- PMC_MCKR : (PMC Offset: 0x0030) Master Clock Register -------- */
#define PMC_MCKR_CSS (0x3 << 0) /**< \brief (PMC_MCKR) Master Clock Source Selection */
#define PMC_MCKR_CSS_SLOW_CLK (0x0 << 0) /**< \brief (PMC_MCKR) Slow Clock is selected */
@@ -3102,8 +3108,10 @@ typedef struct {
#define PMC_MCKR_PLLADIV2 (0x1 << 12) /**< \brief (PMC_MCKR) PLLA Divisor by 2 */
#define PMC_MCKR_PLLBDIV2 (0x1 << 13) /**< \brief (PMC_MCKR) PLLB Divisor by 2 */
/* -------- PMC_USB : (PMC Offset: 0x0038) USB Clock Register -------- */
#define PMC_USB_USBS (0x1 << 0) /**< \brief (PMC_USB) USB Input Clock Selection */
#define PMC_USB_USBDIV (0xf << 8) /**< \brief (PMC_USB) Divider for USB Clock. */
#define PMC_USB_USBS (0x1u << 0) /**< \brief (PMC_USB) USB Input Clock Selection */
#define PMC_USB_USBDIV_Pos 8
#define PMC_USB_USBDIV_Msk (0xfu << PMC_USB_USBDIV_Pos) /**< \brief (PMC_USB) Divider for USB Clock. */
#define PMC_USB_USBDIV(value) ((PMC_USB_USBDIV_Msk & ((value) << PMC_USB_USBDIV_Pos)))
/* -------- PMC_PCK[3] : (PMC Offset: 0x0040) Programmable Clock 0 Register -------- */
#define PMC_PCK_CSS (0x7 << 0) /**< \brief (PMC_PCK[3]) Master Clock Source Selection */
#define PMC_PCK_PRES (0x7 << 4) /**< \brief (PMC_PCK[3]) Programmable Clock Prescaler */
@@ -4927,6 +4935,11 @@ typedef struct {
} Tc;
#endif /* __ASSEMBLY__ */
/* -------- TC_CCR0 : (TC Offset: 0x0) Channel Control Register (channel = 0) -------- */
#define TC_CCR_CLKEN TC_CCR0_CLKEN /**< \brief (TC_CCR) Counter Clock Enable Command */
#define TC_CCR_CLKDIS TC_CCR0_CLKDIS /**< \brief (TC_CCR) Counter Clock Disable Command */
#define TC_CCR_SWTRG TC_CCR0_SWTRG /**< \brief (TC_CCR) Software Trigger Command */
#define TC_CCR0_CLKEN (0x1 << 0) /**< \brief (TC_CCR0) Counter Clock Enable Command */
#define TC_CCR0_CLKDIS (0x1 << 1) /**< \brief (TC_CCR0) Counter Clock Disable Command */
#define TC_CCR0_SWTRG (0x1 << 2) /**< \brief (TC_CCR0) Software Trigger Command */
@@ -4954,6 +4967,8 @@ typedef struct {
#define TC_CMR0_ETRGEDG_FALLING (0x2 << 8) /**< \brief (TC_CMR0) falling edge */
#define TC_CMR0_ETRGEDG_BOTH (0x3 << 8) /**< \brief (TC_CMR0) each edge */
#define TC_CMR0_ABETRG (0x1 << 10) /**< \brief (TC_CMR0) TIOA or TIOB External Trigger Selection */
#define TC_CMR_CPCTRG TC_CMR0_CPCTRG
#define TC_CMR0_CPCTRG (0x1 << 14) /**< \brief (TC_CMR0) RC Compare Trigger Enable */
#define TC_CMR0_WAVE (0x1 << 15) /**< \brief (TC_CMR0) */
#define TC_CMR0_LDRA (0x3 << 16) /**< \brief (TC_CMR0) RA Loading Selection */
@@ -5001,6 +5016,8 @@ typedef struct {
#define TC_IER0_LOVRS (0x1 << 1) /**< \brief (TC_IER0) Load Overrun */
#define TC_IER0_CPAS (0x1 << 2) /**< \brief (TC_IER0) RA Compare */
#define TC_IER0_CPBS (0x1 << 3) /**< \brief (TC_IER0) RB Compare */
#define TC_IER_CPCS TC_IER0_CPCS
#define TC_IER0_CPCS (0x1 << 4) /**< \brief (TC_IER0) RC Compare */
#define TC_IER0_LDRAS (0x1 << 5) /**< \brief (TC_IER0) RA Loading */
#define TC_IER0_LDRBS (0x1 << 6) /**< \brief (TC_IER0) RB Loading */
@@ -5548,8 +5565,10 @@ typedef struct {
#define UDP_GLB_STAT_RSMINPR (0x1 << 3) /**< \brief (UDP_GLB_STAT) */
#define UDP_GLB_STAT_RMWUPE (0x1 << 4) /**< \brief (UDP_GLB_STAT) Remote Wake Up Enable */
/* -------- UDP_FADDR : (UDP Offset: 0x008) Function Address Register -------- */
#define UDP_FADDR_FADD (0x7f << 0) /**< \brief (UDP_FADDR) Function Address Value */
#define UDP_FADDR_FEN (0x1 << 8) /**< \brief (UDP_FADDR) Function Enable */
#define UDP_FADDR_FADD_Pos 0
#define UDP_FADDR_FADD_Msk (0x7fu << UDP_FADDR_FADD_Pos) /**< \brief (UDP_FADDR) Function Address Value */
#define UDP_FADDR_FADD(value) ((UDP_FADDR_FADD_Msk & ((value) << UDP_FADDR_FADD_Pos)))
#define UDP_FADDR_FEN (0x1u << 8) /**< \brief (UDP_FADDR) Function Enable */
/* -------- UDP_IER : (UDP Offset: 0x010) Interrupt Enable Register -------- */
#define UDP_IER_EP0INT (0x1 << 0) /**< \brief (UDP_IER) Enable Endpoint 0 Interrupt */
#define UDP_IER_EP1INT (0x1 << 1) /**< \brief (UDP_IER) Enable Endpoint 1 Interrupt */
@@ -5633,17 +5652,20 @@ typedef struct {
#define UDP_CSR_FORCESTALL (0x1 << 5) /**< \brief (UDP_CSR[8]) Force Stall (used by Control, Bulk and Isochronous Endpoints) */
#define UDP_CSR_RX_DATA_BK1 (0x1 << 6) /**< \brief (UDP_CSR[8]) Receive Data Bank 1 (only used by endpoints with ping-pong attributes) */
#define UDP_CSR_DIR (0x1 << 7) /**< \brief (UDP_CSR[8]) Transfer Direction (only available for control endpoints) */
#define UDP_CSR_EPTYPE (0x7 << 8) /**< \brief (UDP_CSR[8]) Endpoint Type */
#define UDP_CSR_EPTYPE_CTRL (0x0 << 8) /**< \brief (UDP_CSR[8]) Control */
#define UDP_CSR_EPTYPE_ISO_OUT (0x1 << 8) /**< \brief (UDP_CSR[8]) Isochronous OUT */
#define UDP_CSR_EPTYPE_BULK_OUT (0x2 << 8) /**< \brief (UDP_CSR[8]) Bulk OUT */
#define UDP_CSR_EPTYPE_INT_OUT (0x3 << 8) /**< \brief (UDP_CSR[8]) Interrupt OUT */
#define UDP_CSR_EPTYPE_ISO_IN (0x5 << 8) /**< \brief (UDP_CSR[8]) Isochronous IN */
#define UDP_CSR_EPTYPE_BULK_IN (0x6 << 8) /**< \brief (UDP_CSR[8]) Bulk IN */
#define UDP_CSR_EPTYPE_INT_IN (0x7 << 8) /**< \brief (UDP_CSR[8]) Interrupt IN */
#define UDP_CSR_EPTYPE_Pos 8
#define UDP_CSR_EPTYPE_Msk (0x7u << UDP_CSR_EPTYPE_Pos) /**< \brief (UDP_CSR[8]) Endpoint Type */
#define UDP_CSR_EPTYPE_CTRL (0x0u << 8) /**< \brief (UDP_CSR[8]) Control */
#define UDP_CSR_EPTYPE_ISO_OUT (0x1u << 8) /**< \brief (UDP_CSR[8]) Isochronous OUT */
#define UDP_CSR_EPTYPE_BULK_OUT (0x2u << 8) /**< \brief (UDP_CSR[8]) Bulk OUT */
#define UDP_CSR_EPTYPE_INT_OUT (0x3u << 8) /**< \brief (UDP_CSR[8]) Interrupt OUT */
#define UDP_CSR_EPTYPE_ISO_IN (0x5u << 8) /**< \brief (UDP_CSR[8]) Isochronous IN */
#define UDP_CSR_EPTYPE_BULK_IN (0x6u << 8) /**< \brief (UDP_CSR[8]) Bulk IN */
#define UDP_CSR_EPTYPE_INT_IN (0x7u << 8) /**< \brief (UDP_CSR[8]) Interrupt IN */
#define UDP_CSR_DTGLE (0x1 << 11) /**< \brief (UDP_CSR[8]) Data Toggle */
#define UDP_CSR_EPEDS (0x1 << 15) /**< \brief (UDP_CSR[8]) Endpoint Enable Disable */
#define UDP_CSR_RXBYTECNT (0x7ff << 16) /**< \brief (UDP_CSR[8]) Number of Bytes Available in the FIFO */
#define UDP_CSR_RXBYTECNT_Pos 16
#define UDP_CSR_RXBYTECNT_Msk (0x7ffu << UDP_CSR_RXBYTECNT_Pos) /**< \brief (UDP_CSR[8]) Number of Bytes Available in the FIFO */
#define UDP_CSR_RXBYTECNT(value) ((UDP_CSR_RXBYTECNT_Msk & ((value) << UDP_CSR_RXBYTECNT_Pos)))
/* -------- UDP_FDR[8] : (UDP Offset: 0x4C) Endpoint FIFO Data Register (ept_num = 0) -------- */
#define UDP_FDR_FIFO_DATA (0xff << 0) /**< \brief (UDP_FDR[8]) FIFO Data Value */
/* -------- UDP_TXVC : (UDP Offset: 0x074) Transceiver Control Register -------- */
+8 -15
View File
@@ -145,8 +145,8 @@ enum menuProcSetupItems {
ITEM_SETUP_MINUTE_BEEP,
ITEM_SETUP_COUNTDOWN_BEEP,
ITEM_SETUP_FLASH_BEEP,
ITEM_SETUP_LIGHT_SWITCH,
ITEM_SETUP_LIGHT_OFF_AFTER,
ITEM_SETUP_BACKLIGHT_MODE,
ITEM_SETUP_BACKLIGHT_DELAY,
#if defined(SPLASH)
ITEM_SETUP_DISABLE_SPLASH,
#endif
@@ -330,21 +330,14 @@ void menuProcSetup(uint8_t event)
g_eeGeneral.flashBeep = onoffMenuItem( g_eeGeneral.flashBeep, y, STR_FLASHONBEEP, attr, event ) ;
break;
case ITEM_SETUP_LIGHT_SWITCH:
lcd_putsLeft( y, STR_LIGHTSWITCH);
putsSwitches(GENERAL_PARAM_OFS,y,g_eeGeneral.lightSw,attr ? INVERS : 0);
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.lightSw, SWITCH_OFF, SWITCH_ON);
case ITEM_SETUP_BACKLIGHT_MODE:
g_eeGeneral.backlightMode = selectMenuItem(y, STR_BLMODE, PSTR("\004OFF KeysStksBothON\0"), g_eeGeneral.backlightMode, e_backlight_mode_off, e_backlight_mode_on, attr, event);
break;
case ITEM_SETUP_LIGHT_OFF_AFTER:
lcd_putsLeft( y, STR_LIGHTOFFAFTER);
if(g_eeGeneral.lightAutoOff) {
lcd_outdezAtt(GENERAL_PARAM_OFS, y, g_eeGeneral.lightAutoOff*5, attr|LEFT);
lcd_putc(lcdLastPos, y, 's');
}
else {
lcd_putsiAtt(GENERAL_PARAM_OFS, y, STR_OFFON, 0, attr);
}
case ITEM_SETUP_BACKLIGHT_DELAY:
lcd_putsLeft( y, STR_BLDELAY);
lcd_outdezAtt(GENERAL_PARAM_OFS, y, g_eeGeneral.lightAutoOff*5, attr|LEFT);
lcd_putc(lcdLastPos, y, 's');
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.lightAutoOff, 0, 600/5);
break;
+1
View File
@@ -70,6 +70,7 @@ inline MenuFuncP lastPopMenu()
void doMainScreenGrphics();
void menuMainView(uint8_t event);
void menuProcDiagAna(uint8_t event);
#ifdef FRSKY
void menuProcFrsky(uint8_t event);
#endif
+251 -79
View File
@@ -827,7 +827,7 @@ static uint8_t s_currIdx;
void menuProcPhaseOne(uint8_t event)
{
PhaseData *phase = phaseaddress(s_currIdx);
putsFlightPhase(13*FW, 0, s_currIdx+1, 0);
putsFlightPhase(13*FW, 0, s_currIdx+1, (getFlightPhase()==s_currIdx ? BOLD : 0));
#define MAX_TRIM_LINE (3+NUM_ROTARY_ENCODERS)
@@ -1308,86 +1308,80 @@ void memswap(void *a, void *b, uint8_t size)
resumeMixerCalculations();
}
bool swapExpo(uint8_t &idx, uint8_t up)
{
ExpoData *x = expoaddress(idx);
int8_t tgt_idx = (up ? idx-1 : idx+1);
if (tgt_idx < 0) {
if (x->chn == 0)
return false;
x->chn--;
return true;
}
if (tgt_idx == MAX_EXPOS) {
if (x->chn == NUM_STICKS-1)
return false;
x->chn++;
return true;
}
ExpoData *y = expoaddress(tgt_idx);
if(x->chn != y->chn || !y->mode) {
if (up) {
if (x->chn>0) x->chn--;
else return false;
}
else {
if (x->chn<NUM_STICKS-1) x->chn++;
else return false;
}
return true;
}
memswap(x, y, sizeof(ExpoData));
idx = tgt_idx;
return true;
}
bool swapMix(uint8_t &idx, uint8_t up)
{
MixData *x = mixaddress(idx);
int8_t tgt_idx = (up ? idx-1 : idx+1);
if (tgt_idx < 0) {
if (x->destCh == 0)
return false;
x->destCh--;
return true;
}
if (tgt_idx == MAX_MIXERS) {
if (x->destCh == NUM_CHNOUT-1)
return false;
x->destCh++;
return true;
}
MixData *y = mixaddress(tgt_idx);
if(x->destCh != y->destCh) {
if (up) {
if (x->destCh>0) x->destCh--;
else return false;
}
else {
if (x->destCh<NUM_CHNOUT-1) x->destCh++;
else return false;
}
return true;
}
memswap(x, y, sizeof(MixData));
idx = tgt_idx;
return true;
}
bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up)
{
bool result = (expo ? swapExpo(idx, up) : swapMix(idx, up));
if (result)
STORE_MODELVARS;
return result;
void *x, *y;
uint8_t size;
int8_t tgt_idx = (up ? idx-1 : idx+1);
if (expo) {
x = (ExpoData *)expoaddress(idx);
if (tgt_idx < 0) {
if (((ExpoData *)x)->chn == 0)
return false;
((ExpoData *)x)->chn--;
return true;
}
if (tgt_idx == MAX_EXPOS) {
if (((ExpoData *)x)->chn == NUM_STICKS-1)
return false;
((ExpoData *)x)->chn++;
return true;
}
y = (ExpoData *)expoaddress(tgt_idx);
if(((ExpoData *)x)->chn != ((ExpoData *)y)->chn || !((ExpoData *)y)->mode) {
if (up) {
if (((ExpoData *)x)->chn>0) ((ExpoData *)x)->chn--;
else return false;
}
else {
if (((ExpoData *)x)->chn<NUM_STICKS-1) ((ExpoData *)x)->chn++;
else return false;
}
return true;
}
size = sizeof(ExpoData);
}
else {
x = (MixData *)mixaddress(idx);
if (tgt_idx < 0) {
if (((MixData *)x)->destCh == 0)
return false;
((MixData *)x)->destCh--;
return true;
}
if (tgt_idx == MAX_MIXERS) {
if (((MixData *)x)->destCh == NUM_CHNOUT-1)
return false;
((MixData *)x)->destCh++;
return true;
}
y = (MixData *)mixaddress(tgt_idx);
if(((MixData *)x)->destCh != ((MixData *)y)->destCh) {
if (up) {
if (((MixData *)x)->destCh>0) ((MixData *)x)->destCh--;
else return false;
}
else {
if (((MixData *)x)->destCh<NUM_CHNOUT-1) ((MixData *)x)->destCh++;
else return false;
}
return true;
}
size = sizeof(MixData);
}
memswap(x, y, size);
idx = tgt_idx;
return true;
}
enum ExposFields {
@@ -1703,6 +1697,7 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
else
s_copyTgtOfs--;
} while (s_copyTgtOfs != 0);
STORE_MODELVARS;
}
sub = m_posVert = s_copySrcRow;
}
@@ -1778,6 +1773,7 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
else {
// only swap the mix with its neighbor
if (!swapExpoMix(expo, s_currIdx, key==KEY_UP)) break;
STORE_MODELVARS;
}
s_copyTgtOfs = next_ofs;
@@ -2108,6 +2104,7 @@ void menuProcCurvesAll(uint8_t event)
case EVT_KEY_BREAK(BTN_REb):
if (!navigationRotaryEncoder(event))
break;
// no break
#endif
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_MENU):
@@ -2146,6 +2143,180 @@ void menuProcCurvesAll(uint8_t event)
if(!m) s_pgOfs++;
}
#if defined(PCBARM)
enum CustomSwitchFields {
CSW_FIELD_FUNCTION,
CSW_FIELD_V1,
CSW_FIELD_V2,
CSW_FIELD_DURATION,
CSW_FIELD_DELAY,
CSW_FIELD_COUNT
};
#define CSW_2ND_COLUMN (9*FW)
void menuProcCustomSwitchOne(uint8_t event)
{
TITLEP("CUSTOM SWITCH");
CustomSwData &cs = g_model.customSw[s_currIdx];
uint8_t sw = DSW_SW1+s_currIdx;
putsSwitches(14*FW, 0, sw, (getSwitch(sw, 0) ? BOLD : 0));
SIMPLE_SUBMENU_NOTITLE(CSW_FIELD_COUNT);
int8_t sub = m_posVert;
for (uint8_t k=0; k<7; k++) {
uint8_t y = (k+2) * FH;
uint8_t i = k + s_pgOfs;
uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
uint8_t cstate = CS_STATE(cs.func);
switch(i) {
case CSW_FIELD_FUNCTION:
lcd_putsLeft(y, "Func");
lcd_putsiAtt(CSW_2ND_COLUMN, y, STR_VCSWFUNC, cs.func, attr);
if (attr) {
CHECK_INCDEC_MODELVAR(event, cs.func, 0, CS_MAXF);
if (cstate != CS_STATE(cs.func)) {
cs.v1 = 0;
cs.v2 = 0;
}
}
break;
case CSW_FIELD_V1:
{
lcd_putsLeft(y, "V1");
int8_t v1_min=0, v1_max=NUM_XCHNCSW;
if (cstate == CS_VBOOL) {
putsSwitches(CSW_2ND_COLUMN, y, cs.v1, attr);
v1_min = SWITCH_OFF; v1_max = SWITCH_ON;
}
else {
putsChnRaw(CSW_2ND_COLUMN, y, cs.v1, attr);
}
if (attr) {
CHECK_INCDEC_MODELVAR(event, cs.v1, v1_min, v1_max);
}
break;
}
case CSW_FIELD_V2:
{
lcd_putsLeft(y, "V2");
int8_t v2_min=0, v2_max=NUM_XCHNCSW;
if (cstate == CS_VBOOL) {
putsSwitches(CSW_2ND_COLUMN, y, cs.v2, attr);
v2_min = SWITCH_OFF; v2_max = SWITCH_ON;
}
else if (cstate == CS_VOFS) {
#if defined(FRSKY)
if (cs.v1 > NUM_XCHNCSW-NUM_TELEMETRY) {
putsTelemetryChannel(6*FW, y, cs.v1 - (NUM_XCHNCSW-NUM_TELEMETRY+1), convertTelemValue(cs.v1 - (NUM_XCHNCSW-NUM_TELEMETRY), 128+cs.v2), attr|LEFT);
v2_min = -128; v2_max = maxTelemValue(cs.v1 - (NUM_XCHNCSW-NUM_TELEMETRY)) - 128;
if (cs.v2 > v2_max) {
cs.v2 = v2_max;
eeDirty(EE_MODEL);
}
}
else
#endif
{
v2_min = -125; v2_max = 125;
lcd_outdezAtt(CSW_2ND_COLUMN, y, CSW_2ND_COLUMN, attr|LEFT);
}
}
else {
putsChnRaw(CSW_2ND_COLUMN, y, cs.v2, attr);
}
if (attr) {
CHECK_INCDEC_MODELVAR(event, cs.v2, v2_min, v2_max);
}
break;
}
case CSW_FIELD_DURATION:
lcd_putsLeft(y, "Duration");
lcd_outdezAtt(CSW_2ND_COLUMN, y, 5*cs.duration, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR(event, cs.duration, 0, MAX_CSW_DURATION);
break;
case CSW_FIELD_DELAY:
lcd_putsLeft(y, "Delay");
lcd_outdezAtt(CSW_2ND_COLUMN, y, 5*cs.delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR(event, cs.delay, 0, MAX_CSW_DELAY);
break;
}
}
}
void menuProcCustomSwitches(uint8_t event)
{
MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, 2/*repeated...*/});
uint8_t y = 0;
uint8_t k = 0;
int8_t sub = m_posVert - 1;
switch (event) {
#if defined(ROTARY_ENCODERS)
case EVT_KEY_BREAK(BTN_REa):
case EVT_KEY_BREAK(BTN_REb):
if (!navigationRotaryEncoder(event))
break;
// no break
#endif
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_MENU):
if (sub >= 0) {
s_currIdx = sub;
pushMenu(menuProcCustomSwitchOne);
}
break;
}
for (uint8_t i=0; i<7; i++) {
y = (i+1)*FH;
k = i+s_pgOfs;
CustomSwData &cs = g_model.customSw[k];
// CSW name
uint8_t sw = DSW_SW1+k;
putsSwitches(0, y, sw, (sub==k ? INVERS : 0) | (getSwitch(sw, 0) ? BOLD : 0));
if (cs.func > 0) {
// CSW func
lcd_putsiAtt(4*FW - 2, y, STR_VCSWFUNC, cs.func, 0);
// CSW params
uint8_t cstate = CS_STATE(cs.func);
if (cstate == CS_VOFS)
{
putsChnRaw(12*FW-6, y, cs.v1, 0);
#if defined(FRSKY)
if (cs.v1 > NUM_XCHNCSW-NUM_TELEMETRY) {
putsTelemetryChannel(19*FW, y, cs.v1 - (NUM_XCHNCSW-NUM_TELEMETRY+1), convertTelemValue(cs.v1 - (NUM_XCHNCSW-NUM_TELEMETRY), 128+cs.v2), 0);
int8_t v2_max = maxTelemValue(cs.v1 - (NUM_XCHNCSW-NUM_TELEMETRY)) - 128;
if (cs.v2 > v2_max) {
cs.v2 = v2_max;
eeDirty(EE_MODEL);
}
}
else
#endif
{
lcd_outdezAtt(19*FW, y, cs.v2, 0);
}
}
else if (cstate == CS_VBOOL)
{
putsSwitches(12*FW-6, y, cs.v1, 0);
putsSwitches(17*FW, y, cs.v2, 0);
}
else // cstate == CS_COMP
{
putsChnRaw(12*FW-6, y, cs.v1, 0);
putsChnRaw(17*FW, y, cs.v2, 0);
}
}
}
}
#else
void menuProcCustomSwitches(uint8_t event)
{
MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, 2/*repeated...*/});
@@ -2223,6 +2394,7 @@ void menuProcCustomSwitches(uint8_t event)
}
}
}
#endif
void menuProcFunctionSwitches(uint8_t event)
{
+12 -1
View File
@@ -106,6 +106,14 @@ enum AdcInput {
e_adc_filtered
};
enum BacklightMode {
e_backlight_mode_off = 0,
e_backlight_mode_keys,
e_backlight_mode_sticks,
e_backlight_mode_both,
e_backlight_mode_on
};
#define ALTERNATE_VIEW 0x10
PACK(typedef struct t_EEGeneral {
uint8_t myVers;
@@ -117,7 +125,7 @@ PACK(typedef struct t_EEGeneral {
uint8_t contrast;
uint8_t vBatWarn;
int8_t vBatCalib;
int8_t lightSw;
int8_t backlightMode;
TrainerData trainer;
uint8_t view; //index of subview in main scrren
uint8_t spare0:3;
@@ -292,6 +300,8 @@ PACK(typedef struct t_MixData {
#endif
#if defined(PCBARM)
#define MAX_CSW_DURATION 120 /*60s*/
#define MAX_CSW_DELAY 120 /*60s*/
PACK(typedef struct t_CustomSwData { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
@@ -328,6 +338,7 @@ enum Functions {
#if defined(PCBARM)
FUNC_VOLUME,
#endif
FUNC_BACKLIGHT,
#if defined(DEBUG)
FUNC_TEST, // should remain the last before MAX as not added in companion9x
#endif
+459 -27
View File
@@ -165,7 +165,6 @@ LimitData *limitaddress(uint8_t idx)
void generalDefault()
{
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
g_eeGeneral.lightSw = SWITCH_ON;
g_eeGeneral.myVers = EEPROM_VER;
g_eeGeneral.contrast = 25;
g_eeGeneral.vBatWarn = 90;
@@ -527,6 +526,12 @@ volatile bool s_default_switch_value;
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used;
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value;
/* recursive function. stack as of today (16/03/2012) grows by 8bytes at each call, which is ok! */
#if defined(PCBARM)
uint32_t delays[NUM_CSW];
uint32_t durations[NUM_CSW];
#endif
bool __getSwitch(int8_t swtch)
{
bool result;
@@ -574,10 +579,11 @@ bool __getSwitch(int8_t swtch)
break;
}
}
#if !defined(PCBARM)
if (result)
s_last_switch_value |= ((GETSWITCH_RECURSIVE_TYPE)1<<cs_idx);
else
s_last_switch_value &= ~((GETSWITCH_RECURSIVE_TYPE)1<<cs_idx);
#endif
}
else {
int16_t x = getValue(cs.v1-1);
@@ -641,6 +647,33 @@ bool __getSwitch(int8_t swtch)
}
}
}
#if defined(PCBARM)
if (cs.delay) {
if (result) {
if (delays[cs_idx] > get_tmr10ms())
result = false;
}
else {
delays[cs_idx] = get_tmr10ms() + (cs.delay*50);
}
}
if (cs.duration) {
if (result) {
if (durations[cs_idx] < get_tmr10ms()) {
result = false;
if (cs.delay) delays[cs_idx] = get_tmr10ms() + (cs.delay*50);
}
}
else {
durations[cs_idx] = get_tmr10ms() + (cs.duration*50);
}
}
if (result)
s_last_switch_value |= ((GETSWITCH_RECURSIVE_TYPE)1<<cs_idx);
#endif
}
return swtch > 0 ? result : !result;
@@ -650,9 +683,11 @@ bool getSwitch(int8_t swtch, bool nc)
{
#if defined(PCBARM)
s_last_switch_used = 0;
s_last_switch_value = 0;
s_default_switch_value = nc;
#else
s_last_switch_used = ((GETSWITCH_RECURSIVE_TYPE)nc<<15);
s_last_switch_value = 0;
#endif
return __getSwitch(swtch);
}
@@ -861,7 +896,7 @@ uint16_t stickMoveValue()
void checkBacklight()
{
if (getSwitch(g_eeGeneral.lightSw, 0) || g_eeGeneral.lightAutoOff)
if (g_eeGeneral.backlightMode == e_backlight_mode_on || g_LightOffCounter || isFunctionActive(FUNC_BACKLIGHT))
BACKLIGHT_ON;
else
BACKLIGHT_OFF;
@@ -1427,7 +1462,8 @@ uint16_t isqrt32(uint32_t n)
int16_t anas [NUM_STICKS] = {0};
int16_t trims[NUM_STICKS] = {0};
int32_t chans[NUM_CHNOUT] = {0};
uint32_t inacCounter = 0;
uint8_t inacPrescale;
uint16_t inacCounter = 0;
uint16_t inacSum = 0;
BeepANACenter bpanaCenter = 0;
@@ -2402,17 +2438,20 @@ void perMain()
if (!tick10ms) return; //make sure the rest happen only every 10ms.
if (g_eeGeneral.inactivityTimer && g_vbat100mV>50) {
inacCounter++;
uint16_t tsum = 0;
for(uint8_t i=0;i<4;i++) tsum += anaIn(i)/64; // reduce sensitivity
if(tsum!=inacSum){
inacSum = tsum;
inacCounter=0;
uint16_t tsum = stickMoveValue();
if (tsum != inacSum) {
inacSum = tsum;
inacCounter = 0;
if (g_eeGeneral.backlightMode & e_backlight_mode_sticks)
backlightOn();
}
else if (g_eeGeneral.inactivityTimer && g_vbat100mV>50) {
if (++inacPrescale > 15 ) {
inacCounter++;
inacPrescale = 0;
if (inacCounter > ((uint16_t)g_eeGeneral.inactivityTimer*100*60/16))
if ((inacCounter&0x3F)==10) AUDIO_INACTIVITY();
}
if (inacCounter>((uint32_t)g_eeGeneral.inactivityTimer*100*60))
if((inacCounter&0x3F)==10) AUDIO_INACTIVITY();
}
#if defined(PCBV4) && defined(SDCARD)
@@ -2453,14 +2492,10 @@ void perMain()
uint8_t evt = getEvent(false);
#endif
// TODO port lightOnStickMove from er9x + flash saving, call checkBacklight()
if(g_LightOffCounter) g_LightOffCounter--;
if(evt) backlightOn(); // on keypress turn the light on
if (g_LightOffCounter) g_LightOffCounter--;
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on
if (getSwitch(g_eeGeneral.lightSw,0) || g_LightOffCounter)
BACKLIGHT_ON;
else
BACKLIGHT_OFF;
checkBacklight();
#if defined(PCBARM) && defined(FRSKY)
check_frsky();
@@ -2517,15 +2552,20 @@ void perMain()
uint16_t instant_vbat = anaIn(7);
instant_vbat = (instant_vbat*16 + instant_vbat*g_eeGeneral.vBatCalib/8) / BandGap;
#endif
if (g_vbat100mV == 0 || g_menuStack[g_menuStackPtr] != menuMainView) g_vbat100mV = instant_vbat;
static uint8_t s_batCheck;
static uint16_t s_batSum;
s_batCheck += 32;
s_batSum += instant_vbat;
if (g_vbat100mV == 0 || g_menuStack[g_menuStackPtr] == menuProcDiagAna) {
g_vbat100mV = instant_vbat;
s_batSum = 0;
}
if (s_batCheck==0) {
g_vbat100mV = s_batSum / 8;
if (s_batSum) g_vbat100mV = s_batSum / 8;
s_batSum = 0;
if (g_vbat100mV<g_eeGeneral.vBatWarn && g_vbat100mV>50) {
AUDIO_TX_BATTERY_LOW();
@@ -2694,7 +2734,7 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS
uint16_t val = (capture - lastCapt) / 2;
// G: We prcoess g_ppmIns immediately here, to make servo movement as smooth as possible
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
// while under trainee control
if (val>4000 && val < 16000) // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
ppmInState = 1; // triggered
@@ -3011,21 +3051,392 @@ void mixerTask(void * pdata)
}
}
#ifdef MASSSTORAGE
extern "C" {
#define TRACE_DEBUG(...)
#define TRACE_DEBUG_WP(...)
#define TRACE_INFO(...)
#define TRACE_WARNING(...)
#define TRACE_WARNING_WP(...)
#define TRACE_INFO_WP(...)
#define TRACE_ERROR(...)
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/wdt.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/include/pio.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/include/pio_capture.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/pio_capture.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/pmc.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/pio_it.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/tc.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/memories/include/Media.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/include/MSDLun.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/include/MSDescriptors.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/include/MSD.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/include/USBDDriver.h"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/include/MSDDriver.h"
#include "../../Atmel/sam3s/sam3s-ek/examples_usb/usb_massstorage/device_descriptor.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/pio.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/massstorage/MSDLun.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/massstorage/MSDDriver.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/core/USBDDriver.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/core/USBD.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/libchip_sam3s/source/USBD_HAL.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/common/core/USBDescriptors.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/massstorage/MSDFunction.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/common/core/USBRequests.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/core/USBDDriverCallbacks.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/core/USBDCallbacks.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/massstorage/MSDDStateMachine.c"
#include "../../Atmel/sam3s/sam3s-ek/libraries/usb/device/massstorage/SBCMethods.c"
/*----------------------------------------------------------------------------
* Local definitions
*----------------------------------------------------------------------------*/
/** Maximum number of LUNs which can be defined. */
#define MAX_LUNS 2
/** Media index for different disks */
#define DRV_RAMDISK 0 /** RAM disk */
#define DRV_IFLASH 0 /** Internal flash */
#define DRV_SDMMC 0 /** SD card */
#define DRV_NAND 1 /** Nand flash */
/** Delay for pushbutton debouncing (ms) */
#define DEBOUNCE_TIME 10
/** PIT period value (seconds) */
#define PIT_PERIOD 1000
/** Delay for display view update (*250ms) */
#define UPDATE_DELAY 4
/** Delay for waiting DBGU input (*250ms) */
#define INPUT_DELAY 15
/** Size of one block in bytes. */
#define BLOCK_SIZE 512
/** Size of the MSD IO buffer in bytes (6K, more the better). */
#define MSD_BUFFER_SIZE (12*BLOCK_SIZE)
/* Ramdisk size: 20K (WinXP can not format the disk if lower than 20K) */
/* #define RAMDISK_SIZE (20*1024) */
/** Size of the reserved Nand Flash (4M) */
#define NF_RESERVE_SIZE (4*1024*1024)
/** Size of the managed Nand Flash (128M) */
#define NF_MANAGED_SIZE (128*1024*1024)
/*----------------------------------------------------------------------------
* Global variables
*----------------------------------------------------------------------------*/
/** MSD Driver Descriptors List */
//extern const USBDDriverDescriptors msdDriverDescriptors;
/** Available medias. */
Media medias[MAX_LUNS];
/*----------------------------------------------------------------------------
* Local variables
*----------------------------------------------------------------------------*/
/** Device LUNs. */
MSDLun luns[MAX_LUNS];
/** LUN read/write buffer. */
uint8_t msdBuffer[MSD_BUFFER_SIZE];
/** Total data read/write by MSD */
unsigned int msdReadTotal = 0;
unsigned int msdWriteTotal = 0;
unsigned short msdFullCnt = 0;
unsigned short msdNullCnt = 0;
/** Update delay counter, tick is 250ms */
uint32_t updateDelay = UPDATE_DELAY;
/** Flag to update Display View */
uint8_t updateView = 0;
/** Pins used to access to nandflash. */
static const Pin pPinsNf[] = {PINS_NANDFLASH};
/** Nandflash device structure. */
// static struct TranslatedNandFlash translatedNf;
/** Address for transferring command bytes to the nandflash. */
static unsigned int cmdBytesAddr = BOARD_NF_COMMAND_ADDR;
/** Address for transferring address bytes to the nandflash. */
static unsigned int addrBytesAddr = BOARD_NF_ADDRESS_ADDR;
/** Address for transferring data bytes to the nandflash. */
static unsigned int dataBytesAddr = BOARD_NF_DATA_ADDR;
/** Nandflash chip enable pin. */
static const Pin nfCePin = BOARD_NF_CE_PIN;
/** Nandflash ready/busy pin. */
static const Pin nfRbPin = BOARD_NF_RB_PIN;
/*----------------------------------------------------------------------------
* VBus monitoring (optional)
*----------------------------------------------------------------------------*/
/** VBus pin instance. */
static const Pin pinVbus = PIN_USB_VBUS;
static void _ConfigureUsbClock(void)
{
/* Enable PLLB for USB */
PMC->CKGR_PLLBR = CKGR_PLLBR_DIVB(1)
| CKGR_PLLBR_MULB(7)
| CKGR_PLLBR_PLLBCOUNT_Msk;
while((PMC->PMC_SR & PMC_SR_LOCKB) == 0);
/* USB Clock uses PLLB */
PMC->PMC_USB = PMC_USB_USBDIV(1) /* /2 */
| PMC_USB_USBS; /* PLLB */
}
static void _ConfigureTc0(void)
{
uint32_t div;
uint32_t tcclks;
/* Enable peripheral clock */
PMC->PMC_PCER0 = 1 << ID_TC0;
/* Configure TC for a 4Hz frequency and trigger on RC compare */
TC_FindMckDivisor(4, BOARD_MCK, &div, &tcclks, BOARD_MCK);
TC_Configure(TC0, 0, tcclks | TC_CMR_CPCTRG);
TC0->TC_CHANNEL[0].TC_RC = (BOARD_MCK / div) / 4;
/* Configure and enable interrupt on RC compare */
NVIC_EnableIRQ((IRQn_Type)ID_TC0);
TC0->TC_CHANNEL[0].TC_IER = TC_IER_CPCS;
TC_Start(TC0, 0);
}
/**
* Initialize Nand Flash for LUN
*/
static void NandFlashInitialize(void)
{
unsigned char nfRc;
unsigned short nfBaseBlock = 0;
struct RawNandFlash *pRaw = (struct RawNandFlash*)&translatedNf;
struct NandFlashModel *pModel = (struct NandFlashModel*)&translatedNf;
unsigned int nfMamagedSize;
/* Configure SMC for NandFlash (8-bit) */
BOARD_ConfigureNandFlash(SMC);
/* Configure PIO for Nand Flash */
PIO_Configure(pPinsNf, PIO_LISTSIZE(pPinsNf));
/* Nand Flash Initialize (ALL flash mapped) */
nfRc = RawNandFlash_Initialize(pRaw,
0,
cmdBytesAddr,
addrBytesAddr,
dataBytesAddr,
nfCePin,
nfRbPin);
if (nfRc) {
printf("Nand not found\n\r");
return;
}
else {
printf("NF\tNb Blocks %d\n\r",
NandFlashModel_GetDeviceSizeInBlocks(pModel));
printf("\tBlock Size %dK\n\r",
NandFlashModel_GetBlockSizeInBytes(pModel)/1024);
printf("\tPage Size %d\n\r",
NandFlashModel_GetPageDataSize(pModel));
nfBaseBlock =
NF_RESERVE_SIZE / NandFlashModel_GetBlockSizeInBytes(pModel);
}
printf("NF disk will use area from %dM(B%d)\n\r",
NF_RESERVE_SIZE/1024/1024, nfBaseBlock);
printf("!! Erase the NF Disk? (y/n):");
updateDelay = INPUT_DELAY;
updateView = 0;
while(1) {
if(UART_IsRxReady()) {
char key = UART_GetChar();
UART_PutChar(key);
if (key == 'y') {
if (nfRc == 0) {
unsigned int block;
printf(" Erase from %d ... ", nfBaseBlock);
for (block = nfBaseBlock;
block < NandFlashModel_GetDeviceSizeInBlocks(pModel);
block ++) {
RawNandFlash_EraseBlock(pRaw, block);
}
printf("OK");
}
}
printf("\n\r");
break;
}
if (updateView) {
printf("No\n\r");
break;
}
}
nfMamagedSize = ((NandFlashModel_GetDeviceSizeInMBytes(pModel) - NF_RESERVE_SIZE/1024/1024) > NF_MANAGED_SIZE/1024/1024) ? \
NF_MANAGED_SIZE/1024/1024 : (NandFlashModel_GetDeviceSizeInMBytes(pModel) - NF_RESERVE_SIZE/1024/1024);
if (TranslatedNandFlash_Initialize(&translatedNf,
0,
cmdBytesAddr,
addrBytesAddr,
dataBytesAddr,
nfCePin,
nfRbPin,
nfBaseBlock, nfMamagedSize * 1024 * 1024/NandFlashModel_GetBlockSizeInBytes(pModel))) {
// printf("Nand init error\n\r");
return;
}
/* Media initialize */
MEDNandFlash_Initialize(&medias[DRV_NAND], &translatedNf);
/* Initialize LUN */
LUN_Init(&(luns[DRV_NAND]), &(medias[DRV_NAND]),
msdBuffer, MSD_BUFFER_SIZE,
0, 0, 0, 0,
MSDCallbacks_Data);
}
/**
* \brief Initialize all medias and LUNs.
*/
static void MemoryInitialization(void)
{
uint32_t i;
for (i = 0; i < MAX_LUNS; i ++)
LUN_Init(&luns[i], 0, 0, 0, 0, 0, 0, 0, 0);
// TODO: Add LUN Init here
/* Nand Flash Init */
NandFlashInitialize();
}
static void ISR_Vbus(const Pin *pPin)
{
/* Check current level on VBus */
if (PIO_Get(&pinVbus)) {
TRACE_INFO("VBUS conn\n\r");
USBD_Connect();
}
else {
TRACE_INFO("VBUS discon\n\r");
USBD_Disconnect();
}
}
static void VBus_Configure( void )
{
TRACE_INFO("VBus configuration\n\r");
/* Configure PIO */
PIO_Configure(&pinVbus, 1);
PIO_ConfigureIt(&pinVbus, ISR_Vbus);
PIO_EnableIt(&pinVbus);
/* Check current level on VBus */
if (PIO_Get(&pinVbus)) {
lcd_putcAtt( 48, 24, 'O', DBLSIZE ) ;
lcd_putcAtt( 60, 24, 'K', DBLSIZE ) ;
refreshDisplay() ;
/* if VBUS present, force the connect */
TRACE_INFO("conn\n\r");
USBD_Connect();
}
else {
lcd_putcAtt( 48, 24, 'K', DBLSIZE ) ;
lcd_putcAtt( 60, 24, 'O', DBLSIZE ) ;
refreshDisplay() ;
USBD_Disconnect();
}
}
void usbMassStorage()
{
/* Disable watchdog */
WDT_Disable( WDT ) ;
/* If they are present, configure Vbus & Wake-up pins */
PIO_InitializeInterrupts(0);
/* Enable UPLL for USB */
_ConfigureUsbClock();
/* Start TC for timing & status update */
_ConfigureTc0();
/* Initialize memories and LUN */
MemoryInitialization();
/* BOT driver initialization */
MSDDriver_Initialize(&msdDriverDescriptors,
luns, MAX_LUNS);
/* connect if needed */
VBus_Configure();
/* Infinite loop */
updateDelay = UPDATE_DELAY;
updateView = 0;
while (1) {
/* Mass storage state machine */
if (USBD_GetState() < USBD_STATE_CONFIGURED) {
}
else {
MSDDriver_StateMachine();
}
/* Update status view */
if (updateView) {
updateView = 0;
if (msdWriteTotal < 50 * 1000) {
// MED_Flush(&medias[DRV_NAND]);
}
/* printf("Read %5dK, Write %5dK, IO %5dK; Null %4d, Full %4d\r",
msdReadTotal/(UPDATE_DELAY*250),
msdWriteTotal/(UPDATE_DELAY*250),
(msdReadTotal+msdWriteTotal)/(UPDATE_DELAY*250),
msdNullCnt, msdFullCnt);
*/
msdReadTotal = 0;
msdWriteTotal = 0;
msdNullCnt = 0;
msdFullCnt = 0;
}
}
}
}
#endif
void menusTask(void * pdata)
{
register uint32_t shutdown_state = 0;
#ifdef MASSSTORAGE
uint8_t mass_storage = false;
#endif
open9xInit();
while (1) {
shutdown_state = check_soft_power();
#if 0
#ifdef MASSSTORAGE
if (shutdown_state == e_power_off) {
break;
}
@@ -3042,7 +3453,8 @@ void menusTask(void * pdata)
if (result == STR_BOOTLOADER)
break;
else {
usbMassStorage();
mass_storage = true;
break;
s_menu_count = 0;
}
}
@@ -3081,7 +3493,27 @@ void menusTask(void * pdata)
lcd_putcAtt( 60, 24, 'S', DBLSIZE ) ;
lcd_putcAtt( 72, 24, 'B', DBLSIZE ) ;
refreshDisplay() ;
usb_mode();
#ifdef MASSSTORAGE
if (mass_storage) {
stop_rotary_encoder();
endPdcUsartReceive() ; // Terminate any serial reception
end_ppm_capture() ;
end_spi() ;
end_sound() ;
TC0->TC_CHANNEL[2].TC_IDR = TC_IDR0_CPCS ;
NVIC_DisableIRQ(TC2_IRQn) ;
// PWM->PWM_IDR1 = PWM_IDR1_CHID0 ;
disable_main_ppm() ;
// PWM->PWM_IDR1 = PWM_IDR1_CHID3 ;
// NVIC_DisableIRQ(PWM_IRQn) ;
disable_ssc() ;
usbMassStorage();
}
else
#endif
{
usb_mode();
}
}
lcdSetRefVolt(0); // TODO before soft_power_off?
+1 -1
View File
@@ -468,7 +468,7 @@ extern uint8_t heartbeat;
#define MAX_ALERT_TIME 60
extern uint32_t inacCounter;
extern uint16_t inacCounter;
#if defined(PXX)
extern uint8_t pxxFlag;
+2 -2
View File
@@ -176,8 +176,8 @@ const pm_char STR_THROTTLEREVERSE[] PROGMEM = TR_THROTTLEREVERSE;
const pm_char STR_MINUTEBEEP[] PROGMEM = TR_MINUTEBEEP;
const pm_char STR_BEEPCOUNTDOWN[] PROGMEM = TR_BEEPCOUNTDOWN;
const pm_char STR_FLASHONBEEP[] PROGMEM = TR_FLASHONBEEP;
const pm_char STR_LIGHTSWITCH[] PROGMEM = TR_LIGHTSWITCH;
const pm_char STR_LIGHTOFFAFTER[] PROGMEM = TR_LIGHTOFFAFTER;
const pm_char STR_BLMODE[] PROGMEM = TR_BLMODE;
const pm_char STR_BLDELAY[] PROGMEM = TR_BLDELAY;
const pm_char STR_SPLASHSCREEN[] PROGMEM = TR_SPLASHSCREEN;
const pm_char STR_THROTTLEWARNING[] PROGMEM = TR_THROTTLEWARNING;
const pm_char STR_SWITCHWARNING[] PROGMEM = TR_SWITCHWARNING;
+2 -2
View File
@@ -274,8 +274,8 @@ extern const pm_char STR_THROTTLEREVERSE[];
extern const pm_char STR_MINUTEBEEP[];
extern const pm_char STR_BEEPCOUNTDOWN[];
extern const pm_char STR_FLASHONBEEP[];
extern const pm_char STR_LIGHTSWITCH[];
extern const pm_char STR_LIGHTOFFAFTER[];
extern const pm_char STR_BLMODE[];
extern const pm_char STR_BLDELAY[];
extern const pm_char STR_SPLASHSCREEN[];
extern const pm_char STR_THROTTLEWARNING[];
extern const pm_char STR_SWITCHWARNING[];
+3 -3
View File
@@ -147,7 +147,7 @@
#else
#define TR_TEST
#endif
#define TR_VFSWFUNC "Bezpe\201\0 ""Tren\202r\0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME TR_TEST
#define TR_VFSWFUNC "Bezpe\201\0 ""Tren\202r\0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME "Backlight\0 " TR_TEST
#define LEN_VFSWRESET "\006"
#define TR_VFSWRESET "Timer1""Timer2""Vse ""Telem."
@@ -323,8 +323,8 @@
#define TR_MINUTEBEEP "P\204pat: Minuta"
#define TR_BEEPCOUNTDOWN " += Odpo\201et"
#define TR_FLASHONBEEP "Podsv\203tl.:Alarm"
#define TR_LIGHTSWITCH " += Sp\204na\201"
#define TR_LIGHTOFFAFTER " += Zhasnout po"
#define TR_BLMODE " += Sp\204na\201"
#define TR_BLDELAY " += Zhasnout po"
#define TR_SPLASHSCREEN "\210vodn\204Logo"
#define TR_THROTTLEWARNING "Upoz:Plyn"
#define TR_SWITCHWARNING "+=Sp\204na\201e"
+3 -3
View File
@@ -147,7 +147,7 @@
#else
#define TR_TEST
#endif
#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME TR_TEST
#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME "Backlight\0 " TR_TEST
#define LEN_VFSWRESET "\006"
#define TR_VFSWRESET "Timer1""Timer2""Alle ""Telem."
@@ -323,8 +323,8 @@
#define TR_MINUTEBEEP "Pieper Minuten"
#define TR_BEEPCOUNTDOWN "Pieper Countdown"
#define TR_FLASHONBEEP "Pieper+Blinken"
#define TR_LIGHTSWITCH "Licht Steuerung"
#define TR_LIGHTOFFAFTER "Licht aus nach"
#define TR_BLMODE "Licht Steuerung"
#define TR_BLDELAY "Licht aus nach"
#define TR_SPLASHSCREEN "Startbild"
#define TR_THROTTLEWARNING "T-Warnung"
#define TR_SWITCHWARNING "S-Warnung"
+3 -3
View File
@@ -148,7 +148,7 @@
#else
#define TR_TEST
#endif
#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME TR_TEST
#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME "Backlight\0 " TR_TEST
#define LEN_VFSWRESET "\006"
#define TR_VFSWRESET "Timer1""Timer2""All ""Telem."
@@ -324,8 +324,8 @@
#define TR_MINUTEBEEP "Minute beep"
#define TR_BEEPCOUNTDOWN "Beep countdown"
#define TR_FLASHONBEEP "Flash on beep"
#define TR_LIGHTSWITCH "Light switch"
#define TR_LIGHTOFFAFTER "Light off after"
#define TR_BLMODE "Backlight mode"
#define TR_BLDELAY "Backlight delay"
#define TR_SPLASHSCREEN "Splash screen"
#define TR_THROTTLEWARNING "T-Warning"
#define TR_SWITCHWARNING "S-Warning"
+3 -3
View File
@@ -142,7 +142,7 @@
#else
#define TR_TEST
#endif
#define TR_VFSWFUNC "S\200cur.\0 ""Ecolage \0 ""Trim instant." TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME TR_TEST
#define TR_VFSWFUNC "S\200cur.\0 ""Ecolage \0 ""Trim instant." TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME "Backlight\0 " TR_TEST
#define LEN_VFSWRESET "\006"
#define TR_VFSWRESET "Timer1""Timer2""Tout ""T\200l\200m."
@@ -321,8 +321,8 @@
#define TR_MINUTEBEEP "Bip t.minutes"
#define TR_BEEPCOUNTDOWN "Bip \202 rebours"
#define TR_FLASHONBEEP "Flash quand bip"
#define TR_LIGHTSWITCH "Inter \200clairage"
#define TR_LIGHTOFFAFTER "Dur\200e \200clairage"
#define TR_BLMODE "Inter \200clairage"
#define TR_BLDELAY "Dur\200e \200clairage"
#define TR_SPLASHSCREEN "Ecran d'accueil"
#define TR_SWITCHWARNING "Alerte Int"
#define TR_MEMORYWARNING "Alerte m\200moire"
+3 -3
View File
@@ -147,7 +147,7 @@
#else
#define TR_TEST
#endif
#define TR_VFSWFUNC "Blocco\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME TR_TEST
#define TR_VFSWFUNC "Blocco\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME "Backlight\0 " TR_TEST
#define LEN_VFSWRESET "\006"
#define TR_VFSWRESET "Timer1""Timer2""Tutto ""Telem."
@@ -323,8 +323,8 @@
#define TR_MINUTEBEEP "Beep minuto"
#define TR_BEEPCOUNTDOWN "Beep cont.rov."
#define TR_FLASHONBEEP "Lamp. al beep"
#define TR_LIGHTSWITCH "Switch ill. "
#define TR_LIGHTOFFAFTER "Spegni ill.dopo"
#define TR_BLMODE "Switch ill. "
#define TR_BLDELAY "Spegni ill.dopo"
#define TR_SPLASHSCREEN "Schermata avvio"
#define TR_THROTTLEWARNING "All. Thr "
#define TR_SWITCHWARNING "Avv. SW. "
+3 -3
View File
@@ -142,7 +142,7 @@
#else
#define TR_TEST
#endif
#define TR_VFSWFUNC "S\201kra\0 ""Trainer\0 ""S\201tt Trim " TR_SOUND TR_HAPTIC "Nollst\201ll " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME TR_TEST
#define TR_VFSWFUNC "S\201kra\0 ""Trainer\0 ""S\201tt Trim " TR_SOUND TR_HAPTIC "Nollst\201ll " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_FSW_VOLUME "Backlight\0 " TR_TEST
#define LEN_VFSWRESET "\006"
#define TR_VFSWRESET "Timer1""Timer2""Allt ""Telem."
@@ -320,8 +320,8 @@
#define TR_MINUTEBEEP "Minutpip"
#define TR_BEEPCOUNTDOWN "Nedr\201kningspip"
#define TR_FLASHONBEEP "Pip vid blink"
#define TR_LIGHTSWITCH "Ljusbrytare"
#define TR_LIGHTOFFAFTER "Ljus av efter"
#define TR_BLMODE "Ljusbrytare"
#define TR_BLDELAY "Ljus av efter"
#define TR_SPLASHSCREEN "Bild vid start"
#define TR_THROTTLEWARNING "Gasvarn."
#define TR_SWITCHWARNING "Bryt.varn."
+1 -1
View File
@@ -145,7 +145,7 @@ void playDuration(int16_t seconds)
seconds = -seconds;
}
uint8_t ore;
uint8_t ore = 0;
uint8_t tmp = seconds / 3600;
seconds %= 3600;
if (tmp > 0) {