jb3 / language-circuitpython

A plugin for the Atom Editor to allow interfacing with CircuitPython devices.
MIT License
17 stars 4 forks source link

Serial plotter doesn't seem to work? #6

Closed AdinAck closed 4 years ago

AdinAck commented 4 years ago

I made my board print a number in a while True loop and I could see it in the serial monitor but not in the serial plotter.

jb3 commented 4 years ago

Hey @AdinAck

Sorry to hear you're experiencing this bug.

Could you provide the code you are using? If it's long you can put it at https://gist.github.com/

FYI, for something to appear in the plotter you cannot print it like

print(1)
# Prints "1"

You must use:

print((1, ))
# Prints "(1,)"
AdinAck commented 4 years ago

Awesome, that works! Maybe include that in the readme?

jb3 commented 4 years ago

Good idea, will look into that. It is covered briefly in https://learn.adafruit.com/make-it-graph-plot/circuitpython-and-mu

The code below will read the Circuit Playground Express light sensor and send the output to the Serial port (also called the REPL) in a form called a Tuple. A tuple is just a group of fixed values gathered together, surrounded by parenthesis. For one value, a tuple would be shown as (tuplevalue, ), to two (tupleval1, tupleval2), etc. The comma in the first one makes sure it's a tuple and not a number in parenthesis like in math.

AdinAck commented 4 years ago

So now that I have it working I have noticed that it is very slow, updating maybe once every 7-15 seconds, is there a reason for this, can I somehow increase the update speed?

jb3 commented 4 years ago

I can't reproduce that locally.

It may sound counter-intuitive but could you try add a delay somewhat like 0.05 seconds between, this might be better.

AdinAck commented 4 years ago

Unfortunately, I cannot try that in this case because my loop has to run as fast as possible for it is updating a screen. The value I am printing is the framerate. The Arduino serial plotter does it fast so I am interested as to why it is slow for me but not for you. The value being printed repeats a lot, could that be the issue? I'll pug in another board and run a test program to try and find the scenario required to recreate my issue.

jb3 commented 4 years ago

Hmm, I'll give it some further testing tomorrow, but I don't know of any snags in the rendering that would cause huge delay.

AdinAck commented 4 years ago

Ok I ran the test and here is the result:

Here is the code:

import time

i = 0
while True:
    print((i,))
    i += 1
    time.sleep(.05)
    if i >= 100:
        i = 0

This will only update the plotter once, right when it runs. I tried setting the delay time to .25 seconds, no change. When I completely removed the delay, the plotter started slow but then sped up very fast! but was erratic and clearly not updating as fast as the loop on the board.

Here is a video: link

dunkmann00 commented 4 years ago

The pull request I just submitted should fix this problem. I tested your example with it and it worked fine for me.

jb3 commented 4 years ago

Fixed in 0.7.2

AdinAck commented 4 years ago

Works, Thank you!