generated from RaccoonlabDev/mini_v2_node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d9ea66
commit 6d12421
Showing
23 changed files
with
346 additions
and
370 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
url = [email protected]:PonomarevDA/tools.git | ||
[submodule "Libs/stm32-cube-project"] | ||
path = Libs/stm32-cube-project | ||
url = https://github.com/RaccoonLabHardware/mini-v2-software.git | ||
url = https://github.com/RaccoonLabHardware/lights-v0-software.git |
Submodule stm32-cube-project
updated
from dd64a6 to 6f196b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/// This software is distributed under the terms of the MIT License. | ||
/// Copyright (c) 2023 Dmitry Ponomarev. | ||
/// Author: Dmitry Ponomarev <[email protected]> | ||
|
||
#include "lights.hpp" | ||
#include <algorithm> | ||
#include "cyphal.hpp" | ||
#include "params.hpp" | ||
#include "main.h" | ||
#include "periphery/ws2812/ws2812.h" | ||
#include "periphery/adc/adc.hpp" | ||
|
||
extern TIM_HandleTypeDef htim2; | ||
|
||
static constexpr uint8_t RED_SCALE = 256 / (reg_udral_physics_optics_HighColor_0_1_MAX_RED + 1); | ||
static constexpr uint8_t GREEN_SCALE = 256 / (reg_udral_physics_optics_HighColor_0_1_MAX_GREEN + 1); | ||
static constexpr uint8_t BLUE_SCALE = 256 / (reg_udral_physics_optics_HighColor_0_1_MAX_BLUE + 1); | ||
|
||
|
||
int8_t RgbLights::init() { | ||
int8_t res; | ||
|
||
res = ws2812bInit(32, &htim2, TIM_CHANNEL_3); | ||
if (res < 0) { | ||
return res; | ||
} | ||
|
||
res = _rgbled_sub.init(); | ||
if (res < 0) { | ||
return res; | ||
} | ||
|
||
res = AdcPeriphery::init(); | ||
if (res < 0) { | ||
return res; | ||
} | ||
|
||
return 0; | ||
}; | ||
|
||
void RgbLights::update() { | ||
static uint32_t next_time_ms = 0; | ||
if (HAL_GetTick() < next_time_ms) { | ||
return; | ||
} | ||
next_time_ms = HAL_GetTick() + 10; | ||
|
||
auto color = _rgbled_sub.get(); | ||
static Leds_Color_t leds; | ||
|
||
// static uint8_t counter = 0; | ||
// leds.colors[counter].shades.red = color.red * RED_SCALE; | ||
// leds.colors[counter].shades.green = color.green * GREEN_SCALE; | ||
// leds.colors[counter].shades.blue = color.blue * BLUE_SCALE; | ||
// counter = (counter + 1) % 32; | ||
|
||
for (uint_fast8_t led_idx = 0; led_idx < 32; led_idx++) { | ||
leds.colors[led_idx].shades.red = color.red * RED_SCALE; | ||
leds.colors[led_idx].shades.green = color.green * GREEN_SCALE; | ||
leds.colors[led_idx].shades.blue = color.blue * BLUE_SCALE; | ||
} | ||
ws2812bSetColors(&leds); | ||
ws2812bStartOnce(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// This software is distributed under the terms of the MIT License. | ||
/// Copyright (c) 2023 Dmitry Ponomarev. | ||
/// Author: Dmitry Ponomarev <[email protected]> | ||
|
||
#ifndef SRC_CYPHAL_APPLICATION_LIGHTS_LIGHTS_HPP_ | ||
#define SRC_CYPHAL_APPLICATION_LIGHTS_LIGHTS_HPP_ | ||
|
||
#include "cyphal_subscribers.hpp" | ||
#include "Udral/rgbled.hpp" | ||
#include "Udral/circuit_status.hpp" | ||
|
||
class RgbLights { | ||
public: | ||
RgbLights(cyphal::Cyphal* driver) : _rgbled_sub(driver), _temp_pub(driver, 0) {}; | ||
int8_t init(); | ||
void update(); | ||
private: | ||
|
||
cyphal::HighColorSubscriber _rgbled_sub; | ||
RaccoonLab::CircuitStatusTemperaturePublisher _temp_pub; | ||
}; | ||
|
||
#endif // SRC_CYPHAL_APPLICATION_LIGHTS_LIGHTS_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// This software is distributed under the terms of the MIT License. | ||
/// Copyright (c) 2022-2023 Dmitry Ponomarev. | ||
/// Author: Dmitry Ponomarev <[email protected]> | ||
|
||
#include "adc.hpp" | ||
#include "main.h" | ||
|
||
extern ADC_HandleTypeDef hadc1; | ||
|
||
int8_t AdcPeriphery::init() { | ||
HAL_ADCEx_Calibration_Start(&hadc1); | ||
_is_adc_already_inited = true; | ||
return 0; | ||
} | ||
|
||
uint16_t AdcPeriphery::get(AdcChannel channel) { | ||
if (!_is_adc_already_inited || channel >= AdcChannel::ADC_NUMBER_OF_CNANNELS) { | ||
return 0; | ||
} | ||
|
||
HAL_ADC_Start(&hadc1); | ||
uint8_t channels_amount = static_cast<uint8_t>(AdcChannel::ADC_NUMBER_OF_CNANNELS); | ||
uint16_t _adc_raw[static_cast<uint8_t>(AdcChannel::ADC_NUMBER_OF_CNANNELS)]; | ||
for (size_t ch_idx = 0; ch_idx < channels_amount; ch_idx++) { | ||
_adc_raw[ch_idx] = (uint16_t)HAL_ADC_GetValue(&hadc1); | ||
} | ||
return _adc_raw[static_cast<uint8_t>(channel)]; | ||
} |
Oops, something went wrong.