From 0df8a4ced02a59bd5e4290323bd8edd23b228e88 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Tue, 13 Mar 2018 15:37:14 -0700 Subject: [PATCH] Add color to axes positions --- src/avr/step-test/plot_velocity.py | 7 ++-- src/avr/step-test/step-test.c | 54 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/avr/step-test/plot_velocity.py b/src/avr/step-test/plot_velocity.py index 979098f..ebf7d15 100755 --- a/src/avr/step-test/plot_velocity.py +++ b/src/avr/step-test/plot_velocity.py @@ -121,9 +121,6 @@ if __name__ == '__main__': axes = [] axes_text = [] - for i in range(5): - axes.append(ax.plot([], [])[0]) - font = dict(fontsize = 14, family = 'monospace') axes_text.append(plt.text(0, 11700, '', **font)) @@ -132,6 +129,10 @@ if __name__ == '__main__': axes_text.append(plt.text(800, 10500, '', **font)) axes_text.append(plt.text(1500, 11700, '', **font)) + for i in range(5): + axes.append(ax.plot([], [])[0]) + axes_text[i].set_color(axes[i].get_color()) + plot.update_text(axes_text, 0, [0] * 4) anim = animation.FuncAnimation(fig, plot.update, fargs = [axes, axes_text], diff --git a/src/avr/step-test/step-test.c b/src/avr/step-test/step-test.c index b529bf0..f239ede 100644 --- a/src/avr/step-test/step-test.c +++ b/src/avr/step-test/step-test.c @@ -99,33 +99,6 @@ int32_t channel_read(int i) { ISR(PORTC_INT0_vect) {reset = 32;} -void channel_init(int i) { - uint8_t step_pin = channel[i].step_pin; - uint8_t dir_pin = channel[i].dir_pin; - - // Configure I/O - DIRCLR_PIN(step_pin); - DIRCLR_PIN(dir_pin); - PINCTRL_PIN(step_pin) = PORT_SRLEN_bm | PORT_ISC_BOTHEDGES_gc; - PINCTRL_PIN(dir_pin) = PORT_SRLEN_bm | PORT_ISC_BOTHEDGES_gc; - - // Dir change interrupt - PIN_PORT(dir_pin)->INTCTRL |= PORT_INT0LVL_MED_gc; - PIN_PORT(dir_pin)->INT0MASK |= PIN_BM(dir_pin); - - // Events - EVSYS_CHMUX(i) = PIN_EVSYS_CHMUX(step_pin); - EVSYS_CHCTRL(i) = EVSYS_DIGFILT_8SAMPLES_gc; - - // Clock - channel[i].timer->CTRLA = TC_CLKSEL_EVCH0_gc + i; - channel[i].timer->INTCTRLA = TC_OVFINTLVL_HI_gc; - - // Set initial clock direction - channel_update_dir(i); -} - - ISR(TCC1_OVF_vect) { if (reset) reset--; @@ -156,6 +129,33 @@ static void _splash(uint8_t addr) { } +void channel_init(int i) { + uint8_t step_pin = channel[i].step_pin; + uint8_t dir_pin = channel[i].dir_pin; + + // Configure I/O + DIRCLR_PIN(step_pin); + DIRCLR_PIN(dir_pin); + PINCTRL_PIN(step_pin) = PORT_SRLEN_bm | PORT_ISC_BOTHEDGES_gc; + PINCTRL_PIN(dir_pin) = PORT_SRLEN_bm | PORT_ISC_BOTHEDGES_gc; + + // Dir change interrupt + PIN_PORT(dir_pin)->INTCTRL |= PORT_INT0LVL_MED_gc; + PIN_PORT(dir_pin)->INT0MASK |= PIN_BM(dir_pin); + + // Events + EVSYS_CHMUX(i) = PIN_EVSYS_CHMUX(step_pin); + EVSYS_CHCTRL(i) = EVSYS_DIGFILT_8SAMPLES_gc; + + // Clock + channel[i].timer->CTRLA = TC_CLKSEL_EVCH0_gc + i; + channel[i].timer->INTCTRLA = TC_OVFINTLVL_HI_gc; + + // Set initial clock direction + channel_update_dir(i); +} + + static void init() { cli(); -- 2.27.0