#circuitpython-dev

1 messages ยท Page 144 of 1

stuck elbow
#

for example, chain() should be an operator

manic glacierBOT
manic glacierBOT
cunning crypt
#

Does the NRF52 need any special programmer (IE, JTAG) for putting CircuitPython on it, or do you just need the device and a computer?

raven canopy
#

@cunning crypt Feather nRF? or just the chip?

cunning crypt
#

The chip.

#

Like, if I designed a PCB

#

and wanted to put CircuitPython on it

raven canopy
#

yeah, you'll need a JLINK, IIRC.

cunning crypt
#

(I know CP on NRF52 isn't done yet)

#

bah, J-links are so expensive

#

Yes, I know there's a $20 one, but that's an EDU version and this would be something to sell, so the EDU board is right out

raven canopy
#

enroll in my emu farming school, and you...oh. n/m.

#

๐Ÿ˜„

cunning crypt
#

Emu school? Does it teach military tactics?

raven canopy
#

i can neither confirm nor deny the existence of a select group of individual classes designed for tactical emu usage. ๐Ÿ•ต

cunning crypt
#

Well, I was thinking about the Emu's track record. The one war they were in, they did pretty well

#

The Emu War, also known as the Great Emu War, was a nuisance wildlife management military operation undertaken in Australia over the latter part of 1932 to address public concern over the number of emus said to be running amok in the Campion dist...

manic glacierBOT
manic glacierBOT
#

Sounds good, thanks. I'll double check the linker scripts, etc., to make sure they align with requirements for the internal filesystem, etc. I'm wrapping up another project today and tomorrow, but Friday is perfect for me to come back to this and have a look at what you've put together for a PR! We're poking at some higher level wrappers for BLE as well since the current API is pretty low level and not as friendly as it could be. If you have any example python files to push out to test agains...

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

This is very odd:

  1. Get the .py version of the CPX library: https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/releases/download/1.2.0/adafruit-circuitpython-circuitplayground-py-1.2.0.zip
  2. Unzip it and put the adafruit_circuitplayground directory at the top level of CIRCUITPY
  3. In the repl, try to import it. Note that the Memory Error: is incomplete.
Adafruit CircuitPython 2.2.1 on 2018-01-23; Adafruit CircuitPlayground Express with samd21g18
>>> from ...
raven canopy
#

is documentation too good sometimes? now that i'm done with doc strings in my library, i get the constant MemoryError when importing (on an Express).

#

library is now 14KB (up from 4KB). working on 2.2.0, to ensure compatibility.

digital ingot
#

hey i wanted to ask about the upcoming m4 boards. I am working on making an fft based wearable music visualizer and was wondering if there is any roadmap for a m4 based flora type device (or even a feather if flora is far away). Even if there are any beta boards available I am down, ill send bug reports and try to help fix it if i run into any blockers!

manic glacierBOT
manic glacierBOT
#

Yes, I added the flash fatfs in the linker scripts, for example i just used the peripheral and scanner in nrf/examples. I noticed the Central is commented out so I guess it's not available yet? I also have a question regarding the umachine module, I see it's missing in the module listbut some of the parts work, maybe we could re-add it? Is there any TODO/schedule/issue list for the nrf port so I could go through them and try fixing them?

cunning crypt
#

@digital ingot At the moment there's no solid release date for even the Metro M4, aside from "soon-ish"

#

After that, though, it has been said that any sort of new board would be M4

stuck elbow
#

except for the itsy bitsy m0

#

and trinket m0 express

cunning crypt
#

Well, if I rember correctly, thatvs been planned for a while

manic glacierBOT
sharp bramble
#

Does anyone know how to close a tab in Mu? Or, is that a code contribution on my part waiting to happen?

#

Mu won't let two files of the same name be open, and it can get into a state where it doesn't want to open a newer version of a file (on the CPx) if it thinks the file is already open elsewhere. But, I can't figure out how to close the tab. Hopefully, it's documented somewhere, and I'm just desperate before class.

manic glacierBOT
manic glacierBOT
#

The placement in sys.path is not always the issue, and may be a red herring. Here are more oddities, testing with various versions.
In this case the library is in lib/. If I make a typo on the first import, then the correct import does not do the printf expansion:

Adafruit CircuitPython 3.0.0-alpha.1-109-g7c6adaa66-dirty on 2018-02-01; Adafruit CircuitPlayground Express with samd21g18
>>> 
>>> from adafruit_circuitplayground import cpx
Traceback (most recent call last):
  File...
solar whale
#

@tulip sleet @slender iron did something fail with this mornings bundle release?

tulip sleet
#

@solar whale, yeah it did, travis failed. Leaving it for @slender iron to check on.

#

lots of changes yesterday

solar whale
#

yup - I saw the new issue on the bundle and was puzzled, but I think it was just because the usual .zip files are not there.

slender iron
#

@raven canopy more docs is better. mpy-cross will strip them out for low-memory devices

#

@tulip sleet @solar whale looking now

#

looks like the travis check on the fancyled bundle wasn't strict enough and then adabot came along and changed it back to the current release which breaks travis

solar whale
#

battling bots

slender iron
#

who is around for a quick review?

tidal kiln
#

โœ‹

slender iron
#

thanks for the review @tidal kiln

tidal kiln
#

@slender iron np. curious why that PR was needed. i thought once in the bundle updates would just be brought in automatically.

slender iron
#

@tidal kiln I did it myself so that it'd be done earlier. adabot would automatically do it tonight but I wanted to push another since last nights failed

tidal kiln
#

ah

manic glacierBOT
timber lion
manic glacierBOT
#

@arturo182 The machine module is a MicroPython API so its not urgent for us to get working. If you'd like to then we'll merge it in. Our focus is the CircuitPython APIs defined in the shared-bindings and implemented in common-hal within each port. #526 has a list of some that are missing currently.

We have a short list of issues for nrf52 here: https://github.com/adafruit/circuitpython/issues?q=is%3Aissue+is%3Aopen+label%3Anrf52 Feel free to file more as you find them too.

tidal kiln
#

'tuple' rhymes with 'couple'? huh. i've been doing it wrong.

stuck elbow
#

what did you rhyme it with?

tidal kiln
#

more like 'scruple'

stuck elbow
#

to my non-native-speaker ear there is no difference

manic glacierBOT
tidal kiln
#

yah, it's subtle. 'uh' vs. 'oo'.
maybe 'cup' vs. 'clue' (if that helps)

raven canopy
#

@tidal kiln you're not alone. I'm a "toople" sayer as well.

stuck elbow
#

I see, yeah, It's more like topple than toople

tidal kiln
#

yep

stuck elbow
#

we should all just be writing IPA and there would be no problems

manic glacierBOT
#

@arturo182 I'm currently looking at higher level BLE helper classes on top of the current lower level API where an above average understanding of BLE at a packet level is required. A colleague of mine is working on USB for the x40. Other than that, there isn't currently a specific ToDo list for the 52832 and 52840 familiies, but as @tannewt mentioned feel free to add module-level requests to #526, or file specific x40 issues here in a checklist at the top?

neon ferry
#

Hello. New here. Looking to convert seconds since 1970 using CircuitPython, but noticed CircuitPython time is a subset of MicroPython ctime available. Has anyone tried doing this another way? (Making a clock that update time from NIST.) Thanks! Jim.

#

no ctime available I mean*

slender iron
#

hi @neon ferry at this point you'll need to do the math yourself. it would be a good api for us to have on our time module though

neon ferry
#

I see. So, CircuitPython is by design a subset of MicroPython for like space reasons?

#

And thanks for the reply btw

slender iron
#

yeah, its meant to be a subset of Python's API due to space reasons

#

we want people to be able to learn on CircuitPython and move to CPython (desktop Python) without much trouble

neon ferry
#

It's neat, and I am starting too appreciate the amount of work that goes into it, so thanks!

slender iron
#

its weird to me that ctime returns a string

neon ferry
#

I'm a long time C++ developer, so it all seems weird to me ๐Ÿ˜ƒ

slender iron
#

๐Ÿ˜ƒ

#

I think we'd add gmtime if anything

#

our RTCs use time.struct_time so that'd make more sense to support

neon ferry
#

When you say "add", do you like try to port stuff by compiling C++ under the hood of the python interface, or what? Just curious.

slender iron
#

yeah, the time module is C code so it'd be added there

manic glacierBOT
#

Our time module is missing gmtime which converts a number of seconds after January 1, 1970 to a time.struct_time: https://docs.python.org/3/library/time.html#time.gmtime

The Python-> conversion would be added here: https://github.com/adafruit/circuitpython/blob/master/shared-bindings/time/__init__.c

and the implementation in a new time/__init__.c here: https://github.com/adafruit/circuitpython/tree/master/shared-module

It'd make sense to support converting to and from struct_time...

neon ferry
#

Neat thanks!

slender iron
#

๐Ÿ˜„

#

let me know if you want to try adding it ๐Ÿ˜‰

manic glacierBOT
#

Sounds good!

On Thu, Feb 1, 2018 at 10:28 AM Dan Halbert notifications@github.com
wrote:

I'll debug it in 3.0. If it's a serious memory problem I'll backport.

โ€”
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/adafruit/circuitpython/issues/569#issuecomment-362358118,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADNqfF3US6gv5tOaZCngIt8F9IJHl4xks5tQgJigaJpZM4R0_i9
.

neon ferry
#

I'll check it out! (I've never used github!) It would also be interesting to get the compiler toolchain going on my machine. Neat.

slender iron
#

what os are you running?

neon ferry
#

Win10, but I could anything going.

#

get8

#

get*

slender iron
#

k, windows is bit trickier than mac or linux

neon ferry
#

I have a mac mini langushing in the corner.

opaque patrol
#

Virtual Machines are great

slender iron
opaque patrol
#

I think I was able to get it to build on Raspberry pi at one time

slender iron
#

although it says micropython the build instructions are the same for circuitpython

neon ferry
#

I have a Huzzah, not even sure of the chip...

stuck elbow
#

huzzah has esp8266

neon ferry
#

I guess if one changed the project code, then one would have to check it on each chip too, right? To be ethical ๐Ÿ˜ƒ ?

opaque patrol
#

Circuit Playground Express is the best to learn CP on, it has so many components to play with and learn

neon ferry
#

Ah the round guy with lights

slender iron
#

you can test on one board

#

the tiem changes should work everywhere

opaque patrol
#

and buttons, and accelerometer and light sensor and microphone and speaker and temp sensor

neon ferry
#

I guess I am used to my office where you haev to run regresion tests on alll hardware and then send to a test team ๐Ÿ˜ƒ

stuck elbow
#

the huzzah has an rtc, which is nice

slender iron
#

we do have a continuous testing setup here at my house with boards but its pretty flaky still

neon ferry
#

How many boards do you have for it?

slender iron
#

most of the m0s

#

I think its 7 now

neon ferry
#

I never thought about it but each delivery could be a major pain for testing for you all

#

Although the function that we are talking about is probably low risk

opaque patrol
#

We all get to test changes

neon ferry
#

Oh I see then it becomes official after you all check it out?

#

Neat

opaque patrol
slender iron
#

@neon ferry yeah, we'd add it to the core

#

@opaque patrol will look now

#

oh! I just fixed this

#

we used to require __init__.py for packages

#

then we can release a new build tools and it'll be fixed

heavy galleon
#

def str(self):
"""
Returns the name of the State.
"""
return self.class.name

#

class LockedState(State):
"""
The state which indicates that there are limited device capabilities.
"""

def on_event(self, event):
    if event == 'pin_entered':
        return UnlockedState()

    return self
#

sorry about pasting that there. can anyone tell me why the return statement doesnt work for the class lockedstate? it says AttributeError: 'LockedState' object has no attribute 'class'

#

but it is the class

opaque patrol
#

@heavy galleon fyi, the back-tick (key to the left of number 1) 3 times before and after the code will create a code - block like this

heavy galleon
#
    """
    The state which indicates that there are limited device capabilities.
    """

    def on_event(self, event):
        if event == 'pin_entered':
            return UnlockedState()

        return self

def __str__(self):
        """
        Returns the name of the State.
        """
        return self.__class__.__name__
opaque patrol
#

Usually these kind of attribute errors, are actually due to inconsistencies with spacing and tabs in the source file

heavy galleon
#

cool thanks for that

#

this is from a tutorial and I understand what its saying but I dont really see why I can return the class and name of self

opaque patrol
#

make sure the dunder str function is indented as a member of the LockedState class

heavy galleon
opaque patrol
#

No problem, I ran into a simliar problem once and drove me crazy until I figured out you shouldn't mix spaces and tabs for indent.

heavy galleon
#

They were from three separate code files all really small and simple

#

I was given good advice for my project that a state machine is the way to go. I have tried following 3 different tutorials and none of the code from any of them work even off a copy and paste like this one is giving me an error. I did a tutorial on classes and i understand them pretty well now but i need exactly what this tutorial is doing just a simple 2 state machine.

opaque patrol
#

Are you looking for help implementing a state machine in Circuit Python or just in general?

heavy galleon
#

in circuit python on a trinket m0

opaque patrol
#

Can I get more details, there might be an easier solution that won't take up as much memory

#

The tutorial you linked is describing the State Design Pattern which is just one way to implement a state machine.

heavy galleon
#

I am doing this project in python as it is my goal this year to learn python. I am using a trinket m0 as it is the most cost effective chip i could use and get in quantities. The project is a simple relay timer. press a button and the relays turn on and automatically turn off after the set time. The button I want to act with 2 functions. First press starts the timer but if you press a second time before the timer completed it will turn them off and reset waiting for another start press. This is for a saftey incase someone wants to cut the power as there is no other power switch.

#

the two function button is where I want the state machine

opaque patrol
#

Okay, have you considered using a dict object as a state machine?

#

here is a simple example. create a dict object with states as the keys and functions as the values....``` state_dict = {
0 : default_func,
1 : func_one,
2 : func_two,
# etc...
}

heavy galleon
#

I am pretty new to python so I made this originally work only using functions and alot more lines of code than needed. Problem I was having a recursion from repeatedly calling the function and was told a state machine is the way to fix that. I dont know the differnet types of state machine is there somewhere I can get a tutorial on how to do that?

#

I havent really looked into dictionary objects do you recommend i do so?

stuck elbow
#

well, with just two states, you can really get away with just using a flag

opaque patrol
#

It is a simple and elegant way to implement a state machine

#
state = 0

def get_input():
    move = 0
    if buttonA.value:
        led.value = True
        time.sleep(.01)
        while buttonA.value:
            pass
        move = -1
    if buttonB.value:
        led.value = True
        time.sleep(.01)
        while buttonB.value:
            pass
        move = +1
    led.value = False
    return move

def default_func():
    '''
    This is the default state function
    '''
    print("In default state")

def func_one():
    '''
    This is the function for state 1
    '''
    print("In first state")

def func_two():
    '''
    This is the function for state 2
    '''
    print("In second state")

state_dict = {
    0 : default_func,
    1 : func_one,
    2 : func_two,
    # etc...
}

while True:
    state += get_input()
    state += state_dict[state % len(state_dict)]()
#

I omitted the setup for the led's and buttons, but you should be able to get the idea, get input simply checks for a a button press and returns -1, 0, or 1 which changes the state variable, I than use this to call the function for the correct state.

#

the code I pulled this from also had functions that could change the state. If you want more precise control of what state a function sets than change the last statement to state = state_dict[state % len(state_dict)]()

heavy galleon
#

and bacause this is using a dictionary its not going to eat as much stack and cause recursion? Seems like it would plug into my code pretty well.

opaque patrol
#

The issue I ran into was if I pressed any buttons while in a state that took a long time. So I added a get_input call inside a large loop in that function and broke out of the loop if a button was pressed and returned the value

heavy galleon
#

yeah the button press needs to be able to interrupt

#

and really I can turn it on and off almost 20 times before I get recursion but I would like it to be infinite if possible

#

if the dictionary object takes care of that I will impliment it

neon ferry
#

Where is end_time used?

#

(besides the print)

opaque patrol
#

You could try something like this, change funct0 to simple pass (do nothing), get rid of the buttonpressed variable and have funct1 return 2 and funct2 return 1

#

then add this to the end of the file in place of what funct0 was doing ```
state_dict = {
0 : funct0,
1 : funct1,
2 : funct2,
# etc...
}

state = 1

while True:

# check for button press...
if button.value:
    while button.value:
        # wait for button to be released
        pass  
    state = state_dict[state]()

else:    # button has not been pressed
    time.sleep(.10) 
#

oops, I had to make a quick change

heavy galleon
#

@neon ferry it should be in function0 while button has been pressed if end_time then stop but it is not in there on git right now

opaque patrol
#

you want the initial state to be 1

heavy galleon
#

@opaque patrol thanks Im gonna add it in right now and see what I can get going with it

opaque patrol
#

I see where you are setting end_time in funct1 but that isn't being checked anywhere

heavy galleon
#

yea that should be a condition after the start button has been pressed and reset if the stop button is pressed

opaque patrol
#

I suggest you create a global variable for end_time and set that in funct1 and then check that in the else portion inside the while loop

heavy galleon
#

ok Im going to try to doctor this up right now

opaque patrol
#
while True:
    
    # check for button press...
    if button.value:
        while button.value:
            # wait for button to be released
            pass  
        state = state_dict[state]()

    else:    # button has not been pressed
        time.sleep(.10)
        # check timeout
        if end_time != None:
            if time.monotonic() >= end_time:
                state_dict[2]()
                # or simple funct2()
                state = 0
slender iron
#

I don't think you need a state machine

#
last_press = None

while True:
    if button.value:
        if last_press: # The relay is already on so turn it off.
            relay.value = False
            last_press = None
        else: # Turn on the relay
            relay.value = True
            last_press = time.monotonic()
    # Enough time has elapsed the we want to turn the relay off.
    if last_press and time.monotonic() - last_press > timeout:
        relay_value = False
        last_press = None
opaque patrol
#

You would also need to set end_time to None inside function 2

slender iron
#

there is a bit missing for imports but that should be simple

#

state machines are great if you have a lot of states to go between but this is pretty simple

heavy galleon
#

@slender iron that seems a pretty simple possibility, I guess that wouldn't casue recursion like mine due to the fact there are no functions?

slender iron
#

yup yup

opaque patrol
#

@slender iron I would add something to detect button release, if you hold the button down for any length of time will cause the relays to switch on and off each time the loop iterates while the button is down

slender iron
#

sure

opaque patrol
#

I like using state's even for a simple operation like this if you think you will add to it in the future, makes it easy to add new features and such

heavy galleon
#

I should am going to need to learn how to switch between states theres no way around that

opaque patrol
#

Think about a workflow, for any given state, what events can you run and what should the resulting state be for any event (including no state change).

slender iron
#

@opaque patrol I fixed the FancyLED packages

opaque patrol
#

In you code, you have states 'ready', 'started' and 'stopping', You can only run the start event from the ready state which moves it into the started state. You can only run the stop event from the started state which moves it (temporarily) into the stopping state and then to the ready state.....

#

@slender iron Thanks, looks good so far, I wanted to see what it does

heavy galleon
#

@slender iron where you say just if last_press: .. what is it really checking as the condition? is it checking if it is true from the statement above? because this variable is not set to true of false this is confusing to me

slender iron
#

@heavy galleon its checking if its set or not essentially. let me find a link

heavy galleon
#

ok but it wouldnt count that we just set it to none right above?

#

or does "none" have that specific functionality

slender iron
#

the following values are interpreted as false: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets).

#

basically its checking if its unset somehow

heavy galleon
#

Ok that makes perfect sense. I kinda figured but did not formally know that. thanks for the clarification

slender iron
#

yeah, javascript has a similar handwavy nature of boolean values

#
#

if you want to know the history

heavy galleon
#

yea I'll give it a read

opaque patrol
#

Any one test fancy led yet? I am getting this error trying to run on the examples... ```code.py output:
Traceback (most recent call last):
File "code.py", line 11, in <module>
AttributeError: 'module' object has no attribute 'CRGB'

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 2.2.1 on 2018-01-23; Adafruit Metro M0 Express with samd21g18

import adafruit_fancyled as fancy
help(fancy)
object <module 'adafruit_fancyled'> is of type module
name -- adafruit_fancyled
path -- /lib/adafruit_fancyled

slender iron
#

the exampl eis wrong

#

thats a PR to fix it

#

basically you need import adafruit_fancyled.adafruit_fancyled as fancy

opaque patrol
#

okay, I was going to try from adafruit_fancyled import * and see if that saw the different objects and functions

slender iron
#

(I saw pylint complaining when linting the examples)

#

k, lunch time for me

heavy galleon
#

@slender iron @opaque patrol Im outta here have a good evening. Thanks for all the great help as always guys. Catch up with ya tomorrow!

slender iron
#

you too @heavy galleon !

manic glacierBOT
#

I guess my problem is that I'm not that familiar with micropython/circuitpython way of working and miss details about the inner-workings as well (and I don't know what I don't know). I'm working on my own PCB with the nRF52840 module I mentioned above and I guess as I'm implementing that I will notice what information I'm missing and then can get more info from you. Is there any resources you would recommend that would tell me more about the lower levels of circuitpython? Any websites/books?

opaque patrol
manic glacierBOT
slender iron
#

@opaque patrol briefly for planned maintenance

raven canopy
#

figured out why cookiecutter won't create the .py project files in Windows. it's the | character in the file name. Silly windows and it's character restrictions...

slender iron
#

oops!

raven canopy
#

yeah, i just realized that the file isn't even in the local repo. so it fails on git clone. good thing my copy+paste skills are up to the task. ๐Ÿ˜„

slender iron
#

๐Ÿ˜ƒ

raven canopy
#

just saw PaintYourDragon's commit message on FancyLED. good thing my mouth didn't contain liquid, or I'd be cleaning my monitor right now....

I hate Travis with the fire of a thousand suns 
slender iron
#

๐Ÿ˜ƒ

#

๐Ÿ”ฅ โ˜€

raven canopy
#

โœ– 1โƒฃ 0โƒฃ 0โƒฃ 0โƒฃ

slender iron
#

lol

idle owl
#

lol

raven canopy
#

i have just realized one possible downside to breaking trellis into separate files. the base driver has 2 lookup tables. when you then use the base to make up to 8 objects to use with the matrix, those LUTs are duplicated 8 times. am i thinking that correctly? or will the core optimize?

import time
import busio
from board import SCL, SDA
import trellis           # base driver
import trellis_set       # matrix driver

i2c = busio.I2C(SCL, SDA)
matrix2 = trellis.TRELLIS(i2c) # 2 LUTs
matrix1 = trellis.TRELLIS(i2c, 0x72) # + 2 LUTs = 4 LUTs?
trellis = trellis_set.MATRIX(matrix1, matrix2) 
manic glacierBOT
timber mango
#

LATE NITE LEEEKS

#

add a circuitpy board, rotary encoder and neopixel ring for a desktop multimedia dia

tidal kiln
#

@raven canopy is the LUT some static resource you could put at the class level and share between instances?

raven canopy
#

so, i think i may have been false warning myself.

tidal kiln
#

yah, i think you're OK. module level also works. it won't create more copies for each matrix.

raven canopy
#

thanks @tidal kiln for the course correction. i still get "it will break when OTHER people use it" moments when going through the release-to-the-masses stage. now to start the battle with Travis.

tidal kiln
#

no worries. it'll get reviewed too. and scott's good at spotting things like that and suggesting other ways. and no one can make something 100% bullet proof before sending out into the wild.

raven canopy
#

pylint just ate me up! still a 7/10 though. better than negative. ๐Ÿ˜„

tidal kiln
#

sometime it's tempting to # pylint: skip-file

raven canopy
#

exactly. i need to find the pylint keyword list...need to keep of couple of the "gripes". is it standard practice to add comments on why you want to send pylint packing?

tidal kiln
#

i think the diable flag is enough of a comment, they're trypically somewhat descriptive so it's fairly obvious from context why it's there

raven canopy
#

looking at the docs, they seem to line up with the error messages. also in the docs: can't integrate with IDLE. so maybe i should switch to PyCharm. hmm.

#

then i could keep all the commits to a minimum. ๐Ÿ˜„

raven canopy
#

@slender iron getting this error from Travis, with the new doc setup. I've edited lines 8 & 9 on GitHub to make sure it wasn't my silly windows-box. Also tried making it 3 spaces vs 4. No go. I'm stumped...

Warning, treated as error:
/home/travis/build/sommersoft/Adafruit_CircuitPython_Trellis/docs/examples.rst:8:Unexpected indentation.
ruby lake
errant grail
#

@ruby lake very nice!

slender iron
#

@raven canopy I may have broken it with my new stuff. I can figure it out with you tomorrow after the hack chat.

full ginkgo
#

I'm getting bleary eyed tonight and have probably missed something simple.. was hoping to get someone to help set me in the right direction

#

I've got a trinket with the NeoPixel LED Strand 20 attached

#

using the repl, the demos work great

#

if I save a demo as main.py and put battery power on, I don't get anything from the strand anymore

#

I get my on button green and my onboard pixel locked at green too

errant grail
#

@full ginkgo how is the power for the strand wired?

full ginkgo
#

gnd to gnd, pos to usb, using pin 1 to drive it

errant grail
#

Can you measure the voltage on the pos/usb pin?

full ginkgo
#

I have the JST right angle on the bottom to give power

#

yup.. one sec

#

ooooh

#

I think I may have realized my issue

#

I should probably have my pos pin over on the battery term?

#

that voltage is low on the usb pin

#

.23v or so

#

239mv... that's a bit more clear

errant grail
#

yes. there's no path from the battery to the USB pin.

full ginkgo
#

makes sense..

errant grail
#

The Trinket is unlike the Feathers where the battery voltage and USB voltage are common to the VBUS pin -- 'cause the Trinket doesn't have a battery management/charging circuit.

full ginkgo
#

gotcha

#

hey... what do you know, a re-solder to the right pin and I'm in action

#

thanks @errant grail !

errant grail
#

Super!

full ginkgo
#

now, I just need to get some nice looking purple action going before Saturday

#

this is a gift for the mother in law... her birthday party is purple themed

errant grail
#

Ah. Purple is also the color of CircuitPython's Blinka. blinka

#

Music by Prince?

#

Anyway best of luck to you.

full ginkgo
#

Ha.. good point

#

There will certainly be Prince!

#

thanks again... I'm off for now

manic glacierBOT
solar whale
#

@timber lion I am able to successfully use the circuitpython rfm69 driver on my esp8266 (feather huzzah). I am also able to get the esp8266 to comunicate with adafruit.io usin the urequests library (using a request.post) command. However, when I try to use both, things get nasty. If I have the rfm69 set up then every time I issue the requests.post command, the esp8266 resets. Before I create an issue report, I just wanted to check to see if there was any known reason to expect problems using the ESP8266 Wifi and the rfm69 together.

manic glacierBOT
solar whale
#

@timber lion hmm - a bit more information - I can run the basic rfm69 example on the esp8266 BUT if It run it via the WEBREPL, the WEBREPL gets disconnected after the first packet is received by the rfm69.... the plot thickens.

#

but the rfm69 code keeps running!

#

I can reconnect the WEBREPL, but if a nother packet is recieived by the rfm69, the WEBREPL agian disconnects.

timber lion
#

ah interesting that makes me think perhaps a memory issue

#

webrepl takes a lot more memory to run

#

you might import the micropython module and run the mem_info() function

#

i think we still have that

#

it's a good way to see the total memory available

solar whale
#

OK - thanks _ I'll giv it a try.

timber lion
#

yeah hard to say it's anything specific with the rfm69 lib since it's working well on samd21

#

could be a power thing too, you might double check there's a good source of power for both

#

since two things transmitting / receiving at once might need a bit more power

#

i can't imagine more than an amp supply would be necessary though

solar whale
#

ah - but my USB port may not be sufficient - I'll try connection a lipo

timber lion
#

the rfm69 lib allocates all the memory it needs ahead of time too so it makes me think the webrepl perhaps is fragmenting or needing more memory

#

ohhh yeah

#

yeah usb ports can be tricky, 500mA max if they follow the spec

#

and that could get dicey, two radios and a few chips could push past that

solar whale
#

well - the lipo did not fix the problem -- I'll check memory usage

#

@timber lion but disabloing the WEBREPL did make some real progress - At least one resuests.post actually got out to adafruit.io with WEBREPL disabled. Thanks - at least I have something to work with.

timber lion
#

you can call it before and after doing something

#

and look for the total free IIRC

manic glacierBOT
slender iron
#

@timber lion @solar whale there is also gc.mem_free() just remember to gc.collect() before it

solar whale
#

@slender iron yup - both seem to work

#
>>> import aio_rfm69
Temperature: 24.0C
Frequency: 915.0mhz
Bit rate: 250.0kbit/s
Frequency deviation: 250000.0hz
Received (raw bytes): bytearray(b'\xfc*\x00\x00\x00')
stack: 2800 out of 8192
GC: total: 35968, used: 20912, free: 15056
 No. of 1-blocks: 217, 2-blocks: 77, max blk sz: 264, max free sz: 813
None
stack: 2800 out of 8192
GC: total: 35968, used: 24480, free: 11488
 No. of 1-blocks: 283, 2-blocks: 81, max blk sz: 264, max free sz: 435
None
Received (raw bytes): bytearray(b'\xfc)\x00\x00\x00')
stack: 2800 out of 8192
GC: total: 35968, used: 21408, free: 14560
 No. of 1-blocks: 222, 2-blocks: 87, max blk sz: 264, max free sz: 614
None

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

#

this was a "good" case folloed by a RESET -- mem_info called befor/after requests.post

#

so after it reported 15056 free, it ran OK but the next time with 14560, it reset.

#

If I run the aio test without the rfm69, then the free memory is up around 20000 - there may just not be enough room for the urequests once the rfm69 stuff is loaded. ...

timber lion
#

oh the other thing with the esp

#

ahh you know i think i know what's up for you

#

it has a watchdog

#

if it goes too long without a time.sleep it will reset

#

the rfm69 library waits for the chip to have a packet available

#

but it's a busy wait loop

#

what does your main code look like?

#

you might set the receive timeout to a small value like a tenth of a second

#

then put your own time.sleep in and just call receive more often with some explicit sleep

#

the rfm69 is still listening for packets and you'll catch anything received during that sleep

solar whale
#
from busio import SPI
import time
import urequests
import digitalio
import adafruit_rfm69
import gc

aio_fail=0
aio_delay=30
# Define radio parameters.
RADIO_FREQ_MHZ   = 915.0  # Frequency of the radio in Mhz. Must match your
                          # module! Can be a value like 915.0, 433.0, etc.

# Define pins connected to the chip.
CS    = digitalio.DigitalInOut(board.GPIO2)
RESET = digitalio.DigitalInOut(board.GPIO15)

# Initialize SPI bus.
spi = SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

# Initialze RFM radio
rfm69 = adafruit_rfm69.RFM69(spi, CS, RESET, RADIO_FREQ_MHZ)

# Optionally set an encryption key (16 byte AES key). MUST match both
# on the transmitter and receiver (or be set to None to disable/the default).
rfm69.encryption_key = b'\x01\x02\x03\x04\x05\x06\x07\x08\x01\x02\x03\x04\x05\x06\x07\x08'

# Print out some chip state:
print('Temperature: {0}C'.format(rfm69.temperature))
print('Frequency: {0}mhz'.format(rfm69.frequency_mhz))
print('Bit rate: {0}kbit/s'.format(rfm69.bitrate/1000))
print('Frequency deviation: {0}hz'.format(rfm69.frequency_deviation))



try:
  while True:
    # send a packet
    rfm69.send('gimme data\r\n')
    # Look for a new packet - wait up to 5 seconds:
    packet = rfm69.receive(timeout_s=5.0)
    # If no packet was received during the timeout then None is returned.
    if (packet is not  None):
      # Received a packet!
      # Print out the raw bytes of the packet:
      print('Received (raw bytes): {0}'.format(packet))
      # send reading after any packet received
      temp=packet[0]
      gc.collect()
      print(gc.mem_free())
      r=urequests.post("https://io.adafruit.com/api/groups/Default/send.json?x-aio-key=94cce1f27dd2caac8da3ed48571946a147be82ee&esp8266temperature="+str(temp))
      r.close()
      print(gc.mem_free())
      gc.collect()
      print(gc.mem_free())
    time.sleep(aio_delay)
except KeyboardInterrupt:
    pass
finally:
    pass
timber lion
#

ahh yeah in that rfm69.receive(timeout_s=5.0) it's going to busy wait constantly polling the rf69 to see if it has a new packet

#

what if you try changing that to timeout_s=0.1

#

then add a little time.sleep(0.01) to end of the while loop

#

the exact values don't really matter much

#

just to give the esp some time to handle wifi state

#

and it will reset its watchdog

solar whale
#

hmm tried setting .1 but it immediatel resets when the urequest.post is issued.

timber lion
#

and if it gets a packet during your sleep or other code it stays in its buffer until you next call receive and get it

#

oh so it's only on the send to AIO that it's failing?

solar whale
#

interesting that the reset.cause is 2 which is an externalt reset

#

yes only on AIO call

timber lion
#

that makes me think memory then, i have a feeling web request processing needs to allocate some string buffers

#

potentially big ones as it gets responses and such back

solar whale
#

I think you are correct.

timber lion
#

it could be fragmentation too, one thing you might try

#

maybe have it just turn a LED on instead of calling the post

#

or even just print to repl

#

to see that it really is just that line

#

then hrm, it gets tricky if it is urequests

solar whale
#

It runs fine if I dont do the post.

timber lion
#

it might be possible to drop urequests entirely and do a raw TCP socket connection

#

don't even worry about getting a response from the server, just open the connection and blast out a post request

#

but it could get a bit trickier if you haven't done a lot of web stuff like that at a low level

solar whale
#

That would be good - urequsts causes some other issues taht I ahve been fighting. I'm trying to find the simplest way to send data to AIO. via circuitpython - any suggestions?

timber lion
#

which is unfortunate, it would be nice if they had a 'fire and forget' option to not construct and parse the response

solar whale
#

the response ishuge!

#

ofteen get TSL buffer overflows - it is a know issue with ESP8266

timber lion
solar whale
#

ohhh - good idea - I'll give taht a ty.

timber lion
#

other little sanity check that might be handy, double check a post without any rfm stuff works too

#

just to make sure AIO is up and the post code is working well

#

if the AIO servers don't respond soon enough i wonder if it might trigger the watchdog too

solar whale
#

I can post to AIO just fine -- either rfm69 or AIO , just not both.

manic glacierBOT
solar whale
#

@timber lion I'll keep woking on reducing the impact of the urequests. Just removing the response did not work - at least on the first try but that may not be reliable. I have found hat I need to do a clean RESET sometimes to get anyhting working after it gets hosed up. Thanks for the help. I tihnk I'm on the right track. I'll report back after i try some more tests.

manic glacierBOT
timber lion
#

ah yikes math.floor has a limit

#

math.floor(1.1375e+09)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: float too big

#

that's not the case in normal python

#

it must not support floats bigger than the int limit

#

i wonder if there's another way i can floor a value

idle owl
#

@timber lion Quick unrelated q: what OS were you using with the MicroPython plugin on PyCharm?

timber lion
#

oh i was using OSX

#

python3 result if anyone is curious

#

import math
math.floor(1.1375e+09)
1137500000

#

tricky for me because these clock generator calculations go way up into the high hertz values

prime flower
#

@timber lion bitwise OR'ing?

idle owl
#

@timber lion thanks

manic glacierBOT
#

This isn't really a problem from circuitpython and rather almost certainly a problem with upstream, but it appears math.floor (converting a float into the next lowest integer representation) fails with large numbers.

In circuitpython/micropython:

>>> import math
>>> math.floor(1.1375e+09)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: float too big

Vs in python3:

>>> import math
>>> math.floor(1.1375e+09)
1137500000

Th...

timber lion
#

yeah it's trickier because it's a float @prime flower so it's in IEEE float format

#

with the mantissa and all that.. been a long time since i did float at that low level ๐Ÿ˜ƒ

#

but there might be some math or divisions i can do

prime flower
#

Yea i dont think | works for floats past a certain val.

timber lion
#

or ultimately where i'm hitting this i could just keep it float and skip the floor

#

it's just for users to see.. it won't be the 'true' frequency but close

tulip sleet
#

a float that big has no significant digits before the decimal point, though the decimal representation may not show the digits to the right of the decimal point as 0 (because the decimal and binary representations cannot be converted back and forth exactly). We only have about 6 digits of precision.

#

If you wrote out 1.1375e9 without decimals it would be 1,137,500,000.

#

integers are 31 bits including sign bit

#

2^30 = 1073741824

#

1,073,741,824

#

we'll have longint support in 3.0

tidal kiln
#
Adafruit CircuitPython 2.2.0 on 2018-01-02; Adafruit CircuitPlayground Express with samd21g18
>>> import sys
>>> sys.maxsize
1073741823
>>> 
#

what will longint be, size wise?

tulip sleet
#

it's variable length, as long as you need

tidal kiln
#

nice

tulip sleet
#

it's not just 64 bits or something like that

#

but it's too big to include on the m0's

#

(the implementation is too much extra code)

tidal kiln
#

yah, i've used that in full python (a 256 bit integer ๐Ÿ˜ƒ )

river quest
slender iron
half sedge
#

THIS CONVERSATION DOES NOT EXIST
Click on "New Conversation" or on an existing conversation to start chatting

#

Should I click again in 8 minutes?

tulip sleet
slender iron
#

@half sedge I think you need to apply to the group first

timber mango
#

Join thru github to speed it up

tulip sleet
#

Click on Join Hack Chat

slender iron
#

If you need help on your project you've come to the right place.
Click on the "Request to join this project" link on the left to be added to the list of collaborators. From there you'll be able to join the group messaging.

Those that just want to talk about hacking have found the place as well. All are welcome!

half sedge
#

I follow on Youtuve now.

timber mango
fiery panther
#

hello

raven canopy
#

i don't have enough monitors for all this! ๐Ÿ˜„

stuck elbow
#

I have 2 chats and video open, and I'm getting crazy trying to listen and read all that

timber mango
#

MORE CHATTSS

stuck elbow
#

I have some good questions prepared ๐Ÿ˜›

prime flower
#

@raven canopy I'm working from a hospital (my friend got a concussion but they got wifi) today, and I dont think they'd appreciate me setting up another monitor ๐Ÿ˜›

modern wing
#

Pffst, who needs that vitals monitor anyways?

#

And it even comes on its own rolling stand!

modern wing
#

I'm passively listening -- handling a few of my own bugs here for work, but this is awesome to have on in the background ๐Ÿ˜ƒ

manic glacierBOT
stuck elbow
#

hackchat is always chaotic

prime flower
#

yeah, it's really chaotic! (but chaos is kinda fun right?)

stuck elbow
#

the website is black, so you know what to expect ๐Ÿ˜‰

prime flower
#

I asked a question ๐Ÿ˜ƒ

hasty saffron
#

If you put a microscope on the chaos. You think your looking into a mirror

stuck elbow
#

It's a standard keyboard, not a mechanical one, the key travel is small so it's faster ๐Ÿ˜‰

quick python
#

heh, I can see which of you is typing by your mic's picking up keys and highlighting your username

stuck elbow
#

the most random number is 17

quick python
prime flower
#

...I like the NSA EFF(?) pin you have there

quick python
#

It's actually a button from a Japanese BBQ place in Oakland CA, EFF pin is on teh other side ;+)

prime flower
#

Oh - neat!

quick python
prime flower
#

....I love that logo and want to eat there now

stuck elbow
#

what is a vegan chicken?

#

poor animals, are they feeding them soy?

quick python
#

anyone know any particular meetups/groups/chats etc that focus on ESP32 dev, looking to connect with more contributors around BLE and such

stuck elbow
#

@quick python there is the #esp8266 channel on freenode

manic glacierBOT
#

I downloaded and build an image fpr the pca10056 SDK - It built fine and loaded.

make BOARD=pca10056 SD=s140
make BOARD=pca10056 SD=s140 sd -- to load soft device
make BOARD=pca10056 SD=s140 flash -- to load image
I can get to the Circuitpython REPL - Woohoo! great work.

I am not able to access the file system via ampy as I can for the feather52.
Dis I miss something in the configuration?
Is there some other way to upload files or is only the REPL available now?

timber mango
#

good work circuit py peeps

#

EPIC HACKCHAT

quick python
#

cool, anyone in Bay Area that wants to do a meetup give me a ping

idle owl
#

@timber mango you too ๐Ÿ˜ƒ

timber mango
#

@idle owl ok i got pycharm working

#

seems ok to me

idle owl
#

I was able to get it going if I started fresh. I think it gets confused if you try to enable it again after having it enabled/disabled

#

Or something like that?

prime flower
#

that was fun to watch in the background! good job all!

idle owl
#

I have no idea. It failed miserably for me mulitple times.

#

But when it works, it's smoooooth

#

@timber mango So publish it and go with it?

quick python
#

@timber lion @timber mango @stuck elbow thanks for all your contributions, things have come a long in the last ~year and keep getting better! And thanks @tulip sleet and everyone that put together the hack chat today... back to hack'n all teh things

timber mango
#

@idle owl i published it - replying to BC now ๐Ÿ˜ƒ

idle owl
#

@timber mango yep I see it, also replying ๐Ÿ˜ƒ

timber mango
#

@quick python team work makes the dream work

manic glacierBOT
#

I am fairly new to circuitpython so I wasn't aware of ampy, looks super useful, I was wondering how does one upload files to the flash fs :D

As you can guess from this, I have not tested the flashfs, I needed it in the linker scripts or otherwise I got warnings from these lines: https://github.com/adafruit/circuitpython/blob/master/ports/nrf/boards/common.ld#L2

If you want me to, I can look into fixing the issues with ampy before this is merged, I think it will be a good way to learn so...

stuck elbow
#

"yes to both"

manic glacierBOT
stuck elbow
#

I think SAMD11 can do USB

#

and it's almost as cheap as the samd09 in seesaw

manic glacierBOT
raven canopy
#

@slender iron got previously mentioned Travis issue solved. someday i'll remember to have proper spacing in the rST format.

#

but now he's asking for a docs/README.rst?

manic glacierBOT
raven canopy
#

found it. docs/conf.py still has master_doc = 'README' vs 'index'.

he's also complaining about the toctree -> api reference on line 17.

#

i'm off for a few. let me know if you want me to fork-n-fix.

idle owl
#

@slender iron Even if the PyCharm REPL is in the raw REPL from attempting to perform one of the two MicroPython functions, it still fails "could not get to the raw repl" so it looks like you can't ampy flash a file to it or delete everything from it using the PyCharm MicroPython plugin. Good to know I guess.

slender iron
#

@raven canopy yeah, please fix cookiecutter if you find issues

#

@idle owl bummer, we could look into it later

idle owl
#

@slender iron No, I don't think it's a bad thing. Those functions are meant to use ampy on an ESP8266 type setup, not meant to be used with the UF2 boards. I think it would be bad to put "here do this" in an intro guide and have an option right below REPL to erase the board.

slender iron
#

I think they should still work

#

we just shouldn't encourage their use

idle owl
#

valid.

#

We'd need someone to write support in for the CircuitPython boards. The plugin is written in java.

slender iron
#

is it open source?

idle owl
#

yup

slender iron
#

kk, its probably not too hard to fix then

manic glacierBOT
#

@ladyada would you like me to release 2.2.2 or are there other boards we
should add before releasing? Need it by Monday or can we release on Monday?

On Fri, Feb 2, 2018 at 2:22 PM ladyada notifications@github.com wrote:

done! i just tested on both USON flashes with the same hardware PCB!

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/adafruit/circuitpython/pull/571#issuecomment-362725233,...

manic glacierBOT
#

Sounds good! keep us posted

On Fri, Feb 2, 2018 at 3:13 PM ladyada notifications@github.com wrote:

i could add prelim pIRkey definition over the weekend, its a trivial
trinket-like. lets see where we stand on monday

โ€”
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/adafruit/circuitpython/pull/571#issuecomment-362736622,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADNqUTI9r_j...

manic glacierBOT
raven canopy
#

now Travis is happy. ๐ŸŽ‰ only took 17 builds. lol

tidal kiln
#

something something fire of a thousand suns?

raven canopy
#

yeah...but most of it was my fault, not Travis'. ๐Ÿ˜„

#

@slender iron cookiecutter updates PR'd. it was only 2, that i encountered.

timber mango
#

LEEEEEKZ

idle owl
#

Excellent

sick creek
#

LEEKA

timber mango
#

here's a board ive been waiting to do!

idle owl
#

oooh

sick creek
#

was this what was showing in your screen during hackday? beginning?

timber mango
#

its just a trinkety cpy board with an IR receiver

#

maybe? i think i showed the M4 metro

#

they all look athe same after a while

idle owl
#

Yah it was the M4 Metro

tidal kiln
#

ir2hid?

timber mango
#

yah

#

but that one was really rough to supprot

tidal kiln
#

tee hee. imma gonna control your compy....from way over here.

timber mango
#

noooooooooooooooo

idle owl
manic glacierBOT
#

After spending a few hours trying to see what was causing the issues, I'm still not entirely sure, it does seem like we are getting wrong data on UART, ampy was sending

            try:
                import os
            except ImportError:
                import uos as os
            print(os.listdir('{0}'))

But in the uart fifo we got:

Breakpoint 13, mp_parse (lex=0x20004b40 <heap+1692>, input_kind=MP_PARSE_FILE_INPUT) at ../../py/parse.c:1077
1077	        mp_o...
idle owl
#

@errant grail That's really neat!

#

And it looks good! I like the groovy meter ๐Ÿ˜ƒ

errant grail
#

Thanks! A fun and useful project!

manic glacierBOT
manic glacierBOT
timber mango
#

I'd like to see that schematic. ;)

errant grail
#

@timber mango not much to it, actually. If you're interested, I can DM a block diagram or the Fritzing prototype graphic.

timber mango
#

Anything you got. I just want to know how isolated it is and how the USB port on the laptop/host PC can still talk over just D+ D- and I suppose GND.

#

I suppose the USB hardware has no idea that the supply 5VDC lead isn't in use. Do you have to load the USB 5V supply lead, to trick some firmware inside the host PC to believe the USB is in use?

#

So basically you severed +5 in the USB cable. ;)

errant grail
#

Yup, then inserted a PowerBoost 1000C, a shunt resistor, and a traditional analog meter.

timber mango
#

And then diverted it to a somewhat unrelated circuit that enjoys +5VDC.

#

So I'm guessing GND and D+ and D- are the important USB leads to 'talk' on. GND is probably necessary.

errant grail
#

Absolutely. At some point I may insert a USB data isolator between the host and the monitor, but I'm getting reliable USB 2.0 data transfer as-is.

timber mango
#

Yeah USB is pretty fast so seems likely D+ and D- mean it's a differential like RS-422 485 &c.

#

I don't understand the exact role of GND on those protocols but I'm guessing they like to have a GND. I'm starting to try to port an old development board to modern (it uses MAX3232 to talk to the Host PC).
Not sure how I'll go about it. Either use a Trinket M0 as translator (a UART pass-thru) .. or CP2104 as with the PiUART.

#

I need to present a USB interface to the Host PC (/dev/USB0) (/dev/ttyACM0) instead of a COM port (/dev/ttyS0).

#

That's Linux talk. MSDOS was COM1 COM2 COM3 or COM4.

errant grail
#

I don't have any experience using HID via USB -- I just use the default serial output libraries.

timber mango
#

I think HID is all about mice and keyboards (Human Interface Device).

errant grail
#

... and being recognized by the host computer, right?

timber mango
#

Well yeah on some level sure. There's always been a lot of drivers on the host PC related to USB, so I'd say they have drivers for just about every role the USB connection can play (which falls into broad classes).

#

So like the CP2104 chip from Silabs, that basicallly provides a new way to do RS-232 -like serial connections via USB.

#

I imagine the day that SIlabs minted that chip it wasn't all like 'TADA' here's you chip. It was like "this is dead, Jim, without a driver running on the host PC".

errant grail
#

That's my understanding. Haven't had the need to deal with that just yet...

#

Although I've worked with RS-232 and similar interconnection interfaces/protocols "back in the day."

timber mango
#

We fell into a period where our RS-232 stuff was being phased out and we still had lots of development boards that relied on it.

errant grail
#

Sorry -- dinner bell just rang. Good talking to you, nis.

timber mango
#

I got one right here -- an old Mini ITX board. Has the required serial port and it works fine. I'm trying to bypass the need for it.

#

Yeah you too, CGrover. Thanks for the exchange!

neon ferry
#

New subject. I tried out the pycharm MicroPython plugin, and I'm wondering, after it loads the code on my Huzzah (no SD card or anything like that) where does the code go? Into the internal flash of the part? I don't see it running...Thanks!

#

Oh, and hello ๐Ÿ˜ƒ

neon ferry
#

Answered me own question, needed to naem my file main.py ๐Ÿ˜ƒ

#

And thank you for creating all this. it's fun.

idle owl
#

Great job! It hadn't occurred to me to suggest that as the problem. I'll remember to make sure that's the case if anyone else runs into that.

neon ferry
#

Well, I'm new to this whoel platform as of yesterday. You all do a great job with the documentation. And the boards are really cute and awesome and all the little parts. I love it. Thanks!

idle owl
#

You're welcome! I'm really glad to hear it!

neon ferry
#

(Making a Huzzah NTP alarm clock for/with my 9-year-old, with hopefully other electronic pranks to follow for her.)

idle owl
#

Nice!

manic glacierBOT
neon ferry
#

If anyone still around, I had some issues using AMPY with the Huzzah feather. It's the famous "can't enter raw REPL". If I replace the second:

#

self.serial.write(b'\r\x03\x03')

#

With:

#
        time.sleep(0.5)
        self.serial.write(b'\x03')```
#

It gives the stuff after the first ctrl-c time to come out, and then it is ready to get the next ctrl-c

#

Two in a row is too fast in other words.

timber mango
#

That makes some sense. I don't know the specifics as I don't have that board nor have I run AMPY.

#

Half a second is overkill. 0.01 might be long enough.

neon ferry
#

Do you use something else besidew AMPY?

timber mango
#

Well I don't have the HUZZAH. I have all SAMD21 stuff (and old C8051F330 stuff).

neon ferry
#

SO how do you load py files onto your stuff?

#

(And thanks for asnwering as well)

timber mango
#

You're welcome. On most CircuitPython boards, we have a .UF2 file that is simply copied onto the target board (which appears as a disk drive on the host computer).

#

The board you bought (probably mail order) is called a 'target' board (at least by me. ;)

neon ferry
#

I see. I call them targets as well :). I imagine your target has a CF card and that is the difference. This one uses built-in flash.

timber mango
#

Well they even managed this with the built-in flash on the SAMD21E18A chip of Gemma M0 and Trinket M0 (those two do not have an external flashROM chip the way the 'express' boards do).

#

Basically they found a consistent way to boot these boards from three competing platforms: Microsoft's Makecode, Arduino IDE, and Adafruit CircuitPython. That's a three-fer. I already wanted it when it was a one-fer with Arduino IDE. ;)

#

I would try to make your code say something on the REPL so you know it's connected and talking.

neon ferry
#

Roger that. This was just a side mission to get additional Python library files into the flash. I swear to you the documentation and examples on the Adafruit site are pretty impressive.

#

The tool was having issues with my board, but I could do what it was doing manually fine. So it was a race condition in there.

timber mango
#

Tony DiCola wrote a lot of the earlier ones and I really think he has a great insight on this.

#

So you have the Silabs driver for that board installed, I'd think.

neon ferry
#

I don't know much yet as it's only been a day :). Still learning the lore.

timber mango
#

Haha. I think it's the CP2104 chip doing the hard work. That's USB to UART bridge and is also used in the PiUART and they do a breakout board using it as well. Silabs makes that chip. Linux ships supporting that CP2104 chip; some other operating systems may need a driver downloaded and installed:

#

I'm going to scroll back and re-read so I know where we are at.

neon ferry
#

Oh the issue is more or less resolved. I just wanted to let someone know so they can adjust the AMPY code accordingly. I'm afraid at this point to try and change it for fear of breaking it on other platforms.

#

So I jsut fixed it locally until if and when I become more bold.

timber mango
#

Oh I see you were offering a bugfix. ;) I get that you are on Feather HUZZAH (foo) and that you were able to author a main.py which you named something else, and discovered it needs a special name to auto-execute.

You can

>>  include nonmain

and it will read in nonmain.py (any name you like ending in .py).
When you get to the point where you have a library, you want to use mpy-cross to reduce the memory footprint of your library, if coding on the HUZZAH holds similarly to the platform I use.

neon ferry
#

I see thanks!

#

Ya there isn't much room apparently

timber mango
#

The mpy-cross program produces I think .mpy from .py and you'll see that .mpy is bytecode, not ascii plaintext.

neon ferry
#

But enough for my kid's project.

#

Yeah thanks for telling me about that. I noticed that the additional libraries are in fact .MPY and I was wondering abou tthat.

timber mango
#

I just found out about that about two weeks ago, from jerryn. I posted my error and he knew right away what the problem was. Luckily I understood it immediately so we were good to go after that. ;)

neon ferry
#

Roger that! See you around. I'm set for now!

#

Thanks.

timber mango
#

Very good! Nice to meet you.

neon ferry
#

You too ๐Ÿ˜ƒ

manic glacierBOT
#

I see, that would point to the ATSAM chip used for the debug interface, I will try to connect a external USB to uart board and verify there.

There's also this thread on Nordic's forums: https://devzone.nordicsemi.com/f/nordic-q-a/16721/pca10040-uart-problem

I am running Linux Mint which is based on Ubuntu so that's why I might be getting similar problems, I tried another USB port and disabling auto-mount like the thread suggests but that didn't help.

manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

yeah, Nordic chips use the P0.xx and P1.xx way of naming pins, I guess since originally MicroPython was created for the stm32 chips, it uses PNx way of naming so do other ports. I'm not sure how much consistency between ports should be kept, otherwise we could rename the pins to match more what's on the silk of the DKs, I see that even the feather52 PCB just has numbers on the silk (the nrf52832 only has one port of 32 GPIOs total).

#

I used:

>>> dir(board)
['PA0', 'PA1', 'PA2', 'PA3', 'PA4', 'PA5', 'PA6', 'PA7', 'PA8', 'PA9', 'PA10', 'PA11', 'PA12', 'PA13', 'PA14', 'PA15', 'PA16', 'PA17', 'PA18', 'PA19', 'PA20', 'PA21', 'PA22', 'PA23', 'PA24', 'PA25', 'PA26', 'PA27', 'PA28', 'PA29', 'PA30', 'PA31', 'PB0', 'PB1', 'PB2', 'PB3', 'PB4', 'PB5', 'PB6', 'PB7', 'PB8', 'PB9', 'PB10', 'PB11', 'PB12', 'PB13', 'PB14', 'PB15']
>>> import digitalio
>>> led= digitalio.DigitalInOut(board.PA13)
>>> led.direction=digi...
indigo wedge
#

Oh, I didn't realize this was spamming so much ๐Ÿ˜„

solar whale
#

yeah - all the circuitpython PR comments go here, but I think its good for folks to see.

raven canopy
#

its not spamming. more like eavesdropping. ๐Ÿ˜„

indigo wedge
#

Oh no, all my secrets!

solar whale
#

and all my mistakes...

#

@indigo wedge Thanks for the work on the pca10056 - It's been fun to dust off the board and play with it again.

indigo wedge
#

No problem, it was a good learning exercise in CircuitPyton getting stuff to work

#

I also have a pca10040 and from what I can see that one is also not fully suppported,the build fails cause boards/pca10040/board.c is missing, so I will look into getting that one running also

#

i guess the board.c will be very similar for most nrf52 DKs so could make it a common one to not duplicate code

#

from what I can see the ble support in CircuitPython has quite a long way ahead of it, one can advertise and connect to a central, exchange some data but doing more advance stuff like security, bonding, whitelisting is still missing

#

hope I can find some time to look into it ๐Ÿ˜ƒ

#

I'm also curious about performance when using SPI in python, Nordic have a example code to run a ILI9341 display and when i hooked it up it was not the fastest ever (see https://twitter.com/arturo182/status/948656935808749573), and I noticed there is a ILI9341 example code for the nrf in python , but I wonder, how fast can that be, is it anywhere close to usable or just a fun demo? Maybe a better idea is to implement a C driver for the ili9341 and just provide python class wrapper for that?

solar whale
#

I have the feather52 and the pca10056 so I have been able to take advantage of what is available. I have so much to learn about BLE so Iโ€™m still way behind the implementation!

indigo wedge
#

I've been working on the nrf51 and nrf52 BLE professionally for almost 3 years now so I think I can be of some help to the project ๐Ÿ˜„

solar whale
#

Iโ€™ve done a bit with the ili9341 with dome of the M0 boards, but not the NRF. With the extra space on these boards, a lot more can go in C.

indigo wedge
#

is the ubluepy planned to follow bluepy API 1:1 or is it more of a loose implementation?

solar whale
#

@slender iron has been advocating for a switch to bluepy.

indigo wedge
#

i thought the API was already following bluepy

solar whale
#

It may well be. I donโ€™t have enough experience to know.

manic glacierBOT
#

I added gamepad with a example in https://github.com/arturo182/circuitpython/commit/823940ef2001a46eaff3a9bdb4c29cc3cae91bec but it is on top of my pca10056 changes and seems github doesn't allow me to push it into a new PR that depends on #573 and I don't want to mix those. So I can wait for this one to be merged before pushing a new PR unless there is some way to do it in a clean way in Github (sorry I come from Gerrit world).

solar whale
indigo wedge
solar whale
#

As I recal, the screen painting looked similar to your example when I tried it on an SAMD21 board but it's been awhile. When I get a chance, I'lltry it on the nrf boards.

half sedge
#

I found the pyboard/MicroPython booth at Fosdem and I am so happy. Would you like/accep picture uploaded here?

stuck elbow
#

Certainly!

raven canopy
#

Brussels is by far my favorite European city. Although, Ixelles is probably the closest I've gotten to where FOSDEM is being held.

stuck elbow
#

mussels and beer

#

I'm going to Chez Leon every time I'm there

raven canopy
#

i miss non-imported European beer. I can get Duvel in a few places...but it just isn't as good. And I've never found Orangeboom (Dutch) in the states.

stuck elbow
#

yeah, beer doesn't like to travel

raven canopy
#

also miss the coffee. those are the two things that 5 years in Europe ruined for me. ๐Ÿ˜›

stuck elbow
#

haha, yeah, that's what all the Americans who came anywhere near Italy say

#

though it gets worse further north

raven canopy
#

we got beans from a roaster in Maastrich; best coffee I've ever had. I actually never made it to Italy. But, the best Italian food I've ever had was in Constanta, Romania.

stuck elbow
#

shockingly, actual Italian food mostly consists of grilled meat, not pizza and pasta

half sedge
#

Is this your baby?

stuck elbow
#

yes!

#

thanks!

#

(it's all stained in flux, because it's the one faulty unit that I had to re-solder manually)

half sedge
#

This look like a microbit... Colour with another form factor.

stuck elbow
#

interesting

#

do you know what it is called?

half sedge
#

Prototype

indigo wedge
#

@stuck elbow where do you get your PCBs assembled?

stuck elbow
#

@indigo wedge Makerfabs

half sedge
#

There was a M4 pyboard. Maybe v1.1 but I don't find a picture.

indigo wedge
#

I'm really impressed by how cheap you can sell the boards, when I looked into PCBA it was so expensive for small runs

stuck elbow
#

@half sedge the Metro M4?

#

@indigo wedge the magic of China, I suppose

indigo wedge
#

yeah but I looked at Seeed and PCBWay for PCBA and still darn expensive, I'll have to try and get a quote from Makerfabs then ๐Ÿ˜„

stuck elbow
#

@smoky swallow I think they gave me a big discount because they expect this to sell well and they think I will come back for more soon

half sedge
#

I believe it was this (from the spec/size/look) but I don't see M4??? https://www.adafruit.com/product/2390

stuck elbow
#

Ah, that's the first pyboard

indigo wedge
#

That's an interesting strategy for them ๐Ÿ˜„

stuck elbow
#

but it's STM32, not SAMD

#

I think they were right this time โ€” I got 50 units, and I started selling them on Wednesday, and I only have 20 left now

#

but I will wait for the Spring Festival to end first

half sedge
#

Noooo! Where is my credit card?

#

I don't have a banana for scale, but it is tiny!

stuck elbow
#

it's the size of the small altoids can

#

42x50mm

indigo wedge
#

Yeah, I've seen your board all around the web, great job ๐Ÿ˜ƒ

stuck elbow
#

thanks

indigo wedge
#

If I can pester you a little longer, I checked the code for the uGame and I see that pretty much everything is written in python, the lcd driver, the sprite engine and the games, how is the performance, have you checked FPS?

stuck elbow
#

if you look really closely, you will see that the sprite engine actually imports _stage module, which is written in C

#

the performance is not great, but mostly because the communication with the display is 24MHz SPI

#

you can get 24FPS as long as you don't update more than 1/4 screen every frame

indigo wedge
#

yeah, I'm working on a project with a display and that's one of my worries

stuck elbow
#

but for the kinds of games I want, 6FPS is enough

#

if you can use the parallel mode

indigo wedge
#

but how can one play a game if it's not exactly 60 FPS? ๐Ÿ˜‰

stuck elbow
#

it's a mystery

timber mango
#

@idle owl heya do you know if the raw_value stuff for touchio is documented anyone

idle owl
#

@timber mango I don't think so. But I don't know for sure. I think we used it for testing and never documented it.

manic glacierBOT
timber mango
#

@idle owl had a fun time figuring that out lol ^

#

@idle owl ok we'll soon take on The Great CircuitPython Quickstart Unification of 2018

#

it ill be gl0rious

idle owl
#

Yeesssss

heady dove
#

Hello all, I seem to be having a problem getting a "code.py" or "main.py to run when I copy it my CPX. I'm using a linux machine, with gedit to edit. It copies over but doesn't seem to reboot, though if I manually reboot it doesn't run either. entering it on the repl and running the code does work. What am I doing wrong?

#

I've read about waiting for the code to completely copy (90 ssec) but I've waited along time multiple times and it never runs

stuck elbow
heady dove
#

I've tried both

stuck elbow
#

how do you know it doesn't run

heady dove
#

but thank you fr the clarification

#

I'm blinking a led (D13) and it doesn't blink

stuck elbow
#

ok, can you enter the repl and press ctrl+d?

#

and see if you get any errors?

heady dove
#

got it! a couple of errors

#

so I should as a habit keep the repl open so I can see errors

stuck elbow
#

yeah, that's useful

#

also, the led will blink red if there is an error, I think

heady dove
#

very much appreciate the community support

stuck elbow
#

don't hesitate to ask anything

heady dove
#

never saw a blink, but I might have blinked in sync ๐Ÿ˜›

wise bluff
#

Hi everyone. I'm very new to circuitpython and pretty new to coding in general. Been hunting all morning to find out how I can use the D4 button on CPX to initiate a simple loop for the neopixels. If I am not already pushing the button when I save the file, nothing happens. If I am, it works fine. I want it to wait until I press the button. What should I be doing? Patience for a new guy and any info is much appreciated!

#

import board
import neopixel
import time
import digitalio

button = digitalio.DigitalInOut(board.D4)
button.direction = digitalio.Direction.INPUT
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
value = button.value

if value is True:

heady dove
#

I really want to reiterate how much I enjoy this community, originally I was hesitant to follow the branch from upython to circuit python, but you all have done a remarkable job of advancing the project and are so helpful everytime I've had a question, I love being part of this. Plus slow but sure my python skills are getting better AGAIN THANKS

stuck elbow
#

@wise bluff the code you wrote executes only once, when the board resets, you need to use a loop to make it execute all the time, and keep checking the button

wise bluff
#

At first I thought to use a 'while' loop, but couldn't get it to work. I'll keep digging. . .

stuck elbow
#

can you paste your whole program?

wise bluff
#

Sure. There's not much a whole lot more to it:

#

import board
import neopixel
import time
import digitalio

button = digitalio.DigitalInOut(board.D4)
button.direction = digitalio.Direction.INPUT
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
value = button.value

if value is True:
pixels[0] = (0,5,10)
time.sleep(0.5)
pixels[9] = (10,5,3)
time.sleep(0.5)
pixels[1] = (10,3,1)
time.sleep(0.5)
pixels[8] = (0,0,10)
time.sleep(0.5)
pixels[2] = (10,0,0)
time.sleep(0.5)
pixels[7] = (10,0,10)
time.sleep(0.5)
pixels[3] = (10,10,10)
time.sleep(0.5)
pixels[6] = (0,10,0)
time.sleep(0.5)
pixels[4] = (5,5,0)
time.sleep(0.5)
pixels[5] = (10,3,1)
time.sleep(0.5)
pixels[0] = (0,0,0)
time.sleep(0.5)
pixels[9] = (0,0,0)
time.sleep(0.5)
pixels[1] = (0,0,0)
time.sleep(0.5)
pixels[8] = (0,0,0)
time.sleep(0.5)
pixels[2] = (0,0,0)
time.sleep(0.5)
pixels[7] = (0,0,0)
time.sleep(0.5)
pixels[3] = (0,0,0)
time.sleep(0.5)
pixels[6] = (0,0,0)
time.sleep(0.5)
pixels[4] = (0,0,0)
time.sleep(0.5)
pixels[5] = (0,0,0)

wise bluff
#

Ok, so maybe I inadvertently fixed my variable 'value' to False since it is assigned before I press the button?

stuck elbow
#

yes, that too

#

but also, you are only checking it once

#

you can pause your program until the button is pressed

#

with:

while not button.value:
    time.sleep(0.5)
#

or something like that

wise bluff
#

Ah, nice! Probably more elegant that my fix. I got rid of the variable looped like this:

#

while True:
if button.value is True:

#

else:

#

pass

#

Seems to be working ok.

stuck elbow
#

it's best to only use is with None, and otherwise use either == or simple just if button.value:

#

any non-zero non-empty value is treated as True

#

otherwise you are kinda repeating yourself, you know you could as well write if (((x == True) == True) == True):

#

of course the computer doesn't care

wise bluff
#

That makes sense. I really appreciate your patience and help! These little things I'm learning are adding up slowly but surely.

manic glacierBOT
#

I've been researching this between Travis battles. I think I've got USB mostly figured out, but still working on a plan for REPL. Initially I was hoping it could go into the micropython module. But, with USB being handled at the port level, somewhere in shared-bindings & common-hal is probably better. I imagine REPL will end up the same way, given the REPL flavors on different ports.

Here are my USB notes so far.

  • Atmel-SAMD: ports/atmel-samd/usb.c is an easy place to grab `usb_c...
stuck elbow
#

@wise bluff yeah, don't worry about the style at first too much, more important to get the big idea

#

I'm just mentioning it because it looks better, but of course the most important is that it works

idle owl
#

@heady dove code.py will work as well on the CPX.

stuck elbow
#

@idle owl really?

#

@idle owl what if you have both?

idle owl
#

@stuck elbow If you have both, it reads code.py. It looks for, in this order: code.txt, code.py, main.txt, main.py.

#

And reads the first one it finds.

stuck elbow
#

txt?

idle owl
#

Yeah, it's included for people who don't have editors that recognise .py files.

#

Remember this is geared towards beginners, so we want it to be as simple as possible to get started.

stuck elbow
#

curiouser and curiouser

#

but only the cpx?

idle owl
#

I never suggest using the .txt version, but in the event that you create that because that's all you can create, it works.

#

Nope, all CP boards

stuck elbow
#

I will have to rememeber to not put the levels for my games in a main.txt file then

#

that would be hard to debug

idle owl
#

To make it even more curious for you, there's also support for code.py.py etc because Windows hides the file extensions and people were adding them due to confusion and ending up effectively having two extensions on the file.

#

It would indeed!

stuck elbow
#

do imports also work with .txt files?

manic glacierBOT
#

Yes, this is a documentation issue, but it's kind of a more general warning about the limited size of integers, which are 31 bits, not 32 bits. So, @tdicola, I think you're saying that there are peripherals that can take full 32-bit integers but those integers can't be dealt with properly. It would even be true if you were using all-integer arithmetic: there'd be no way for you to do that arithmetic and get a value larger than sys.maxsize (1073741823, 2**30-1). It only has to do with floats...

stuck elbow
#

how about code.py.txt

idle owl
#

I believe so yes.

stuck elbow
#

is there any filename that is safe to use?

idle owl
#

Anything not main or code won't try to run.

stuck elbow
#

unless you try to import anything called the same as them

idle owl
#

Correct. I haven't tested it but if you use code.py and import main.py, I think you'd be able to run them both, which means issues if they're both entire programs and you didn't import it in the right context.

stuck elbow
#

say I have my level reading code in level.py and the contents of the level in level.txt, and I do import level, the .txt has priority, right?

idle owl
#

That one I'm not sure about.

stuck elbow
#

fortunately "level.txt" can't be imported with "import level"

idle owl
#

Ah good to know

stuck elbow
#

that is inconsitent but at least safe

idle owl
#

If it's inconsistent, I assume it's in place to presereve the use of main.txt and code.txt. Since we try to be as consistent as possible.

stuck elbow
#

well, in this case it would be rather bad

idle owl
#

ah

#

That's helpful then

stuck elbow
#

like this, I can just be careful to never name my data files "main" or "code"

#

if it was consistent, I couldn't name them anything

idle owl
#

Ah. Ok. I see. That's good then.

stuck elbow
#

thanks for the information, anyways, I somehow missed it

idle owl
#

You're welcome ๐Ÿ˜ƒ

candid sun
#

hey a quick neopixel question. i'm trying to have a pot control the value of a color. so far i'm able to have the value of pot send to the color when the board is reset but after that even though the pot value changes the color doesn't change. it just stays at whatever the pot was set at originally.

solar whale
#

@indigo wedge For the PCA10056 SDK how did you connect your ILI9341 display device?

stuck elbow
#

@candid sun you need to keep checking and updating it in a loop

#

@candid sun the way the .value works, it only looks like an attribute, in reality there is a hidden function call in there

#

@candid sun so the moment you do something = pot.value, you get the current value at the moment you run this code, and it doesn't change anymore

#

because under the covers it does something like something = pot.get_current_value()

indigo wedge
#

@solar whale I just used the pins that were default for the example from Nordic, but on the nRF chips pretty much any pin can be used for SPI/UART/I2C

solar whale
#

AH - thanks - so all of those are "bitbang" interfaces. No HW I2C or SPI on this chip?

candid sun
#

@stuck elbow thanks yeah i wrote a function for it and was calling that in the loop but i'll try to rearrange things

indigo wedge
#

@solar whale no, the HW supports setting any pin as MISO/MOSI/SCL/RX etc...

solar whale
#

ooh! cool! Thanks - I've spent too much time on the 8266 ๐Ÿ˜‰

indigo wedge
#

which makes mu curious how well does that work with circuitpython since again the STM heritage might not be as flexible

stuck elbow
#

@indigo wedge I think that CP doesn't care as long as the underlying HAL doesn't throw an error

solar whale
#

I'll try some I2C and SPI devices.

#

Is that also true for the nrf52832?

indigo wedge
#

ah I see, the busio classes accept pins in their constructors

#

yes, nrf51 and nrf52

#

but i don't know how much is implemented in circuitpython so beware ๐Ÿ˜‰

solar whale
#

interesting - I did a bit with I2C devices on the feather52 (nrf52832) and had some issues with one of them, but did not persue it. Time to revisit and learn more about it.

#

@stuck elbow I was using I2C on an ESP8266 yesterday and forgot to switch busio to bitbangio, but it still worked fine. Does the busio code know to use bitbang on the ESP8266... or am I even more confused than I thought I was.

stuck elbow
#

@solar whale I think that busio is an alias for bitbangio on the esp8266, or something along those lines

#

the I2C peripheral is, at least

#

so that you don't have to modify the examples

solar whale
#

I hope so ๐Ÿ˜‰ I'll check the code to confirm.

stuck elbow
#

I remember there was a bug for this

tulip sleet
idle owl
#

@tulip sleet She found it. There were differences in the versions on RTD, there's an issue filed for it.

#

That's why she couldn't find it at first.

manic glacierBOT
#

It would be nice to be able to erase and re-create a damaged filesystem from the REPL or a program. Currently on non-Express boards we need to erase all of flash and then reload CircuitPython. On Express boards we have a special Arduino program that erases SPI flash, and then we need to reload CPy.

Something like storage.format(<filesystem>) would be helpful. One minor issue is how to specify the filesystem if it's so damaged we don't know what it's named.

Some previous discussion: ht...

dawn palm
#

Can you directly drive a DC motor with CircuitPython boards?

tulip sleet
#

@dawn palm The pins don't put out enough current. Same is true of Arduino boards. You could use a motor driver board, or maybe just a transistor for a simple application.

dawn palm
#

Are there any not that expensive (/cheap) motor drivers?

tulip sleet
#

what kind of motors: is this a robot or are you just using a little hobby motor?

dawn palm
#

Little hobby motor

tulip sleet
heady dove
#

On to my next question, I have a Feather Huzzah, which appears to be running uPython and spitting data out ttyUSB0. How do I remove uPython and update it with Circuitpython? I can't get esptol.py to talk to the board.

#

esptool

tulip sleet
#

what os are you using, and what version of esptool do you have?

#

looks like linux

heady dove
#

1I'm running ubuntu 16.04 feather is running 1.9 uP esptool is 1.3

tulip sleet
#

esptool.py erase_flash; esptool.py --baud 460800 write_flash 0 something.bin

#

did you do something like that?

heady dove
#

esptool.py --port /dev/ttyUSB0 erase_flash is what I entered

tulip sleet
#

i have omitted the port and it worked.

heady dove
#

okay must be me floundering about on the commandline

#

I'll try to sort it out, as long as it should work, I'll bang away at it

tulip sleet
#

i'm actually using v1.2 of esptool.py, from the extensa toolkit. Also 16.04. my port is also ttyUSB0

#
$ esptool.py erase_flash; esptool.py --baud 460800 write_flash 0 ~/Downloads/circuitpython/adafruit-circuitpython-feather_huzzah-2.2.1.bin 
esptool.py v1.2
Connecting...
Running Cesanta flasher stub...
Erasing flash (this may take a while)...
Erase took 8.7 seconds
esptool.py v1.2
Connecting...
Auto-detected Flash size: 32m
Running Cesanta flasher stub...
Flash params set to 0x0040
Writing 602112 @ 0x0... 602112 (100 %)
Wrote 602112 bytes at 0x0 in 14.3 seconds (336.7 kbit/s)...
Leaving...
heady dove
#

so when I try your code (after changing the location of the file ) I get this error

#

serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'

#

I know there is a program running on the Huzzah that is spitting data out the ttyUSB0 port

#

FYI I tried it with 1.3 not 1.2

tulip sleet
#

are you connected via screen or anything to ttyUSB0

#

actually I can think of simpler reason: you are not in the dialout group.

#

maybe

heady dove
#

I am connected via screen

tulip sleet
#

that's why the port is busy. So if you disconnect that, should work.

heady dove
#

?

#

how do I talk to the chip

tulip sleet
#

I mean are you using the screen program right now? You can't flash the chip if you have a serial terminal program connected to /dev/ttyUSB0.

#

so just exit out of screen and then try esptool agian

heady dove
#

well I'm not connected via screen when I try to use esptool

#

if I screen in, I get a stream of data coming from the huzzah

tulip sleet
#

that's odd, shouldn't matter. but could you just go in and delete main.py with ampy and then try again?

heady dove
#

got it sudo ๐Ÿ˜›

tulip sleet
#

ok, so you do need to add yourself to the dialout group. Then you won't need sudo.

heady dove
#

so you were right

#

yea, I'll have to try and figure out how to do that ๐Ÿ˜›

tulip sleet
heady dove
#

shoot it failed

tulip sleet
#

did the erase work?

heady dove
#

File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'

tulip sleet
#

ls /dev/ttyUSB* is there more than one ttyUSB device?

heady dove
#

no

tulip sleet
#

wait did you do sudo esptool.py erase_flash; esptool.py --baud 460800 write_flash 0 something.bin? You need to put sudo in front of both esptool.py invocations.

heady dove
#

just USB0

#

ahhh

#

let me try that

#

Connecting........

A fatal error occurred: Timed out waiting for packet header

tulip sleet
#

try reducing 460800 to 230400

heady dove
#

I know just enough to be dangerous

#

Connecting.........

A fatal error occurred: Invalid head of packet ('\x00')

tulip sleet
#

try 115200 or just omit --baud <n> altogether

heady dove
#

I had been doing 15200 prior so that's what I used

#

115200

#

you can do that? I'll try

tulip sleet
#

115200 is half of 230400

heady dove
#

yes it is ๐Ÿ˜‰

#

timed out again

tulip sleet
#

but the flash_erase works?

heady dove
#

A fatal error occurred: Timed out waiting for packet content

#

I believe so, I had been leaving it off these last few try's

#

I have a single red led to the left of the usb connector

tulip sleet
heady dove
#

and am unable to screen in

tulip sleet
#

if it partly wrote some of the code, then you should do flash_erase again. So maybe do that first and try at a lower speed

heady dove
#

let me try

#

esptool.py v1.3
Connecting....
Running Cesanta flasher stub...

A fatal error occurred: Timed out waiting for packet content
esptool.py v1.3
Connecting......

A fatal error occurred: Timed out waiting for packet content

#

should I try using V1.2?

tulip sleet
#

probably doesn't matter, but you could try. But it sounds like it's not going into bootloader mode. Did you press the reset button?

heady dove
#

at what point - "press reset"?

tulip sleet
#

first, just try before erase_flash

#

it may be in a bad state. Try unplugging it, attaching GPIO #0 to ground, and then powering it up. It will go into bootloader mode.

heady dove
#

do you know what the red led indicates? If I press reset it goes out

tulip sleet
#

it's just for general purpose blinking, and it pulls up GPIO #0 to not switch to bootloader mode normally.

#

I have to go shortly -- sorry.

heady dove
#

no problem, thanks for all the help

tulip sleet
#

hope it works eventually!

heady dove
#

I'll sort it out with all your links

heady dove
#

@tulip sleet Finally got it working ๐Ÿ˜ƒ Thank you so much for your help

idle owl
#

@heady dove Awesome! Great job!

heady dove
#

I guess I had gotten used to having the drag & drop virtual disk, had forgotten how convoluted the 8266 could be .... Again the community here is amazing

idle owl
#

Thanks! Glad to have you as a part of it!

#

I haven't worked much with the ESP8266 for that very reason. So I understand.

timber mango
#

@tulip sleet been having good luck with latest 3.0 on M4. no crashes yet!

idle owl
#

Nice!

timber mango
#

@idle owl how's the lamp going, need anything from me?

idle owl
#

@timber mango Haven't tested the light response yet but sound doesn't work very well. I can smack the table and it reacts but clapping at it doesn't do anything. So we could theoretically use sound for another "tap" input but it's not going to work like normal. The copper tape doesn't stick to it at all, so I'm not sure how to integrate that yet. I need to stick a dab of hot glue on it to see if that sticks at all, and then we could theoretically run a wire up the side or something for cap touch.

timber mango
#

kk

#

its all about experimenting - seeing what sticks. literally ๐Ÿ˜ƒ

idle owl
#

quite literally ๐Ÿ˜„

timber mango
#

we'll probably stick to the motion sensor

idle owl
#

That's what I'm thinking

timber mango
#

but - its worth it to look at other things

#

its also good to integrate that into theg uides "I went with the motion sensor because..."

idle owl
#

I put the other lamp together. Without the lampshade part on it, it looks like the lunar lander.

#

Oh yeah makes sense to include all that

timber mango
#

saying what didnt work can be really helpful!

idle owl
#

I'll have to glue/tape the CPX into the big geometrical lamp but there's a spot it fits on top of really well

#

The third one, the paper one we got, not so much, it will be a trick to get it to stay in it.

timber mango
#

k skip that then

idle owl
#

ok

timber mango
#

give it to a friend moving into a new apartment if ya dont need it

idle owl
#

hah ok. ๐Ÿ˜ƒ

timber mango
#

or freecycle ๐Ÿ˜ƒ

idle owl
#

With the geometrical one, it seems doable to run wires up the seams of it, that could be attached to the touch sensors

#

don't know if we want to include soldering or not, or whether twisting them is enough

#

I've had mixed results with twisting wires onto it, but I've only tried a couple of times

timber mango
#

hmm yeah you can do it with pliers

#

if you twist tight enough,

idle owl
#

yeah

#

So you can also reach into it really easily, so we can use the buttons, and maybe the switch if I can secure it to the lamp well enough

#

but IR from across the room for most of it I figured. Wasn't sure if you wanted to do more than that with this one

timber mango
#

yah be creative, you can also look up ikeahacks, see what people like to do

idle owl
#

ok keen

timber mango
#

can even ~go wierd~

#

ok rest time

idle owl
#

ok! have a good rest!

idle owl
#

@tulip sleet The numerical results of rotating this lamp differ significantly depending on how you rotate it... if I rotate it slowly in more of an arc, z drops to zero on either end and x cycles between about 10 and -10. If I twist my wrist, x changes and z gets sharp increases. I guess if we go with this as an input, I'll have to put up a video or a series of images showing what the necessary rotate motion looks like.

tulip sleet
#

@idle owl could you maybe demonstrate rotation by turning it upside while it was sitting on a table, so that its head then touched the table? Maybe that would be a consistent way to demonstrate? Or just turn it upside down (or sideways left or right) and wait a few seconds?

idle owl
#

@tulip sleet Potentially. I've been trying different things to see what the results are. In the end, whatever I go with needs to be consistent, so as long as that's possible with something, we're good to go. That's what I'm trying to sort is what I can do consistently.

#

If it's slow, it seems to be consistent

tulip sleet
#

so can you detect static upside-down or static on left ear or right ear? then wait 2-3 seconds and confirm it's still in same position, then change state?

idle owl
#

Dinner! Be back in a bit.

tulip sleet
#

bye - late dinner!

idle owl
#

Yeah we often eat late... I didn't realise how late it was today though.

#

@tulip sleet I like the static idea. Sounds easier to code. Could be wrong though, might be the same concept regardless.

light gate
#

Hi everyone. I am having trouble "see"the CIRCUITPY drive on my new Cicuit Playground Express M0. I unistalled/installed the drivers from wev stight. Funny thing I can see the drive when I plug in my Trinket M0. Also with th CPEM0 I am able to see the serial print out using PUTTY. any suggestions?

#

Wev =web. Stight=site

#

Update: I am able to see CPLAYBOOT drive.

#

Update: updated the .uf2 file. SUCCESS driveis available but main.py is gone.

#

Is there a location I can get the default Main.py program???? Please advise.

idle owl
#

Was this a new Circuit Playground Express?

light gate
#

Yes

idle owl
#

If so, the demo on it wasn't CircuitPython. So it didn't have a main.py file on it to begin with.

#

When you first install CircuitPython, it's empty.

light gate
#

Doing that blew away the existing program

idle owl
#

Yes the demo it ships with is done with a different programming language.

#

I can give you the file so you have it, but it isn't a main.py. If you load the file on the board, you'll overwrite CircuitPython. The two can't exist on the board together.

light gate
#

Is it ardruino c

idle owl
#

No it's MakeCode.

#

You can't get to the code this way, it's more like an image file.

light gate
#

Can you email it to me

idle owl
#

Are you unable to download it?

light gate
#

So loading the .uf2 for cicuitpyton was what I needed ti do if I want to use it. Im on smartnot phone.

idle owl
#

Correct. But to begin coding with CircuitPython, you'll need to load the libraries on onto the Circuit Playground Express, and either grab a demo file, or write up some code yourself to put in main.py

#

That guide has a lot of valuable info on getting started with CircuitPython as well.

light gate
#

Thanks

#

Got it ..... Thanks for the help Kattni

idle owl
#

You're welcome!

#

Feel free to keep asking questions. That's what the community is here for. Weekends are sometimes quiet, but people will get back to you.

manic glacierBOT
manic glacierBOT
manic glacierBOT
manic glacierBOT
#

Yes I am aware of that but it seems Github doesn't support PRs that are on top of other PRs, so I could commit a series of commits and put them into separate commits because the PR will always include all commits not in the main branch. For example the LED fix depends on the nRF52840 PR so I wish i could make a LED PR which is marked to depend on the nRF one and can't be merged until that one is. But I can see how that could get complicated and confusing fast ;)

#

I see, then we should maybe discuss how we should name pins on nRF board, because the datasheets (page 11 @ http://infocenter.nordicsemi.com/pdf/nRF51822_PS_v3.1.pdf), (page 13 @ http://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.0.pdf), (page 13 @ http://infocenter.nordicsemi.com/pdf/nRF52840_OPS_v0.5.pdf) always refer to the pins as PX.YY where X is 0 for nRF51, nRF52832 and nRF51810, and 0 or 1 for nRF52840, and YY is 00-32 for X=0 and 00-15 for X=1.

Same notation is used on the DKs, f...

manic glacierBOT
indigo wedge
#

Is there a class available for receiving a callback when a input pin changes value?

#

DigitalInOut seems like something that might have such functionality but it doesn't

stuck elbow
#

no, there is no support for interrupts as of yet

#

what are you trying to do?

indigo wedge
#

not much yet, just trying to gather some info, but I was thinking of getting some code going for a SPI keyboard driver that uses a interrupt pin to signal when data is available

#

and i know i could just poll the pin but a callback seems more sane

manic glacierBOT
indigo wedge
#

it could be probably added in C in a similar fashion to how the gamepad module is implemented, have a map of pin -> callback and poll the gpios at regular intervals, if the state changes (optionally the class could offer functionality to select low->high, high->low or any->any), then the callback is called

stuck elbow
#

the problem with interrupts is that there are restrictions on the code that can run in such a callback โ€” since they can happen in any moment of executing a python instruction, you can't do anything that would affect the running interpreter โ€” in particular, you can't allocate any memory

#

micropython has interrupts, and people have a lot of problems with them because of that

indigo wedge
#

i see, i wasn't aware

#

but doing it at python level would be fine, right? then it's just a call to a function inside python

stuck elbow
#

so we are waiting to collect more data about the use cases before implementing a more restricted, but easier to use alternative

#

one idea is to use "soft interrupts" โ€” that is, don't call the callback immediately, but only set a flag instead, and call it when the current python instruction finishes

#

of course then it's not so useful for real-time stuff

manic glacierBOT
uneven yarrow
#

I know there's a python library for raspberry pi, but will that same library work with cirucit python?

solar whale
#

@uneven yarrow probably not without some modification - what libarary are you trying ot use?

uneven yarrow
#

haven't tried it yet

idle owl
#

Oh we have a CircuitPython Trellis lib in the works.

uneven yarrow
#

I'm considering switching my project's code base from c over to circuit python so I can use a trinket m0

#

oh nice!!!!

solar whale
#

@indigo wedge I am trying to connect and SPI device (SDCard reader) to the PCA10056 board but I am not having much luck. It works fine on the feather52 using the defined SCK,MISO,MOSI and D27 for CS -- On the PCA10056 I tried PB12,PB11,PB10 for SCK,MISO,MOSI and PB3 as CS but it is not detecting the card as it does on the feather52. Are there certain pins I should be using for SPI?

uneven yarrow
#

@idle owl is there any kind of ETA on the trellis for circuit python library?

#

just curious

idle owl
#

@uneven yarrow Unfortunately no. As far as I know he's got a single Trellis working, but is working on adding a matrix. I can find the link to the github repo for you. It's public, it's not in the bundle yet. Hold on.

uneven yarrow
#

gotcha