Ejemplo n.º 1
0
int main() {
  int ret;

  if ( (ret=check_simple()) != 0) { return ret; }
  if ( (ret=check_multi()) != 0)  { return ret; }

  return 0;
}
Ejemplo n.º 2
0
int
main (int argc, char *argv[])
{
  int h;

  if (argc == 5)
    {
      check_random (atoi (argv[1]), atoi (argv[2]), atoi (argv[3]),
                    (mpfr_rnd_t) atoi (argv[4]));
      return 0;
    }

  tests_start_mpfr ();

  if (argc != 1)
    {
      fprintf (stderr, "Usage: tsum\n       tsum n k prec rnd\n");
      exit (1);
    }

  check_simple ();
  check_special ();
  check_more_special ();
  for (h = 0; h <= 64; h++)
    check1 (h);
  check2 ();
  check3 ();
  check4 ();
  bug20131027 ();
  bug20150327 ();
  bug20160315 ();
  generic_tests ();
  check_extreme ();
  cancel ();
  check_overflow ();
  check_underflow ();

  check_coverage ();
  tests_end_mpfr ();
  return 0;
}
Ejemplo n.º 3
0
void check_submenu_simple(check_event_t event, uint8_t maxrow)
{
  check_simple(event, 0, 0, 0, maxrow);
}
Ejemplo n.º 4
0
int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, uint8_t i_flags)
#endif
{
    int16_t newval = val;

#if defined(DBLKEYS)
    uint8_t in = KEYS_PRESSED();
    if (EVT_KEY_MASK(event)) {
        bool dblkey = true;
        if (DBLKEYS_PRESSED_RGT_LFT(in))
            newval = -val;
        else if (DBLKEYS_PRESSED_RGT_UP(in)) {
            newval = (i_max > 100 ? 100 : i_max);
#if defined(CPUARM)
            if (i_flags & DBLKEYS_1000) newval *= 10;
#endif
        }
        else if (DBLKEYS_PRESSED_LFT_DWN(in)) {
            newval = (i_min < -100 ? -100 : i_min);
#if defined(CPUARM)
            if (i_flags & DBLKEYS_1000) newval *= 10;
#endif
        }
        else if (DBLKEYS_PRESSED_UP_DWN(in))
            newval = 0;
        else
            dblkey = false;

#if defined(CPUARM)

#endif

        if (dblkey) {
            killEvents(KEY_UP);
            killEvents(KEY_DOWN);
            killEvents(KEY_RIGHT);
            killEvents(KEY_LEFT);
#if defined(PCBTARANIS)
            killEvents(KEY_PAGE);
            killEvents(KEY_MENU);
            killEvents(KEY_ENTER);
            killEvents(KEY_EXIT);
#endif
            event = 0;
        }
    }
#endif

#if defined(PCBTARANIS)
    if (s_editMode>0 && (IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))) {
#else
    if (event==EVT_KEY_FIRST(KEY_RIGHT) || event==EVT_KEY_REPT(KEY_RIGHT) || (s_editMode>0 && (IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP)))) {
#endif
#if defined(CPUARM)
        do {
            if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
                newval += min(10, i_max-val);
            }
            else {
                newval++;
            }
        } while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
        if (newval > i_max) {
            newval = val;
            killEvents(event);
            AUDIO_WARNING2();
        }
        else
#else
        newval++;
#endif
            AUDIO_KEYPAD_UP();
    }
#if defined(PCBTARANIS)
    else if (s_editMode>0 && (IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))) {
#else
    else if (event==EVT_KEY_FIRST(KEY_LEFT) || event==EVT_KEY_REPT(KEY_LEFT) || (s_editMode>0 && (IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN)))) {
#endif
#if defined(CPUARM)
        do {
            if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
                newval -= min(10, val-i_min);
            }
            else {
                newval--;
            }
        } while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min);
        if (newval < i_min) {
            newval = val;
            killEvents(event);
            AUDIO_WARNING2();
        }
        else
#else
        newval--;
#endif
            AUDIO_KEYPAD_DOWN();
    }

    if (!READ_ONLY() && i_min==0 && i_max==1 && (event==EVT_KEY_BREAK(KEY_ENTER) || IS_ROTARY_BREAK(event))) {
        s_editMode = 0;
        newval = !val;
    }

#if defined(NAVIGATION_POT1)
    // change values based on P1
    newval -= p1valdiff;
    p1valdiff = 0;
#endif

#if defined(AUTOSWITCH)
    if (i_flags & INCDEC_SWITCH) {
        if (s_editMode>0) {
            int8_t swtch = getMovedSwitch();
            if (swtch) {
#if defined(PCBTARANIS)
                if(swtch == SWSRC_SH2)
                    newval = (newval == SWSRC_SH2 ? SWSRC_SH0 : SWSRC_SH2);
                else if(swtch != SWSRC_SH0)
                    newval = swtch;
#else
                if (IS_MOMENTARY(newval) && IS_MOMENTARY(swtch))
                    newval = -newval;
                else
                    newval = swtch;
#endif
            }
        }
    }
#endif

#if defined(AUTOSOURCE)
    if (i_flags & INCDEC_SOURCE) {
        if (s_editMode>0) {
            int8_t source = GET_MOVED_SOURCE(i_min, i_max);
            if (source) {
                newval = source;
            }
#if defined(AUTOSWITCH)
            else {
                uint8_t swtch = abs(getMovedSwitch());
                if (swtch) {
                    newval = switchToMix(swtch);
                }
            }
#endif
        }
    }
#endif

    if (newval > i_max || newval < i_min) {
        newval = (newval > i_max ? i_max : i_min);
        killEvents(event);
        AUDIO_WARNING2();
    }

    if (newval != val) {
        if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && (newval==0 || newval==-100 || newval==+100) && !IS_ROTARY_EVENT(event)) {
            pauseEvents(event); // delay before auto-repeat continues
            if (newval>val) // without AUDIO it's optimized, because the 2 sounds are the same
                AUDIO_KEYPAD_UP();
            else
                AUDIO_KEYPAD_DOWN();
        }
        eeDirty(i_flags & (EE_GENERAL|EE_MODEL));
        checkIncDec_Ret = (newval > val ? 1 : -1);
    }
    else {
        checkIncDec_Ret = 0;
    }
    return newval;
}

#if defined(CPUM64)
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
{
    return checkIncDec(event, i_val, i_min, i_max, EE_MODEL);
}

int8_t checkIncDecModelZero(uint8_t event, int8_t i_val, int8_t i_max)
{
    return checkIncDecModel(event, i_val, 0, i_max);
}

int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
{
    return checkIncDec(event, i_val, i_min, i_max, EE_GENERAL);
}
#endif

bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t maxrow)
{
    return check(event, curr, menuTab, menuTabSize, 0, 0, maxrow);
}

bool check_submenu_simple(check_event_t event, uint8_t maxrow)
{
    return check_simple(event, 0, 0, 0, maxrow);
}

void title(const pm_char * s)
{
    lcd_putsAtt(0, 0, s, INVERS);
}

#define SCROLL_TH      64
#define SCROLL_POT1_TH 32

#if defined(CPUARM)
#define CURSOR_NOT_ALLOWED_IN_ROW(row)   ((int8_t)MAXCOL(row) < 0)
#else
#define CURSOR_NOT_ALLOWED_IN_ROW(row)   (MAXCOL(row) == TITLE_ROW)
#endif

#if defined(PCBTARANIS)
#define MAXCOL_RAW(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#define MAXCOL(row)     (MAXCOL_RAW(row) >= HIDDEN_ROW ? MAXCOL_RAW(row) : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE)))
#define COLATTR(row)    (MAXCOL_RAW(row) == (uint8_t)-1 ? (const uint8_t)0 : (const uint8_t)(MAXCOL_RAW(row) & NAVIGATION_LINE_BY_LINE))
#else
#define MAXCOL(row)     (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#endif

#define INC(val, min, max) if (val<max) {val++;} else {val=min;}
#define DEC(val, min, max) if (val>min) {val--;} else {val=max;}

#if LCD_W >= 212
uint8_t scrollbar_X = LCD_W-1;
#endif

#if defined(CPUARM)
bool modelHasNotes()
{
    char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/";
    char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
    strcpy(buf, TEXT_EXT);

    return isFileAvailable(filename);
}
Ejemplo n.º 5
0
void check_submenu_simple(const char *name, check_event_t event, uint8_t rowcount)
{
  check_simple(name, event, 0, 0, 0, rowcount);
}
Ejemplo n.º 6
0
bool check_submenu_simple(uint8_t event, uint8_t maxrow)
{
  return check_simple(event, 0, 0, 0, maxrow);
}