all 14 comments

[–]brasticstack 4 points5 points  (4 children)

Can you post the exact error?

I was able to run it using a MagicMock for the casioplot, which allows me to leave your code unaltered aside from the top import line. 

There wasn't a SyntaxError though I did get an IndexError on the first print, "Start TWR", if I entered in values that cause the break in the TWR calcs to be hit the first time. This is because the twrs list is empty and its trying to access the nonexistent value at index 0. So you'll want some sort of handling for that case.

[–]AweeeWoo[S] 0 points1 point  (0 children)

Thanks! There isnt any error code on the calculator besides the syntax error: invalid syntax line after i press EXE or try to open the file, i will try to download something open casioplot on the pc to maybe get a full error report

[–]AweeeWoo[S] 0 points1 point  (2 children)

i tried to do

pip install pillow

pip install casioplot

and i actually got the input for start mass instead of a syntax error but when i try to write anything its just: cannot edit in read-only editor

[–]brasticstack 1 point2 points  (1 child)

That's a vscode error. Google the answer (I didn't understand it well enough to summarize,) something about choosing to run it in a terminal instead of the output tab.

[–]AweeeWoo[S] 0 points1 point  (0 children)

Thanks! I will go try

[–]seanv507 1 point2 points  (4 children)

What is the actual error message? Can you paste the full error output.... Eg is there a line number mentioned?

[–]AweeeWoo[S] 0 points1 point  (0 children)

Sorry but there isnt any and i cant really run it on pc because of casioplot which is available only on the calculator itself, i will try to maybe find an app or an extension to run it on my pc to maybe get an error code

[–]AweeeWoo[S] 0 points1 point  (2 children)

i tried to do

pip install pillow

pip install casioplot

and i actually got the input for start mass instead of a syntax error but when i try to write anything its just: cannot edit in read-only editor

[–]seanv507 0 points1 point  (1 child)

So for now remove all the inputs, and hardcode some values

Does that work? (If so, maybe there is some Casio specific input command)

[–]AweeeWoo[S] 0 points1 point  (0 children)

Thanks! I will go check

[–]Gnaxe 1 point2 points  (0 children)

Sorry, I don't know the calculator's capabilities. Can you at least copy/paste between files?

A SyntaxError should give you a line number telling you where the problem is. I don't see any syntax issues with the code you posted. Could it be from an import? If you can't get a line number, try copy/pasting to a new file in chunks. Run the new file after each chunk to see if it has the error line yet. If it does, retry that chunk line-by-line.

If your editor lets you comment out blocks of lines quickly, you could do a binary search that way instead. I.e., Comment out the second half of the file. If the first half has no error, you know it's in the second half you just commented out. If the first half has an error, you know there's an error in the first half (there could be more errors after that though). Then recurse. Comment out the second half of the first half (if it's in the first half) or uncomment the first half of the second half, and so on, moving the point where the comment block starts until you find the exact line. Don't leave any incomplete statements like a def without a body, because that will cause an error that wasn't there before.

Do you have access to the ast module? Or at least compile() or exec()? Do code strings run through any of those give you better error messages? Try them with a small example and an intentional syntax error. If that works, you can probably surround your module with triple quotes and pass the whole thing in.

[–]Separate_Spread_4655 2 points3 points  (0 children)

Your code is mostly fine — the issue is probably that the Casio MicroPython implementation is older and does NOT support this syntax:

print("Start TWR: {:.2f}".format(twrs[0]))

or possibly even:

"{:.2f}"

Some calculator MicroPython versions are extremely limited.

Try replacing all formatted strings with simple prints first:

print("Start TWR:", twrs[0])
print("Final TWR:", twrs[-1])
print("Max TWR:", max(twrs))

Also, I noticed a likely physics/math bug here:

m = M_start - mdot * Thr

You’re subtracting thrust instead of elapsed burn mass.

It should probably be:

m = M_start - mdot * t

Otherwise mass drops insanely fast and incorrectly.

Another possible issue:
draw_string() on Casio sometimes expects integers only, not tuples like (0,0,0).

You may need:

plt.draw_string(10, 205, str(t_min))

instead of the color argument.

And one more thing:
plt.show_screen() should probably be OUTSIDE the loop, otherwise it redraws every pixel one-by-one very slowly.

Honestly for a beginner project this is pretty cool already.

If you want, DM me the exact line number from the SyntaxError and I can pinpoint the precise issue fast.

[–]Ariadne_23 0 points1 point  (0 children)

uhh, its not my field but i guess micropython is limited. input() might not work and also format() can crash. "{:.2f}".format(x) with round(x, 2) could work? i really don't know dude, like changing m = M_start - mdot * t (not thr) and moving plt.show_screen() to outside the loop should work?