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

ColorRemap block is generating NaN in first argument #434

Closed
zfi opened this issue May 16, 2020 · 12 comments
Closed

ColorRemap block is generating NaN in first argument #434

zfi opened this issue May 16, 2020 · 12 comments
Assignees
Labels
bug Something isn't working deployment/staged Issue is pending in staged code. Ready for verification when deployed. task/verify Bug or feature is ready to be tested and verified Verified The reported issue has been mitigated

Comments

@zfi
Copy link
Contributor

zfi commented May 16, 2020

The simple project below is generating code with a 0x NaN in the remapColor() call.

Screen Shot 2020-05-15 at 5 41 34 PM

#include "simpletools.h"
#include "ssd1331.h"
#include "colormath.h"

// ------ Global Variables and Objects ------
screen *oledc;// ------ Libraries and Definitions ------


// ------ Main Program ------
int main() {
  oledc = ssd1331_init(17, 6, 5, 3, 2, 96, 64);
  fillRect(oledc, 0, 0, 96, 63, remapColor(0x NaN, "8R8G8B", "5R6G5B"));
}

@zfi zfi added the bug Something isn't working label May 16, 2020
@zfi zfi self-assigned this May 16, 2020
@zfi
Copy link
Contributor Author

zfi commented May 22, 2020

The C code generator for the color_value_from block is returning a function call.

getColorRRGGBB(50, 50, 50)

The C code generator for the OLED triangle block is expecting a hexadecimal value in RRGGBB format. The actual call to getColor() does return an appropriate value, so the call should be inlined in the C code output and not converted to a hex value.

In this example project, using a color value generates reasonable code.

Screen Shot 2020-05-21 at 5 50 05 PM

// ------ Libraries and Definitions ------

#include "simpletools.h"
#include "ssd1331.h"
#include "colormath.h"

// ------ Global Variables and Objects ------
screen *oledc;


// ------ Main Program ------
int main() {
  oledc = ssd1331_init(17, 6, 5, 3, 2, 96, 64);
  fillRect(oledc, 0, 0, 96, 63, remapColor(0xff0000, "8R8G8B", "5R6G5B"));
}

If the color value is replaced with the problematic color_value_from block, the code generated is now reasonable.

Screen Shot 2020-05-21 at 5 54 16 PM

// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "ssd1331.h"
#include "colormath.h"

// ------ Global Variables and Objects ------
screen *oledc;



// ------ Main Program ------
int main() {
  oledc = ssd1331_init(17, 6, 5, 3, 2, 96, 64);
  fillRect(oledc, 0, 0, 96, 63, remapColor(getColorRRGGBB(50, 50, 50), "8R8G8B", "5R6G5B"));
}

A workaround for this issue is to assign the value of the color_value_from block to a variable and then assign that variable to the color input of the OLED triangle block

Screen Shot 2020-05-21 at 6 00 39 PM

@zfi zfi mentioned this issue May 22, 2020
@Automaxion
Copy link

I tried your block-code exactly as you show with 'item' declared first and then used as the color and it still does not work and still gives 'not a number':

// Libraries and Definitions #include "simpletools.h"
#include "colormath.h"
#include "ssd1331.h"

// Global Variables and Objects screen *oledc;
int item;

// Main Program int main() {
oledc = ssd1331_init(17, 6, 5, 3, 2, 96, 64);
item = (getColorRRGGBB(50, 50, 50));
fillRect(oledc, 0, 0, 96, 63, remapColor(0x NaN, "8R8G8B", "5R6G5B"));
}

@zfi
Copy link
Contributor Author

zfi commented May 27, 2020

The "get [color] value from" block is also not returning a 24 bit value as expected. It is instead returning a string that is a function call to convert the selected color. The previous patch applied to the OLED triangle block may work, but that patch will have to applied to each block that expects a color input.

It seems reasonable that these two blocks should be updated to return a 24 bit value.

Screen Shot 2020-05-27 at 3 13 14 PM

@Automaxion
Copy link

Any idea when this will be resolved, such that I can use these blocks without error?

@pjewald pjewald added this to the v1.5.0 Release milestone Jun 2, 2020
pjewald added a commit that referenced this issue Jun 3, 2020
@zfi zfi added deployment/staged Issue is pending in staged code. Ready for verification when deployed. task/verify Bug or feature is ready to be tested and verified labels Jun 3, 2020
@zfi
Copy link
Contributor Author

zfi commented Jun 3, 2020

@Automaxion The update that addresses this issue is running on our staging server, SoloCup. Please try running your project there and let me know if the issue is resolved.

@Automaxion
Copy link

Automaxion commented Jun 3, 2020

In my more complicated program, I use get colour blocks for red and blue and calculate the green level. Using a simplified version as attached, it still does not compile using SoloCup.

simple solocup

simple solocup errors

@zfi
Copy link
Contributor Author

zfi commented Jun 3, 2020

Thanks for the additional feedback. Digging deeper into the problem we discovered that the OLED blocks were incapable of handling input from variables under certain conditions. These blocks expected numeric inputs in the form 0xRRGGBB. Variable values were evaluated to NaN, which was the root issue. The code has been improved and is available for further testing on SoloCup.

PR #450 contains the update for this issue.

@Automaxion
Copy link

It appears to work now, both for the simple code, as above and in my project.

@Automaxion
Copy link

I hope the update comes soon since using SoloCup keeps failing on download to Flip after compiling. It works once but then I need to restart and reconnect to Launcher (now v1.0.1)

@zfi
Copy link
Contributor Author

zfi commented Jun 5, 2020

I have created a new issue for the download failures. We'll track it there.

This issue appears to be resolved in v1.5.0-b4.

@zfi zfi added the Verified The reported issue has been mitigated label Jun 5, 2020
@PropGit
Copy link
Collaborator

PropGit commented Jun 5, 2020

@Automaxion - Please see Issue #452 to answer a question about the download problems.

@zfi zfi closed this as completed Jun 11, 2020
@Automaxion
Copy link

Automaxion commented Jun 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deployment/staged Issue is pending in staged code. Ready for verification when deployed. task/verify Bug or feature is ready to be tested and verified Verified The reported issue has been mitigated
Projects
None yet
Development

No branches or pull requests

4 participants