-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix get_lamp_coordinates #12
base: indexable_strip_base
Are you sure you want to change the base?
Conversation
if (ledIndex > LED_COUNT) return 0; | ||
|
||
return round(std::fmod(ledIndex, stripXCoordinates)); | ||
return cos16(ledIndex * 1.0/ledPerTurn * 2 * 3.14159265358 * ceil(ledPerTurn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use constants like PI (available with #include <Arduino.h>")
Put temporary computations in preprocessed :
static constexpr uint16_t temp = 1.0/ledPerTurn * 2 * 3.14159265358 * ceil(ledPerTurn);
return cos16(ledIndex * temp);
if (ledIndex > LED_COUNT) return 0; | ||
return (ledIndex * 1.0/LED_COUNT) * INT16_MAX; | ||
|
||
} | ||
|
||
uint16_t to_strip(uint16_t screenX, uint16_t screenY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that the to_screen_x/y/z returns a signed int, this should also take in a signed int
@@ -6,19 +6,21 @@ | |||
#include "../ext/math8.h" | |||
#include "constants.h" | |||
|
|||
uint16_t to_screen_x(const uint16_t ledIndex) { | |||
int16_t to_screen_x(const uint16_t ledIndex) { | |||
if (ledIndex > LED_COUNT) return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return LED_COUNT would be better
uint16_t to_screen_z(const uint16_t ledIndex) { return 1; } | ||
int16_t to_screen_z(const uint16_t ledIndex){ | ||
if (ledIndex > LED_COUNT) return 0; | ||
return (ledIndex * 1.0/LED_COUNT) * INT16_MAX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static constexpr float temp = * 1.0/LED_COUNT) * INT16_MAX;
return ledIndex * temp;
8c8feee
to
3264804
Compare
Refers to issue #11
strip.get_lamp_coordinates
are now actually in Cartesian fomatTODO:
Change coordinates in Cartesian struct from int16 to half floats. Should fix those issues with mapping, but will slow down booting.