GLOBAL SITE AUSTRALIAN SITE

Ed.TuneString() implementation details | EdPy Programming | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic3
Ed.TuneString() implementation details
November 20, 2017
10:30 pm
Paul
Member
Members
Forum Posts: 3
Member Since:
November 20, 2017
sp_UserOfflineSmall Offline

It would be MUCH better if you could do something like

text = “d4c4”

tune = Ed.TuneString(text)

I imagine it is because you have to know the tune up front, and cannot dynamically generate it on the robot,

BUT

It would be a big improvement if you could do

tune = Ed.TuneString(“d4c4”)

and EdPy would figure out the length of the string itself.

Why are we forced to provide the length of the string in the parameters?

Please fix, the code generator should be able to figure it out…

cheers,

Paul

November 21, 2017
9:58 am
Paul
Member
Members
Forum Posts: 3
Member Since:
November 20, 2017
sp_UserOfflineSmall Offline

And what is Ed.TuneString(size) for?

Why is it in the documentation?

It doesn’t return anything, so is there a sideeffect of the method?

November 30, 2017
10:20 am
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

Hi Paul

All of the answers to these questions get into how Edison and EdPy actually works.

EdPy is not real python.

It has to be compiled to be run on Edison, therefore it is a “python-like” compiled language.

EdPy has to be compiled because Edison runs own form of assembly, code from EdBlocks, EdWare and EdPy all get compiled down to assembly before being sent to Edison.

Edison has very limited memory for user programs.

Advanced string/array manipulation functions (such as allowing dynamically sized arrays/strings) would either clog up the user programming space or cause the download to be super long and also clog up the user programming space.

As such EdPy needs to know how much space to set aside for your string when you create it. Its is possible to manipulate the values in a string after it has been created, it is just not possible to add additional space to the string.

Ed.TuneString(size) creates the memory location for your sting and returns the pointer to that location

I hope this helps

March 11, 2018
10:01 pm
Avatar
Pavel
Member
Members
Forum Posts: 3
Member Since:
March 8, 2018
sp_UserOfflineSmall Offline

Hi Ben,

I understand what you mean, but this does not actually answers the question. The original question was, why the EdPy cannot do the length conversion automatically.

E.g. Instead of typing

tune = Ed.TuneString(5, “c1d1z”)
Ed.PlayTune(tune)

Which the compiler, for example, translates into:

int[5] tune = [‘c’, ‘1’, ‘d’, ‘1’, ‘z’]

Ed.PlayTune(*tune)

The user could just type

Ed.PlayTune(“c1d1z”)

and the EdPy compiler can translate that to the exactly same output. E.g. not letting Edison CPU calculate the memory required but the EdPy will do that.

March 13, 2018
10:32 am
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

Hi Pavel

The compiler is set up this way so that a user can extend a tune string during the program.

If the compiler locked the size of the string based on the initial input then because of Edisons architecture it would be locked at that size for the whole program and could not be modified.

If the compiler locked the size of the tune based on the input, this code would not be possible:

x=Ed.TuneString(5, “g2z”)

y=Ed.TuneString(5);

Ed.PlayTune(x)
while Ed.ReadMusicEnd()!=Ed.MUSIC_FINISHED:
pass

x[2]=’f’
x[3]=’1′
x[4]=’z’

Ed.PlayTune(x)
while Ed.ReadMusicEnd()!=Ed.MUSIC_FINISHED:
pass

Also any code that builds a tune string based on outside input would not work.

  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Country

Pin It on Pinterest

Share This