From b67339abe07692badee4b23d44ea0d1f58759a1c Mon Sep 17 00:00:00 2001
From: Tangent 128 <Tangent128@gmail.com>
Date: Sun, 27 Oct 2019 00:58:35 -0400
Subject: [PATCH] Expose a lot of NeopixelLights innards (and add the red led
 to that) to facilitate debugging

---
 itsybitsy_m0_lights/src/lib.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/itsybitsy_m0_lights/src/lib.rs b/itsybitsy_m0_lights/src/lib.rs
index bc081b0..8f9bccc 100644
--- a/itsybitsy_m0_lights/src/lib.rs
+++ b/itsybitsy_m0_lights/src/lib.rs
@@ -12,7 +12,7 @@ use atsamd21g18a::{
     Peripherals
 };
 use core::u8;
-use embedded_hal::digital::v2::OutputPin;
+pub use embedded_hal::digital::v2::OutputPin;
 use hal::{
     clock::GenericClockController,
 };
@@ -21,7 +21,7 @@ use lights::{
     Lights
 };
 
-pub fn boot() -> NeopixelLights<impl OutputPin, impl OutputPin> {
+pub fn boot() -> NeopixelLights<impl OutputPin<Error = ()>, impl OutputPin<Error = ()>, impl OutputPin<Error = ()>> {
     let mut peripherals = Peripherals::take().unwrap();
     let _clock = GenericClockController::with_internal_32kosc(
         peripherals.GCLK,
@@ -35,6 +35,7 @@ pub fn boot() -> NeopixelLights<impl OutputPin, impl OutputPin> {
     NeopixelLights {
         out: pins.d7.into_push_pull_output(&mut pins.port),
         high_out: pins.d5.into_push_pull_output(&mut pins.port),
+        red_led: pins.d13.into_open_drain_output(&mut pins.port),
     }
 }
 
@@ -46,9 +47,10 @@ const ZERO_LOW_CYCLES: u32 = 29; // about 580ns
 const ONE_LOW_CYCLES: u32 = 11; // about 220ns
 const LATCH_CYCLES: u32 = 15000; // about 300us
 
-pub struct NeopixelLights<T: OutputPin, U: OutputPin> {
-    out: T,
-    high_out: U
+pub struct NeopixelLights<T: OutputPin, U: OutputPin, V: OutputPin> {
+    pub out: T,
+    pub high_out: U,
+    pub red_led: V
 }
 
 impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> {
@@ -63,7 +65,7 @@ impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> {
     }
 
     #[inline]
-    fn byte(&mut self, byte: u8) {
+    pub fn byte(&mut self, byte: u8) {
         self.write(byte & 0x80 != 0);
         self.write(byte & 0x40 != 0);
         self.write(byte & 0x20 != 0);