#circuitpython-dev
1 messages ยท Page 136 of 1
I don't think I'm running the tip of 2.2, maybe that's the difference.
I need to build it.
you can grab it from s3
Oh. much simpler.
yeah in a bigger demo it does 'lose' taps
Can I try your code
That's what I figured
Is it the loop? because I'm dropping the threshold significantly and it's not really improving
as in is it the fact that the loop has a lot in it that it's only looking for the tap when it's in that part of the loop so it's missing some?
found it
Oh what did you get
we got the same thing then, really.
I increased time_latency, to keep the click event longer
and it responded much better
the click event was expiring before the loop maybe?
instead we should just be setting the top bit high
yeah
wanna do a fix? you want to "| 0x80" ๐
only thing is, its frozen
so...a little challeging
Yeah easy to test though
sort of.
because we might run into memory allocation issues, but we can easily test non-frozen copies by commenting out the prefer-frozen bit in the express.py file
I don't know how to build a frozen test build, but @slender iron and @tulip sleet do
sure
i have great faith in you ๐
the demo is good for testing because it EEPs when it works ๐
real quick though: where does | 0x80 go in lis3dh
right here https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH/blob/master/adafruit_lis3dh.py#L229
I put lights in mine so it would blink ๐
you want to flip the top bit high
so "threshold | 0x80"
threshold as is, is only bottom 7 bits. top bit is 'special'
its a little silly they put that config bit there. but they did. so. thats life
heh true so often
whatever you do to save a few gates
@timber mango I feel like I tried that and it didn't detect any clicks then
it does sound familiar.
its been a little while those since @idle owl and I were playing with it
I'll try to test it
@slender iron once I update it can you teach me how to do a frozen test build? (not sure what you're up to)
i can also test this on a feather sepatately
increasing time_latency seemed to fix it @timber mango, so that might be another option
increasing time_latency will totally do it, but...its a bit of a hack
to build it into a frozen module you need to edit the file in the submodule of the circuitpython repo
valid.
I think the issue we may have seen was missing double taps on fast loops
we were clearing click too quickly to detect double taps
but it may have been a different bug
bbl
I'm gonna go climb, will be back in an hour and a half or so
Ok
me also gone for a while
ok! see you all later!
@idle owl k im back, any luck?
@timber mango still working on sorting git. I get what needs to be done, just getting the last few git steps ironed out. But I'm on it!
np ๐
Hey everyone, Givemelove here. I just received my Circuit Playground Express for Christmas. Looking forward to running some projects on it.
@spiral herald Welcome! That's exciting! Congrats ๐
Thanks @idle owl , i'm pretty excited. Going through the tutorial for now. Seems a lot more straightforward than Arduino
That's what I've found to be the case!
@timber mango I got it built with the change in. Now I'm tweaking all the values again because it's back to being entirely too sensitive for single-tap.
@timber mango But testing with double-tap and it doesn't work.
Both in the demo code and in a tight loop.
I'm back
Hiya
I think I managed to get the right thing to build. And it does still fail on double-tap.
kk
weird
yah.
i mean, i would rather get this Right
I'm currently tweaking latency anyway.
i can play around with a feather version, so not freezing
blah wont fit - let me move to m4
@slender iron Is there anything that needs to be tested with the cookiecutter travis change?
yeah
nah, I think I enabled it in one repo already
@idle owl are you making possible changes to the LIS3DH library, or only the CircuitPlayground library? I have a PR for updating the CPX frozen modules, but happy to wait if you're still working on the library.
@tulip sleet Possible to LIS3DH
k, so I'll wait
ok keen ๐
oof getting USB MSD disappearances on M4 - odd i never got them before
oi
making progrss tho
nice!
@meager fog jerryn saw probs with M4 build on latest gcc 7 toolchain. My guess is that new optimizations uncovered latent bug
yah
when i save main.py the python runtime is good, but the MSD dies
and it erases main.py
i can build you one with the old toolchain if you need it
@idle owl whats your test code for single/doubel tap testing with the | 0x80 line?
im going in a few mins but i think it ought to be working?
It was written for CPX, you're using lis3dh right?
eh, we haven't made a "master" release in a while, you mean from AWS? Not even sure they're there
I think this is the code we used, but I don't remember what iteration this was:
last_tap = False
tap = lis3dh.tapped
if tap and not last_tap:
print("tapped!")
pixels.fill((30, 0, 0))
else:
pixels.fill((0, 0, 0))
last_tap = tap```
can't use pixels because that was CPX specific, but you get the idea
@meager fog ```python
import adafruit_lis3dh
import busio
import board
i2c = busio.I2C(board.SCL, board.SDA)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c)
lis3dh.range = adafruit_lis3dh.RANGE_8_G
lis3dh.set_tap(1, 20, time_limit=4, time_latency=17, time_window=150)
last_tap = False
while True:
tap = lis3dh.tapped
if tap and not last_tap:
print("tapped!")
last_tap = tap```
I'm having issues making it work, but I'm not yet convinced it's not something else.
Such as how I'm trying to tap the breakout. (it's mostly working now)
I edited the code snippet. Moved last_tap = False outside the loop. It spams the serial output if it's inside.
Even single-tap doesn't work very well with the config change to the driver on the breakout board.
@idle owl im just not getting the last_tap thing
something is weird
and my m4 keeps borking on me ๐ฆ
hmm.
I did it using a feather and .mpy'd the file
but I have no idea what else to try changing in the driver to make the threshold change work
I can't remember why we did it that way. with last_tap. something about keeping it from spamming the serial? Or keep it from mistaking taps for double-tapping? maybe that was specific to doubletap but not needed for single.
Yeah, even single tap without it spams the serial. I think it has something to do with how it lis3dh uses the buffer
i remember when i wrote this code in c it totally sucked ๐
and it wasnt documented at all
always helpful
im going to do more research, will work more onit tomorrow
Ok sounds good. I'm heading out for the night
ansi.sys style color escapes:
https://github.com/wa1tnr/cpx-basic-studies/blob/master/141-print.d/color_print_demo.py
@tannewt It looks like I only need to edit build_adafruit_bins.sh since there is only one build target we are testing against for now, but let me know if I missed something? See: https://github.com/adafruit/circuitpython/pull/496/commits/f1e1699c9f74e5aefdc6488c60daca52c8cd15bc
@meager fog @timber mango @idle owl the last_tap thing ensures the cpx's tapped only returns once per tap. The lis3dh bit is potentially held high over multiple reads for the same tap because the "clear on read" bit is off
@microbuilder I think that only runs it off Travis builds. The ESP8266 isn't built on travis because the toolchain isn't available on Travis.
You'll want to add a TRAVIS_BOARD here for it: https://github.com/adafruit/circuitpython/blob/master/.travis.yml#L15
That list makes the checks run in parallel and speeds up the build.
// LED for standard examples Abbreviated versions like this makes it harder to read.
np ๐
@idle owl @slender iron yah but...it shouldnt if we set the high bit... so lets do that?
@idle owl i have a few things to do today for show, but will get back to this tnoite
setting the high bit breaks double tap detection when you read it back quickly I believe
@meager fog ok sounds good
i didnt see that, double tap seems to work ok for me? :/
lis3dh.set_tap(2, 50, time_limit=10, time_latency=50, time_window=255)
Loop forever printing accelerometer values
while True:
# Read accelerometer values (in m / s ^ 2). Returns a 3-tuple of x, y,
# z axis values.
#x, y, z = lis3dh.acceleration
#print('x = %0.2f \t y = %0.2f \t z = %0.2f' % (x / 9.806, y / 9.806, z / 9.806))d
# Small delay to keep things responsive but give time for interrupt processing.
if lis3dh.tapped:
print("Tapped!", time.monotonic())
time.sleep(0.5)
@meager fog did you try it with the top bit of the threshold register set?
ah then we must have had a different bug
i think yah maybe...
hmm
So... that's weird.
Ok now double-tap sort of works. With ladyada's code and with the top bit set.
and no last tap?
Yeah.
O.o
No spamming the serial output either.
Finger stings. Successfully tapping a breakout on a breadboard is more difficult than it should be. ๐
@slender iron yeah i didnt need last-tap code either
you do have to be careul with setting the params
When it was spamming without last_tap, params didn't matter
i think that was something else
yup yup
i used this "lis3dh.set_tap(2, 50, time_limit=10, time_latency=50, time_window=255)"
I'm happy for it to change since you two refined it
ok kattni if you want to tweak both lis3 and cpx and commit, ill test it but i guess we have to rebuild the cpx firmware since its frozed?
But it doesn't yet explain it failing to work on CPX. I'll change up the params in express and load the test-build I made last night
I already have a test build with the 80 changed
So I can test it before we start committing
k yeah i only tried it on a bb
Still no double-tap on cpx.
does it work on a lis3dh + BB?
yes.
I just managed to get one double-tap as I set it down. But I even changed the thresdhold to 5 in express (should be spamming), and it's still not double-tapping on the CPX. If I leave it sit here without touching it, every so often, it will blink and say tapped. (tested it with your demo, now testing it without)
Issue with different thresholds being needed is back with this though: at 50 single is super-touchy with your demo, goes off all the time. So once this is sorted, we may have to go back to 80 or whatever ends up working for both.
Sanity check: yes still works on the lis3dh breakout with a feather m0 express.
...
hold up.
Ok here's some fun to add to the mystery. It works with different code.
Intermittently. But more than not at all.
It's the time.sleep
Without it, double-tap fails. But if you put it in the loop and outside the if/else (like in your test code), it works.
its because we're querying too fast
thats my theory
so it doesnt have time to get the second tap
Ok.... so doesn't tweaking the other params resolve that? Or is that a limitation of the hardware and we're required to have time.sleep in any code using double-tap?
I can test it if we're not sure
explains why your tests worked and ours didn't though....
So at least that mystery seems to be solved.
oi.
breakout fails without time.sleep! ๐
Ok so I'm ratcheting down the params in express class. To make the single-tap less touchy, and testing double-tap as I go.
It's always a tradeoff since wanting to stick to 80 chars wide, and abbreviation, but if you prefer to run over I'll update this.
Running over or placing the comment above is fine.
@meager fog is the functionality of the TB6612 generic or should I make a driver specific to it?
Params in express are tightened up. Works with tight loop and with the shipping demo code. Threshold is higher than it was. Double-tap is responsive but you have to time right, and it's obviously a little less responsive due to the time.sleep.
So include that in the docs I suppose? Going to be 3 examples for that one in that case.
yup to you, I'm headed to the gym
k
@slender iron heya back, for TB6612 and such, we should make a Stepper library, like arduino has
but since we have loose types, we can just pass in pin objects
~ideally~ if we do it right, we should be able to pass in port expanders, etc ๐
i can make the library if ya like
@idle owl did ya figure stuff out?
@timber mango Yeah!
yay thank you for helping ๐
I'm making the change to lis3dh right now, and will do a PR for that. Then I'll merge your PR and do the rest of the changes locally and do another PR for express
Thanks for helping too! That was a group effort for sure. I'd have been staring at it for a bunch more days
I tightened up the params in express so you can handle the board and not have it going off constantly with the demo code running
I can send it to you now if you have a couple of minutes. I have a test build with it in there and an express.mpy
(pretty proud of that uf2 ๐ )
Yep! Needs a time.sleep(0.4) or higher
I added it into your demo, slows down the rainbow, but it was good for testing
Also works in the code.py
hm not triggering for me
hmm.
updated for double_tap
Works for me in that...
Timing maybe? I left the time_window 255.
highest it can be afaik.
can you tell me the new express settings
yep
lis3dh.set_tap(value, 90, time_limit=2, time_latency=50, time_window=255)
I tightened up time_limit because otherwise single_tap goes off when the board is moved around, keeps it from triggering when you shake the board.
Do you want express.py?
ok figured i'd check
Just checked it again to make sure I had the most updated express.mpy, and it's still working for me in the demo code. ๐
@pastel panther what oscillator are you using on your board?
ok so
yah
@idle owl @slender iron i made it so its betternow
because we keep clearing the register when we read
the Right Way is to use IRQ
yeah
irq = DigitalInOut(board.ACCELEROMETER_INTERRUPT)
irq.direction = Direction.INPUT
irq.pull = Pull.UP
while True:
# Read accelerometer values (in m / s ^ 2). Returns a 3-tuple of x, y,
# z axis values.
#x, y, z = lis3dh.acceleration
#print('x = %0.2f \t y = %0.2f \t z = %0.2f' % (x / 9.806, y / 9.806, z / 9.806))d
# Small delay to keep things responsive but give time for interrupt processing.
if irq.value:
if cpx._lis3dh.tapped:
print("Tapped!", time.monotonic())
this way it doesnt matter if you query too soon
ok... so does that go into express then?
(thinking)
yes
well
yes - we should check the irq first
thinks hard
it could also go into lis3dh
but there's a chance that they didnt set up the lis3dh for irq-on-tap
whereas we do for sure with cpx
but on the other hand, we will not allow the pin to be exposed
let me check the DS, we may have to update lis3dh
actually, sorry, we should do it in lis3dh
ok
if thats ok, thats the best place for it
this line https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH/blob/master/adafruit_lis3dh.py#L189
Should be fine, I haven't gotten a notification that Dan's done the update yet.
read INT1_SRC (reg 0x31)
and look if the value & 0x40 > 0
if so, THEN read CLICKSRC
@idle owl I just did a release of the library (which was probably premature), but I am waiting on your finishing the debugging before doing anything in adafruit/circuitpython
@timber mango I'm not sure I follow what that will end up looking like. I have it pulled up, but I don't get how to translate from the concept to the actual code ๐
@tulip sleet Ok I'll let you know
ok start here
make a new register called REG_INT1SRC
ok
then read_register_byte(theoneIjustmade) ?
yep here
read the raw value
then you want to test that this bit is set
0 = no interrupt, 1 = yes interrupt!
it is the 7'th bit in, so thats 0x40 hex
(1 << 7) == 0x40
if (raw & 0x40): interrupt is set, so now check that the interrupt is from CLICK
self._read_register_byte(REG_INT1SRC)
raw = self._read_register_byte(REG_CLICKSRC)
if raw & 0x40 > 0:
return raw & 0x40
?
no
wrong order
That?
It's not interacting with the INT1SRC though I don't think. What I just wrote I mean.
So I don't think it's right.
you have to save that register read, it gives you back the byte
raw = self._read_register_byte(REG_INT1SRC)
then you can test it
does that make sense? registers are a bit of a stretch the first time u use them
sort of.
its data, but its representing the hardware
if raw & 0x40 > 0:
click_raw = self._read_register_byte(REG_CLICKSRC)
if click_raw & 0x40 > 0:
return raw & 0x40```
the number you get back has bits set that tell you what the chip has stored in it
?
ok I guess it makes more than sort of sense ๐
when you read a register, sometimes it clears it
thats why we have to do 2 checks - because if we clear it too early, by reading, then the lis3dh is like "that first click never happend"
so this should eliminate the need for time.sleep?
hmm how to test this...
because I don't know what accel_interrupt would be on a feather.
owait it only uses frozen if we're using cpx. oi.
yah you dont need time.sleep
oh you dont need the accel_int anymore
you should be able to just call tapped()
i sorta did a workaround. the IRQ pin is 'elegant' but not really needed for us.
(since, we dont have interrupt support in cpy anyhow)
so this is what I have, it runs but it's not working:
import digitalio
import adafruit_lis3dh
import busio
import board
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19)
lis3dh.range = adafruit_lis3dh.RANGE_8_G
irq = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
irq.direction = digitalio.Direction.INPUT
irq.pull = digitalio.Pull.UP
lis3dh.set_tap(1, 20, time_limit=2, time_latency=50, time_window=255)
while True:
if irq.value:
if lis3dh.tapped:
print("Tapped!", time.monotonic())```
this is on a CPX.
with t he new compiled lis3dh code?
Yeah.
so I figured out why the stlink flashing wasn't reliable
it's related to the fact that it uses its own 3.3V signals, and that's sometimes a little bit different voltage than the microcontroller gets from the ldo
if I power the microcontroller from the stlink directly, it flashes flawlessly
good catch
the jlink doesn't have that problem, because it always uses the target's voltage
I kept pruning the program back. The problem appears to be much more fundamental, and appears to have to do with storage allocation or garbage collection. This program hangs around i=479:
for i in range(10000):
print(i)
l = [0]*50
Interestingly, it doesn't fail in the repl, but does fail if named as, say gcc7crash.py and then I do import gcc7crash. Don't make it main.py: it will crash before you get to the REPL, and CIRCUITPY will be nonfunctional quickly. I had ...
Have you tried this with a debugger hooked up to see where it is in C land?
@idle owl I understand what @timber mango was going for if you need more help
@slender iron I do. I have code that runs but it's not working.
ok can you post what you have?
In adafruit_lis3dh: python @property def tapped(self): """True if a tap was detected recently. Whether its a single tap or double tap is determined by the tap param on `set_tap`. This may be True over multiple reads even if only a single tap or single double tap occurred.""" raw = self._read_register_byte(REG_INT1SRC) if raw & 0x40 > 0: click_raw = self._read_register_byte(REG_CLICKSRC) if click_raw & 0x40 > 0: return raw & 0x40
In code.py: ```python
import digitalio
import adafruit_lis3dh
import busio
import board
import time
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19)
lis3dh.range = adafruit_lis3dh.RANGE_8_G
irq = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
irq.direction = digitalio.Direction.INPUT
irq.pull = digitalio.Pull.UP
lis3dh.set_tap(1, 20, time_limit=10, time_latency=50, time_window=255)
while True:
if irq.value:
if lis3dh.tapped:
print("Tapped!", time.monotonic())```
Oh and this in lis3dh: REG_INT1SRC = const(0x31)
ok. I tried that too and it still didn't work. I'll remove it
yeah, I think there is some config to do to make INT1 == the CLICK_SRC IA
going to do that - just wanted to redirect where to look. It's doesn't seem like it's IO or USB or something like that. I have a feeling it's something that got optimized out or misplaced even though it's "asm"d or something like that.
Yup, thats my feeling too. I'll assign to you.
not sure what you mean
we may not have to configure anything is its configured correctly by default
ah
ah!
(section 8.10 in the data sheet)
0: default, 1: enable
know how to set it?
hmm. write_register_byte(REG_CTRL3, 0x80) ?
yup, theres a similar line in the init already that I think you can replace
Ah. change 0x10 to 0x80
so just in init? or in tapped too?
because I'm still not getting any response from the cpx.
Or on a feather with a breakout.
@idle owl just in init
should it still be in set_tap then?
should what be?
self._write_register_byte(REG_CTRL3, 0x80) # Turn on int1 click.
oh no, I didn't know it was in set_tap already
oh. yah
this both: self._write_register_byte(REG_CTRL3, 0x80) # Turn on int1 click. self._write_register_byte(REG_CTRL5, 0x08) # Latch interrupt on int1.
ah
seems like it should work then
I'm not convinced the INT1 register == INT1 pin
I think I had something wrong, but I changed it and it didn't fix it: python if raw & 0x40 > 0: click_raw = self._read_register_byte(REG_CLICKSRC) if click_raw & 0x40 > 0: return click_raw & 0x40 ^^ I had return raw & 0x40
ah. that would mean we're not really calling the interrupt pin?
yeah, we're not exactly reading the pin state
I think the INT1 registers would be better named IA1 and IA2 to match the bits in CTRL_REG3
how's that work
I don't think we can read INT1_SRC as a proxy for CLICK_SRC
ah
INT1_SRC only pertains too the inertial interrupts like free fall
why does CTRL_REG3 call it "CLICK interrupt on INT1"?
I think because INT1 is ambiguous
ah
in that case they mean the pin, not the registers
ohhhh.
because REG3 also has IA1 and IA2 on INT1
I see that
which match the INT1 and INT2 register sets
you could read the actual pin state
ya, I don't think it'll do what we want
ok
I think we'll need some more @timber mango time to sort out what she wants
ok
was the issue that double taps are missed when a sleep waits a while in the loop?
It was a combination of that and the fact that we needed time.sleep at all, I think
double taps weren't working for her, they were working for me with a sleep in the code
so she went on a hunt
if the LIR bit is off we don't need sleep then though
did we do that? Or does that need to be done still
oh.
hmm.
then the time_latency needed to be higher I think, and that's a workaround, and she wanted to do it right, so that's what started all of this.
yup, its tricky
the latching is weird because ideally it should effect the latency detection for double tap
yeah, thats the only way I can think of getting what she expects
Digi-Key and Adafruit orders arrived yesterday. The CPy StringCar PCBs arrived today, ahead of schedule! Assembly starts after AaE tonight. May have to brave the snow storm tomorrow for final testing. 
@errant grail are you going to show it on show and tell?
@slender iron Not tonight. Perhaps sometime after testing.
but PCBs are fun to look at!
I think so too. Designing PCBs is almost as much fun as soldering!
yeah totally!
The area to the right of the two StringCar boards is for a special retro-ish USB power monitor I've been working on. Perhaps that will make it to S&T before the StringCar stuff, we'll see.
cool cool
< PCB project endorphins >
Is or has anyone worked on a LSM303 (e.g. the Flora accel/mag board, https://www.adafruit.com/product/1247) driver fir CP?
Pin state read implemented!
nice!
@umbral dagger not yet!
@slender iron @idle owl hiya thanks for patience, i am about to eat food
i see we use the INT1 for two purposes?
yeah but not INT1SRC
can we use INT2 for tap, INT1 for 'other'?
I don't know if INT2 is even there
i think there's two ints
I don't think it's connected to anything
there is a pin on the chip
not on the CPX for sure
chip has both, but i think hardware wise we only connect one
yknow, its probably best we just use the pin
I implemented the irq read into lis3dh
this darn chip does tooo much!
I tested it with lis3dh directly, I'm currently making a test build for CPX so we can try it with express class
Ok, we don't have to do what I did, but Scott thought that reading the pin state directly was the only way to do what it was you were trying to do, so I figured I'd try to do it
and did
Everything works at the moment. ๐
Haven't tested with express class yet, but lis3dh works with pin state read implemented
And error checking if someone doesn't pass in the irq_pin, so if they don't have it connected, they can still do single_tap but not double_tap because that was the error we were having to begin with, and the only way around it is time.sleep etc etc etc etc
(went in a circle)
Want my test stuff?
at least the lis3dh anyway
Works for me anyway
mmm. test build fails with the CPX demo code though. Time to sort why.
@timber mango OK, I've started fiddling with converting the C code.
@timber mango Sneak peek at a project:
So amendement to earlier statement: the demo code isn't currently working with express class with the changes to lis3dh.
@umbral dagger cool! check out our 'how to port libraries' guide ๐
@idle owl i have to eat now, sorry ๐ฆ
@timber mango I appear to have the Flora lsm303 sensor working in CP (on a Feather M0 Express).
@meager fog Status: I have the irq pin state read working on the breakout, and on the CPX not using express class. My test frozen module build fails on the demo code for express class with pin PA13 is in use. I don't know what else is using it in Express, or if the issue is pervasive to lis3dh and it's a fluke that it works directly. I need to head out for the night. I'll see when you're around tomorrow.
Is there a place where to find the Bossa desktop tool compiled ? The one I use from Shumatec keep crashing on my Mac
there are some compiled binaries there
also, I think it ships inside Arduino, so you might be able to use that one
@stuck elbow thats the one I am using but it keep crashing. I need the desktop version not the command because I need my customer to update code with a simple app from their desktop
Bossa has been forked many time but I can't compile the fork myself
So I am looking for a stable desktop wrapper for the bossac
I made one with Processing that works on my Mac but I have trouble porting it to Windows
So maybe the solution is already available somewhere ?
Here is my Processing wrapper : http://www.polaxis.be/bossa-uploader/
I didn't even know there were gui versions
@stuck elbow Yep I knew this wasn't exactly the right place to ask ๐ฉ
sorry
hmmm - I am playimg with an SI7021 sensor. On my metro M0_express, it works under CP 2.x but not under 3.0 .... error message under 3.0 ```Adafruit CircuitPython 3.0.0-alpha.1-16-g36ec29d on 2017-12-23; Adafruit Metro M0 Express with samd21g18
import si7021_test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "si7021_test.py", line 8, in <module>
File "adafruit_si7021.py", line 79, in init
File "adafruit_si7021.py", line 79, in init
File "adafruit_si7021.py", line 75, in init
File "adafruit_si7021.py", line 74, in init
File "adafruit_bus_device/i2c_device.py", line 94, in write
OSError: 5
This was using the 20171223 Bundle.
does the i2c.scan show it?
yes 64 = 0x40 ```Adafruit CircuitPython 3.0.0-alpha.1-16-g36ec29d on 2017-12-23; Adafruit Metro M0 Express with samd21g18
from board import SCL,SDA
from busio import I2C
import adafruit_si7021
import time
i2c=I2C(SCL,SDA)
i2c.try_lock()
True
i2c.scan()
[64, 104]
I don't suppose you have a logic analyzer handy?
can you upload the capture file?
si7021_error
awesome
FYI - it failed on the Metro_M4 and nrf52 board as well.
why is it trying to write to 0x80? that's not a valid i2c address
hmm - sounds like a shifted 0x40
no - this wa just the init
ah, no, it's the i2c_bus checking if the device exists
can you compare that to a working session?
Line #74 in the backtrace is i2c.write(data, stop=False). stop=False is unusual
from busio import I2C
import adafruit_si7021
import time
i2c=I2C(SCL,SDA)
sensor=adafruit_si7021.SI7021(i2c)
while True:
print(sensor.temperature,sensor.relative_humidity)
time.sleep(1)
@tulip sleet why is it unusual?
@stuck elbow sure - it'll take a few minutes to reconfigure for 2.x
not always used: not THAT unuusual, but might be something wrong with the 3.0 impl
@tulip sleet it's a common pattern in i2c reads -- you send the register number, and then you switch to reading and read the value
every single driver uses that
@tulip sleet what is unusual is that line is inside a try-except that should catch that OSError
@tulip sleet but for some reason it doesn't
ah, I see, it expects OSError 19 but it's giving it OSError 5 instead
the error is expected, because the sensor is resetting
19 is MP_ENODEV; 5 is MP_EIO
19 is thrown only if it's an I2C_ERR_BAD_ADDRESS
so the problem is that 3.0 returns MP_EIO instead of MP_ENODEV when the device doesn't respond to a write request
Ah - that makes sense
I wish MicroPython would finally define, document and freeze its API
and document api changes like this
the code is essentially the same in 2.x and 3.0, but the lower level ASF3 vs ASF4 libraries may be returning diff values
maybe see how other libraries handle this; perhaps it's being too picky
well, we can always add 5 to that list of expected error values
but I would hate to catch and ignore unexpected errors
MP_EIO makes more sense, because the device is there, I think
you can't tell
you would get exactly the same behavior if it was disconnected
the clock line remains high
I think we have some code that assumes error 19 in the i2c bus device
don't know if it is meaning ful but the nrf52 say it can't find the device. ```Adafruit CircuitPython 3.0.0-alpha.1-29-ga14bfeb-dirty on 2017-12-23; Bluefruit nRF52 Feather with NRF52832
impost si701_test
Traceback (most recent call last):
File "<stdin>"
SyntaxError: invalid syntax
import si7021_test
Traceback (most recent call last):
File "<stdin>", in <module>
File "si7021_test.py", in <module>
File "adafruit_si7021.py", in init
File "/home/travis/build/adafruit/Adafruit_CircuitPython_Bundle/libraries/helpers/bus_device/adafruit_bus_device/i2c_device.py", in init
File "/home/travis/build/adafruit/Adafruit_CircuitPython_Bundle/libraries/helpers/bus_device/adafruit_bus_device/i2c_device.py", in init
ValueError: No I2C device at address: 40
ah, no, it just catches all OSErrors
in ASF4:
uint16_t status = hri_sercomi2cm_read_STATUS_reg(hw);
if (flags & MB_FLAG) {
/* tx error */
if (status & SERCOM_I2CM_STATUS_ARBLOST) {
hri_sercomi2cm_clear_interrupt_MB_bit(hw);
msg->flags |= I2C_M_FAIL;
msg->flags &= ~I2C_M_BUSY;
if (status & SERCOM_I2CM_STATUS_BUSERR) {
return I2C_ERR_BUS;
}
return I2C_ERR_BAD_ADDRESS;
not sure when BUSERR is NOT set; have to look on the datasheet
I wonder if just catching all OSErrors there would be the right thing โ personally I cringe a bit, because that's hiding errors, but it would surely be more robust against such api changes, and if it's an actual error, it will fail later anyways
@solar whale that ValueError definitely looks wrong
BUSERR is protocol violation or timeout. But ASF3 is checking for RXNACK, not BUSERR. Does a timeout give RXNACK
in ASF3, RXNACK gives BAD_ADDRESS.
%-)
yes ๐
@stuck elbow yes - lets defer the nrf52 until the M0/M4 issues get resolved....
in ASF4, RXNACK just returns a NACK error code
so ASF3 and ASF4 are not consistent on the error codes they return. I think I will browse through other CPy drivers and see if they're so specific
@tulip sleet @stuck elbow thanks for the quick response and debugging. I opened an issue on the si7021 -- this is not a critcal need - just testing stuff.
@solar whale do you think you could testing with 5 added to that tuple on line 74?
<@&356864093652516868> The meeting is still on for today at 3pm Pacific / 6pm Eastern. Make it if you can otherwise no worries! Have a great holiday break.
@stuck elbow sure - - looks like current code has a fe changes - it is now in line 78 ๐ - I'll try it
@solar whale @stuck elbow no other driver in the bundle catches 19 specifically. bno055 catches any OSError and assumes device is resetting
I guess I was overzealous
has anyone come across an error when casting a float to an int (TypeError: can't convert float to int)?
@prime flower with int()?
yep
@prime flower in C or Pyton?
pyth
python doesn't do implicit casting, you have to use int() or math.round() explicitly
it's too big?
not sure. passing in frequency = 25.2 to length = int(4000 // frequency) and hitting that error
@stuck elbow @tulip sleet adding 5 to the tuple woks
tried doing /, still gets the same error.
oops - not so fast - I forgot to go back to 3.0....
works for me
just a sec - will try unde 3.0
yea, it works within the REPL but not the lib.
now that is fishy
@prime flower can you point to the code?
@solar whale would suggest just catching OSError withOUT checking for 5 or 19
@tulip sleet so just "pass" on OSError?
@prime flower I think the error is actually here for i in range(length / 2):
range cant' take a float, and thats float dividision
v>>> range(5.5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert float to int
yeah, those pokemon try-excepts are confusing
@solar whale prob fine, that's what bno055 does
it's just witing for the sensor to start responding again after a reset
I wonder if we should have a timeout there
maybe good to note that in a comment if not already noted
and raise an exception after a number of tries
otherwise you could have your whole project stuck because of a bad connection
then again, this is not Apollo computer...
@tulip sleet using pass in lin 78 - bumps the error down the ine ....
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "si7021_test.py", line 10, in <module>
File "/lib/adafruit_si7021.py", line 121, in temperature
File "/lib/adafruit_si7021.py", line 100, in _data
File "/lib/adafruit_si7021.py", line 100, in _data
File "/lib/adafruit_si7021.py", line 97, in _data
File "/lib/adafruit_si7021.py", line 97, in _data
File "adafruit_bus_device/i2c_device.py", line 78, in readinto
OSError: 5
yes it repeats in _data - I'll add the pass there as well.
bno055 does this for reset:
def reset(self):
"""Resets the sensor to default settings."""
self.switch_mode(CONFIG_MODE)
try:
self._write_register(_TRIGGER_REGISTER, 0x20)
except OSError: # error due to the chip resetting
pass
while True: # wait for the chip to reset
time.sleep(0.01)
try:
chip_id = self._read_register(_ID_REGISTER)
except OSError:
chip_id = 0
if chip_id == _CHIP_ID:
break
I know, I wrote it, but I'm starting to have second thoughts about this now
just showing jerry
self.i2c_device = I2CDevice(i2c_bus, address)
self._command(_RESET)
# Make sure the USER1 settings are correct.
while True:
# While restarting, the sensor doesn't respond to reads or writes.
try:
data = bytearray([_READ_USER1])
with self.i2c_device as i2c:
i2c.write(data, stop=False)
i2c.readinto(data)
value = data[0]
except OSError:
pass
else:
break
if value != _USER1_VAL:
raise RuntimeError("bad USER1 register (%x!=%x)" % (
value, _USER1_VAL))
self._measurement = 0
def _command(self, command):
with self.i2c_device as i2c:
i2c.write(struct.pack('B', command))
def _data(self):
data = bytearray(3)
data[0] = 0xff
while True:
# While busy, the sensor doesn't respond to reads.
try:
with self.i2c_device as i2c:
i2c.readinto(data)
except OSError:
pass
else:
if data[0] != 0xff: # Check if read succeeded.
break
value, checksum = struct.unpack('>HB', data)
if checksum != _crc(data[:2]):
raise ValueError("CRC mismatch")
return value
this works
I guess we could replace that while loop with a for loop with an else, and raise an exception in that else?
modified init and data
@solar whale looks good!
@tulip sleet @stuck elbow I'll update the issue wit thsi information. Do you want a PR with this change or should it wait for further discussion.
@solar whale a PR would be great!
@solar whale i defer to @stuck elbow 's thoughts on the best way to fix tit
I think this is good enoughโข
@tulip sleet what is the pr merging policy? Can I just merge it, or do we require a minimum number of reviews?
I rebase when the commits are ok and squash if not. dan likes to merge and thats ok too
@slender iron debugging the gcc 7.2.1 issue: gdb sometimes hangs when printing backtrace and some other weird stuff when debugging these hangs. Older gdb does too. I just have to be careful. It prints enough so that when I restart it I know what frame to go to. just YI
i was kinda astounded. Also when I was printing some objs. Yes I can debug it. It's in gc, calling __del__ on an object it wants to gc. The obj looks like a vfs_fat obj (??). I noticed these comments in gc_collect() in main.c:
// WARNING: This gc_collect implementation doesn't try to get root
// pointers from CPU registers, and thus may function incorrectly.
Is this a potential serious issue? accidentally gc'ing something that seems to have no ptrs, but might have refs in a register?
prob. I'd need to know which regs might contain python object pointers. The regs are checked in the the esp8266 gc_collect() and some others. Prob need to understand the abi conventions or something. If they only look like objects perhaps that's safe, or would it try to follow them? Not expecting an answer - I have to understand the gc and I don't really know the details right now
as far as I know the MicroPython gc is pretty loose about what it considers a pointer โ it can have false positives
I think it'd ignore any values outside the range of the heap
I think the assumption is that they will get gc-ed next time around, or something
so I could easily check the right regs for pointers. I'll add that to the list of things to do
since arm-none-eabi-gcc is used for stm and other arm impls, I can probably just follow what's done in those ports, since the reg use should be the same
@meager fog Still climbing this particular learning curve as quickly as I can ๐ Feedback appreciated: https://github.com/dastels/circuitpython_lsm303
https://github.com/dastels/circuitpython_lsm303/blob/master/adafruit_lsm303.py#L219 isnt ever called, remove?
how much time until the meeting?
4 hours
thanks, not sure if I can make it either
@stuck elbow Do you have a minute?
sure, always
For the ssd1331 update. I don't know why the pylint messages are there. Scott wants comments included to explain. Could you help?
I think you explained the init one in the comment
well, the other is about the number of arguments
and we simply need that many arguments in that function, because that's how many arguments it needs
no, wait, that's circular argument
because that's the API
"due to function requiring the given number of arguments" ?
or method I guess since it's api
so that we can override the default values
ok
got that then too.
What about the "no-member" after that? Although I'm not sure he wanted comments on the whole thing or not. But might as well.
let me see
ok
not sure what that is about, do you remember what the lint error message was?
No. I can remove it and lint it though. two shakes.
:no-member (E1101): %s %r has no %r member
Used when a variable is accessed for an unexistent member.
is "unexistent" a word? %)
E:103, 8: Instance of 'SSD1331' has no 'dc_pin' member (no-member)
I didn't think so
It is now ๐
The dc_pin is called in another file iirc
yeah, it's inherited from the DisplaySPI
ok, I'll look now @idle owl
keen
@stuck elbow and @timber lion sorry you can't make it. we'll still do 11am normally. I just wanted to experiment with a different time
@idle owl did you mean to merge and approve https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/pull/10 before your pull?
No because it doesn't work in his and there's still 3 other drivers that have to be tested in that one.
He knew he'd have to rebase that file.
@stuck elbow said it was a totally different issue so we did it separately.
Since it was an issue with the original driver
ok, well the dc lint error is correct because its stil just dc and not dc_pin in master
there is a pull request to change it
right, its an ordering problem
Yeah it'll break in the meantime
I thought the lint PR would be merged first but it shouldn't be if they aren't all tested
There's so much in it, I've been working through it slowly
yeah, that library is large
I didn't realise there's even multiples in each lib file. I have so many displays now
so that's why it's not done
k, no worries
so change mine to dc and remove the pylint bit and it should at least be good for master, and it'll need to be updated in the PR?
yeah
ok
because pylint isn't enabled in travis now anyway
I totally missed the fact that dc_pin is not merged
That's why we have multiple eyes-on ๐
ok merged (squashed)
nice. thanks!
@slender iron I wonder, is there a way to see the summary of all open circuitpython-related pull requests somehow?
just to make sure we are not missing any
I had some pull requests to the micropython libraries that I didn't see for months
@stuck elbow Not exactly. Adabot can traverse all of the repos already though so it shouldn't be too hard to add. https://github.com/adafruit/adabot/blob/master/adabot/circuitpython_libraries.py#L208
ideally we could hook some of that logic up to adabot on discord
pylint question: it's complaining about my use of "const" . How can/do I fix that?
I think I found it's build into travis ci, so it'll complain locally but build fine in the PR. If you're talking about the same error I think you are
Undefined variable 'const' (undefined-variable)
oh nope. That's different.
resulting from things like _REG_ACCEL_CTRL_REG1_A = const(0x20)
right. I'm looking at one right now that has those, and there's no pylint-disable for that. Just the whitespace disable
not sure.
(thought maybe we were disabling it or something, so I checked)
did you do the import like this from micropython import const ?
dunno if that matters
I'm going through things in this lib that might have helped. That's the last of the ideas I have if that didn't help.
no import for it
you need the import
(micropython and circuitpython don't actually require it but they should.) we should add another built-in function
That did it. It lints clean now
Nice!
If anyone cares to have a look: https://github.com/dastels/circuitpython_lsm303
@umbral dagger I'd suggest using properties for most of what you are doing
any methods with a set_ prefix should likely be properties
Oh neat
@timber lion can I make the thermal printer repo public?
oh, nice
So with the tap int pin state read changes, acceleration is broken on the CPX using lis3dh directly. Which means somehow acceleration was using the interrupt. Everything works great on the LIS3DH breakout.
strikes out another part for which he wanted to write a driver from the list
@slender iron Updated to use properties
Broken as in: acceleration grabbed one initial set of data, and then never updates.
@stuck elbow Total yak shave... I wanted an accel featherwing and that flora breakout fit on a featherwing protowing just right, and was fairly cheap.
@umbral dagger sorry, I was thinking about the printer
@stuck elbow But I did want to start writing driver level studd, soo...
@stuck elbow ah
๐
@umbral dagger its weird you are setting _LSM303MAG_GAUSS_LSB_XY which is formatted like a global. I'd suggest using a attribute on the object
also accel should be accelerometer to match other drivers and the guide
How would acceleration using the same driver be using something one way on the breakout and something another way on the CPX? It's the same driver...
@slender iron True. An artifact from the inital C code I ported.
looks like we need to add one to the guide for magnetometer as well
@idle owl I'll look at the CPX driver api
@idle owl Makes sense for them to be compatible
@umbral dagger I was on a different tangent if you're referring to what I just said. But your statement is still valid either way.
@umbral dagger no need for sensor_type either. you can just pass the device directly
@umbral dagger the design guide should have magnetic as an x, y, z of uT
ideally you would look for an existing driver for a similar device, and make it work the same way
I worked form the C driver and a different CP accel driver
not sure we've done a magnetometer driver yet
Which different driver? We might need to synchronize it
@rapid ember is the build sorted out and able to make releases? if so yep it's good to make public
er @slender iron
@timber lion it needs to be public to get the build sorted out
its ok for it to be public without a release right?
oh gotcha, yep fine with me
ok perfect! will do that after lunch
yeah i wasn't sure if travis would be mad now if it's not public
any commit will likely try to trigger it
i don't see any commits in the near future though
we'll see ๐
I do have some feedback on it, how should I get that to you?
(for example why we need begin separate from __init__)
@stuck elbow Bah... I was looking more closely at the C lsm303 lib.
But hey... make it work, then make it work nice
sure
I'm a huge fan of working software
in fact I try to only use working software myself
Its listed as a single value but should actually be an x, y, z tuple like acceleration.
@stuck elbow Whaaaaat? Working software? Come on.
I know, I know, dream on. But it's nice to aspire to something.
@slender iron yeah i made it in the comments, begin takes about a half second to run so i want people to have control when it happens
it's waiting for printer warmup
if you do it in the initializer it's not obvious to people and they're going to put it in all their global object creation at the top of their script
and wonder why it takes 1/2 second to get to main code ๐
the guide and explanation also mentions it a lot too
coming from the C++ world I'm still super leery of putting a lot of logic in object creation too
i know python can throw exceptions and such.. but no one really catches them in object creation ๐
I do
totally, you can and should but in practice most python beginners avoid it
it's not usually an expected thing
particularly if coming from C++ ๐
the list of things you do in Python that are not common in C++ is very long ๐
yeah i wish someone would make a good book about coming to python from a C/C++ background
it's a big mind shift
haven't really seen much out there
but in C++ when you call the constructor for a global variable, you can't really do much logic
so it makes sense to have a deferred "real" constructor
yeah and C++ has all the quirks around when objects are created, like static initialization and such
i remember there was a brief period of time where i fully undestood those semantics
and then immediately forgot them ๐
it gets super strange though and IIRC there's actually undefined behavior in the spec for lots of static objects that depend on each other
I wonder if it would make sense to have a pair for methods, for switching the heater on and off, so you could save energy when not using the printer
could matter for battery-powered projects
yeah it's not actually turning anything on unfortunately, it's happening as a side effect of resetting its state
these printers are odd little beasts
the firmware works but i have a feeling is kinda buggy like some of the fancy sensors (BNO055)
they dramatically change instructions between minor firmware versions
like setting inverse mode totally changes from version 2.64 to 2.68
kinda feels like they just hack things in as necessary ๐
yes, also the font switching and even what fonts are available
it feels like they actually have several branches of that firmware for different use cases, but we get whatever branch was most recently released
hah yeah could be!
I still didn't figure out the images on that thing
I have some thermal sticker paper, the kind you use for labels โ I wanted to connect a microbit to it, and have kids design their own 5x5 stickers
yeah i couldn't get bitmaps going either
i think we're sending data too slowly and the printer bugs out
I guess I could print 5x5 images with ascii-art
it starts interpreting the bitmap data as characters for me and prints bizarre stuff
ah fun yeah ascii printer art
are you powering it properly? usb is not nearly enough for it
I had it reset in the middle of a line when powered from usb
and i'm sending the same data.. but something is up
ah interesting
i was going to go back later and look more with a saleae to see if anything is up
but my gut is that it's not getting data fast enough and starts interpreting the bitmap bytes as characters to print
even though you tell it how many bytes to expect, it seems to just stop and go back to print mode
are you using the samd21?
you could buffer the whole thing first, and then send in one burst
yeah samd21, yeah i tried for a very small 8x8 image that and it might have worked but it was hard to tell (it's a really small 8x8 pixel square.. super tiny when printed and hard to see if it's filled in or not)
but big images in general are hard as they take a ton of memory
75x75 pixel adafruit image basically filled up memory
with the library and such
so even if printing worked right now it would be pretty limited ๐
Is there a map function in circuitpython like there is in arduino or makecode?
hmm, streaming from a file could be an option
@carmine hornet in the simpleio module
yeah totally i'd like to stream from file or SD, but if from memory is too slow right now need to figure that out first
@carmine hornet something i like to use instead is a linear interpolation function (what map does internally), good background here: https://en.wikipedia.org/wiki/Linear_interpolation
it's a couple lines as a function though, very clear in python:
def lerp(x, x0, x1, y0, y1):
return y0 + (x -x0) * ((y1 - y0) / (x1 - x0))
can see the formula exactly matches the simplified version in the articule
i used lerp everywhere.. it's great for animating colors
it looks like the docs for simpleio are not picking up the docstrings from the code: http://circuitpython.readthedocs.io/projects/simpleio/en/latest/#api-reference
like if you get a sine wave that goes from -1 to 1 you can map to a color value 0 to 255 like
x = math.sin(... whatever your sine wave is...)
color = lerp(x, -1.0, 1.0, 0.0, 255.0)
easier to add that one liner than import a whole separate lib too ๐
@tannewt This includes 'feather52' builds on travis now, but the CTRL+C issue with REPL still needs to be addressed before this can be merged (hopefully tomorrow).
I have no idea. The breakout is wired the same. It only uses INT1, INT2 isn't connected to anything. Same as CPX. But the CPX is using the lis3dh driver differently than the breakout.
alright i have to run, sorry i thought the meeting was at normal time of 11am today... i have to be at a family get together at 3pm and will miss the meeting this afternoon
It's all good. Have a great time!
I'm on the other side - I'll be here!
Just no voice from me today. We have family visiting. Family in the form of four children.
@timber lion have fun with your fam!
@stuck elbow here is the list of open PRs:
- https://github.com/adafruit/Adafruit_CircuitPython_SD/pull/4
- https://github.com/adafruit/Adafruit_CircuitPython_VC0706/pull/1
- https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/pull/1
- https://github.com/adafruit/Adafruit_CircuitPython_MAX7219/pull/9
- https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/pull/6
- https://github.com/adafruit/Adafruit_CircuitPython_BNO055/pull/4
- https://github.com/adafruit/Adafruit_CircuitPython_SSD1306/pull/6
- https://github.com/adafruit/Adafruit_CircuitPython_SSD1306/pull/5
- https://github.com/adafruit/Adafruit_CircuitPython_SI7021/pull/6
- https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/pull/10
- https://github.com/adafruit/circuitpython/pull/496
#adafruit/circuitpython#475
I test this using Feather M0 Express with a Featherwing RTC+SD. Works fine.
I haven't tested these changes on device yet. Please only merge you test it or I follow up later to say its tested.
For adafruit/circuitpython#475
#adafruit/circuitpython#493
@slender iron I found 2 more for the micropython libraries
kk, this is only looking in libraries returned by github's repo search for circuitpython
@slender iron Do you have those statistics broken down into which boards are more popular?
- arduino_zero 83 +14
- circuitplayground_express 1171 +422
- feather_huzzah 254 +31
- feather m0 adalogger 76 +10
- feather m0 basic 99 +13
- Feather m0 express 337 +50
- gemma m0 206 +44
- metro m0 express 144 +27
- trinket m0 638 +144
Oh, neat.
CPX is,completely unsurprisingly the clear leader
Even without that, though, it had a good lead
I'm surprised a little at how many downloads there are for the Huzzah, given how much more difficult it is to install compared to the Express
Probably right.
Hug Report: Lady Ada, as she updated Kattni's wonderful "Intro to CP" with instructions on how to install CP onto non-Express boards and ESP boards, in a matter of minutes, in the middle of the night, when someone was looking for how to do it. Also, group hug because everyone here is awesome and I won't be able to do another one until next year.
?whois tannewt
252717193496756235
None
online
None
Thu, Jun 22, 2017 1:13 AM
1
Mon, Nov 28, 2016 8:47 AM
community helpers, world-maker-faire, Show & Tell, osh-summit, circuitpython helpers, seattle-mini-maker-faire, admins, multiplayer-gaming, metro m4 testers
Kick Members, Ban Members, Administrator, Manage Channels, Manage Server, Manage Messages, Mention Everyone, Manage Nicknames, Manage Roles, Manage Webhooks, Manage Emojis
Server Admin
Jerry
He'll just have to step up his game, right?
Status Update: Begun work on "Migrating from Arduino to CP" guide. Not much yet, but if anyone wants to peek at it feel free to prod me. That's also my plan for the next week, too.
That looks amazing!
Ice rain is problemmatic for strings, not just the electronics.
Wow!
It's so tiny!
This device I'm building is not very beginner-friendly. It uses all SMD components, a bare displays screen, needs you to flash the bootloader to a bare chip and compile your own CircuitPython, etc. Quite a bit of work, to be honest. On the other hand, I would like the software library I'm making for this to be generally useful, and not just limited to this one device. So I wrote it in a way that lets you use it with pretty much any SPI display with 16-bit colors, and any buttons. Today I went and made a "homebrew" version of ยตGame, to show that it really doesn't have to be hard.
My initial experiments used a Trinket M0, but to really write an interesting game you will probably need much more room, so this time I used a Feather M0 Express, which has an additional flash chip. I also used a breakout board I made for displays, and a bunch of buttons:
---------- more ----------I had to bend the legs of those buttons a little bit, to pack them on the board tightly enough:
A little bit of soldering:
And we have out gamepad:
Next, we
@solar whale M4 3.0 gcc7 test code: CIRCUITPY/c.py
def r():
for i in range(510):
print(i)
l = [0]*50
in REPL:
>>> import c
>>> c.r()
Will hang around i=497. That is when gc gets called.
Do NOT put c.py in main.py, because you'll get stuck and not be able to get to CIRCUITPY when it hangs
I'm sorry - I have to go - good night and Happy New Year all.
Have a good one!
import adafruit_lis3dh
import busio
import board
import time
i2c = busio.I2C(board.SCL, board.SDA)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c)
lis3dh.range = adafruit_lis3dh.RANGE_8_G
lis3dh.set_tap(2, 20, board.D11, time_limit=10, time_latency=50, time_window=255)
while True:
x, y, z = lis3dh.acceleration
print(x, y, z)
time.sleep(0.1)
if lis3dh.tapped:
print("Tapped!", time.monotonic())```
try:
self._lis3dh.set_tap(value, 90, board.ACCELEROMETER_INTERRUPT, time_limit=2,
time_latency=50, time_window=255)```
Thanks all! Have an excellent New Years!
thank you all!
thanks
Thanks so much!
Video recording is a monster on disk space
Everyone pitch in $1 and we can get him a set of floppy disks for his videos.
@errant grail @idle owl GitHub is NOT intuitive well
Reel-to-reel tape storage?
@slender iron Out of curiosity, what's your typing speed? It sounds like you type pretty fast
@slender iron Do you use hibernation on your computer? I remember a while back that Windows would end up with a several-gig hibernation file even if you're not actively using it
ALL the NVidia drivers.
Upgrading from tiny SSD + storage HDD to pure SSD was the biggest upgrade my computer has had
GPUs also matter if you run multiple monitors
I have six monitors on my computer. I still need to fiddle things around to get them all working again though.
Oi
Yes I do!
Vivo makes good mounting brackets
They're solid steel bars. can't get much simpler
that's good the vivo 6-monitor thing is $1125
I didn't spend NEARLY that much on mine.
Hopping out of voice chat as well. Later!
g'nite!
night
Night all!
night all!
@tulip sleet This is the one I have: https://smile.amazon.com/gp/product/B00B1D4P56/
def __init__(self, spi, cs, baudrate=100000):
@cunning crypt looks good as long as the tabletop is sturdy!
def __init__(self, spi, cs, *, baudrate=100000, int1=None, int2=None):
I went hunting for an appropriately sturdy desk before purchasing.
hey. happy holidays all. sry. very afk season for me.
I was working with a neopixel strip and the circuit playground, and it was working perfectly fine until I taped the strip to the wall. Can anyone help?
Now it only controls two pixels
heres my code
I don't see any physical damage to the strip
@carmine hornet if you didn't change the code then you may have cracked one of the solder joints on the strip. try pressing on the last lit pixel or the first dark one, and also inspect the solder joints carefully with a magnifying glass. it may help to bend the strip slightly to see a crack. Also are you using longer wires to the strip than you did before? And are you powering the strip with 5v or3.3v?
@tulip sleet I'm about to do the PR for LIS3DH. I can send you some testing files if you want to try it, including a test build with the frozen module updated and the current demo code.
Still have some documentation to change in express class but the core or everything is done.
@idle owl sure, but in the morning
@tulip sleet Ok np. Figured I'd offer in case you were up for it tonight.
no, I'm fading fast after staring at assembly language
That sounds tiring ๐
if I add a print statement in a certain place, then the 3.0 gcc7 stuff works. I know what is different, but not why it makes a difference yet.
oi, yeah
@slender iron think I found a compiler bug; I know how to get around it. something's forgetting to save one of the arg passing registers. Have to find all the cases where this happens. Has to do with calling routines designated attribute(na k e d) (spaces added to avoid bot censoring. This bug appears to be new in gcc7. @idle owl I lied when I said I was going to sleep.
@tulip sleet I noticed
but now I don't have to chew on it overnight ๐
I totally understand
I had to go to sleep with the lis3dh thing still in the air last night
yeah, wake up at 3am with visions of code dancing in your head
exactly
ttyl this time for real
Night!
@meager fog I have a test build of CircuitPython for the CPX with the updated lis3dh frozen in. I have a PR in for the update to both lis3dh and the CPX express class updated to work with it. I have files for you when you're around.
I am done for the night!
@slender iron my diagnosis was incorrect, but still maybe getting closer.
@tulip sleet progress is not always forward ๐
@solar whale ๐คท but now I understand the calling conventions on ARM, which is actually very helpful to know.
@tulip sleet I just ran your "c.r" on my Metro M0 (Cp 3 gcc 7.2.1) and it completed ok.