From a2a1b8a6982143ab957d1223cfa4ce9bff5b75a3 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 18 Aug 2021 09:15:27 +0200 Subject: [PATCH] Switch LEDs to match selected tool --- src/config/config.h | 2 ++ src/main.cpp | 9 +++++---- src/modules/leds.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/config/config.h b/src/config/config.h index 755c8d7..4abbf4b 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -7,6 +7,8 @@ namespace config { static constexpr const uint8_t toolCount = 5U; ///< Max number of extruders/tools/slots +static constexpr const uint8_t ledCount = 10U; ///< LED count + /// Absolute positions for Idler's slots: 0-4 are the real ones, the 5th index is the idle position static constexpr U_deg idlerSlotPositions[toolCount + 1] = { 45.0_deg, diff --git a/src/main.cpp b/src/main.cpp index d13282b..11f4ca6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -97,7 +97,7 @@ void setup() { // watchdog init shr16::shr16.Init(); - ml::leds.SetMode(4, ml::Color::green, ml::Mode::blink0); + ml::leds.SetMode(0, ml::Color::green, ml::Mode::on); ml::leds.Step(); // @@TODO if the shift register doesn't work we really can't signalize anything, only internal variables will be accessible if the UART works @@ -108,7 +108,7 @@ void setup() { .baudrate = 115200, }; hu::usart1.Init(&usart_conf); - ml::leds.SetMode(3, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(1, ml::Color::green, ml::Mode::on); ml::leds.Step(); // @@TODO if both shift register and the UART are dead, we are sitting ducks :( @@ -127,12 +127,13 @@ void setup() { ml::leds.Step(); // tmc::Init() - ml::leds.SetMode(1, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(3, ml::Color::green, ml::Mode::on); ml::leds.Step(); adc::Init(); - ml::leds.SetMode(0, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(4, ml::Color::green, ml::Mode::on); ml::leds.Step(); + } static constexpr const uint8_t maxMsgLen = 10; diff --git a/src/modules/leds.h b/src/modules/leds.h index 5cb521e..8800996 100644 --- a/src/modules/leds.h +++ b/src/modules/leds.h @@ -79,7 +79,7 @@ public: /// @param color green or red LED /// @param mode to set inline void SetMode(uint8_t slot, Color color, Mode mode) { - SetMode(slot * 2 + color, mode); + SetMode(((config::ledCount/2-1)-slot) * 2 + color, mode); } /// Sets the mode of a LED in a pair