Around 30bytes saved

This commit is contained in:
bsongis
2012-09-08 21:29:35 +00:00
parent 3b319d1aa5
commit 7f401d9155
9 changed files with 30 additions and 20 deletions
+4
View File
@@ -57,7 +57,9 @@ uint8_t frskyTxBufferCount = 0;
#endif
uint8_t FrskyRxBufferReady = 0;
int8_t frskyStreaming = -1;
#if defined(WS_HOW_HIGH)
uint8_t frskyUsrStreaming = 0;
#endif
uint8_t link_counter = 0;
FrskyData frskyData;
@@ -685,9 +687,11 @@ NOINLINE void check_frsky()
}
#ifndef SIMU
#if defined(WS_HOW_HIGH)
if (frskyUsrStreaming > 0) {
frskyUsrStreaming--;
}
#endif
if (frskyStreaming > 0) {
frskyStreaming--;
+2 -2
View File
@@ -186,7 +186,9 @@ extern uint8_t barsThresholds[THLD_MAX];
// Global Fr-Sky telemetry data variables
extern int8_t frskyStreaming; // >0 (true) == data is streaming in. 0 = nodata detected for some time
#if defined(WS_HOW_HIGH)
extern uint8_t frskyUsrStreaming;
#endif
#define SEND_MODEL_ALARMS 6
extern uint8_t frskyAlarmsSendState;
@@ -196,8 +198,6 @@ extern FrskyData frskyData;
extern uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE];
extern uint8_t frskyTxBufferCount;
void FRSKY_Init(void);
NOINLINE void check_frsky(void);
+2 -2
View File
@@ -73,7 +73,7 @@ void hapticQueue::heartbeat()
buzzTimeLeft = queueHapticLength[t_queueRidx];
buzzPause = queueHapticPause[t_queueRidx];
if (!queueHapticRepeat[t_queueRidx]--) {
t_queueRidx = (t_queueRidx + 1) % HAPTIC_QUEUE_LENGTH;
t_queueRidx = (t_queueRidx + 1) & (HAPTIC_QUEUE_LENGTH-1);
}
}
}
@@ -94,7 +94,7 @@ void hapticQueue::play(uint8_t tLen, uint8_t tPause, uint8_t tFlags)
tFlags &= 0x0f;
if (tFlags) {
uint8_t next_queueWidx = (t_queueWidx + 1) % HAPTIC_QUEUE_LENGTH;
uint8_t next_queueWidx = (t_queueWidx + 1) & (HAPTIC_QUEUE_LENGTH-1);
if (next_queueWidx != t_queueRidx) {
queueHapticLength[t_queueWidx] = tLen;
queueHapticPause[t_queueWidx] = tPause;
+1 -1
View File
@@ -34,7 +34,7 @@
#ifndef haptic_h
#define haptic_h
#define HAPTIC_QUEUE_LENGTH 3
#define HAPTIC_QUEUE_LENGTH 2
class hapticQueue
{
+5 -3
View File
@@ -72,7 +72,9 @@ void doMainScreenGrphics()
}
}
#if defined(MASSSTORAGE)
extern char usbState;
#endif
void menuMainView(uint8_t event)
{
@@ -210,7 +212,7 @@ void menuMainView(uint8_t event)
if (unexpectedShutdown) {
lcd_putcAtt(20*FW-3, 0*FH, '!', INVERS);
}
#if defined(PCBARM)
#if defined(MASSSTORAGE)
if (usbState >= '0')
lcd_putcAtt(20*FW-3, 0*FH, usbState, INVERS);
#endif
@@ -289,9 +291,9 @@ void menuMainView(uint8_t event)
x0 = (i%4*9+3)*FW/2;
y0 = i/4*FH+40;
#if defined (DECIMALS_DISPLAYED)
lcd_outdezAtt( x0+4*FW , y0, GPERC(val), PREC1);
lcd_outdezAtt( x0+4*FW , y0, calcRESXto1000(val), PREC1);
#else
lcd_outdezAtt( x0+4*FW , y0, GPERC(val)/10, 0); // G: Don't like the decimal part*
lcd_outdezAtt( x0+4*FW , y0, calcRESXto1000(val)/10, 0); // G: Don't like the decimal part*
#endif
break;
+1 -1
View File
@@ -2145,7 +2145,7 @@ void menuProcLimits(uint8_t _event)
lcd_outdezAtt(13*FW, 0, PPM_CENTER+limitaddress(sub)->ppmCenter+g_chans512[sub]/2, 0);
lcd_puts(13*FW, 0, STR_US);
#else
lcd_outdezAtt(13*FW, 0, GPERC(g_chans512[sub]), PREC1);
lcd_outdezAtt(13*FW, 0, calcRESXto1000(g_chans512[sub]), PREC1);
#endif
}
+8 -5
View File
@@ -468,6 +468,13 @@ int16_t calc1000toRESX(int16_t x) // improve calc time by Pat MacKenzie
x-=y;
return x+(y>>2);
}
int16_t calcRESXto1000(int16_t x)
{
// *1000/1024 = x - x/32 + x/128
return (x - x/32 + x/128);
}
#endif
int16_t applyLimits(uint8_t channel, int32_t value)
@@ -3280,8 +3287,6 @@ void mixerTask(void * pdata)
}
}
// #define MASSSTORAGE
#ifdef MASSSTORAGE
extern "C" {
@@ -3314,8 +3319,6 @@ extern "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/usb/device/core/USBDCallbacks.c"
// #include "../Atmel/sam3s/sam3s-ek/libraries/usb/device/core/USBDDriverCallbacks.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"
@@ -3454,7 +3457,7 @@ static void _ConfigureTc0(void)
void USBDCallbacks_Initialized(void)
{
TRACE_INFO("USBDCallbacks_Initialized\n\r");
NVIC_EnableIRQ(UDP_IRQn);
NVIC_EnableIRQ(UDP_IRQn);
}
/**
+5 -4
View File
@@ -42,6 +42,10 @@
#include <stddef.h>
#include <stdlib.h>
#if defined(PCBARM)
// #define MASSSTORAGE
#endif
#define EEPROM_VARIANTS (0x00)
#if defined(PCBSTD)
@@ -836,12 +840,9 @@ inline int16_t calc1000toRESX( register int32_t x) // improve calc time by Pat
#else
extern int16_t calc100toRESX(int8_t x);
extern int16_t calc1000toRESX(int16_t x);
extern int16_t calcRESXto1000(int16_t x);
#endif
// *1000/1024 = x - x/32 + x/128
// TODO flash saving?
#define GPERC(x) (x - x/32 + x/128)
#if defined(PCBARM)
// This doesn't need protection on this processor
#define tmr10ms_t uint32_t
+2 -2
View File
@@ -79,7 +79,7 @@ void audioQueue::heartbeat()
toneFreqIncr = queueToneFreqIncr[t_queueRidx];
tonePause = queueTonePause[t_queueRidx];
if (!queueToneRepeat[t_queueRidx]--) {
t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH;
t_queueRidx = (t_queueRidx + 1) & (AUDIO_QUEUE_LENGTH-1);
}
}
else {
@@ -147,7 +147,7 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
tFlags &= 0x0f;
if (tFlags) {
uint8_t next_queueWidx = (t_queueWidx + 1) % AUDIO_QUEUE_LENGTH;
uint8_t next_queueWidx = (t_queueWidx + 1) & (AUDIO_QUEUE_LENGTH-1);
if (next_queueWidx != t_queueRidx) {
queueToneFreq[t_queueWidx] = tFreq;
queueToneLength[t_queueWidx] = tLen;