Jump to content
THIS IS THE TEST SITE OF EUROBRICKS!
THIS IS THE TEST SITE OF EUROBRICKS!

Featured Replies

Posted

Does anyone know of a method of getting some clarification on what the expected output of programs should be?
I've tried going through LEGO Customer Service but I'm not really getting anyway (they also can't receive images / videos via the support emails so that makes it harder)

I've been writing some small testing scripts to extract behaviours of the different micropython functions on the hub but some of the outcomes are odd.

Here's an example in the app using the blocks:

rotate.jpg.c8ca06950f9dd83289b76075650e4d98.jpg

Or in micropython:

from hub import display
from utime import sleep

display.pixel(0,0,100)
sleep(1)
display.rotation(90)
sleep(1)
display.pixel(0,0,100)
sleep(1)
display.rotation(-90)
sleep(1)
display.pixel(0,0,0)

They both give the same results:

output_actual.gif.3a3bac6028aac25b3ef9037c494fc6ce.gif

While I would expect it to have done something like this:

output_expected.gif.6049ca67032d3303f26af5497ba6fda3.gif

You have to turn the pixles off manually I think. Otherwise they stay activated.

  • Author

I'm happy with them staying activated, I'm just confused about what rotate is actually doing.
I'd either expect it to rotate what's on the screen but not change the indexing of pixels (so 0,0 is always the top left)
Or I'd expect it to rotate what's on the screen and change the indexing (so 0,0 would be the top right after a 90 degree rotation and it would be the bottom right after a 180 degree rotation)
Neither of these is what happens.

Edited by gw_shadow

I think display.rotation() is equivalent to the "set orientation to" block rather than the "rotate orientation" block.

  • Author

I've tried that too. If I run this script:

from hub import display
from utime import sleep

display.clear()
sleep(1)

display.pixel(0,0,100)
sleep(1)
display.rotation(90)
sleep(1)
display.pixel(0,0,100)
sleep(1)
display.rotation(90)
sleep(1)
display.pixel(0,0,100)
sleep(1)
display.rotation(90)
sleep(1)
display.pixel(0,0,100)
sleep(1)
display.rotation(90)
sleep(1)

I get this result:

output.gif.2218d85b7bfd33d84cc911219563af75.gif

I'm at a loss.

Ah, and if I run it twice in a row without doing a soft reset in between it does this...

output2.gif.a50fb9a9e86f6cb7f6ff02a4fef478e8.gif

---

Edit: Ah the reason for the first result being super weird (jumping 180) seems to be some internal state that only gets applied after the first rotate call, if I do a hard reset then run the script it only jumps 90 and otherwise follows the same pattern as the final gif.

Edited by gw_shadow

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.
Sponsored Links