6 bytes saved in flash (pulled from er9x)

This commit is contained in:
bsongis
2012-07-05 10:31:26 +00:00
parent a761db40a2
commit 3cb83df6cd
5 changed files with 21 additions and 19 deletions
+6 -2
View File
@@ -443,6 +443,8 @@ void lcd_filled_rect(uint8_t x, int8_t y, uint8_t w, uint8_t h, uint8_t pat, uin
void putsTime(uint8_t x,uint8_t y,int16_t tme,uint8_t att,uint8_t att2)
{
div_t qr;
if (att & LEFT) x+=3*FW;
if (tme<0) {
@@ -450,9 +452,11 @@ void putsTime(uint8_t x,uint8_t y,int16_t tme,uint8_t att,uint8_t att2)
tme = -tme;
}
lcd_outdezNAtt(x, y, tme/60, att|LEADING0|LEFT, 2);
qr = div(tme, 60);
lcd_outdezNAtt(x, y, qr.quot, att|LEADING0|LEFT, 2);
lcd_putcAtt(lcdLastPos-((att & DBLSIZE) ? 1 : 0), y, ':', att&att2);
lcd_outdezNAtt(lcdLastPos+FW, y, tme%60, att2|LEADING0|LEFT, 2);
lcd_outdezNAtt(lcdLastPos+FW, y, qr.rem, att2|LEADING0|LEFT, 2);
}
// TODO to be optimized with putsTelemetryValue
+6 -9
View File
@@ -602,28 +602,25 @@ void menuProcModel(uint8_t event)
(attr && m_posHorz==1 ? blink:0),
(attr && m_posHorz==2 ? blink:0) );
if (attr && (s_editMode>0 || p1valdiff)) {
uint16_t timer_val = timer->val;
div_t qr = div(timer->val, 60);
switch (m_posHorz) {
case 0:
CHECK_INCDEC_MODELVAR(event, timer->mode, -2*(MAX_PSWITCH+NUM_CSW), TMR_VAROFS-1+2*(MAX_PSWITCH+NUM_CSW));
break;
case 1:
{
int8_t min = timer_val/60;
CHECK_INCDEC_MODELVAR(event, min, 0, 59);
timer_val = timer_val%60 + min*60;
CHECK_INCDEC_MODELVAR(event, qr.quot, 0, 59);
timer->val = qr.rem + qr.quot*60;
break;
}
case 2:
{
int8_t sec = timer_val%60;
sec -= checkIncDecModel(event, sec+2, 1, 62)-2;
timer_val -= sec ;
if ((int16_t)timer_val < 0) timer_val=0;
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
timer->val -= qr.rem ;
if ((int16_t)timer->val < 0) timer->val=0;
break;
}
}
timer->val = timer_val;
}
break;
}
+6 -5
View File
@@ -2552,22 +2552,23 @@ ISR(TIMER5_COMPA_vect, ISR_NOBLOCK) // mixer interrupt
#if defined (PCBV4)
ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) //10ms timer
#else
// Clocks every 64 uS
ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
#endif
{
cli();
#if defined (PCBV4)
static uint8_t accuracyWarble = 4; // becasue 16M / 1024 / 100 = 156.25. So bump every 4.
static uint8_t accuracyWarble = 4; // because 16M / 1024 / 100 = 156.25. So bump every 4.
uint8_t bump = (!(accuracyWarble++ & 0x03)) ? 157 : 156;
TIMSK2 &= ~(1<<OCIE2A); //stop reentrance
TIMSK2 &= ~(1<<OCIE2A); // stop reentrance
OCR2A += bump;
#else
TIMSK &= ~(1<<OCIE0); //stop reentrance
TIMSK &= ~(1<<OCIE0); // stop reentrance
#if defined (AUDIO)
OCR0 += 2; // run much faster, to generate speaker tones
OCR0 += 2; // interrupt every 128 uS
#else
static uint8_t accuracyWarble = 4; // becasue 16M / 1024 / 100 = 156.25. So bump every 4.
static uint8_t accuracyWarble = 4; // because 16M / 1024 / 100 = 156.25. So bump every 4.
uint8_t bump = (!(accuracyWarble++ & 0x03)) ? 157 : 156;
OCR0 += bump;
#endif
+3 -2
View File
@@ -40,6 +40,7 @@
#include <inttypes.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#if defined(PCBSTD)
#define WDT_RESET_STOCK() wdt_reset()
@@ -708,13 +709,13 @@ inline int16_t calc1000toRESX( register int32_t x) // improve calc time by Pat
// return x + x/32 - x/128 + x/512;
}
#else
extern inline int16_t calc100toRESX(int8_t x)
inline int16_t calc100toRESX(int8_t x)
{
// return (int16_t)x*10 + x/4 - x/64;
return ((x*41)>>2) - x/64;
}
extern inline int16_t calc1000toRESX(int16_t x)
int16_t calc1000toRESX(int16_t x)
{
// return x + x/32 - x/128 + x/512;
int16_t y = x>>5;
-1
View File
@@ -32,7 +32,6 @@
*/
#include "open9x.h"
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>