Completly moved ledstrip custom colors into NVS
This commit is contained in:
@@ -29,15 +29,15 @@ int8_t selected_color;
|
|||||||
bool state_select_color{false};
|
bool state_select_color{false};
|
||||||
bool last_state = {false};
|
bool last_state = {false};
|
||||||
|
|
||||||
const std::array<CRGB, 8> Colors = {
|
const std::array<uint32_t, 8> Colors = {
|
||||||
CRGB{0,0,0},
|
CRGB_TO_UINT32(CRGB{0,0,0}),
|
||||||
CRGB{255,255,255},
|
CRGB_TO_UINT32(CRGB{255,255,255}),
|
||||||
CRGB{255,0,0},
|
CRGB_TO_UINT32(CRGB{255,0,0}),
|
||||||
CRGB{255,255,0},
|
CRGB_TO_UINT32(CRGB{255,255,0}),
|
||||||
CRGB{0,255,0},
|
CRGB_TO_UINT32(CRGB{0,255,0}),
|
||||||
CRGB{0,255,255},
|
CRGB_TO_UINT32(CRGB{0,255,255}),
|
||||||
CRGB{0,0,255},
|
CRGB_TO_UINT32(CRGB{0,0,255}),
|
||||||
CRGB{255,0,255}
|
CRGB_TO_UINT32(CRGB{255,0,255})
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::array<uint16_t, 8> tft_colors = {
|
const std::array<uint16_t, 8> tft_colors = {
|
||||||
@@ -118,7 +118,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ledstrip_custom_colors[selected_side] = Colors[selected_color];
|
configs.ledstrip.custom_color[selected_side].write(configs.nvs_handle_user, Colors[selected_color]);
|
||||||
// Uncomment to close select color menu on color select
|
// Uncomment to close select color menu on color select
|
||||||
/*
|
/*
|
||||||
state_select_color = false;
|
state_select_color = false;
|
||||||
|
@@ -126,7 +126,11 @@ class AllCustomLedsOffAction : public virtual espgui::ActionInterface
|
|||||||
public:
|
public:
|
||||||
void triggered() override
|
void triggered() override
|
||||||
{
|
{
|
||||||
std::fill(std::begin(ledstrip_custom_colors), std::end(ledstrip_custom_colors), CRGB{0, 0, 0});
|
// std::fill(std::begin(ledstrip_custom_colors), std::end(ledstrip_custom_colors), CRGB{0, 0, 0});
|
||||||
|
for (uint8_t i = 0; i < configs.ledstrip.custom_color.size(); i++)
|
||||||
|
{
|
||||||
|
configs.write_config(configs.ledstrip.custom_color[i], 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -325,30 +325,30 @@ void showCustomColor()
|
|||||||
const auto eighth_length = leds.size() / 8;
|
const auto eighth_length = leds.size() / 8;
|
||||||
const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value);
|
const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value);
|
||||||
|
|
||||||
std::fill(std::begin(leds), std::end(leds), ledstrip_custom_colors[int(Bobbycar_Side::FRONT)]); // Front
|
std::fill(std::begin(leds), std::end(leds), configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT)].value); // Front
|
||||||
std::fill(center - (eighth_length / 2), center + (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK)]); // Back
|
std::fill(center - (eighth_length / 2), center + (eighth_length / 2), configs.ledstrip.custom_color[int(Bobbycar_Side::BACK)].value); // Back
|
||||||
|
|
||||||
#ifdef LEDSTRIP_WRONG_DIRECTION
|
#ifdef LEDSTRIP_WRONG_DIRECTION
|
||||||
std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::BACK_LEFT)]); // Back Left
|
std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_LEFT)].value); // Back Left
|
||||||
std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK_RIGHT)]); // Back Right
|
std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_RIGHT)].value); // Back Right
|
||||||
#else
|
#else
|
||||||
std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::BACK_RIGHT)]); // Back Right
|
std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_RIGHT)].value); // Back Right
|
||||||
std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK_LEFT)]); // Back Left
|
std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_LEFT)].value); // Back Left
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LEDSTRIP_WRONG_DIRECTION
|
#ifdef LEDSTRIP_WRONG_DIRECTION
|
||||||
std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::LEFT)]); // Left
|
std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::LEFT)].value); // Left
|
||||||
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::RIGHT)]); // Right
|
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::RIGHT)].value); // Right
|
||||||
#else
|
#else
|
||||||
std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::RIGHT)]); // Right
|
std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::RIGHT)].value); // Right
|
||||||
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::LEFT)]); // Left
|
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::LEFT)].value); // Left
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LEDSTRIP_WRONG_DIRECTION
|
#ifdef LEDSTRIP_WRONG_DIRECTION
|
||||||
std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_LEFT)]); // Front Left
|
std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_LEFT)].value); // Front Left
|
||||||
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_RIGHT)]); // Front Right
|
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_RIGHT)].value); // Front Right
|
||||||
#else
|
#else
|
||||||
std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_RIGHT)]); // Front Right
|
std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_RIGHT)].value); // Front Right
|
||||||
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_LEFT)]); // Front Left
|
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_LEFT)].value); // Front Left
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user