#circuitpython-dev
1 messages ยท Page 149 of 1
lemee see if I can find it amongst the forest of bookmarks
This also tweaks the board reset to occur after a file is run rather than before it is. That way the PWM will not continue while in the "wait state" after code.py runs.
Fixes #265
@slender iron it's older than I thought and now broken except for the cached version:
https://webcache.googleusercontent.com/search?q=cache:JPhDWkJ1nbcJ:https://eewiki.net/display/microcontroller/Getting%2BStarted%2Bwith%2Bthe%2BSAM%2BD21%2BXplained%2BPro%2Bwithout%2BASF+&cd=1&hl=en&ct=clnk&gl=us
ah yeah, thats the basics ๐
There was another couple about unrolling some ASF4 code which was neet:
http://www.avrfreaks.net/forum/tutsoftcunderstanding-asf4-atmel-studio-7-code-part1
http://www.avrfreaks.net/forum/tutsoftcunderstanding-asf4-atmel-studio-7-code-part2
In part 1 we looked at the USART_0_example function to transmit bytes over the virtual serial com port to the data visualizer.
I wonder if we can clock this qspi at 120 mhz ๐
the peripheral does but the flash doesn't from what I can see
Which chip did she use? I thought the winbond ones supported it
gigadevice I believe
I'll keep it in mind
looks like we can do 120mhz sdr or 100mhz ddr
unless we overclock a gclk to 240
Do you know which footprint she used? If the pins are broken out or tappable, I made a breakout board for the winbond chips a while back
mmmm....240
soc-8 or whatever
my proto actually has a spansion chip on it
point being, we have multiple chips we use
right
If you think it might be useful, I can send you one of my m4 board which has a winbond qspi chip in addition to the regular spi flash, though it's a> a prototype with one or two issues, and b> different enough from the metro as to probably be not useful.
None the less, I'll send you one if you want
boo-urns
108 sdr or...
54 ddr
I was thinking a 96mhz clock would be good to add
for everything that can only run up to 100mhz
sounds good: up the 2 MHz clock or the 48 MHz clock?
The W25Q16JV supports the standard Serial Peripheral Interface (SPI), and a high performance Dual/Quad
output as well as Dual/Quad I/O SPI: Serial Clock, Chip Select, Serial Data I/O0 (DI), I/O1 (DO), I/O2, and
I/O3. SPI clock frequencies of up to 133MHz are supported allowing equivalent clock rates of 266MHz
(133MHz x 2) for Dual I/O and 532MHz (133MHz x 4) for Quad I/O when using the Fast Read Dual/Quad
I/O instructions. Th
not sure, dividing the 120 down might actually be easier
@pastel panther the datasheet for that doesn't say it does DDR
It does mention reading on one edge and writing on another but I don't know if that counts
I have clock changes from the uart stuff and asf4 changes, maybe I should PR that without the rest of uart
I think thats normal
DDR is reading on both clock edges
@tulip sleet did you move them around?
that makes sense
isn't that the D of DDR?
yeah
I think "dual spi" is confusing
not moved around, just better comments in the gclk_config.h (and maybe some updates in the constants). I tried to make the Atmel START setup actually match the clock setup we were using.
kk
time to fetch groceries! ttyl
byeeee!
I'll be on later as I try and figure out my SPI issue again
(i'm guessing PEBCAK)
I might be on. may try to work on qspi later
Well - that was embarrassing.... It works fine on the Linux box now - even ampy seems to works via the J-Link USB now!
I am kinda worried about the change in semantics after code.py runs, that the pins and board get reset, instead of waiting to do it when the board restarts. Suppose I write a non-looping main.py that just does a bunch of setup (like turn lights on by tweaking pins, etc.). That setup state will get lost, no?
i is a uint8_t, so it can't be < 0, so not sure why you're checking this. What situation did you have in mind?
well, I see the break, but the condition in the for loop is always true.
index is a uint8_t. So I don't see that this loop will ever finish.
Good to hear ... no reason you'd know if you've never seriously used the board before, and most boards from silicon vendors don't include an on-board J-Link. Glad it's working reliably, though.
It is working fine on my linux box but I still can't get it to work on the Mac. Odd thing is that even after installing nrfutil 0.5.2b - nrfutil version still shows 0.5.2 -- on the linux box is shows 0.5.2b
Still working on that, but it's nice to have it working on the linux box which is where I use it most.
question, my daugther and i made the "sire" from makecode and it doesnt wants to run on my CPE and i updated the lib and cpx
chage the file name to code.py
and nothin
when i try to look at the code on notepad, the text are " ร ยฟHh + รยฝK "
The nrfutil repo in /lib is pointing to a specific version. I need to update that to point to the latest code with the increased delay on flash erases (0.5.2b). Thanks for the heads up.
@normal mica did you write the program in MakeCode or Python? I'm a little confused
If you wrote it in MakeCode, copy the .uf2 file to CPLAYBOOT.
The .uf2 download from MakeCode is a whole program in its own right that does not use CircuitPython to run.
makecode
@tulip sleet thank you it wrk i guess thing has change since my last makecode project
finally got around to making a code.py blinky work on my m4 board
does a happydance
working on internal flash for now; I'll look at the external flash after I get SPI verified working
listening to async discussion. welcome @quick oyster! will be awsome to see it come to life.
i was totally going to jam out on my 2 open projects tomorrow since i have off. but now i have to type slow b/c i'm down a pinky...silly backyard football.
jammed digits are no fun
i'm hoping its just jammed. pretty swoled at the first knuckle... ice + time is the only thing with fingers though. and occasional motrin...
elevation also; keep it above your heart
I broke my ankle last year so I'm recently famillar with such things
yep. immediately after it happened, iced it and had my hand resting on top of my head.
i've broken both pinkys...and have a lot of other misc injuries. "adds character" as my dad used to say. ๐
right; I just messed up my knee last week jumping over a fence while playing disc golf. I think I'm officially getting old
lol. sucks, doesn't it?
indeed.
Just for clarification/get-out-in-front of questions: will these need PRs to the bundle repo, or will adabot pull them automagically?
Totally flaked on adding this after the meeting this week...
ESP32: When is it coming to CircuitPython?
The summarized standard answer I've seen, and given, is that we're not currently developing for it and will pull from MicroPython once their dev is complete. Also, we have no ETA.
Just PRs to individual repos. ReadTheDocs is based on each repo so it'll pick them up once merged. They don't even need a release.
@slender iron setting the timeout=1 on the serial port fixed my issue
๐
zonk time, later folks
hello
not bad, you?
nope, not me
maybe don't have it in your name then? Or post it?
FYI - just for fun I tried loading via the On Board J-Link "directly"
make BOARD=feather52840 SD=s140 sd
That worked fine, but then I found that ampy does not work via /dev/ttyACM0 (the IF MCU port)
When I load via the serial boot loader (reload boot-flash, then dfu-gen/dfu-flash. I can then also run ampy via /dev/ttyACM0. Does this make sense? Not a problem, just showing my ignorance, I expect.
BTW - I did finally get a successful dfh-flash to execute on the Mac. I'm no...
@jerryneedell Just as a visual indicator, it should be obvious when you have successfully entered DFU/Serial Bootloader mode ... you'll get a distinctive fast blinky pattern on LED1. When you are doing an actual firmware update, the DFU Blinky will get even faster. No fast blinky means you aren't in DFU mode.
I'm not sure what's up with the J-Link flashing causing a conflict with ampy, but it's not something I've tried yet since the only design goal on my side with this BSP was serial, but...
This pulls in the latest version of nrfutil, which is required to flash the nRF52840 over serial using the new serial bootloader introduce in #623
@slender iron a couple of elementary q's I can't seem to find the answer to: in a interrupt handler, can I find out which interrupt called me (e.g., which slot?). If I write a general handler I need to know which SERCOM, etc. Also, is our NVIC vector relocated to RAM or is it in flash somewhere?
@tulip sleet each sercom usually has a handler of its own that can pass an index to the general one
I don't think its relocated. its at the start of flash
so it's all by the initial handler - there's no register to retrieve the interrupt number?
not that I know of
yeah, I couldn't find one. but if it's at start of flash, is that not where bootloader is?
ah ok, so it's relocated but in flash, not copied to ram. there is a relocation register. default is to put vector at 0x0 (assumes no bootloader, I guess).
good poitn
here is where I do it for timer interrupts: https://github.com/adafruit/circuitpython/pull/625/files#diff-bd5f9610fd61c59692577747565e92a1R263
This also tweaks the board reset to occur after a file is run rather than before it is. That way the PWM will not continue while in the "wait state" after code.py runs.
Fixes #265
and for the EIC: https://github.com/adafruit/circuitpython/pull/625/files#diff-6e52668b7716bc449e8344e2db2e1dc5R350
This also tweaks the board reset to occur after a file is run rather than before it is. That way the PWM will not continue while in the "wait state" after code.py runs.
Fixes #265
usart_async code keeps track of which sercom by setting a global to the ASF4 descriptor for the usart functionality
thanks, very helpful
EIC is more interesting because the M0 has one irq for all lines
don't forget to clear the interrupt in the handler otherwise you'll infinite loop
thanks - trying to reuse ASF4 code but i think I need to change the API to pass in more info
all of the handlers are weakly defined so you just need to provide a function with the expected name
that's what I thought -- they hardwire the sercom interrupt handler to the (fixed) one in hpl_sercom.c, based on the bindings you set up in Atmel START. I have to undo that.
ah, yeah that'd do it
i don't mind using their code in general because it has a lot of knowledge of the SERCOM registers. USART SERCOMs are quite featureful and complicated. So if I can get away with patches rather than a rewrite it might be better.
I find the datasheet is better documented than asf4 is
each section usually includes init instructions and how to do common tasks
did see that - i liked the old asf3 application notes too but they don't exist for asf4. Also until reading your code last night I was blind to the fact that the CMSIS-style peripheral register access was available for ASF4. I thought it was only via hri_
we'll see how far I get with modifying asf4 or give up in frustration and go to reg-leve access
I hadn't thought about wrap around. I was checking both "ends" because we don't know which direction the loop is running.
kk, I've given up but am fine if you want to use asf4 more
as far as I could tell hri only provides locking hooks on top of the cmsis-style manipulation
We could potentially spend a long time but we don't make any promises about how quickly we'll change duty_cycle so we should be ok.
Good catch! I would have needed to test that it works when all TCs are already in use.
This is a little trickier because the register its assigning to changes. Its hard to see but the fourth letter changes. Still want me to have two look up tables?
Style and loops fixed.
I don't think we should preserve state after main.py exits because the python code is no longer running. Instead, the code should be explicit that it wants to keep the state by using time.sleep or an empty infinite loop.
@tulip sleet any other questions? I'm gonna go run errands for an hour or so
hmmm, still not sure that's a great idea; we can talk after you return
have time to talk now? I can leave in an hour if need be
k
@slender iron and @tulip sleet Thanks for having that interrupt/usart/sercom chat here in #circuitpython-dev; it was very interesting and informative
I just wanted to say: YAY! Great work @tannewt! This will be fun to dissect.
@pastel panther Did you see we recorded and posted the asyncio discussion?
@idle owl yea, thanks! I'll listen to it tonight probably
Ok keen
It shall sooth me as I do more SPI and now pulseio testing tonight ๐
@pastel panther I'm back
buh, just finished putting out a fire, I think
๐
k
Are there any stackable short headers on adafruit?
I am looking for https://www.adafruit.com/product/2940 but with the male pins extended
you mean with a short female part, but long male part?
Yes
I don't know about anything like that
For the Trinket M0 I had some luck using those: https://www.aliexpress.com/item/2-54mm-Female-Header-Single-Row-5PIn-short-version-plasticheight-3-5mm-straight-180o/622209657.html โ they are even shorter than the Adafruit ones, and since Trinket's PCB is so thin, they actually stick out on the other side enough to stack them.
but that won't work for the feather
I have the larger stackable headers from adafruit, but the pins are so long they are easy to bend
Not to mention the actual size
you can always cut them shorter
@analog drift so you are looking for something longer than the short header but shorter than the extended header (https://www.adafruit.com/product/2830) ?
@steel copper yea
I just need the male section of the product https://www.aliexpress.com/item/2-54mm-Female-Header-Single-Row-5PIn-short-version-plasticheight-3-5mm-straight-180o/622209657.html to be longer so I can stack
Do they have something like this available on DigiKey? I'm not a wizard, so using that site is a bit... challenging.
@stuck elbow Unfortunately, I cannot cut them shorter, the female section of the header is too deep to work with cut male pins
Something like this https://www.amazon.com/Arduino-Stackable-Header-10-Pin/dp/B00PCCWG3A/ ?
@steel copper Yea, that but shorter length
Or does that suffer from the same issue of too deep a female?
That is essentially what I currently have
It does seem that any header that extends the male also extends the female section. Not seen any with the small female / extended male combo that you are looking for.
Its probably a material strength issue.
Yea. I've been trying to crawl my way through DigiKey to see if they have any custom headers that match my needs
Navigating though DigiKey is such a pain
do you have a potential path using just standard male header, without the female section at the bottom of the board?
You can use the long male headers, and have female headers on both the shields
I had to do that sometimes
@steel copper Oh my god. You wont believe this. You can shove both the male and female connectors into the same socket.
I mean. It is a bit hackish in a way. But it looks like it works.
It is going to make me want to cry come solder time.
But it fits: it ships!
May the electrical engineering gods have mercy on my soul.
you want to move the plastic on the male headers way back to the edge
and push it back when you finish soldering
Thats a really great idea
careful not to scar the board when you do so
I just need to be careful to lineup the placement during adjustment so this thing doesn't look like a bucktooth pin board
also, getting them straight is going to be a challenge
Yuck, ugly.
If it's ugly but it works... it's still ugly
start by soldering a single pin, then you can adjust it easily
I actually have a solution for that
only solder the others when it's straight
I have an alignment board that I can use
You could also sacrifice 1 set of male headers for a second spacer bar to help keep alignment.
This is what the stacked short headers look like.
I can get this to work on the M0 Express, but the other M0 w/ WiFi that I have will not fit the two headers. Even though the solder through holes look the same size
What is the function to call to get an approximation of memory available?
@opaque patrol import gc then gc.mem_free()
thanks
@analog drift 10 points to griffindor for ingenious hackery
hahaha
@analog drift Good to see you are getting into the CircuitPython ... I am yet to setup my work station in my new place ...
@slender iron I know you're "off the clock", but pylint refuses to allow me to use a [] as a default argument on Trellis.... seems this is a CPython no-no as well (being mutable and all). Answer can wait. I hate to steal weekend time from peoples. I'm off Monday, so available all day.
๐
the problem with using mutable types as default values is that they get created at the function definition time, not every time the function is called
which is confusing for many people
ah! makes sense
Alright I have a reasonable means to shape pulse width.
ah, not that advanced yett. Just counted loops and time.sleep().
Trying to find the limit of that method. Seems to be an order slower than I'd like.
I feel like that might not be as reliable timing wise
(and slower)
There is also likely going to be an upper limit on frequency; see what you get if you just loop with no sleep and toggle the pin every loop
That's what I'm doing this afternoon. Just toggling pin 13.
Do you have a scope or logic analyzer?
(D29 and D30 aren't mapped in CircuitPython). I just have a frequency measurement on the Extech EX330 multimeter (haven't checked to see what kind of range it has; I'd suppose 400 kHz is probably a limit or maybe lower).
47 # sclk = digitalio.DigitalInOut(board.D30)
48 a0 = digitalio.DigitalInOut(board.D9)
49 rst = digitalio.DigitalInOut(board.D6)
50 cs = digitalio.DigitalInOut(board.D5)
aka MOSI and SCK
10 MHz res. 0.01 MHz
I have a pretty good timer/counter setup for Arduino IDE so I should be able to calibrate the meter against real world conditions.
Still, it ain't no o-scope. ;)
๐
Alright so the 1250 Hz the meter gave for the frequency of the toggled GPIO pin was spot-on.
def pulse():
a0.value = 0
time.sleep(0.001); # 1 ms
a0.value = 1
time.sleep(0.001);
def loops():
for i in range(0, (1250 * 10)):
pulse()
print(time.monotonic())
loops()
print(time.monotonic())
main.py output:
260.538 269.959
If I have this right, I need to ramp that up to 200 KHz to get a 5 usec pulse. ;)
Might be time for some science.
@timber mango EX330 goes to 10 MHz (I just got one).
Yeah so 200 KHz should be well within the range it'll display. ;)
siddacious was right - pulseio is looking good for this job.
HI there! I have cloned https://github.com/adafruit/uf2-samd21 but for some reason files such as /lib/uf2/utils/uf2conv.py don't clone . I even tried getting just downloading the .zip from the github webpage does not contain these files either. Any thoughts? thanks.
very peculiar
@barren peak that uf2 subfolder is included as a git submodule
after you clone the repo, do the following:
git submodule init
git submodule update
that should pull in the submodules
@inner raft Thank you! that did the trick.
Just wanted to make some notes here. I was skimming through Noridc documentation, and noticed that nRF52x also has rotary encoder as a peripheral. Not surprising, since it's M4 based.
They refer to it as "Quadrature decoder" or "QDEC". Here are links to the documentation:
-
nRF52832: QDEC
-
nRF52840: [QDEC](https://infocenter.nordicsemi.com/topic/com.nordic.infoce...
Hello! I am trying to replicate some i2c work that works fine in the Arduino IDE in C, but I'm not having success in circuitpython.
@graceful tusk are you getting any specific errors? or just a general "doesn't work"?
more info coming. mostly, I'm getting an empty result instead of data back.
so, what works in the C using Wire is this:
and what I tried in circuitpython was this:
So, I am just getting zeros back in circuitpython implementation, but in the arduino c code using wire, I get real data back.
the only real difference i see is that you're reading from register 0x6 in the C version, and not in the circuitpython version.
give me a sec while i check something though...
right, that just is a size of data returned register (which is instead set by the bytearray size in the circuitpython)
haven't actually used I2C on circuit python yet, so just starting to look at how it works. Reading through https://learn.adafruit.com/circuitpython-basics-i2c-and-spi?view=all they seem to be using this device.write(bytes([0x05]), stop=False) syntax. Maybe try adding that stop=False bit?
I did try that; no change
aww foo
are you using the 8-bit address, or the 7-bit? I2CDevice only accepts 7-bit.
It's the 7 bit address
ok
if I change the address, it throws a no i2c device at address error (built into the I2CDevice class)
yeah, i though it should catch it...but nothing is perfect. ๐
what device are you communicating with?
I think that maybe the device cares more about the order here, and I may have to read that size register explicitly before reading out the data?
yeah, that why i ask. was going to peak at the datasheet. some chips require a pointer before reading a register...
it's a thermal camera (Flir lepton) I have the IDD for it, and the working C code, but I was wanting to port it to circuitpython as an exercise.
i would change the bytearray to 33, and set the first byte to 0x6, then send the readinto
ok...
hmm
doesn't make sense to me; the bytearray is just a buffer to read into from the slave; it won't know what is in it.
readinto just calls i2c.readfrom_into( in a nice package
and the "from" there is just a device address, not a register address.
yeah....i was thinking write. man.. ๐
so send a write to the address, then read. (this is required in the library i just wrote in circuitpython)
try doing it all in one context manager
lepton = I2CDevice(i2c, 0x2a)
buf = bytearray(32)
with lepton as l:
buf[0] = 0x00
buf[1] = 0x04
buf[2] = 0x48
buf[3] = 0x1C
l.write(buf, end=3, stop=True)
l.readinto(buf)
print(buf)
EDIT: missed one of the output bytes
EDIT2: also an off-by-one for the end=
Yeah, still not getting what I'm expecting.
Thanks, I'll try to make sure I'm doing things in exactly the same order of steps as the working C code, but I was wondering if there was something I was missing with how it was to be done, since the syntax is quite different from the "requestfrom(devaddress, bytes); read();" way of doing it in C
oh wait. i missed your Wire.requestFrom(0x2A, lepton_readReg(0x6)); line
you have more i2c transactions going on in lepton_readReg() ? is that a basic register read function?
uint16_t reading;
lepton_setReg(reg);
Wire.requestFrom(0x2A, 2);
reading = Wire.read();
reading = reading << 8;
reading |= Wire.read();
return reading;
}```
Wire.beginTransmission(0x2A);
Wire.write(reg >> 8 & 0xff);
Wire.write(reg & 0xff);
Wire.endTransmission();
}```
So, I think I glossed over a couple of sends hidden in there.
not sure why it's all bitshifted and masked.
@graceful tusk If you want to format your code, you can put three backticks on both sides of the text you want to be a code block (the one on the upper left of a US English keyboard on the same key as the tilde, next to the 1 key) like this
Or if you want inline code use one backtick on either side of the text you want to be formatted
```python
code goes here
would have to see the protocol. could be a MSB First vs LSB First thing...
@graceful tusk Nice!
this:
Wire.write(reg >> 8 & 0xff);
Wire.write(reg & 0xff);
looks more like it's setup for a uint16_t
yeah, that makes sense
not sure why you'd right shift a byte by 8
me neither, but I think we're on the right path to what I was missing.
everything is 16 bits in the registers
It seems to me that the first line (Wire.write(reg >> 8 & 0xff);) is effectively the same as Wire.write(0x00)
did you write that lepton_setReg() func?
nope
there's a couple on github
maxritter thermocam is the source
no matter what byte value you have for reg, right shifting it 8 is going to zero it out. crazy code. I'm sure there was a reason it made sense at some point.
Does discord do threads?
my guess is there are no registers above 0xff, so it works, even though it's a bug
My guess is it was originally set up to pass a unint16 and that bit shifting and masking is in place to chop it into MSB and LSB, but here we're passing in a byte value for reg anyway.
if reg == 6
Wire.write(reg >> 8 & 0xff); == 0
Wire.write(reg & 0xff); == 6
agree. should be passing a uint16_t. all the registers are 16 bit.
but i'm not seeing any above 0x00ff
does the code turn off the camera after every capture? seems that 0x0000 will turn the camera on, if its off (IDD paragraph 2.1.4)
not even doing a capture. the camera is on. captures have to be done over spi; I'm just trying to get some of the id stuff from this i2c control bus
as i scroll down this document, i understand why they went with 16bit...they packed all kinds of stuff into this thing. ๐
lepton = I2CDevice(i2c, 0x2a)
buf = bytearray(33)
with lepton as l:
buf[0] = 0x00 # command register MSB
buf[1] = 0x04 # " " LSB
buf[2] = 0x48 # command MSB
buf[3] = 0x1C # " LSB
l.write(buf, end=4, stop=True)
# read data length register
buf[0] = 0x00 # data length register MSB
buf[1] = 0x06 # " " " LSB
l.write(buf, end=2, stop=True)
l.readinto(buf, end=2)
data_length = buf[0] << 8 | buf[1]
# read the data
l.readinto(buf, end=data_length)
print(buf)
@graceful tusk still just guessing, but try that?
The >> 8 business is to convert a 16 bit value to two 8 bit bytes.
25 def scale16():
26 global hiDutyCy
27 global loDutyCy
28 hiDutyCy = dutyCy >> 8
29 loDutyCy = dutyCy & 0xFF
yeah, but the function that it was in was getting passed in a single byte value.
I guess it depends on if you trust the skill of the original coder. ;)
looks like highest register is at 0x0026, so bug never hits
it's expecting 16bit addresses, so just need to pump out 0's for the MSB
Wire.write(reg >> 8 & 0xff); == 0 will do that ๐
I usually remove code elements that don't make sense to me, to see if the situation deteriorates without the odd stuff. It often does, so I put it back without perhaps understanding why it was required or what exactly it does.
I don't understand how appending '== 0' even compiles, after that semicolon. ;)
i think that was just commentary
I have no idea how that is a comment
from @raven canopy 's comment above
not meant to be code, just pointing out what's going on
i debated on putting the //....seemed extraneous at the time. ๐
@graceful tusk did you try that latest?
@tidal kiln yeah, but no juice. currently porting it as line-by-line as I feel is possible. implemented the functions as functions, going to give it a spin.
did it run and just return no data? or did it have a run time error of some kind?
there was a typo I fixed, then all zeros still.
what was typo? (yah, i'm not testing, just throwing up code)
It didn't like the end=datalength parameter; that function takes its data length only from the size of the byte array it's given
gave a number of arguments error
yep. my bad. i fixed that. but you must've copied code before i did.
or did you just remove it?
I removed it
let's see if we can even just read that register, try this:
lepton = I2CDevice(i2c, 0x2a)
buf = bytearray(33)
with lepton as l:
buf[0] = 0x00 # command register MSB
buf[1] = 0x04 # " " LSB
buf[2] = 0x48 # command MSB
buf[3] = 0x1C # " LSB
l.write(buf, end=4, stop=True)
# read data length register
buf[0] = 0x00 # data length register MSB
buf[1] = 0x06 # " " " LSB
l.write(buf, end=2, stop=True)
l.readinto(buf, end=2)
data_length = buf[0] << 8 | buf[1]
print(data_length)
prints 0
ok, try changing that last l.write line to this:
l.write(buf, end=2, stop=False)
good news is that I changed it to the status register and it printed the value there (111=7)
not sure, but I think that might be the root of the problem. I'm waiting an appropriate boot time
but it works with the C code?
The weird bitshifting was copied from a different codebase where it was an an unsigned int, just got changed to a byte in the maxritter codebase. I'm making an uncluttered copy of the c code to verify that it still works. ๐
Well, once it works, you can forget all about how it works. ;)
I'm quite convinced coders are pathological about making things as ornate as the language allows.
the bitshifting isn't really weird, makes sense for this 16bit case
the weird part is:
void lepton_setReg(byte reg) {
instead of:
void lepton_setReg(uint16_t reg) {
yes, that's what I meant. The bitshifting itself is made weird by passing in a byte
sorry, i gotta run. good luck with this.
Thanks. What worked before is no longer working. So... that might explain some of it not working.
I think maybe I accidentally turned it off somehow, and it needed resetting.
anyway, I've got the C code working again.
I'll see if I can get the python to behave similarly.
github is your friend. ;)
hah wow i've been digging into advanced unicode stuff with micropython and the REPL doesn't support entering big characters
like ้ผ
but a main.py is just fine and it works great
print('Ord is {0}'.format(ord('้ผ')))
Ord is 37628
which is right ๐
so that's pretty sweet, micropython actually does unicode pretty well internally
i bet the REPL just doesn't handle inputting those wide UTF-8 characters
i'm guessing buried in its code is an ASCII assumption
i'm super close to getting chinese character rendering though
i have a really nice super space efficient way to store the characters
18 bytes per character.. it's basically as small as you can get to stuff an 11x11 bitmap and the unicode character point in memory
only wastes 3 bits of alignment, not bad
to find the chars i'm not bothering with an index... just storing them sorted and binary search
if i can free up about 20k more of firmware space i can fit a solid 3k chinese characters and that's enough for most communication it seems
I think you could do 16 bytes per character with a bit of a more complicated code
unless the two bytes are for metadata?
@slender iron how is the QSPI-ing coming?
cool
is it checked in on your fork?
uses his eyeballs instead
hmm.. don't see much activity on your fork
yeah, qspi branch
is blind?
its how I back up my code ๐
somehow I missed that, thanks ๐
will the DMA also work with normal SPI?
or is it used already?
(I mean, with SPI called from inside CP)
in 2.x it did but the current 3.x implementation doesn't use dma
I'll probably DMA all the things when I do the audio APIs
I see, thanks
I have sporadic all-dots-filled on ST7565 in CircuitPython. No idea if that is an occasional followed protocol (the basics have not been repeatable except for this).
I'm going to try peppering my code with `time.sleep(0.001) to slow it all down to a uniform time base.
This codebase has no more finesse than turning port pins on and off as GPIO (no comm libs used).
@stuck elbow current spi does not use dma, expediency on my part to get the flash spi chips up and running
you mean current 3.0
yes
to be honest I didn't notice much difference in speed
I know! I was surprised
I only notice when using the saleae to watch the spi lines. ๐
I'm new to python and I'm having trouble doing something I would think is very basic
can someone help me understand what I'm doing wrong or where to go to learn more
I usually code in javascript, C/C++, and Java
@tulip sleet
r = 0
g = 0
b = 0
Helper to give us a nice color swirl
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if (pos < 0) or (pos > 255):
r = 0
g = 0
b = 0
return [r, g, b]
if (pos < 85):
r = int(pos * 3)
g = int(255 - (pos3))
b = 0
return [r, g, b]
elif (pos < 170):
pos -= 85
r = int(255 - (pos3))
g = 0
b = int(pos * 3)
return [r, g, b]
else:
pos -= 170
r = 0
g = int(pos * 3)
b = int(255 - (pos*3))
return [r, g, b]
r,g,b values don't seem to be updated globally
they'll work when wheel(i) is called, but I can't refer to r, g, b and have their values be anything other than 0
@indigo sparrow The r,g,b inside the def are local variables to the def. You'd have to say global a,b,c to refer to the outside variables. This is so new variables inside the function can't accidentally smash variables outside.
Simpler example:
>>> a = 2
>>> def f():
... a
>>> def f(x):
... a = x
... print(a)
...
...
...
>>> f(3)
3
>>> a
2
>>>
notice that the function returns [r,g,b] so you can see the inside values if you want them
Since Python doesn't have variable declarations, variables are assumed to be local unless otherwise specified by global. Compare with Javascript:
$ node
>
> a = 2
2
> f = function(x) { a = x; }
[Function: f]
> f(3)
undefined
> a
3
> f = function(x) { var a = x; }
[Function: f]
> f(4)
undefined
> a
3
>
thank you @tulip sleet
And it's a little more complicated than that:
>>> a = 2
>>> def f(x):
... print(a)
...
...
...
>>> a
2
>>> f(3)
2
so if I wanted to update the global r, g, b how would I do that?
I want to make sure that the global values are updated instead of the local
because a is not assigned inside f, so it uses the outer a.
if (pos < 0) or (pos > 255):
global r = 0
global g = 0
global b = 0
return [r, g, b]
>>> a = 2
>>> def f(x):
... print(a)
... a = x
...
...
...
>>> a
2
>>> f(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in f
NameError: local variable referenced before assignment
a is assigned, so it's assumed to be local.
you can declare them global with global a,b,c:
>>> a
2
>>> f(3)
2
>>> a = 2
>>> def f(x):
... global a
... a = x
... print(a)
...
...
...
>>> a
2
>>> f(3)
3
>>> a
3
ok so I just need to be explicit that my r is not local but global within the context of the def
But it's considered mostly poor form to use global. Instead, do:
r, g, b = wheel(pos)
oh cool, I can do that?
since wheel() is returning the values anyway. Then you don't need to use global and you know when you're assigning the variables. ...
Yes,
a, b, c = (3, 2, 1)
exchange a and b:
a, b = b, a
ok just for my own knowledge
if wheel returned an array with 4 elements [r, g, b, x]
if I did
r, g, b = wheel(pos) would it r, g, b just be the first 3 elements of the returned array?
@indigo sparrow No, you get an error:
>>> a,b,c = [1,2,3,4]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack (expected 3)
So you need to do something like:
a, b, c, junk = [1,2,3,4]
Canonical way to indicate unused data is with the _ variable name:
a, b, c, _ = [1,2,3,4]
You could also do: a,b,c = wheel(pos)[:3] to take a 3-element slice of the return value.
@indigo sparrow I'd recommend spending some time with https://docs.python.org/3/tutorial/ or a good Python book (e.g. Python in a Nutshell, 3rd (latest edition), is very good.
thank you @tulip sleet I'll look into learning python more!
pyoven lives!
reflow oven?
the board at least
I have more testing to do on it
but did figure out my power issue
there's no oven, microwave, or stove emoticon...what gives discord? ๐
<@&356864093652516868> This week's meeting will happen on Tuesday (NOT Monday) due to President's Day here in the US. Have a good weekend!
haha. i was looking forward to attending from home this week. but, agree it's a good move.
oops ๐
@slender iron by the way, you have atmel studio installed, right?
on my windows box, which I never use
I see
do they have a linux/mac version?
Bah! I'll be leaving my house at about 6am Tuesday. And won't be back until probably 11pm or later. As opposed to tomorrow, when I'll be home all day...
I'm reading the application note for usb msc on atsamd11, and it just says "to get the source code, install atmel studio and search in examples"
thanks, I will try
haha. its like xmas/new years all over again. ๐
sorry @cunning crypt ! I didn't think it'd be good two switch our holiday policy
hmm, no msc for d11 there
๐
@slender iron It makes sense
did you find asf3 for it? I think examples are in there
It just happens that I have off tomorrow and Tuesdays are Nerd Night
Also seeing Black Panther after work Tuesday...
sounds like fun @cunning crypt !
I'm off, pottery time in an hour. pyoven will have to wait
Have fun @slender iron !
@slender iron the link to asf3 at http://start.atmel.com/#examples links to "undefined" which is a 404
gotta love web 3.0
anybody wants a discount code?
@slender iron https://twitter.com/micko_mame/status/965213234679738368
Got Micropython running on E310 silicon as well :) it is running on LoFive board from @QwertyEmbedded code available at: https://t.co/3cIshnufuU it requires tools from @SiFiveInc
@timber mango wow thats neat
found it, the example is in there, thanks for the moral support
Anytime ๐
oh @stuck elbow yeah 16 bits is tough for character data, it needs a 16-bit unicode encoding / codepoint and a 4-bit pixel width (it's a variable width font so an I character is just 3 pixels wide vs. a big glyph that's 11 pixels wide) so i do 2 bytes for the 16-bit encoding value, then 16 bytes for the 11x11 bitmap data and there are 7 bits left over (to get up to an even 128 bits total and be on a byte boundary alignment) which is great because i can stick the 4-bit pixel width there and even have a few bits left for potential future use
every bit counts ๐
Ran into a not implemented error in micropython today.
wanted to switch a list [a,b,c,d,e,f,g,h,...] to [b,a,d,c,f,e,h,g,...], and came across this neat slicing: l[1::2], l[::2] = l[::2], l[1::2]
ended up just writing a quick for loop: for i in range(int(len(result)/2)): result2[2*i] = result[2*i+1] result2[2*i+1] = result[2*i]
NotImplementedError: only slices with step=1 (aka None) are supported
oh..i misread what you were doing.
that's two days in a row i've done that to you...
the weird thing is that individual slices worked in the REPL, (i.e. r[1::2])
got it figured. it does work for lists, does not work for bytearrays.
wow. i thought adding to a built-in module was tough. creating a new one has my head spinning... ๐ต
@graceful tusk it's the storing into a step != 1 slice that isn't implemented: http://docs.micropython.org/en/latest/pyboard/genrst/builtin_types.html#list-store-with-step-1-not-implemented
wooo hooo full unicode / asian font rendering now in sino:bit micropython ๐ the hard work is done, now i need to free up as much space as possible to fit as many characters as I can in the firmware. this is looking REALLY cool though so far. a few little tweaks and todo's still too but i am quite pleased with it and myself: https://twitter.com/tdicola/status/965489097769828352
Feeling a bit like ้ข้ไพ (Iron Man) by coding in support for unicode and Asian font rendering in sino:bit MicroPython this weekend! :) @RealSexyCyborg @glowascii @ntoll @dastels @adafruit Need to make few tweaks and free up more space before releasing but groundwork is there! :) https://t.co/8x5HL8zLGS
Looks like I missed out on catching up about asyncio in CircuitPython. The video at https://www.youtube.com/watch?v=rZ2DT8TzxPI got removed. Quite interested as I understood from earlier discussion that async constructs would be withheld from CircuitPython (not on critical path) although I guessed they might arrive when rebasing on later micropython versions. What's the new thinking? I have begun relying on async await a lot! I am also beginning to think it's more confusing to established programmers than it is to learners, for whom it looks like sequential code so could actually help to unlock parallel time-based behaviours for them.
The Arduino nRF52 Repo contains a RotaryEncoder library with both HW and SW implementations for this, just as a reference. If a common API is added at the HAL layer, it shouldn't be too complicated to add nRF52 support used the QDEC peripheral or GPIO.
Hello, can anyone point me to an example of using ISR (interrupt service request) programming on a CircuitPlayground Express board?
no, because CircuitPython doesn't currently support interrupts
hi ho folks, the mu editor will have a plotter for live data and also saves csv files for data logging, short preview video here - https://blog.adafruit.com/2018/02/19/mu-plotter-sneak-preview-live-data-ntoll-raspberry_pi-microbit_edu-adafruit-boards/
@slender iron I am updating Adafruit_CircuitPython_SSD1306 with a pull request (https://github.com/adafruit/Adafruit_CircuitPython_SSD1306/pull/10) I am getting a error running travis.
0.01s$ cd docs && sphinx-build -E -W -b html . _build/html
/home/travis/.travis/job_stages: line 57: cd: docs: No such file or directory
The command "cd docs && sphinx-build -E -W -b html . _build/html" exited with 1.
Any ideas?
@timber lion looks great! well done!
@stuck elbow This article references ISR programming on MicroPython - what is the relationship between CircuitPython and MicroPython, is there a way to use this on a CircuitExpress board?
@fading solstice there is discussion in issue #613 that the ssd1306 RTD build needs some work. that's probably what you're running into. the RTD link is still 404ing, too.
@raven canopy thanks for the heads up.
@hollow ingot Looks like the wrong link. Try: https://youtu.be/SXQAaSYVZ8o
One-off meeting about asyncio plans in CircuitPython. As always, join us on Discord. https://adafru.it/discord Visit the Adafruit shop online - http://www.ad...
@reef seal CircuitPython doesn't implement that part
@fading solstice the docs files have moved with the latest cookiecutter
@reef seal We haven't gone through and removed irrelevant micropython docs. What are you trying to do? We usually rely on C helpers instead of doing interrupts in python.
making a note here that SAMD has very fixed pins for QDEC - so for that platform, at least, we should just DIY with a timer interrupt - an existing one would probably be fine as the checking code is very small
@reef seal can I use MicroPython on CircuitPlayground Express? what boards support micoPython?
@reef seal Nope. pyboard and esp8266 are the core supported boards.
What are you trying to do with ISRs?
Esp32 has increasing support too.
@slender iron i updated using pip -U before I created the files. What should i be doing?
move the files around to match the cookiecutter repo
new docs directory
@slender iron i didn;t see the new docs folder. i will copy that over.
conf.py is moved there along with a path tweak
the table of contents moves from the readme to index.rst as well
@slender iron I'm just getting starting with CircuitPython and the only way to manage timing that I have seen is sleep(). But that puts the entire thread to sleep and my program can't respond to inputs or anything else during that time. So I'm looking for a more sophisticated way to manage that. aka interrupts, threads, something like that.
I've been a software engineer for a long time but just getting started with programming hardware.
@reef seal you can also use time.monotonic() to count time without blocking other operations. similar to the Arduino work around for delay().
last_time = time.monotonic()
interval = 1000
while True:
current_time = time.monotonic()
if (current_time - last_time) > interval:
#dostuff
last_time = time.monotonic()
@raven canopy A bit tedious but I can see how that would work, thanks.
it can get tedious, and long in code...but, work with what you have, right? ๐
yeah, or make something better ๐
@reef seal Ah! Take a look at time.monotonic() its an ever increasing count from start up
now, I see the replies. ๐ good job @raven canopy !
๐ ๐
if only i understood the module-->object<--module chain as well. i'm getting close to getting it to work, but my understanding of what is working is getting less and less. ๐
@slender iron missing comma in docs/conf.py on line 15 " 'sphinx.ext.napoleon' "
oops! mind submitting a PR?
will do
thanks!
@slender iron getting closer. now sphinx needs to resolve import framebuf. do i need to add somehting to requirements.txt file.?
i found the framebuf in micropython doc at
http://circuitpython.readthedocs.io/en/latest/docs/library/framebuf.html
thats different from the import I think
i am not getting what is need ed for framebuf support in sphinx. I now see a # autodoc_mock_imports line
yeah, try changing that line
yeah and add it to the list
["framebuf", "adafruit_bus_device", "micropython"] should be what you'll need
forgot the quotes
ok
getting closer
Warning, treated as error:
../README.rst:12:Error in "image" directive:
no content permitted.
.. image:: https://travis-ci.org/adafruit/adafruit_CircuitPython_SSD1306.svg?branch=master
:target: https://travis-ci.org/adafruit/adafruit_CircuitPython_SSD1306
:alt: Build Status
Adafruit CircuitPython driver for SSD1306 OLED displays.
This driver is based on the SSD1306 driver in the MicroPython source but differs
by supporting hardware I2C interfaces and Adafruit CircuitPython API. For a
MicroPython machine API compatible library see: https://github.com/adafruit/micropython-adafruit-ssd1306
The command "cd docs && sphinx-build -E -W -b html . _build/html" exited with 2.
Looks like the .. image is case sentitive. on the web address
Hi folks! I have a Metro M4 here, and I'm doing some testing. I'm curious, is the schematic available online somewhere?
@fading solstice I think you are missing a space and need to unindent the text
er, by space I mean newline
@frail geode schematics aren't usually released until the project is launched
what do you want to know?
@slender iron Yes, i noticed that and several other problem along the way. I finally got there, but this change for RTD was harder then i expected.
Is this the first project ro use most recent changes in cookiecutter ?
its the second one to be updated to it. the rest now start that way
@fading solstice This is issue has background on it: https://github.com/adafruit/circuitpython/issues/566
tannewt, nothing in particular, just curious as to the differences between it and the metro m0, that's all
Its mainly the core microcontroller
there is the extra inductor in there, no?
maybe, I'm not sure if the latest design has it
my pyoven one doesn't and its fine. it just uses the linear reg though
This enables faster flash reading and writing. The latest revs of the Metro M4 use QSPI to enable faster interactions with the flash.
See isREPLconnected & isUSBconnected issue #544.
This only includes atmel-samd and nRF for now. ESP8266 will require more work since supervisor is not an entity on that port.
This is my first [sub]module from scratch, so please let me know if I totally bungled it. I kind of patchworked my way through it, after initially just putting it all in __init__ then realizing that wouldn't work across ports.
@ tannewt @brentru I believe this issue can now be closed.
does the neopixel lib support different color arrangements? like GRB vs RGB?
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/master/neopixel.py#L79
Hard to say without 'sperimentin'
Not out of the box, from what I could tell by glancing at this code.
@timber mango nice sluething. changing that works.
:)
i forgot to look in closed issues. guess this is somewhat known.
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/issues/1
@tidal kiln crosses posts with you on the forum regarding Gemma โcandle โ I hope I did not confuse things. The 8mm neopixel appears to me to have red/green swapped
@solar whale it does. that's why i was asking.
Just made one yesterday๐
the candle?
ah. so you ran into same issue as forum poster?
Yes
hmm
did you just change the code to swap the first two entries on these lines?
strip[0] = [index, int ( (index * 3) / 8 ), 0]
or did you change the class level ORDER tuple?
Yes, just swapped those lines.
Originally used https://www.adafruit.com/product/1312
<@&356864093652516868> and everyone else. Meeting tomorrow at our normal time, 11am Pacific / 2pm Eastern.
I'll still be at work at that time. Oh well!
@cunning crypt I'm happy to chat with you at other times if you like
@tidal kiln how do you change the ORDER tuple?
Thanks. Swapping the two lines was pretty easy as well ๐
@slender iron I haven't done much regarding CP lately, so I'm not terribly worried at the moment. There's the recordings for now. Might take you up on it in the future though.
@solar whale yah, changing ORDER is a hack, generally not meant to be done like i did
Nice to know how to do it., just in case...
i think ideally, it'd be done under the hood
NeoPixels are still magic...
I am amazed they work at all. But this was confusing, since I thought the demo used the diffused neopixel.
@tidal kiln just checked and the demo does use the 8mm so I donโt think it works as posted.
i think that is an updated guide, originally only Arduino, now with CP added in.
it's a gemma classic in the build photos
and the arduino code instatiates correctly:
wick = new Adafruit_NeoPixel(1, WICK_PIN, NEO_RGB + NEO_KHZ800);
using NEO_RGB
@solar whale agree. i think it's a minor bug in the current guide code. once i get the forum poster sorted, i'll send word to have it checked.
@tidal kiln thanks.
@timber lion Hello, I would like to stick to CircuitPython, (I know nothing of the Arduino sketch language and I teach Python), how different is C++ form a microcontroller perspective? I have seen about a dozen or so of your videos and you seem to be using Python's OOB and class structure. BTW, I love watcing your videos, I end up having to watch them two and three times because they are chock-full of little pearls of wisdoms. Thanks!
supervisor/Status.c line should have a single tab, not spaces.
argh! I meant to go back and fix that before pushing...
Is this a leftover debugging statement?
Does metro_m4_express now work with the old Metro boards that we and the helpers have? If not maybe we should make up another board type at least temporarily.
Do all esp8266 boards run MicroPython/Circuit Python or just Adafruit's? I just spent an hour on the ESP8266 forum and I'm more confused than before.
Last commit says "m4 qspi works. m0 compiles" and is from 3 days ago. Is that the last one?
I'm just a noob at the circuit python stuff, but the way I understand it, all esp8266 boards could run circuit python, but the adafruit ones have the special bootloader on them which actually does it.
how to I write to the circuitpython drive from bash? (mac os)
I found it : /Volumes/CIRCUITPY
@inner raft Mostly right! It'll run on most esp8266 with the same flash setup. the Pin names in board may be wrong though. We don't have a special bootloader for the ESP8266. Its just the atmel one that works like a USB drive
This will no longer work with the black Rev B out of the box. Its not too hard to switch back though.
That is the latest commit. I took a break over the weekend and tested the metro m0 express today before sending the PR. It worked just fine so I didn't need another commit.
Thanks for the review!
@slender iron quick Q: is .. include:: indented underneath the .. code:: block?
I don't think so
I think its just include
ah, .. literalinclude::
(for including an example)
i looked at literal...was going to see if you wanted to use that based on the "warning vs error" footnote when a file isn't found. i'll peep the example...
๐
so this is what it would look like on API reference page, if we put it in the main code? https://circuitpython.readthedocs.io/projects/pcf8523/en/latest/examples.html#
yup!
your call. if nothing else, we can at least test it to see how it looks...
i do like the inclusion of line numbers, and since we now have pylint skipping over examples, none of that will show up.
I like line numbers even though the theme on rtd breaks the spacing
i'll pull the trigger then. easy fix to revert..
๐
I finished the video for my safe using a trinket m0 and hydraulics: https://www.youtube.com/watch?v=57qfl9j-u0E
This is the video that I made for my 8th-grade hydraulics project. Want to build this yourself? The completed instruction manual is here: https://docs.google...
<@&356864093652516868> Warning: The latest master (3.0) commit of adafruit/circuitpython assumes the latest board rev (blue color) because it assumes the SPI flash is connected correctly for QSPI support. The older rev B black boards will not work without changes to boards/metro_m4_express/* files. I will push up a PR to add a new board type metro_m4_express_revb for those without the latest boards. For now you can just restore the old versions of those files to build for your board.
EDIT: you can't restore the old versions of those files -- sorry. But you can change QSPI_FLASH_FILESYSTEM = 1 to SPI_FLASH_FILESYSTEM = 1 in mpconfigboard.mk
Actually there appear to be further problems, so don't upgrade yet.
Will this affect the 2.2.x series? Sounds like a 3.x issue.
no, not at all
I was trying to make a metro_m4_express_revb board temporary board def. I just copied the new version and changed QSPI_FLASH_FILESYSTEMtoSPI_FLASH_FILESYSTEMinmpconfigboard.mk. (I noticed you corrected the MICROPY_PORT_x` defns which describe which pins not to reset, and which appear to have been wrong for a while.)
However, what happens now is that the M4 RevB gets a blue (?color vision issues) status LED every hard-reset and always re-creates the filesystem (takes a number o...
@slender iron I'm gonna have to skip today's meeting to quickly summarize, I had not much time to work on CP last week, hope to get some stuff done this week, mostly the stuff that's assigned on me in Issues. Hug reports for all ๐
Thanks @indigo wedge ! Have a good rest of your day
Hello, I made a dumb mistake. I ordered the PC educational pack thinking it was the PCX, itโs not itโs the classic version. I want to program in Python. Should i exchange for the PCX or keep and use Firmata and Python
@humble mural up to you, but if you want to run circuitpython you'll need the CPX
@tidal kiln I guess the question will my students be able to code a wide variety of projects as they can with the PCX? P
we have a little breathing room in external-flash builds. Rather than using #define's, lets create small packed structs, JEDEC-ID-indexed, with details on all the SPI flash chips we come across. Then circuitpy can automatically initialized no matter what chip it finds. This will future-proof us as SPI flash chips come-and-go & also make it easier for non-adafruit-made hardware
@humble mural the circuitplayground classic is used by code.org through firmata. it has the limitation that it must be tethered to the computer though
@compact solstice there are tons of projects that can be done with the CPC, it's just a matter of what programming environment you want to use. are you wanting to work with something specific?
@compact solstice if you have time to exchange, I would suggest going ahead and doing so.
For anybody who cares about async and await stuff but doesnโt understand it yet (which is where I count myself), I found a good article explaining the details: https://snarky.ca/how-the-heck-does-async-await-work-in-python-3-5/
Being a core developer of Python has made me want to understand how the language generally works. I realize there will always be obscure corners where I don't know every intricate detail, but to be able to help with issues and the general design of Python I feel like I
Itโs not applicable to CP this instant, but my hope is I can make it relevant soon.
@quick oyster thanks for the link!
@quick oyster thanks for this! been looking for some references
<@&356864093652516868> Meeting in two minutes!
do-bip
duu-duu
hey hey. just fly on the wall mode again for me this week.
currently snowing lightly
isn't that called lurking?
It's a "listening skill"
HUGS: @mrmcwethy & @brentr for RTD work. Those got knocked out quick! @cater for course correcting a couple of my troubleshooting efforts on discord.
sry. got called away.
Being a core developer of Python has made me want to understand how the language generally works. I realize there will always be obscure corners where I don't know every intricate detail, but to be able to help with issues and the general design of Python I feel like I
@opaque patrol Super!
@solar whale Yup. 5mm Neo is RGB:
STATUS: Trellis is...closer? ๐ serial_connected PR pending. Next issue...haven't decided/open for suggestions.
Noted.
Still need to figure out how I should frame this..but
Educator resources? Anything better than just "email support" and "look at learn guides"?
That's who I meant...
๐
Black tape
Wish I could mic; but it's like kattni was channeling my thoughts. Thanks @idle owl !
@raven canopy ๐
Thanks to @idle owl and @slender iron for encouraging me to use GitHub more. Created 15 project repositories this week.
Thanks everyone! Have a great rest of your Monday-on-a-Tuesday!
Add support for the Nokia 5110/3110 Monochrome LCD
Product Page: https://www.adafruit.com/product/338
Python Library: https://github.com/adafruit/Adafruit_Nokia_LCD
bye!
This is the board sent to community members for testing.
Also tweaked and commented reset pin list for main Metro M4 Express
which is currently unreleased and is Rev D.
fyi, I'm deleting out of date docs from the 2.x branch
Ayy, $15 cheapest shipping to Sweden for a $3.5
pin :(
@tulip sleet In my gut I agree. The main issue is that I want to stick to Python and more so, the paper work that I have to do in order to make that exchange happen make closing on a home like a walk in the park.
<@&356864093652516868> Here is the recording from the meeting today: https://youtu.be/HBsgUYWqqUA
Notes with timecodes are available here: https://gist.github.com/tannewt/7310cb0573cb9c78c4ab2608a34f4906 Join here for the chat all week: http://adafru.it/d...
That is also true considering that Adafruit seems to be moving to support CircuitPython with both barrels blazing.
Going as fast as we can @humble mural ๐
@slender iron Hello, always a pleasure chatting with you. My comments were in reference to a something I said earlier. I screwed up and ordered the CP Educators pack, wasn't aware of a CP vs CPX (I wanted CPX). I asked the room if the CP was an adequate platform for Python programming. In other words, are there plenty of challenging projects for students to do in Python. 2 reasons for considering keeping that kit is I really don't want to introduce another programming language (Python and Java are enought for three years of high school) and doing the paper to return that kit and then resubmitting the P/O is a nightmare. None the less, that is what I am going to have to end up doing.
@humble mural I think the CPX will be better in the long term. Sorry for the hassle though!
we might have understood CP as CircuitPython not CircuitPlayground
too many acronyms
we are turning into IBM
@slender iron Nothing to be sorry about, it was totally my fault. I feel bummed because I have my CPX and it's going all over the room and the kids are tearing it up, they love it! So I wanted to put it in there hands as soon as possible. @stuck elbow Got it! You have to learn language. thanks
@stuck elbow besides I'm a vet so acronyms are right up my ally (sorry, nothing witty to add here).๐
@humble mural I assume you got the Code.org educator's pack? There is also a Circuit Playground Express Educator's Pack which comes with CPX.
Yes
@opaque patrol That is the other thing, This year I teach one section of AP Computer Science Principles.
I got caught up in everything except the correct content of the pack.
There is.....
I am not an Adafruit employee, but have you tried contacting Support about the mixup?
I offered a list of solutions they responded back with a return to Adafruit response. I was hoping to return the 15 Circuit Playground boards and get 15 CPX in exchange and just pay the difference (even if out of pocket, much easier).
I agree, I have to assume that my suggestion would ruin the package. Again, my mistake, I'll take care of it, at the end of hte day, it's all good.
I'm trying to use serial over USB with a circuit playground express using circuitpython without any success. This seems to be what I'm looking for, but I'm unable to import the machine module: http://circuitpython.readthedocs.io/en/2.x/docs/library/machine.UART.html
I installed the latest library bundle linked here: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries
Is there something else I need to install? Or is there something else I should be using?
@tawdry ether What operating system are you using?
OS X
@tawdry ether you want busio.UART what board are you using?
you want to write text back to the computer?
Yes, as well as read a byte string from the computer
you can simply print() to send to the computer. input() will read data from the computer
usually the serial connection is used for debugging
input generally blocks until there is input, is there a nonblocking way to see if there's input?
the busio interface seems like what I'm looking for, but I can't seem to get it to work
@tulip sleet built M4 for metro revb - working fine! Thanks!
@tawdry ether non-blocking input is actually kind of hard, even in desktop python. it turns out to be a platform specific thing because you're basically looking for key presses and each OS has a different way to do it
like can see on linux you use poll or select https://stackoverflow.com/questions/3762881/how-do-i-check-if-stdin-has-some-data
on windows there are different APIs and on mac IIRC they have select and a different poll
but in micropython there isn't really an analog
however check out the info on file io: https://docs.micropython.org/en/latest/pyboard/library/uio.html
it tries to balance buffered vs. non buffered access and blocking vs. non-blocking
Yeah, I was hoping there was a different interface than stdin/stdout as streams don't seem to fit well with reading a serial input stream of bytes.
so what you want to do is treat sys.stdin as a stream and try to read from it a character at a time
but it might actually block a bit IIRC
but you can do something like this
import sys
while True:
d = sys.stdin.read(1)
if d is not None and d != '':
print('Got: 0x{0:02x}'.format(ord(d[0])))
that prints any kepress from repl as hex
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
main.py output:
Got: 0x64
Got: 0x64
Got: 0x64
Got: 0x64
Got: 0x64
Got: 0x66
Got: 0x66
Got: 0x66
Got: 0x64
Got: 0x66
(pressing d and e)
the tricky thing though is the terminal you use, if it buffers and waits for an enter before sending then you won't see anything
this is just using screen.. i think most are smart and let you check a box to wait for enter before send or just send everything (what you typically want)
i'm being a little extra cautious there to check that the d string i get back has data too
if you read the micropython io doc it says micropython will actually guarantee you get 1 byte back no matter what
vs. in normal python in non blocking modes it would happily return a null value if nothing is available
so it's tricky.. i like to be defensive and just always check
worst case if it's null or empty the code reaching in to get the character value will explode with an exception
that may or may not be what you want ๐
if you're parsing input though, like reading commands it might be easier to use readline
then it waits for a full string with newline and gives it back to you
like this:
import sys
while True:
l = sys.stdin.readline()
print('Got line: {0}'.format(l.strip()))
example output after i type a line and hit enter:
uto-reload is on. Simply save files over USB to run them or enter REPL to disable.
main.py output:
Got line: this is a test line
but readline will definitely block for a while until a full line is available
there's no non-blocking way to do it that i know
@tawdry ether there is no machine module in circuitpython, that part of the documentation is taken from micropython
(and I'm deleting it now)
Awesome, thanks @timber lion! That seems to be what I need! I'll let you know how it goes. In case you're interested, I'm trying to adapt my SerialCraft Arduino library to work with CircuitPython: https://github.com/AllwineDesigns/serialcraft-arduino
Here's a project I used it in: https://www.instructables.com/id/Creeper-Detector/
So the goal is to communicate with Minecraft through a mod called SerialCraft that sends data over the serial port. I'm trying to read that data.
@tawdry ether looks awesome! keep us posted on how it goes
Will do, thanks @slender iron!
oh nifty, yeah if you're lucking and the commands end in newline then readline should be perfect and give you really simple code ๐
if not, then yeah might need to read a byte at a time and buffer it yourself
but at least that's wayyyyy easier in python ๐
string buffer += sys.stdin.read(1)
vs. circular buffers, malloc, str funcs etc in arduino ๐
Ok, I'm porting a library from C arduino code. They sub-class Print() and then re-define the write() method to redirect output from stout to writing each byte to the i2c display. Doing it this way, they have all the printable character things and infrastructure of print.
I COULD just write a new print() method in my code that just don't care and expects a string that it turns into bytes to feed the disply, but it seemed like a good idea to use the same sort of approach in my ported code. Since in circuitpython, print() is a built in function, I can't sub-class it like they did, but it occured to me that it might work to redirect the stdout to catch print's output. Is that a good idea? Is it feasible?
what "infrastructure" of print would you like to inherit, in particular?
it seems to me that print() in python is pretty straightforward and all the work happens before it, with the % operator
? with the % operator?
the string formatting operator, yes
or the .format() method, if you are so inclined
in any case, print just gets a string
ok, so I think that print gets passed an object, and it's the object's .format() method that does the work?
i.e. ```
foo = 0x06
print(foo)
6
print just says whatever foo.__str__() is, that's going out
>>> foo = 0x06
>>> foo.__str__()
'6'
ftfm, thanks
well, it does add sep if you print several things, and end at the end
and what does it do about non-printable chars?
>>> print(1, 2, 3, sep=":", end="...\n")
1:2:3...
it prints them anyways
it just sends the bytes to the UART, and lets your computer on the other side handle them
Ok, I'll just call the .__str()__ on whatever is passed to my print method, and then iterate through the string sending bytes to the display. Easy, done in minutes.
actually use str() functuon, like str(foo)
that calls foo.__str__() under the hood
just like len(foo) calls foo.__len__()
got it.
@timber lion, @slender iron, I'm seeing glitchiness with the USB serial communication: https://youtu.be/PU3UaNmLeHA
Demonstration of Circuit Python USB serial communication glitchiness. The SerialCraft mod reports the distance to the nearest creeper whenever the distance c...
@timber lion, @slender iron, It seems like the CPX is rebooting in some cases and reporting incorrect data in others.
@tawdry ether it'll reboot after the drive is written to
in the samd module there is a way to turn it off
In the middle of running the code, the python script stops reporting serial messages, when another connected device continues to correctly report the serial messages. At some point the CPX is crashing.
It seems like a bug to me, where should I report it?
I don't think it is
have you tried connecting with a serial connection directly?
when it autoreloads it will get a KeyboardException
Well if it's not crashing, then its not correctly receiving serial data that it's being sent.
main.py can be interrupted by default
and it will be reloaded
it does that so its easy to iterate on the code
it should be visible over a normal serial connection
The video description has all the details of what's going on. This is the script that's it's running: https://github.com/AllwineDesigns/CircuitPythonSerialGlitchiness/blob/master/code.py
can you try connecting to the serial port through screen in the terminal? (I think you are on mac osx)
I can
thanks!
Hello I am trying to learn this project. https://learn.adafruit.com/circuit-playground-bike-light?view=all
The first error I get is the Traceback (most recent call last):
File "code.py", line 7, in <module>
ImportError: no module named 'adafruit_circuitplayground'
I assume I have to put that on the board so that Python can access it.
Ok, give me a few minutes to figure it out
@humble mural Would you like a guide link?
@slender iron I can connect fine through screen, but the problem arrises with specific messages, which I can't send with a keyboard
yes, but i won't look at it until I strike out. Struggling is 80% of the fun.
@tawdry ether can you take a screenshot?
@idle owl Thanks!!!
@slender iron of what?
The guide link has a link to the library bundle, which you may want to at least grab that and not struggle through finding it.
@slender iron the message that gives unexpected output is the following bytes of data: 1, 83, 67, 2, 4, 13
oh!
its possible one of those is a control character
if you ctrl-c then the script will quit
ctrl-c is 3 and ctrl-d is 4
That would do it!
do you have any control over what is sent to the circuitplayground?
I do, but I'd prefer not to make changes to the Minecraft mod.
it'd be safer to encode it into text somehow
ok, I'll put some thought into it. Thanks for the help!
no problem! perhaps we should add second serial connection to the usb composite descriptor
How do you properly close screen?
perfect, thanks!
np, I'm excited to see the minecraft integration!
I'm not sure what you mean by "perhaps we should add second serial connection to the usb composite descriptor"
you aren't the first person wanting to transmit and receive data over usb to the board
its tricky now because we also use it for circuitpython itself
in the future we could have the device contain two serial connections, one for circuitpython and one for user code
That would be ideal
Awesome, well I'll keep an eye on your progress and think about ways I can move forward. Thanks again for all the help!
@idle owl thanks got it running. Do I have to copy the entire library folder or can just move in the โadafruit_circuitplaygroundโ folder?
my only concern is future file space.
@humble mural copying it all is easiest but you can copy it as needed as well
you may find you have other import errors after copying the single folder
k, time for dinner. goodnight all!
@humble mural make sure you keep it in a /lib folder if you copy only the one library over because that's where it looks for the lib, or will look for other libs when you start to add more.
Makes it easier for the future as you start to use more libraries.
@idle owl In your judgement it's okay to drag that entire foldre over and deal with space issues when space become an issue. Because right now I am not sure exactly what I would drag over if I didn't drag the entire folder over.
Ahh ok
So when I've dealt with it, there's two major options.
You start with only the library you're using, and as you add more stuff to the project, you get an error "module not found" and you remember to drag that library over from the bundle as you go. I've done this, and sometimes I even remember to add the library before I get the error!
I'd drag over "adafruit_circuitplayground" .... and that's it...correct and I wuold put that in the /lib folder on the CPX.
Or you copy the entire bundle over, and when you get a memory error, you delete the stuff you're not using to free up space.
Yep that's a great place to start!
Option two for now.
Excellent ๐
@slender iron does circuitpython use the control characters for anything other than the REPL? Could there be a separate UF2 file with the REPL turned off?
@idle owl I want to create good habits from the beginning. Right now I am running code.py which is the bike light project code. I want to move on (or finish for the class period) to something else. Do I exit Mu, go to the circuitpy drive and rename code.py to bikeLight.py and reuse code.py later or don't store any file on the CPX at all?
I would, to be safe, create a directory on your computer and at least copy bikelight.py to that directory. If at some point the file system on your CPX gets corrupted, which happens, you'd lose all the files on the board. So I do my projects, and then save them to a CPXDev folder on my computer for reuse later. You can leave it on the CPX if you think you might reuse it soon, so it's there, but still keep a second copy. Which I also do.
Perfect I was going to do a version of that. Through the schools system I have a 1TB OneDrive. I already created an Adafruit directory for drivers, libraries, etc. I'll just put a CPX subdirectory in there, thanks again.
@meager fog, I'm watch you right now, https://www.youtube.com/watch?v=91qnz-VVrpU , you refer to Digikey when searching for infrared receivers. Please incorporate a lesson on how to shop on Digikey. I never buy from them because I can't find what I want half the time. A little lesson for the "Digikey challenged" would be appreciated. Thanks!
if you can't feed a hundred people, then feed just one - mother teresa ----------------------------------------- Visit the Adafruit shop online - http://www....
I used to keep track of when a component was 10x bigger or smaller than I expected ๐ Hasn't happened in a decade but it was funny when it happened!
@compact solstice that's a good idea, ill let ya know ๐
I find their shipping uber fast!
@idle owl "great guide migration" parts ordered. ๐ with a couple "me" projects added (
, meet FRAM and VS1053. FRAM and VS1053, meet
)
I love fram
circuitpython is the new programming language! It's so much better than javascript!
@raven canopy Excellent!
@blazing trail congrats on the bot. what should i do to try it out?
ok all midicv code is as good as it gets, time to build second module
hm, can do stereo string machine
all sorts o things.
Ok, so I have some code that was working, using i2c_device from adafruit_bus_device library. now it is giving OSError: 5 errors.
I suspect that the lcd I am communicating with is borked, would that result in OSError: 5?
File "/lib/adafruit_bus_device/i2c_device.py", line 102, in write
maybe pullups are missing
I have a 4k pullup on SDA to 3.3v
also scl?
do you have a photo of your wiring? that will help
it's on a breadboard; I just reseated the scl pullup and it is doing something different anyway.
I suspect it is breadboard gremlins. can post a pic in a bit.
i2c scans are now not finding devices.
they were before, so I think I just need to get better connections than this cheap breadboard and jumpers are providing.
Assigned myself, but anyone feel free to jump in. @ me if you start one so I can mark it, or if you get one completed and need it marked as complete.
So, I took step one and made a list of the current drivers in the bundle. Then, went through each one to see if any were already completed (knew it would be a short list).
At any rate, here's the task list:
DRIVERS
- [ ] ads1x15
- [ ] amg88x
- [ ] apds9960
- [ ] bme280
- [ ] bme680
- [ ] bmp280
- [ ] bno055
- [ ] ccs81...
that is a nice collection!
I have a compulsion #sorrynotsorry
really though I only have this many so I can test across the available platforms
Hi all. I want to find a way to stream the serial output of my board to the terminal instead of using mu editor for this. Anyone know a command that will do this?
mac
After further investigation, it seems the lcd is borked ๐ฆ le sigh.
/dev/tty.usbmodem1421```
to disconnect use CTRL-A, ATRL-K
looks about right
it you may get different values depending on how many boards you have connected and when
@pastel panther Cannot open line '/dev/tty.usbmodem1421' for R/W: Resource busy
you may have to close mu if you have it open, or at least disconnect from the board
@idle owl Are you responsible for my new CPX behaving like a mario coin block at a rave?
cool!
Make sure to use the ctrl+A then ctrl+K to disconnect or it may screw up your terminal
@graceful tusk Sorry to hear it; I had one suffer the same fate after spending to much time int he box 'o parts
@tawdry ether a custom build would be possible but I wouldn't want to distribute as a supported release
Leaving for @dhalbert's eagle eyes before merge.
Good morning. Last night I was inspired by @timber mango video on the CPX and IR remotes. I shared the Pixmob site with my class and they want to experiment with that using the CPX. Before they run they have to crawl. We want to do this in CircuitPython. My first question is how would I program the CPX to read the it remote so we know what information each button is sending. I found a similar project but it uses C++. I can start with that as a reference if need be. Thanks in advance.
I think there is a library that decodes the remote signal
@compact solstice โฌ that's it, but also, it's still a work in progress
there's also IRLibCP (unofficial) https://github.com/cyborg5/IRLibCP
@slender iron, @timber lion, I'm still unable to read from stdin in a nonblocking way. The docs reference non-blocking mode, but I don't see how to enable that mode. Any ideas?
for anyone else interested - the itsy bitsy m0s are available on the store this morning (stock < 100)
hey <@&356864093652516868> or anyone else here do we have a good link for Express spi flash erase proceedure? I'm helping someone troubleshoot a CPX issue in the forums and it may be time to erase it.
@split ocean https://learn.adafruit.com/welcome-to-circuitpython/troubleshooting#circuitpy-drive-issues
thanks
@pastel panther No Gemma M0?
so jut got my first trinket M0
and been playing with the dotstar
import board
import digitalio
import busio
import time
dotstar = busio.SPI(board.APA102_SCK, board.APA102_MOSI)
print("INIT")
def setPixel(red, green, blue):
if not dotstar.try_lock():
return
print("setting pixel to: %d %d %d" % (red, green, blue))
data = bytearray([0x00, 0x00, 0x00, 0x00,
0xff, blue, green, red,
0xff, 0xff, 0xff, 0xff])
dotstar.write(data)
dotstar.unlock()
time.sleep(0.01)
while True:
stringInp= input("r, g, b: ")
valuesInp= stringInp.split(", ")
red= int(valuesInp[0])
green= int(valuesInp[1])
blue= int(valuesInp[2])
setPixel(red, blue, green)```
is this the most efficient way to do this?
I don't think you need to worry abut efficiency
i want to be able to cram as much code on it as possible xD
you could do:
while True:
setPixel(*(int(c) for c in input("r, g, b").split()))
but it's a little less readable
what does that first asterix do?
lets you pass an iterator as individual arguments to the function
for example, foo(a, b, c) could be replaced with p = [a, b, c] and then foo(*p)
huh nice
thats very nicely efficient
so it just iterates c for each split in r, g, b
yes, precisely
wouldnt it be
while True:
setPixel(*(int(c) for c in input("r, g, b: ").split(", ")))```
of course normally you would also add all sorts of error handling
and for def setPixel( what would it pass?
not sure what you mean
def setPixel(red, green, blue):```
what would i have instead of ``red, blue, green``
when?
oh so it doesnt matter what the call is giving it
itll just name the first three passed variables as red blue and green?
yes
