#circuitpython-dev
1 messages ยท Page 144 of 1
Ok I got both peripheral (advertising, connecting, reading and writing), and scanner working on nrf52840 with SD 6.0.0, just need to clean up the code and can make a PR most likely Friday.
Wow! Sounds great! Looking forward to you PR. Iโll be happy to give it a try. Thank you.
Does the NRF52 need any special programmer (IE, JTAG) for putting CircuitPython on it, or do you just need the device and a computer?
@cunning crypt Feather nRF? or just the chip?
yeah, you'll need a JLINK, IIRC.
(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
Emu school? Does it teach military tactics?
i can neither confirm nor deny the existence of a select group of individual classes designed for tactical emu usage. ๐ต
Well, I was thinking about the Emu's track record. The one war they were in, they did pretty well
I have a CircuitPlayground Express. The lib is 20180128. When I enter the following code the board crashes into safe mode:
Adafruit CircuitPython 2.2.1 on 2018-01-23; Adafruit CircuitPlayground Express with samd21g18
import board
import gamepad
pad = gamepad.GamePad(board.D4)
As I am new to CircuitPython please be gentle ;}
Ah, nevermind I think. I just realized that I need to be passing in a DigitalIO object ... sorry ...
But, it should not crash, so we'll leave this open.
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...
Hmmm, does't seem to be working ...
import board
import time
import digitalio
import gamepad
pad = gamepad.GamePad(digitalio.DigitalInOut(board.D5))
while True:
print("pad=", pad.get_pressed())
time.sleep(0.5)
Doesn't show anything other than 0. And the example code under the gamepad module shows similar results. Should this be a separate issue?
@ctgreybeard This issue is good for now. In the meantime, you likely don't need to use GamePad for what you are doing. I'd suggest using DigitalInOut to start with and only use gamepad if you find you are missing button presses.
This is very odd:
- 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
- Unzip it and put the
adafruit_circuitplaygrounddirectory at the top level ofCIRCUITPY - 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 ...
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.
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!
How is the button connected to D5?
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?
@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
Well, if I rember correctly, thatvs been planned for a while
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.
The truncated Memory Error: message occurs as far back as 2.0.0, but it's OK in 1.0.0.
D5 is a button on the Circuit Playground Express. D4 and D5 are buttons on the board, also called BUTTON_A and BUTTON_B.
And I was missing presses which is why I thought to use gamepad. But I think I will use Touch instead because I can remote that from the board.
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...
@tulip sleet @slender iron did something fail with this mornings bundle release?
@solar whale, yeah it did, travis failed. Leaving it for @slender iron to check on.
lots of changes yesterday
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.
@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
battling bots
who is around for a quick review?
โ
thanks for the review @tidal kiln
@slender iron np. curious why that PR was needed. i thought once in the bundle updates would just be brought in automatically.
@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
ah
I don't think we need to fix this in 2.x. I'd only fix crashes in 2.x at this point. Lets shoot to have this done as polish on 3.0. Please change the milestone if you agree.
new talk from raymond hettinger is up, sounds interesting: https://www.youtube.com/watch?v=lSnBvQjvqnA
Raymond Hettinger - Python 3.7's New Data Classes - SF Python's 2017 Holiday Party Main talk at the 3rd Annual Holiday Party for Python Devs in the Bay Area ...
@tannewt Ah, that would explain it โ the gamepad library assumes the buttons are connected to GND and sets pull-ups. Perhaps I should add an option for this somehow.
I need to add the code checking if it's DigitalInOut anyways.
@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.
'tuple' rhymes with 'couple'? huh. i've been doing it wrong.
what did you rhyme it with?
more like 'scruple'
to my non-native-speaker ear there is no difference
I'll debug it in 3.0. If it's a serious memory problem I'll backport.
yah, it's subtle. 'uh' vs. 'oo'.
maybe 'cup' vs. 'clue' (if that helps)
@tidal kiln you're not alone. I'm a "toople" sayer as well.
I see, yeah, It's more like topple than toople
yep
we should all just be writing IPA and there would be no problems
@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?
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*
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
I see. So, CircuitPython is by design a subset of MicroPython for like space reasons?
And thanks for the reply btw
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
It's neat, and I am starting too appreciate the amount of work that goes into it, so thanks!
its weird to me that ctime returns a string
I'm a long time C++ developer, so it all seems weird to me ๐
๐
I think we'd add gmtime if anything
our RTCs use time.struct_time so that'd make more sense to support
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.
yeah, the time module is C code so it'd be added there
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...
Neat thanks!
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
.
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.
what os are you running?
k, windows is bit trickier than mac or linux
I have a mac mini langushing in the corner.
Virtual Machines are great
this guide has slightly old instructions: https://learn.adafruit.com/micropython-for-samd21?view=all#build-firmware
I think I was able to get it to build on Raspberry pi at one time
although it says micropython the build instructions are the same for circuitpython
I have a Huzzah, not even sure of the chip...
huzzah has esp8266
I guess if one changed the project code, then one would have to check it on each chip too, right? To be ethical ๐ ?
Circuit Playground Express is the best to learn CP on, it has so many components to play with and learn
Ah the round guy with lights
and buttons, and accelerometer and light sensor and microphone and speaker and temp sensor
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 ๐
the huzzah has an rtc, which is nice
we do have a continuous testing setup here at my house with boards but its pretty flaky still
How many boards do you have for it?
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
We all get to test changes
@slender iron The fancyLED zip file appear to be empty https://github.com/adafruit/Adafruit_CircuitPython_FancyLED/releases/tag/1.1.0
@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
these two PRs need reviews: https://github.com/adafruit/circuitpython-build-tools/pulls
then we can release a new build tools and it'll be fixed
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
@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
"""
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__
Usually these kind of attribute errors, are actually due to inconsistencies with spacing and tabs in the source file
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
make sure the dunder str function is indented as a member of the LockedState class
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.
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.
Are you looking for help implementing a state machine in Circuit Python or just in general?
in circuit python on a trinket m0
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.
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
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...
}
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?
well, with just two states, you can really get away with just using a flag
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)]()
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.
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
yeah the button press needs to be able to interrupt
this is my working code that I am trying to fit with the state machine. works with 3 simple functions. https://github.com/Begs97/Relay_Timer/blob/master/Timer.py
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
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
@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
you want the initial state to be 1
@opaque patrol thanks Im gonna add it in right now and see what I can get going with it
I see where you are setting end_time in funct1 but that isn't being checked anywhere
yea that should be a condition after the start button has been pressed and reset if the stop button is pressed
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
ok Im going to try to doctor this up right now
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
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
You would also need to set end_time to None inside function 2
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
@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?
yup yup
@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
sure
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
I should am going to need to learn how to switch between states theres no way around that
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).
@opaque patrol I fixed the FancyLED packages
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
@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
@heavy galleon its checking if its set or not essentially. let me find a link
ok but it wouldnt count that we just set it to none right above?
or does "none" have that specific functionality
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
Ok that makes perfect sense. I kinda figured but did not formally know that. thanks for the clarification
yeah, javascript has a similar handwavy nature of boolean values
looks like there is some backstory about it here: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/18/idiomatic-python-boolean-expressions/
You might think that boolean expressions โ most frequently used as conditional guards which are the the bit of code that tests whether an if or while statement should execute โ are a fairly straight-forward concept and that there isnโt really anything subtle to them at all. And while the general concept is simple, there...
if you want to know the history
yea I'll give it a read
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
the exampl eis wrong
thats a PR to fix it
basically you need import adafruit_fancyled.adafruit_fancyled as fancy
okay, I was going to try from adafruit_fancyled import * and see if that saw the different objects and functions
@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!
you too @heavy galleon !
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?
Adafruit.com is down?
@arturo182 A couple resources are https://circuitpython.readthedocs.io/en/latest/docs/design_guide.html and https://circuitpython.readthedocs.io/en/latest/docs/common_hal.html . Other than those, I'd encourage you to join our Discord chat. I'm usually on there and would be happy to video chat with you to get you going.
@opaque patrol briefly for planned maintenance
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...
oops!
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. ๐
๐
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
โ 1โฃ 0โฃ 0โฃ 0โฃ
lol
lol
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)
I forgot to add this part which is required to support the two SPI flash types for itsybitsy m0!
LATE NITE LEEEKS
add a circuitpy board, rotary encoder and neopixel ring for a desktop multimedia dia
@raven canopy is the LUT some static resource you could put at the class level and share between instances?
actually, since you put it that way...the LUT is declared outside instanciation... (is that how you spell that? haha)
https://github.com/sommersoft/Adafruit_CircuitPython_Trellis/blob/master/adafruit_trellis/trellis.py
so, i think i may have been false warning myself.
yah, i think you're OK. module level also works. it won't create more copies for each matrix.
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.
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.
pylint just ate me up! still a 7/10 though. better than negative. ๐
sometime it's tempting to # pylint: skip-file
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?
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
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. ๐
@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.
Panels finally arrived,
@ruby lake very nice!
@raven canopy I may have broken it with my new stuff. I can figure it out with you tomorrow after the hack chat.
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
@full ginkgo how is the power for the strand wired?
gnd to gnd, pos to usb, using pin 1 to drive it
Can you measure the voltage on the pos/usb pin?
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
yes. there's no path from the battery to the USB pin.
makes sense..
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.
gotcha
hey... what do you know, a re-solder to the right pin and I'm in action
thanks @errant grail !
Super!
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
Ah. Purple is also the color of CircuitPython's Blinka. 
Music by Prince?
Anyway best of luck to you.
@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.
I blogged it on Wednesday and have a post scheduled for 10am PST which is two hours before.
@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.
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
OK - thanks _ I'll giv it a try.
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
ah - but my USB port may not be sufficient - I'll try connection a lipo
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
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.
yeah the mem_info function is handy to help see how much of the heap is being used: http://docs.micropython.org/en/v1.9.3/pyboard/library/micropython.html#micropython.mem_info
you can call it before and after doing something
and look for the total free IIRC
@timber lion @solar whale there is also gc.mem_free() just remember to gc.collect() before it
@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. ...
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
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
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
luckily the rfm69 will stay listening even after the receive call returns (there's actually an extra param i put on receive, keep_listening=True, which puts it back in listen mode after running: https://github.com/adafruit/Adafruit_CircuitPython_RFM69/blob/master/adafruit_rfm69.py#L701 )
hmm tried setting .1 but it immediatel resets when the urequest.post is issued.
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?
interesting that the reset.cause is 2 which is an externalt reset
yes only on AIO call
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
I think you are correct.
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
It runs fine if I dont do the post.
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
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?
ah yeah looking at urequests it expects to parse the response no matter what unfortunately https://github.com/micropython/micropython-lib/blob/master/urequests/urequests.py
which is unfortunate, it would be nice if they had a 'fire and forget' option to not construct and parse the response
the response ishuge!
ofteen get TSL buffer overflows - it is a know issue with ESP8266
if you want you might grab the urequest code and remove this section or add a new request_forget function that's the same as request but doesn't have this bit: https://github.com/micropython/micropython-lib/blob/master/urequests/urequests.py#L102-L105
ohhh - good idea - I'll give taht a ty.
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
I can post to AIO just fine -- either rfm69 or AIO , just not both.
thanks! can we regen the itsybitsy m0 uf2? that's the only one affected
@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.
Could you test the travis-built .uf2 from here? https://adafruit-circuit-python.s3.amazonaws.com/index.html?prefix=bin/itsybitsy_m0/ We can do a quick 2.2.2 release if that works for you. It won't take long.
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
@timber lion Quick unrelated q: what OS were you using with the MicroPython plugin on PyCharm?
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
@timber lion bitwise OR'ing?
@timber lion thanks
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...
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
Yea i dont think | works for floats past a certain val.
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
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
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?
it's variable length, as long as you need
nice
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)
yah, i've used that in full python (a 256 bit integer ๐ )
ok folks @here CircuitPython Hack Chat @hackadayio @hackaday @river quest #circuitpython-dev - https://hackaday.io/messages/room/2369 3pm ET! (20 mins from now)
THIS CONVERSATION DOES NOT EXIST
Click on "New Conversation" or on an existing conversation to start chatting
Should I click again in 8 minutes?
@half sedge I think you need to apply to the group first
Join thru github to speed it up
Click on Join Hack Chat
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!
I follow on Youtuve now.
Multistreaming with https://restream.io/ Visit the Adafruit shop online - http://www.adafruit.com Join the Adafruit Discord http://adafru.it/discord ------...
hello
i don't have enough monitors for all this! ๐
I have 2 chats and video open, and I'm getting crazy trying to listen and read all that
MORE CHATTSS
I have some good questions prepared ๐
@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 ๐
Pffst, who needs that vitals monitor anyways?
And it even comes on its own rolling stand!
I'm passively listening -- handling a few of my own bugs here for work, but this is awesome to have on in the background ๐
As mentioned in #561, both Peripheral and Scanner are working
hackchat is always chaotic
yeah, it's really chaotic! (but chaos is kinda fun right?)
the website is black, so you know what to expect ๐
I asked a question ๐
If you put a microscope on the chaos. You think your looking into a mirror
It's a standard keyboard, not a mechanical one, the key travel is small so it's faster ๐
heh, I can see which of you is typing by your mic's picking up keys and highlighting your username
the most random number is 17
this is totally a work in progress, ESP's in tic-tac's and other things, code and parts list here http://nubcore.com/wiki it's mostly MicroPython with some Adafruit CircuitPython additions
...I like the NSA EFF(?) pin you have there
It's actually a button from a Japanese BBQ place in Oakland CA, EFF pin is on teh other side ;+)
Oh - neat!
@prime flower oops I mean Fried Chicken https://s3-media4.fl.yelpcdn.com/bphoto/h2PF1l6JKMveCX1ceNb4WA/o.jpg
....I love that logo and want to eat there now
anyone know any particular meetups/groups/chats etc that focus on ESP32 dev, looking to connect with more contributors around BLE and such
@quick python there is the #esp8266 channel on freenode
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?
cool, anyone in Bay Area that wants to do a meetup give me a ping
@timber mango you too ๐
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?
that was fun to watch in the background! good job all!
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?
@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
@idle owl i published it - replying to BC now ๐
@timber mango yep I see it, also replying ๐
@quick python team work makes the dream work
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...
"yes to both"
So to test things like BLE scanning do you just enter the commands into he REPL manually or put the script in "freeze" then rebuild?? Just curious how you are using it.
I was able to manually execute a ble scan, but it's pretty painful ;-)
I'm OK with merging it as is and getting ampy working later but I'll leave that up to you and others.
I also verified that I can still build and load the feather52 and use ampy to load files to its FS. So no harm done!!
I just enter REPL and type the code manually, indeed painful, so we need to get ampy working!
Good that the other boards are not broken, but still would be nice to get it working on the pca10056, just to save ourselves some sanity.
@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?
done! i just tested on both USON flashes with the same hardware PCB!
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.
@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.
@raven canopy yeah, please fix cookiecutter if you find issues
@idle owl bummer, we could look into it later
@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.
valid.
We'd need someone to write support in for the CircuitPython boards. The plugin is written in java.
is it open source?
yup
kk, its probably not too hard to fix then
@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,...
I'm ok merging this with ampy not working as long as the other boards are fine. I'll let @microbuilder do the review.
i could add prelim pIRkey definition over the weekend, its a trivial trinket-like. lets see where we stand on monday
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...
Add a page to the Intro guide explaining how to get the REPL working in PyCharm with the MicroPython plugin.
Guide page is published. However, screenshots are still being updated. Leaving issue open until guide is entirely complete.
now Travis is happy. ๐ only took 17 builds. lol
something something fire of a thousand suns?
yeah...but most of it was my fault, not Travis'. ๐
@slender iron cookiecutter updates PR'd. it was only 2, that i encountered.
LEEEEEKZ
Excellent
LEEKA
oooh
was this what was showing in your screen during hackday? beginning?
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
Yah it was the M4 Metro
ir2hid?
yah
but that one was really rough to supprot
tee hee. imma gonna control your compy....from way over here.
noooooooooooooooo
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...
@arturo182 I've seen USBS in USB mass storage packets. What USB descriptor are you using?
Thanks! A fun and useful project!
Have an updated .travis.yml which will build the docs using sphinx for every PR.
Once a month, maybe by scheduled cron job, run make linkcheck on all the docs.
I'd like to see that schematic. ;)
@timber mango not much to it, actually. If you're interested, I can DM a block diagram or the Fritzing prototype graphic.
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. ;)
Yup, then inserted a PowerBoost 1000C, a shunt resistor, and a traditional analog meter.
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.
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.
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.
I don't have any experience using HID via USB -- I just use the default serial output libraries.
I think HID is all about mice and keyboards (Human Interface Device).
... and being recognized by the host computer, right?
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".
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."
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.
Sorry -- dinner bell just rang. Good talking to you, nis.
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!
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 ๐
Screenshots have been updated, guide page here: https://learn.adafruit.com/welcome-to-circuitpython/pycharm-and-circuitpython. Blog post about update has been published here: https://blog.adafruit.com/2018/02/02/guide-update-get-connected-to-the-repl-using-pycharm/
All set to go!
Answered me own question, needed to naem my file main.py ๐
And thank you for creating all this. it's fun.
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.
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!
You're welcome! I'm really glad to hear it!
(Making a Huzzah NTP alarm clock for/with my 9-year-old, with hopefully other electronic pranks to follow for her.)
Nice!
this is probably cause it uses 30-bit floats and that number
https://www.h-schmidt.net/FloatConverter/IEEE754.html
is
0x4e8799bf
which uses the second-to-top bit?
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.
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.
Do you use something else besidew AMPY?
Well I don't have the HUZZAH. I have all SAMD21 stuff (and old C8051F330 stuff).
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. ;)
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.
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.
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.
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.
I don't know much yet as it's only been a day :). Still learning the lore.
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.
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.
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.
The mpy-cross program produces I think .mpy from .py and you'll see that .mpy is bytecode, not ascii plaintext.
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.
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. ;)
Very good! Nice to meet you.
You too ๐
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.
Yes, ampy works with external USB to UART board, so it seems to be something related to the debug interface chip on the DK.
How did you connect the external USB to UART board? I'm still finding my way around this SDK board.
BTW - I tried adding the ubluepy_eddystone.py and ble_scan.py (from feather52 examples) files to freeze and they do run on the pca10056.
The board has all the useful functions written on the back silk. Connect RX to 0.08 and TX to 0.06 and problem solved.
;-) amazing what you find when you turn the board over. Thanks.
led_init was never called, which means the GPIOs were never set to output and the LEDs didn't work.
Verified on pca10056 (even though this commit doesn't depend on that branch).
Nice! - ampy is working via the USB/UART cable! I was able to put a few files onto the board and execute them!
Thanks!
just a heads up - Ive have had this happen twice now:
when trying to load a file via ampy, sometimes it fails and files that were on the FS disappear..
lib
boot_out.txt
ubluepy_scan.py
jerryneedell@Ubuntu-Macmini:~/projects/feather52/examples$ ampy -d 1.5 -p /dev/ttyUSB0 put i2c_scan.py
Traceback (most recent call last):
File "/usr/local/bin/ampy", li...
Thanks - Once I figured out that P0.x on the silkscreen corresponded to PA.x in the Pin list. it works great!
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).
Actually, @jerryneedell how did you test the code that you had to reference the pins at all? I just did:
import pyb
led = pyb.LED(1)
led.toggle()
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...
I see, but then you don't use the LED class and my fix ;)
Sorry about that - I did not think that trough very well. I 'm just used to the digitalio interface and did not look closely at the PR. So much to learn...
No worries, you and me both.
Oh, I didn't realize this was spamming so much ๐
yeah - all the circuitpython PR comments go here, but I think its good for folks to see.
its not spamming. more like eavesdropping. ๐
Oh no, all my secrets!
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.
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?
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!
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 ๐
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.
is the ubluepy planned to follow bluepy API 1:1 or is it more of a loose implementation?
@slender iron has been advocating for a switch to bluepy.
i thought the API was already following bluepy
It may well be. I donโt have enough experience to know.
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).
@indigo wedge there is support for the ili9341 in the Adafruit_CircuitPython_RGB _Display library. https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/tree/d47e0cc09ac36d4a0c7ee60380278ed2bc91de63/adafruit_rgb_display
yes, like I mentioned the nrf port has a ili9341 example as well https://github.com/adafruit/circuitpython/blob/master/ports/nrf/examples/seeed_tft.py but i wasn't sure how was the performance of that one
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.
I found the pyboard/MicroPython booth at Fosdem and I am so happy. Would you like/accep picture uploaded here?
Certainly!
Brussels is by far my favorite European city. Although, Ixelles is probably the closest I've gotten to where FOSDEM is being held.
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.
yeah, beer doesn't like to travel
also miss the coffee. those are the two things that 5 years in Europe ruined for me. ๐
haha, yeah, that's what all the Americans who came anywhere near Italy say
though it gets worse further north
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.
shockingly, actual Italian food mostly consists of grilled meat, not pizza and pasta
yes!
thanks!
(it's all stained in flux, because it's the one faulty unit that I had to re-solder manually)
Prototype
@stuck elbow where do you get your PCBs assembled?
@indigo wedge Makerfabs
There was a M4 pyboard. Maybe v1.1 but I don't find a picture.
I'm really impressed by how cheap you can sell the boards, when I looked into PCBA it was so expensive for small runs
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 ๐
@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
I believe it was this (from the spec/size/look) but I don't see M4??? https://www.adafruit.com/product/2390
Ah, that's the first pyboard
That's an interesting strategy for them ๐
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
Yeah, I've seen your board all around the web, great job ๐
thanks
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?
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
yeah, I'm working on a project with a display and that's one of my worries
but how can one play a game if it's not exactly 60 FPS? ๐
it's a mystery
@idle owl heya do you know if the raw_value stuff for touchio is documented anyone
@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.
there's some old rev documentation in RTD ? not sure whats up but
https://circuitpython.readthedocs.io/en/stable/shared-bindings/touchio/TouchIn.html
is not the same as
http://circuitpython.readthedocs.io/en/2.x/shared-bindings/touchio/TouchIn.html
e.g. raw_value and threshold are missing from 'stable'
here's what it indexes
@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
Yeesssss
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
I've tried both
how do you know it doesn't run
got it! a couple of errors
so I should as a habit keep the repl open so I can see errors
very much appreciate the community support
don't hesitate to ask anything
never saw a blink, but I might have blinked in sync ๐
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:
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
@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
At first I thought to use a 'while' loop, but couldn't get it to work. I'll keep digging. . .
can you paste your whole program?
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)
Ok, so maybe I inadvertently fixed my variable 'value' to False since it is assigned before I press the button?
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
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.
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
That makes sense. I really appreciate your patience and help! These little things I'm learning are adding up slowly but surely.
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.cis an easy place to grab `usb_c...
@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
@heady dove code.py will work as well on the CPX.
txt?
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.
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
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
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!
do imports also work with .txt files?
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...
how about code.py.txt
I believe so yes.
is there any filename that is safe to use?
Anything not main or code won't try to run.
unless you try to import anything called the same as them
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?
That one I'm not sure about.
fortunately "level.txt" can't be imported with "import level"
Ah good to know
that is inconsitent but at least safe
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.
well, in this case it would be rather bad
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
Ah. Ok. I see. That's good then.
thanks for the information, anyways, I somehow missed it
You're welcome ๐
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.
@indigo wedge For the PCA10056 SDK how did you connect your ILI9341 display device?
@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()
@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
AH - thanks - so all of those are "bitbang" interfaces. No HW I2C or SPI on this chip?
@stuck elbow thanks yeah i wrote a function for it and was calling that in the loop but i'll try to rearrange things
@solar whale no, the HW supports setting any pin as MISO/MOSI/SCL/RX etc...
ooh! cool! Thanks - I've spent too much time on the 8266 ๐
which makes mu curious how well does that work with circuitpython since again the STM heritage might not be as flexible
@indigo wedge I think that CP doesn't care as long as the underlying HAL doesn't throw an error
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 ๐
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.
@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
I hope so ๐ I'll check the code to confirm.
I remember there was a bug for this
@meager fog @idle owl touchio is documented here: http://circuitpython.readthedocs.io/en/2.x/shared-bindings/touchio/TouchIn.html not sure if that's sufficient for you.
@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.
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...
Can you directly drive a DC motor with CircuitPython boards?
@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.
Are there any not that expensive (/cheap) motor drivers?
what kind of motors: is this a robot or are you just using a little hobby motor?
Little hobby motor
https://www.adafruit.com/category/865 and chips and transistors https://www.adafruit.com/category/153. Depends on whether the motor is going to be under load or you're just spinning something light
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
1I'm running ubuntu 16.04 feather is running 1.9 uP esptool is 1.3
esptool.py erase_flash; esptool.py --baud 460800 write_flash 0 something.bin
did you do something like that?
esptool.py --port /dev/ttyUSB0 erase_flash is what I entered
i have omitted the port and it worked.
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
i'm actually using v1.2 of esptool.py, from the extensa toolkit. Also 16.04. my port is also ttyUSB0
this is esptool.py v1.2 from esp-open-sdk/xtensa-lx106-elf/bin/esptool.py
$ 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...
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
are you connected via screen or anything to ttyUSB0
actually I can think of simpler reason: you are not in the dialout group.
maybe
I am connected via screen
that's why the port is busy. So if you disconnect that, should work.
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
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
that's odd, shouldn't matter. but could you just go in and delete main.py with ampy and then try again?
got it sudo ๐
ok, so you do need to add yourself to the dialout group. Then you won't need sudo.
https://learn.adafruit.com/adafruit-arduino-ide-setup/linux-setup#udev-rules has insructions for two ways to get the permissions. dialout group isntructions at the end.
shoot it failed
did the erase work?
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'
ls /dev/ttyUSB* is there more than one ttyUSB device?
no
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.
just USB0
ahhh
let me try that
Connecting........
A fatal error occurred: Timed out waiting for packet header
try reducing 460800 to 230400
I know just enough to be dangerous
Connecting.........
A fatal error occurred: Invalid head of packet ('\x00')
try 115200 or just omit --baud <n> altogether
I had been doing 15200 prior so that's what I used
115200
you can do that? I'll try
115200 is half of 230400
but the flash_erase works?
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
someone else complaiend about this and MicroPython, but with a different board: https://github.com/espressif/esptool/issues/213
and am unable to screen in
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
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?
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?
at what point - "press reset"?
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.
do you know what the red led indicates? If I press reset it goes out
it's just for general purpose blinking, and it pulls up GPIO #0 to not switch to bootloader mode normally.
https://learn.adafruit.com/adafruit-feather-huzzah-esp8266?view=all#gpio-pins re bootloader mode.
I have to go shortly -- sorry.
no problem, thanks for all the help
hope it works eventually!
I'll sort it out with all your links
@tulip sleet Finally got it working ๐ Thank you so much for your help
@heady dove Awesome! Great job!
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
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.
@tulip sleet been having good luck with latest 3.0 on M4. no crashes yet!
Nice!
@idle owl how's the lamp going, need anything from me?
@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.
quite literally ๐
we'll probably stick to the motion sensor
That's what I'm thinking
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..."
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
saying what didnt work can be really helpful!
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.
k skip that then
ok
give it to a friend moving into a new apartment if ya dont need it
hah ok. ๐
or freecycle ๐
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
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
yah be creative, you can also look up ikeahacks, see what people like to do
ok keen
ok! have a good rest!
@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.
@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?
@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
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?
Dinner! Be back in a bit.
bye - late dinner!
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.
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.
Was this a new Circuit Playground Express?
Yes
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.
Doing that blew away the existing program
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.
Is it ardruino c
You would load this demo file just like you loaded CircuitPython - by copying it to CPLAYBOOT.
No it's MakeCode.
You can't get to the code this way, it's more like an image file.
Can you email it to me
Are you unable to download it?
So loading the .uf2 for cicuitpyton was what I needed ti do if I want to use it. Im on smartnot phone.
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
Here is how to install the library bundle: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-libraries
That guide has a lot of valuable info on getting started with CircuitPython as well.
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.
@arturo182 you can do separate PRs if you start new branches locally. Star them based on adafruit's master and they can be reviewed in parallel.
Stable is now deactivated but the link still works. The version bar is red. Want that for 1.x as well?
@sommersoft seems like you are headed the right direction! I think a new supervisor module and singleton would be best.
Ok, I'll unassign for now in case someone wants to beat me to it.
@arturo182 are you wedded to pyb and machine support? I'm tempted to disable it to save space.
Regarding pin naming, the intention is for pin names in microcontroller.pins to match the datasheet and board pins to match silkscreen and convention. There is a caveat that python variables must start with a letter, which is why ESP8266 is GPIO0 etc.
A member on Discord was asking about using a Matrix Keypad with CircuitPython, similar to the Adafruit Membrane 3x4 Matrix Keypad (PID: 419).
- The Adafruit product page references this Arduino library to use with it: Keypad Library for Arduino
- The GitHub repo for the Arduino library is here: Keypad
- It is licensed under GNU GPL, so be sure to include that lice...
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...
Machine is not enabled in nRF, pyb is, but probably could disable it since all the functionality is available in the new modules. But for machine, I'm not sure that's the case, so maybe we should enable it but only with the classes that are not implemented and slowly move to the new modules.
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
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
I wonder if we could extend the gamepad library to support matrices.
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
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
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
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
yes please make 1.x red
I know there's a python library for raspberry pi, but will that same library work with cirucit python?
@uneven yarrow probably not without some modification - what libarary are you trying ot use?
I was reading over this: https://learn.adafruit.com/trellis-python-library/usage
haven't tried it yet
Oh we have a CircuitPython Trellis lib in the works.
I'm considering switching my project's code base from c over to circuit python so I can use a trinket m0
oh nice!!!!
@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?
@idle owl is there any kind of ETA on the trellis for circuit python library?
just curious
@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.
gotcha