Add color to axes positions
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Mar 2018 22:37:14 +0000 (15:37 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Mar 2018 22:37:14 +0000 (15:37 -0700)
src/avr/step-test/plot_velocity.py
src/avr/step-test/step-test.c

index 979098f588a3404fe9f83aa34e4d3d64f5666a31..ebf7d152c4f0d0ec000bcc488e625b217f180acb 100755 (executable)
@@ -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],
index b529bf0019380960174bb3c240487eabd102c172..f239ede414eba1b2753717f0071e0ccd3fdbc032 100644 (file)
@@ -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();