New curves system (XCURVES Makefile option)

SmartieParts board v2.2 support (SP22 Makefile option)
This commit is contained in:
bsongis
2012-07-24 15:11:00 +00:00
parent 176cd898a0
commit 10265a90ca
14 changed files with 360 additions and 34 deletions
+15 -1
View File
@@ -59,6 +59,9 @@ AUDIO = NO
# Values = YES, NO
HAPTIC = NO
# SmartieParts 2.2 Backlight support (inverted)
SP22 = NO
# SPLASH on START
SPLASH = YES
@@ -140,6 +143,10 @@ DEBUG = NO
# Values = YES, NO
FLIGHT_PHASES = YES
# Customizable Curves
# Values = YES, NO
XCURVES = YES
#------- END BUILD OPTIONS ---------------------------
# Define programs and commands.
@@ -154,6 +161,7 @@ ifeq ($(PCB), STD)
TRGT = avr-
MCU = atmega64
CPPDEFS += -DF_CPU=$(F_CPU)UL
XCURVES = NO
endif
ifeq ($(PCB), V4)
@@ -277,6 +285,10 @@ ifeq ($(FLIGHT_PHASES), YES)
CPPDEFS += -DFLIGHT_PHASES
endif
ifeq ($(XCURVES), YES)
CPPDEFS += -DXCURVES
endif
# If STD-Support is enabled
ifeq ($(EXT), STD)
CPPDEFS += -DEXTSTD
@@ -382,7 +394,6 @@ ifeq ($(PCB), V4)
CPPDEFS += -DEXTRA_ROTARY_ENCODERS
MODS:=${MODS}X
endif
endif
ifeq ($(PCB), STD)
@@ -406,6 +417,9 @@ ifeq ($(PCB), STD)
CPPSRC += haptic.cpp
endif
ifeq ($(SP22), YES)
CPPDEFS += -DSP22
endif
endif
### Global Build-Option Directives ###
+1 -1
View File
@@ -448,7 +448,7 @@ bool ee32LoadGeneral()
read32_eeprom_data( ( File_system[0].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&g_eeGeneral, size) ;
}
if (g_eeGeneral.myVers == EEPROM_VER) {
if (g_eeGeneral.myVers == EEPROM_VER && g_eeGeneral.variants == EEPROM_VARIANTS) {
uint16_t sum = evalChkSum();
if (g_eeGeneral.chkSum == sum) {
return true;
+8 -9
View File
@@ -186,7 +186,7 @@ int8_t EeFsck()
s_sync_write = true;
uint8_t *bufp = reusableBuffer.eefs_buffer;
memset(bufp, 0, BLOCKS);
memclear(bufp, BLOCKS);
uint8_t blk ;
int8_t ret = 0;
@@ -232,7 +232,7 @@ void EeFsFormat()
{
s_sync_write = true;
memset(&eeFs,0, sizeof(eeFs));
memclear(&eeFs, sizeof(eeFs));
eeFs.version = EEFS_VERS;
eeFs.mySize = sizeof(eeFs);
eeFs.freeList = 0;
@@ -245,7 +245,7 @@ void EeFsFormat()
s_sync_write = false;
}
bool EeFsOpen() // TODO inline?
inline bool EeFsOpen() // TODO inline?
{
eeprom_read_block(&eeFs, 0, sizeof(eeFs));
@@ -286,7 +286,7 @@ void EFile::swap(uint8_t i_fileId1, uint8_t i_fileId2)
void EFile::rm(uint8_t i_fileId)
{
uint8_t i = eeFs.files[i_fileId].startBlk;
memset(&eeFs.files[i_fileId], 0, sizeof(eeFs.files[i_fileId]));
memclear(&eeFs.files[i_fileId], sizeof(eeFs.files[i_fileId]));
s_sync_write = true;
EeFsFlushDirEnt(i_fileId);
if (i) EeFsFree(i); //chain in
@@ -343,13 +343,13 @@ uint8_t EFile::read(uint8_t*buf,uint16_t i_len)
#ifdef TRANSLATIONS
uint16_t RlcFile::readRlc12(uint8_t*buf,uint16_t i_len, bool rlc2)
#else
uint16_t RlcFile::readRlc(uint8_t*buf,uint16_t i_len)
uint16_t RlcFile::readRlc(uint8_t *buf,uint16_t i_len)
#endif
{
uint16_t i=0;
for( ; 1; ){
uint8_t l=min<uint16_t>(m_zeroes,i_len-i);
memset(&buf[i],0,l);
memclear(&buf[i], l);
i += l;
m_zeroes -= l;
if(m_zeroes) break;
@@ -801,8 +801,7 @@ bool eeLoadGeneral()
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 1) == 1 && g_eeGeneral.myVers == EEPROM_VER) {
theFile.openRlc(FILE_GENERAL); // TODO include this openRlc inside readRlc
if (theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral)) <= sizeof(EEGeneral)) {
uint16_t sum = evalChkSum();
if (g_eeGeneral.chkSum == sum) {
if (g_eeGeneral.variants == EEPROM_VARIANTS && g_eeGeneral.chkSum == evalChkSum()) {
return true;
}
}
@@ -813,7 +812,7 @@ bool eeLoadGeneral()
uint16_t eeLoadModelName(uint8_t id, char *name)
{
memset(name, 0, sizeof(g_model.name));
memclear(name, sizeof(g_model.name));
if (id<MAX_MODELS) {
theFile.openRlc(FILE_MODEL(id));
if (theFile.readRlc((uint8_t*)name, sizeof(g_model.name)) == sizeof(g_model.name)) {
-1
View File
@@ -94,7 +94,6 @@ PACK(struct EeFs{
#define BLOCKS_OFFSET 0
#endif
bool EeFsOpen();
int8_t EeFsck();
void EeFsFormat();
uint16_t EeFsGetFree();
+1 -1
View File
@@ -827,7 +827,7 @@ void frskyEvalCurrentConsumptionBoundary()
void resetTelemetry()
{
memset(&frskyData, 0, sizeof(frskyData));
memclear(&frskyData, sizeof(frskyData));
frskyEvalCurrentConsumptionBoundary();
+1
View File
@@ -739,6 +739,7 @@ void menuProcDiagVers(uint8_t event)
lcd_putsLeft(5*FH, stamp4);
lcd_putsLeft(7*FH, STR_EEPROMV);
lcd_outdezAtt(8*FW, 7*FH, g_eeGeneral.myVers, LEFT);
lcd_outdezAtt(15*FW, 7*FH, g_eeGeneral.variants, LEFT);
}
void menuProcDiagKeys(uint8_t event)
+1 -1
View File
@@ -299,7 +299,7 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, LcdFlags flags, uint8_t l
}
lcd_putcAtt(x, y, c, f);
if (mode==i) {
flags &= ~PREC2; // TODO not needed but removes 64bytes, could be improved for sure, check asm
flags &= ~PREC2; // TODO not needed but removes 20bytes, could be improved for sure, check asm
if (dblsize) {
xn = x;
if(c>='1' && c<='3') ln++;
+197 -8
View File
@@ -167,7 +167,7 @@ bool listSdFiles(const char *path, const char *extension)
break;
}
char *menu_entry = &s_bss_menu[s_menu_count*MENU_LINE_LENGTH];
memset(menu_entry, 0, MENU_LINE_LENGTH);
memclear(menu_entry, MENU_LINE_LENGTH);
for (uint8_t i=0; i<MENU_LINE_LENGTH-1; i++) {
if (fn[i] == '.')
break;
@@ -783,7 +783,6 @@ void menuProcModel(uint8_t event)
}
}
}
// TODO port PPM16 ppmDelay from er9x
#if defined(DSM2) || defined(PXX)
else if (IS_DSM2_PROTOCOL(protocol) || IS_PXX_PROTOCOL(protocol)) {
if (attr && m_posHorz > 0 && IS_DSM2_PROTOCOL(protocol))
@@ -1093,6 +1092,155 @@ void DrawCurve(FnFuncP fn)
}
}
#if defined(XCURVES)
bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0)
{
if (g_model.curves[MAX_CURVES-1] + shift > NUM_POINTS-5*MAX_CURVES) {
AUDIO_WARNING2();
return false;
}
int8_t *crv = curveaddress(index);
if (shift < 0) {
for (uint8_t i=0; i<custom; i++)
crv[i] = crv[2*i];
}
int8_t *nextCrv = curveaddress(index+1);
memmove(nextCrv+shift, nextCrv, 5*(MAX_CURVES-index-1)+g_model.curves[MAX_CURVES-1]);
if (shift < 0) memclear(&g_model.points[NUM_POINTS-1] + shift, -shift);
while (index<MAX_CURVES)
g_model.curves[index++] += shift;
for (uint8_t i=0; i<custom-2; i++)
crv[custom+i] = -100 + ((200 * (i+1) + custom/2) / (custom-1)) ;
eeDirty(EE_MODEL);
return true;
}
void menuProcCurveOne(uint8_t event)
{
TITLE(STR_MENUCURVE);
lcd_outdezAtt(5*FW+1, 0, s_curveChan+1, INVERS|LEFT);
DISPLAY_PROGRESS_BAR(20*FW+1);
CurveInfo crv = curveinfo(s_curveChan);
switch(event) {
case EVT_ENTRY:
#if defined(ROTARY_ENCODERS)
s_editMode = -1;
#endif
killEvents(KEY_MENU);
break;
#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_BREAK(KEY_MENU):
if (s_editMode == 0)
m_posHorz = 0;
if (s_editMode == 1 && crv.custom/* && m_posHorz>0 && m_posHorz<points-1*/)
s_editMode = 2;
else
s_editMode = 1;
break;
case EVT_KEY_LONG(KEY_MENU):
if (s_editMode == 0) {
if (++m_posHorz > 4)
m_posHorz = -4;
for (uint8_t i=0; i<crv.points; i++)
crv.crv[i] = (i-(crv.points/2)) * m_posHorz * 50 / (crv.points-1);
eeDirty(EE_MODEL);
killEvents(event);
}
break;
case EVT_KEY_FIRST(KEY_EXIT):
killEvents(event);
if (s_editMode>0) {
if (--s_editMode == 0)
m_posHorz = 0;
}
else
popMenu();
break;
case EVT_KEY_REPT(KEY_LEFT):
case EVT_KEY_FIRST(KEY_LEFT):
if (s_editMode==1 && m_posHorz>0) m_posHorz--;
if (s_editMode==0) {
if (crv.custom) {
moveCurve(s_curveChan, -crv.points+2);
}
else if (crv.points > MIN_POINTS) {
moveCurve(s_curveChan, -1, (crv.points+1)/2);
}
else {
AUDIO_WARNING2();
}
return;
}
break;
case EVT_KEY_REPT(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_RIGHT):
if (s_editMode==1 && m_posHorz<(crv.points-1)) m_posHorz++;
if (s_editMode==0) {
if (!crv.custom) {
moveCurve(s_curveChan, crv.points-2, crv.points);
}
else if (crv.points < MAX_POINTS) {
if (moveCurve(s_curveChan, 1)) {
for (int8_t i=crv.points+crv.points-2; i>=0; i--) {
if (i%2)
crv.crv[i] = (crv.crv[i/2] + crv.crv[1+i/2]) / 2;
else
crv.crv[i] = crv.crv[i/2];
}
}
}
else {
AUDIO_WARNING2();
}
}
break;
}
lcd_putsLeft(7*FH, PSTR("Type"));
uint8_t attr = (s_editMode==0 ? INVERS : 0);
lcd_outdezAtt(5*FW-2, 7*FH, crv.points, LEFT|attr);
lcd_putsAtt(lcdLastPos, 7*FH, crv.custom ? PSTR("pt'") : PSTR("pt"), attr);
for (uint8_t i=0; i<crv.points; i++) {
uint8_t xx = X0-1-WCHART+i*WCHART/(crv.points/2);
uint8_t yy = (DISPLAY_H-1) - (100 + crv.crv[i]) * (DISPLAY_H-1) / 200;
if (crv.custom && i>0 && i<crv.points-1)
xx = X0-1-WCHART + (100 + crv.crv[crv.points+i-1]) * (2*WCHART) / 200;
lcd_filled_rect(xx, yy-1, 3, 3); // do markup square
if (s_editMode>0 && m_posHorz==i) {
if (s_editMode==1 || !BLINK_ON_PHASE) lcd_filled_rect(xx-1, yy-2, 5, 5); // do selection square
int8_t x = -100 + 200*i/(crv.points-1);
if (crv.custom && i>0 && i<crv.points-1) x = crv.crv[crv.points+i-1];
lcd_puts(7, 2*FH, PSTR("x=")); lcd_outdezAtt(7+2*FW, 2*FH, x, LEFT);
lcd_puts(7, 3*FH, PSTR("y=")); lcd_outdezAtt(7+2*FW, 3*FH, crv.crv[i], LEFT);
lcd_rect(3, 1*FH+4, 7*FW-2, 3*FH-2);
if (p1valdiff || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP))
CHECK_INCDEC_MODELVAR(event, crv.crv[i], -100, 100); // edit Y on up/down
if (i>0 && i<crv.points-1 && s_editMode==2 && (event==EVT_KEY_FIRST(KEY_LEFT) || event==EVT_KEY_FIRST(KEY_RIGHT) || event==EVT_KEY_REPT(KEY_LEFT) || event==EVT_KEY_REPT(KEY_RIGHT)))
CHECK_INCDEC_MODELVAR(event, crv.crv[crv.points+i-1], i==1 ? -99 : crv.crv[crv.points+i-2]+1, i==crv.points-2 ? 99 : crv.crv[crv.points+i]-1); // edit X on left/right
}
}
DrawCurve(curveFn);
}
#else
void menuProcCurveOne(uint8_t event)
{
uint8_t points;
@@ -1193,6 +1341,7 @@ void menuProcCurveOne(uint8_t event)
DrawCurve(curveFn);
}
#endif
uint8_t getExpoMixCount(uint8_t expo)
{
@@ -1243,12 +1392,12 @@ void deleteExpoMix(uint8_t expo, uint8_t idx)
if (expo) {
ExpoData *expo = expoaddress(idx);
memmove(expo, expo+1, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
memset(&g_model.expoData[MAX_EXPOS-1], 0, sizeof(ExpoData));
memclear(&g_model.expoData[MAX_EXPOS-1], sizeof(ExpoData));
}
else {
MixData *mix = mixaddress(idx);
memmove(mix, mix+1, (MAX_MIXERS-(idx+1))*sizeof(MixData));
memset(&g_model.mixData[MAX_MIXERS-1], 0, sizeof(MixData));
memclear(&g_model.mixData[MAX_MIXERS-1], sizeof(MixData));
}
resumeMixerCalculations();
STORE_MODELVARS;
@@ -1261,7 +1410,7 @@ void insertExpoMix(uint8_t expo, uint8_t idx)
if (expo) {
ExpoData *expo = expoaddress(idx);
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
memset(expo, 0, sizeof(ExpoData));
memclear(expo, sizeof(ExpoData));
expo->mode = 3; // pos&neg
expo->chn = s_currCh - 1;
expo->weight = 100;
@@ -1269,7 +1418,7 @@ void insertExpoMix(uint8_t expo, uint8_t idx)
else {
MixData *mix = mixaddress(idx);
memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData));
memset(mix, 0, sizeof(MixData));
memclear(mix, sizeof(MixData));
mix->destCh = s_currCh-1;
mix->srcRaw = (s_currCh > 4 ? s_currCh : channel_order(s_currCh));
mix->weight = 100;
@@ -1569,7 +1718,7 @@ void menuProcMixOne(uint8_t event)
case MIX_FIELD_CURVE:
lcd_putsLeft(y, STR_CURVES);
putsCurve(MIXES_2ND_COLUMN, y, md2->curve, attr);
if(attr) CHECK_INCDEC_MODELVAR( event, md2->curve, -MAX_CURVE5-MAX_CURVE9, MAX_CURVE5+MAX_CURVE9+7-1);
if(attr) CHECK_INCDEC_MODELVAR( event, md2->curve, -MAX_CURVES, MAX_CURVES+7-1);
if(attr && event==EVT_KEY_FIRST(KEY_MENU) && (md2->curve<0 || md2->curve>=CURVE_BASE)){
s_curveChan = (md2->curve<0 ? -md2->curve-1 : md2->curve-CURVE_BASE);
pushMenu(menuProcCurveOne);
@@ -2092,9 +2241,44 @@ void menuProcLimits(uint8_t _event)
}
}
#if defined(XCURVES)
void menuProcCurvesAll(uint8_t event)
{
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVE5+MAX_CURVE9);
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES);
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_curveChan = sub;
pushMenu(menuProcCurveOne);
}
break;
}
for (uint8_t i = 0; i < 7; i++) {
uint8_t y = FH + i*FH;
uint8_t k = i + s_pgOfs;
uint8_t attr = (sub == k ? INVERS : 0);
putsStrIdx(0, y, STR_CV, k+1, attr);
}
s_curveChan = sub;
DrawCurve(curveFn);
}
#else
void menuProcCurvesAll(uint8_t event)
{
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES);
int8_t sub = m_posVert - 1;
@@ -2121,7 +2305,11 @@ void menuProcCurvesAll(uint8_t event)
for (uint8_t i = 0; i < 7; i++) {
uint8_t k = i + s_pgOfs;
uint8_t attr = sub == k ? INVERS : 0;
#if defined(XCURVES)
bool cv9 = (getCurvePoints(k) == 9);
#else
bool cv9 = k >= MAX_CURVE5;
#endif
if(cv9 && (yd>6)) break;
if(yd>7) break;
@@ -2142,6 +2330,7 @@ void menuProcCurvesAll(uint8_t event)
if(!m) s_pgOfs++;
}
#endif
#if defined(PCBARM)
enum CustomSwitchFields {
+19 -3
View File
@@ -158,7 +158,7 @@ PACK(typedef struct t_EEGeneral {
EXTRA_ARM_FIELDS
uint8_t lightOnStickMove;
uint8_t variants;
}) EEGeneral;
@@ -589,8 +589,23 @@ PACK(typedef struct t_PhaseData {
#endif
#define MAX_TIMERS 2
#if defined(XCURVES)
#define MAX_CURVES 8
#define NUM_POINTS (112-MAX_CURVES)
#define MIN_POINTS 3
#define MAX_POINTS 17
#define CURVES_DATA \
int8_t curves[MAX_CURVES]; \
int8_t points[NUM_POINTS]
#else
#define MAX_CURVE5 8
#define MAX_CURVE9 8
#define MAX_CURVES (MAX_CURVE5+MAX_CURVE9)
#define CURVES_DATA \
int8_t curves5[MAX_CURVE5][5]; \
int8_t curves9[MAX_CURVE9][9]
#endif
#define TMRMODE_NONE 0
#define TMRMODE_ABS 1
@@ -666,8 +681,9 @@ PACK(typedef struct t_ModelData {
MixData mixData[MAX_MIXERS];
LimitData limitData[NUM_CHNOUT];
ExpoData expoData[MAX_EXPOS];
int8_t curves5[MAX_CURVE5][5];
int8_t curves9[MAX_CURVE9][9];
CURVES_DATA;
CustomSwData customSw[NUM_CSW];
FuncSwData funcSw[NUM_FSW];
SwashRingData swashR;
+71 -4
View File
@@ -162,20 +162,51 @@ LimitData *limitaddress(uint8_t idx)
return &g_model.limitData[idx];
}
#if defined(XCURVES)
int8_t *curveaddress(uint8_t idx)
{
return &g_model.points[idx==0 ? 0 : 5*idx+g_model.curves[idx-1]];
}
CurveInfo curveinfo(uint8_t idx)
{
CurveInfo result;
result.crv = curveaddress(idx);
int8_t *next = curveaddress(idx+1);
uint8_t size = next - result.crv;
if (size % 2 == 0) {
result.points = (size / 2) + 1;
result.custom = true;
}
else {
result.points = size;
result.custom = false;
}
return result;
}
#else
int8_t *curveaddress(uint8_t idx)
{
return (idx >= MAX_CURVE5 ? g_model.curves9[idx-MAX_CURVE5] : g_model.curves5[idx]);
}
#endif
CustomSwData *cswaddress(uint8_t idx)
{
return &g_model.customSw[idx];
}
#if defined(PCBSTD)
void memclear(void *ptr, uint8_t size)
{
memset(ptr, 0, size);
}
#endif
void generalDefault()
{
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
memclear(&g_eeGeneral, sizeof(g_eeGeneral));
g_eeGeneral.myVers = EEPROM_VER;
g_eeGeneral.variants = EEPROM_VARIANTS;
g_eeGeneral.contrast = 25;
g_eeGeneral.vBatWarn = 90;
for (int i = 0; i < 7; ++i) {
@@ -241,6 +272,41 @@ void resetProto()
#endif
}
#if defined(XCURVES)
int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100
{
CurveInfo crv = curveinfo(idx);
int16_t erg = 0;
x+=RESXu;
if (x < 0) {
erg = (int16_t)crv.crv[0] * (RESX/4);
}
else if (x >= (RESX*2)) {
erg = (int16_t)crv.crv[crv.points-1] * (RESX/4);
}
else {
uint16_t a=0, b=0; // TODO init not needed
uint8_t i;
if (crv.custom) {
for (i=0; i<crv.points-1; i++) {
a = (i==0 ? 0 : (100 * (RESX/4) / 25 + crv.crv[crv.points+i-1] * (RESX/4) / 25));
b = (i==crv.points-2 ? 2*RESX : (100 * (RESX/4) / 25 + crv.crv[crv.points+i] * (RESX/4) / 25));
if ((uint16_t)x>=a && (uint16_t)x<=b) break;
}
}
else {
uint16_t d = (RESX * 2) / (crv.points-1);
i = (uint16_t)x / d;
a = i * d;
b = a + d;
}
erg = (int16_t)crv.crv[i]*(RESX/4) + ((int32_t)(x-a) * (crv.crv[i+1]-crv.crv[i]) * (RESX/4)) / ((b-a));
}
return erg / 25; // 100*D5/RESX;
}
#else
int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100
{
#define D9 (RESX * 2 / 8)
@@ -270,6 +336,7 @@ int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 10
}
return erg / 25; // 100*D5/RESX;
}
#endif
int16_t applyCurve(int16_t x, int8_t idx)
{
@@ -891,7 +958,7 @@ void clearKeyEvents()
#else
while (keyDown()) WDT_RESET_STOCK(); // loop until all keys are up
#endif
memset(keys, 0, sizeof(keys));
memclear(keys, sizeof(keys));
putEvent(0);
}
@@ -1948,7 +2015,7 @@ void perOut(uint8_t tick10ms)
#endif
}
memset(chans, 0, sizeof(chans)); // All outputs to 0
memclear(chans, sizeof(chans)); // All outputs to 0
//========== MIXER LOOP ===============
uint8_t lv_mixWarning = 0;
@@ -2201,7 +2268,7 @@ inline void doMixerCalculations(uint16_t tmr10ms, uint8_t tick10ms)
}
if (s_fade_flight_phases) {
memset(sum_chans512, 0, sizeof(sum_chans512));
memclear(sum_chans512, sizeof(sum_chans512));
weight = 0;
for (uint8_t p=0; p<MAX_PHASES; p++) {
if (s_fade_flight_phases & (1<<p)) {
+30
View File
@@ -42,6 +42,16 @@
#include <stddef.h>
#include <stdlib.h>
#define VARIANT_XCURVES_MASK 0x80
#if defined(XCURVES)
#define VARIANT_XCURVES VARIANT_XCURVES_MASK
#else
#define VARIANT_XCURVES 0x00
#endif
#define EEPROM_VARIANTS (VARIANT_XCURVES)
#if defined(PCBSTD)
#define WDT_RESET_STOCK() wdt_reset()
#else
@@ -601,6 +611,12 @@ uint16_t getTmr16KHz();
uint16_t stack_free();
#if defined(PCBSTD)
void memclear(void *ptr, uint8_t size);
#else
#define memclear(p, s) memset(p, 0, s)
#endif
#ifdef SPLASH
void doSplash();
#endif
@@ -644,6 +660,9 @@ void read_9_adc(void ) ;
#define SPEAKER_OFF TCCR0A &= ~(1 << COM0A0)
#define BACKLIGHT_ON PORTC |= (1 << OUT_C_LIGHT)
#define BACKLIGHT_OFF PORTC &= ~(1 << OUT_C_LIGHT)
#elif defined(SP22)
#define BACKLIGHT_ON PORTB &= ~(1 << OUT_B_LIGHT)
#define BACKLIGHT_OFF PORTB |= (1 << OUT_B_LIGHT)
#else
#define BACKLIGHT_ON PORTB |= (1 << OUT_B_LIGHT)
#define BACKLIGHT_OFF PORTB &= ~(1 << OUT_B_LIGHT)
@@ -680,6 +699,9 @@ void read_9_adc(void ) ;
#define NOINLINE __attribute__ ((noinline))
#endif
// Fiddle to force compiler to use a pointer
#define FORCE_INDIRECT(ptr) __asm__ __volatile__ ("" : "=e" (ptr) : "0" (ptr))
/// liefert Betrag des Arguments
template<class t> FORCEINLINE t abs(t a) { return a>0?a:-a; }
/// liefert das Minimum der Argumente
@@ -789,6 +811,14 @@ extern MixData *mixaddress(uint8_t idx);
extern LimitData *limitaddress(uint8_t idx);
extern int8_t *curveaddress(uint8_t idx);
extern CustomSwData *cswaddress(uint8_t idx);
#if defined(XCURVES)
struct CurveInfo {
int8_t *crv;
uint8_t points;
bool custom;
};
extern CurveInfo curveinfo(uint8_t idx);
#endif
extern void deleteExpoMix(uint8_t expo, uint8_t idx);
+8 -5
View File
@@ -77,7 +77,7 @@ MixData* setDest(uint8_t dch, uint8_t src, bool clear=false)
}
memmove(mix+1, mix, (MAX_MIXERS-(i+1))*sizeof(MixData) );
memset(mix,0,sizeof(MixData));
memclear(mix, sizeof(MixData));
mix->destCh = dch;
mix->srcRaw = src;
mix->weight = 100;
@@ -86,20 +86,23 @@ MixData* setDest(uint8_t dch, uint8_t src, bool clear=false)
void clearMixes()
{
memset(g_model.mixData, 0, sizeof(g_model.mixData)); //clear all mixes
memset(g_model.mixData, 0, sizeof(g_model.mixData)); // clear all mixes
STORE_MODELVARS;
}
void clearCurves()
{
memset(g_model.curves5, 0, sizeof(g_model.curves5)); //clear all curves
memset(g_model.curves9, 0, sizeof(g_model.curves9)); //clear all curves
#if defined(XCURVES)
memclear(g_model.curves, sizeof(g_model.curves) + sizeof(g_model.points)); // clear all curves
#else
memclear(g_model.curves5, sizeof(g_model.curves5) + sizeof(g_model.curves9)); // clear all curves
#endif
}
void setCurve(uint8_t c, const pm_int8_t ar[])
{
int8_t * cv = curveaddress(c);
for (uint8_t i=0; i<(c<MAX_CURVE5 ? 5 : 9); i++) {
for (uint8_t i=0; i<5; i++) {
cv[i] = pgm_read_byte(&ar[i]);
}
}
+2
View File
@@ -57,7 +57,9 @@ const pm_char STR_OPEN9X[] PROGMEM =
ISTR(POSNEG)
ISTR(VBLMODE)
ISTR(VCURVEFUNC)
#if !defined(XCURVES)
ISTR(CURVMODES)
#endif
ISTR(EXPLABELS)
ISTR(VMLTPX)
ISTR(VMLTPX2)
+6
View File
@@ -84,8 +84,12 @@ extern const pm_char STR_OPEN9X[];
#define OFS_POSNEG (OFS_VPROTOS + sizeof(TR_VPROTOS))
#define OFS_VBLMODE (OFS_POSNEG + sizeof(TR_POSNEG))
#define OFS_VCURVEFUNC (OFS_VBLMODE + sizeof(TR_VBLMODE))
#if defined(XCURVES)
#define OFS_EXPLABELS (OFS_VCURVEFUNC + sizeof(TR_VCURVEFUNC))
#else
#define OFS_CURVMODES (OFS_VCURVEFUNC + sizeof(TR_VCURVEFUNC))
#define OFS_EXPLABELS (OFS_CURVMODES + sizeof(TR_CURVMODES))
#endif
#define OFS_VMLTPX (OFS_EXPLABELS + sizeof(TR_EXPLABELS))
#define OFS_VMLTPX2 (OFS_VMLTPX + sizeof(TR_VMLTPX))
#define OFS_VMIXTRIMS (OFS_VMLTPX2 + sizeof(TR_VMLTPX2))
@@ -150,7 +154,9 @@ extern const pm_char STR_OPEN9X[];
#define STR_VCURVEFUNC (STR_OPEN9X + OFS_VCURVEFUNC)
#define STR_VWHEN STR_VCURVEFUNC
#define LEN_VWHEN LEN_VCURVEFUNC
#if !defined(XCURVES)
#define STR_CURVMODES (STR_OPEN9X + OFS_CURVMODES)
#endif
#define STR_EXPLABELS (STR_OPEN9X + OFS_EXPLABELS)
#define STR_VMLTPX (STR_OPEN9X + OFS_VMLTPX)
#define STR_VMLTPX2 (STR_OPEN9X + OFS_VMLTPX2)