void main() { int temp; int led_count; while(1) { P0=0xfe; //P0^0输出低电平 temp = P0; for(led_count=7;led_count>=0;led_count--) { delay_on(255); // temp = temp<<1; // temp += 1; // P0 = temp; temp = _crol_(temp, 1); // _crol_将temp循环左移1位,无需像上面再加1 P0 = temp; } } }
/************************************************ *名称:main *功能:实现数码管的扫描 *输入:无 *输出:无 ************************************************/ void main() { // int i; // int j; // while(1) // { // for(i=0;i<=15;i++) // { // P2 = bit_select[2]; // P0 = seg_table[i]; // delay_on(230); // } // } // while(1) // { // for(j=0;j<=7;j++) // { // P2 = bit_select[i]; // P0 = seg_table[0]; // delay_on(230); // } // } while(1) { seg_lock = 1; P0 = seg_table[1]; seg_lock = 0; P0 = 0x00; P2 = bit_select[0]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[2]; seg_lock = 0; P0 = 0x00; P2 = bit_select[1]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[3]; seg_lock = 0; P0 = 0x00; P2 = bit_select[2]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[4]; seg_lock = 0; P0 = 0x00; P2 = bit_select[3]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[5]; seg_lock = 0; P0 = 0x00; P2 = bit_select[4]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[6]; seg_lock = 0; P0 = 0x00; P2 = bit_select[5]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[7]; seg_lock = 0; P0 = 0x00; P2 = bit_select[6]; delay_on(yuhui); seg_lock = 1; P0 = seg_table[8]; seg_lock = 0; P0 = 0x00; P2 = bit_select[7]; delay_on(yuhui); } }
/** * @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); }