Skip to content
Snippets Groups Projects
Commit 70dc8005 authored by fxk8y's avatar fxk8y :spider:
Browse files

Adding gamma correction

parent b0a211d5
No related branches found
No related tags found
No related merge requests found
......@@ -203,6 +203,8 @@ void CyanLight::Controller::setPWM(uint8_t channel, float value) {
return;
}
value = this->gammaCorrector(value);
if (value < 0.0f) value = 0.0f;
if (value > 1.0f) value = 1.0f;
......@@ -213,6 +215,11 @@ void CyanLight::Controller::setPWM(uint8_t channel, float value) {
}
void CyanLight::Controller::setGammaCorrector(GammaCorrector gammaCorrector) {
this->gammaCorrector = gammaCorrector;
}
bool CyanLight::Controller::setFrqRes(uint32_t frq_hz, uint8_t res_bits) {
this->timer_cfg.duty_resolution = (ledc_timer_bit_t)res_bits;
......
......@@ -16,7 +16,7 @@ namespace CyanLight {
const uint8_t channelGPIOS[MAX_CHANNELS] = { 27, 16, 17, 18, 19, 21 };
typedef std::function<void()> PacketHandledCallback;
typedef std::function<float(float)> GammaCorrector;
class Controller {
public:
......@@ -24,6 +24,7 @@ namespace CyanLight {
void setPWM(uint8_t channel, float value);
void setGammaCorrector(GammaCorrector gammaCorrector);
uint8_t getChannelCount();
......@@ -62,6 +63,8 @@ namespace CyanLight {
ledc_timer_config_t timer_cfg;
GammaCorrector gammaCorrector = [](float f) { return f*f; };
PacketHandledCallback packetCallback = []() {};
void callPacketCallback();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment