signal_t copy_delay(signal_t signal2) { signal_t signal = new_signal(delay_signal); delay_get(signal, n) = delay_get(signal2, n); delay_get(signal, a) = delay_get(signal2, a); return signal; }
fa_signal_t fa_signal_delay(int n, fa_signal_t a) { signal_t signal = new_signal(delay_signal); delay_get(signal, n) = n; delay_get(signal, a) = a; return signal; }
test(delay_t *q) { int i; size_t len; char buf[256]; clock_t now; clock_t start; long bytes; /* Make sure you can't overempty it. */ assert(!delay_get(q, buf, sizeof(buf), clock())); /* Make sure you can't put illegal sized things into it. */ assert(delay_put(q, 0, 1000, clock())); /* fill queue with legal elements. */ start = clock(); now = start; bytes = 0; for (i=0; i<delay_QSIZE-1; i++) { int res; /* Put in ten at a time */ if ((i % 10) == 9) now = clock(); len = 100; memset(buf, i, len); res = delay_put(q, buf, len, now); if (res) printf("test failed; i=%d, res=%d\n", i, res); assert(!res); bytes += len; } /* Make sure you can't overfill it. */ assert(delay_put(q, buf, len, clock())); /* Watch the elements come out */ for (i=0; i<delay_QSIZE-1; i++) { do { len = delay_get(q, buf, sizeof(buf), clock()); } while (!len); printf("Got element %d at time %d\n", i, clock() - start); } /* Make sure you can't overempty it. */ assert(!delay_get(q, buf, sizeof(buf), clock())); now = clock(); printf("%d bytes, %d clocks, %d bytes/sec\n", bytes, now - start, (bytes * ECLOCKS_PER_SEC)/ (now - start)); }
/** * @brief provede co je potřeba pro funkci * @note * posledních 8 bitů je pro I2C a opto * zbytek jsou efekty pro relé * * @param[in] function setup * @ingroup LOGIC_HL * */ static void logic_function(const logic_function_t * arg, const logic_button_t * but) { (void) but; //I2C effects 28 - harmonist ,29 - delay uint64_t temp = arg->effects.w; logic_dibit_t temp_i2c = arg->effects; logic_specific(arg->special); uint32_t old_state_eff = switch_getRelays(); old_state_eff |= opto_getEffects() << 20; old_state_eff |= delay_get() << 30; uint8_t in = harm_getInputs(); old_state_eff |= harm_getInput_LED(in) << 31; //relays uint8_t i; logic_effect_t tmp; for (i = 0; i < 12; i++) { tmp = temp & 0b11; temp >>= 2; if (tmp == EFF_ENABLE) switch_setRelay(i); else if (tmp == EFF_DISABLE) switch_clearRelay(i); else if (tmp == EFF_TOGGLE) switch_toggleRelay(i); } //overdrive if (temp_i2c.s.eff14 == EFF_ENABLE) opto_enableEffect(0); else if (temp_i2c.s.eff14 == EFF_DISABLE) opto_disableEffect(0); else if (temp_i2c.s.eff14 == EFF_TOGGLE) opto_toggleEffect(0); //tuner if (temp_i2c.s.eff15 == EFF_ENABLE) opto_enableEffect(1); else if (temp_i2c.s.eff15 == EFF_DISABLE) opto_disableEffect(1); else if (temp_i2c.s.eff15 == EFF_TOGGLE) opto_toggleEffect(1); //harmonist if (temp_i2c.s.eff12 == EFF_ENABLE) harm_enable(); else if (temp_i2c.s.eff12 == EFF_DISABLE) harm_disable(); else if (temp_i2c.s.eff12 == EFF_TOGGLE) harm_toggle(); //delay if (temp_i2c.s.eff13 == EFF_ENABLE) { delay_on(); } else if (temp_i2c.s.eff13 == EFF_DISABLE) { delay_off(); } else if (temp_i2c.s.eff13 == EFF_TOGGLE) { delay_toggle(); } uint32_t new_state_eff = switch_getRelays(); new_state_eff |= opto_getEffects() << 20; new_state_eff |= delay_get() << 30; in = harm_getInputs(); new_state_eff |= harm_getInput_LED(in) << 31; uint32_t diff = new_state_eff ^ old_state_eff; const logic_marshall_t * marsh; if (active.bank->channels[active.activeChannel - 1].VolumeOverloadEnabled && new_state_eff & diff) marsh = &arg->marshall; else marsh = &active.bank->channels[active.activeChannel - 1].marshall; logic_marshallSetup(marsh); }
static bool_t logic_functionLeds(const logic_function_t * arg, uint16_t pin) { logic_ledColor_t coun = arg->led; uint16_t green = 0; uint16_t yellow = 0; if (coun != COL_NONE) { uint8_t yellow_i = foot_getLedsYellow(); uint8_t green_i = foot_getLedsGreen(); if (coun == COL_GREEN) green = pin; else if (coun == COL_YELLOW) yellow = pin; else if (coun == COL_BOTH) { yellow = pin; green = pin; } bool_t watcha = FALSE; if (arg->watchEffect < RELAY_COUNT) { watcha = switch_getRelay(arg->watchEffect); } else if (arg->watchEffect == 12) { uint8_t temp = harm_getInputs(); watcha = harm_getInput_LED(temp); } else if (arg->watchEffect == 13) { watcha = delay_get(); } else if (arg->watchEffect == 14 || arg->watchEffect == 15) { watcha = opto_getEffect(arg->watchEffect); } if (watcha == TRUE) { foot_SetLedsBoth(yellow_i | yellow, green_i | green); /* * projit pole a pokud už tam je tak ho nepřidávat */ if (arg->overloadEff || arg->overloadVolume) { int i; bool_t uz = FALSE; for (i = 0; i < active_functions.count; i++) { if (active_functions.arg[i] == arg) { uz = TRUE; break; } } if (uz == FALSE) active_functions.arg[active_functions.count++] = arg; } } else { foot_SetLedsBoth(yellow_i & (~yellow), green_i & (~green)); /* * projit pole a pokud tam je tak ho vyhodit a pole posunout * pokud tam neni tak nedělat nic */ int i, j; for (i = 0; i < active_functions.count; i++) { if (active_functions.arg[i] == arg) { //vyhodit ho for (j = i; j < active_functions.count; j++) { active_functions.arg[j] = active_functions.arg[j + 1]; } active_functions.count--; break; } } return TRUE; } } return FALSE; }