Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ct converting not working correctly #96

Closed
Schmakus opened this issue Feb 28, 2023 · 0 comments
Closed

Ct converting not working correctly #96

Schmakus opened this issue Feb 28, 2023 · 0 comments

Comments

@Schmakus
Copy link
Owner

Schmakus commented Feb 28, 2023

Describe the bug
the function convertCt not working correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '....'
  4. See error

Expected behavior

function kelvinToRange(kelvin, outMinCt, outMaxCt) {
	const minCt = 2700;
	const maxCt = 6500;
  if (kelvin < minCt) {
    return outMinCt; // below the specified range
  } else if (kelvin > maxCt) {
    return outMaxCt; // above the specified range
  } else {
    const percentValue = (kelvin - minCt) / (maxCt - minCt);
    const rangeValue = percentValue * (outMaxCt - outMinCt) + outMinCt; // map the range to the output range
    return Math.min(Math.max(rangeValue, outMinCt), outMaxCt); // constrain the range to outMinCt and outMaxCt
  }
}

const kelvinValue = 2800; // replace this with your actual Kelvin value
const outMinCt = 2703;
const outMaxCt = 6530;
const rangeValue = kelvinToRange(kelvinValue, outMinCt, outMaxCt);
console.log(rangeValue); // output: 2753.7037

Screenshots & Logfiles
If applicable, add screenshots and logfiles to help explain your problem.

Versions:

  • Adapter version:
  • JS-Controller version:
  • Node version:
  • Operating system:

Additional context
Add any other context about the problem here.

Schmakus added a commit that referenced this issue Mar 21, 2023
-   (Schmakus) Fix calculation of color-temperature and added ct-reverse mode ([#96] [#89])
-   (Schmakus) Added brightness converting. Now you can use brighness states with 0-254 or 0-100
-   (Schmakus) some little bugfixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant