#circuitpython-dev
1 messages · Page 133 of 1
do you have more stuff you want to add, like IR?
it might be a q for Scott and Limor
IR is going to be a serious learning curve for me, and it's lower priority. The only other thing to consider was the sound meter.
That's it though.
That would be every feature having something in express which I guess is what I pictured.
I thought there was an outstanding issue but it's for lis3dh not express
I would ask them as well as me. I wasn't home for JP's mem problems; is that resolved enough not to have it frozen?
Not sure, he's out for a bit, but he'll be back. And Scott rewrote it to not fail on memory error, so it seems to mostly work even with constant memory errors.
Of course I'd ask them as well, but you deal most with the freezing bit, so I started with you.
if we can get away without freezing it, then it can be deferred. maybe 2.2 is a little early
Yeah I'm still up in the air about it myself. It would be nice to avoid memory issues but there are still changes being made.
@idle owl I did some copy-editing on the first couple of pages of that guide. Just typos and font styles. And I made the warning about not resetting or unplugging more obvious.
The screen section needs to say how you exit screen: ctrl-A \ on Linux, ctrl-A ctrl-\ on Mac (right?)
Oh I type :exit
But I think you're right there too
not working for me but I think I ran into this last time where it didn't like me then either.
I know crtl+A, :exit works for me.
ctrl-A :quit on linux. Oy, silly differences.
This is a really great guide. I'm looking forward to pointing people to it.
Thank you! I'm excited about it
there are two versions of screen actually, a gnu one and another one
BSD i think
each has a different exit sequence
it's why mac is different from linux
and very annoying
I’ve been using C-a k y on Linux
Does anyone have a link to the instructions to load CircuitPython on a feather m0 adalogger using bossa?
@opaque patrol i think it's pretty much just:
bossac -e -w -v -R FIRMWARE.bin
and replace FIRMWARE with appropriate file name
Ok I've been going in circles for an hour. I'm trying to get this OLED SPI breakout working with CP and after working through a number of errors, I've come repeatedly to one that I can't seem to get around.
It's the SSD1306 1.3"
Ah, you can hook that up a number of ways I see. You choose I2C. ok. So what kind of errors?
Are you level shifting?
SPI. And I'm getting 'SPIDevice' object has no attribute 'write'. The driver for this device uses another library that uses another library. There's a level shifter built in.
ok, code issue. I see.
so who says there should be a write attribute?
haven't looked at any code yet.
This library calls adafruit_bus_device.SPIDevice I believe. I can find write in all three libraries
try - void fastSPIwrite(uint8_t c);
That isn't CircuitPython....
it should be writeinto, maybe
Counting down the days until I upgrade my laptop. Oi... crashed again.
are you testing the library or just trying to use the display? The I2C impl might work better.
there's no writeinto never mind
Error: Traceback (most recent call last): File "code.py", line 11, in <module> File "adafruit_ssd1306.py", line 183, in __init__ File "adafruit_ssd1306.py", line 46, in __init__ File "adafruit_ssd1306.py", line 72, in init_display File "adafruit_ssd1306.py", line 189, in write_cmd File "adafruit_ssd1306.py", line 189, in write_cmd AttributeError: 'SPIDevice' object has no attribute 'write'
I2C is probably easier, yeah, but this lib is waiting on SPI testing.
I think I see a "writeto(...)"
This is SPIDevice: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/blob/master/adafruit_bus_device/spi_device.py
Right, I2C is part of busio which is imported. have you tried 'writeto'?
In what? The device library? It's also in the other 2 libraries and I don't have those locally
I think SPIDevice might be just wrong. It's missing any actual read or write methods of any name.
Oi! Vindication!
i dunno. just lookin at this.
http://circuitpython.readthedocs.io/en/latest/shared-bindings/busio/I2C.html#busio.I2C.writeto
oh heck, I was in the example. so sorry
@idle owl did you test lis3dh with spi or just i2c?
@tulip sleet I guess just i2c. I didn't think to check both. Or even consider that both were an option. I went with the whatever the example would have been, and then tested shake.
My bad, found something in bitbangio tho
RTD has write for SPI.
But that doesn't mean it's in the lib.
Although Sphinx would have had a fit if it caught it, so I'm not sure this makes sense.
ok, I see what's going on. __enter__ (invoked by with) returns the busio.SPI object, which you can read and write on.
Ok
I tried setting it up like that but because some of it's handled in the device lib, it doesn't seem to work right. Maybe it's my code.
import board
import busio
import digitalio
import adafruit_ssd1306
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
dc = digitalio.DigitalInOut(board.D9)
res = digitalio.DigitalInOut(board.D10)
cs = digitalio.DigitalInOut(board.D11)
oled = adafruit_ssd1306.SSD1306_SPI(128, 64, spi, dc, res, cs)
oled.fill(1)
oled.show()```
There's nothing to it though.
Fails "write" on the first oled line
It's not getting there though.
It's failing on the oled = adafruit_etc line according to traceback.
I tried that though, no change in error
I will stare at the code a minute...
doesn't this SPI need to be locked first?
def write_cmd(self, cmd):
self.dc.value = 0
with self.spi_device:
self.spi_device.write(bytearray([cmd]))
def write_framebuf(self):
self.dc.value = 1
with self.spi_device:
self.spi.write(self.buffer)
Yeah
change that code to:
def write_cmd(self, cmd):
self.dc.value = 0
with self.spi_device as spi:
spi.write(bytearray([cmd]))
def write_framebuf(self):
self.dc.value = 1
with self.spi_device as spi:
spi.write(self.buffer)
Oh I need to download the driver then.
@lofty topaz the locking is done by the SPIDevice when you do with. with calls __enter__ invisibly.
Oh I have it from downloading it for the M4
Oh no that's in the one I've been working on. Oi. ok.
I had never looked at this in detail before. The I2CDevice and SPIDevice work quite differently. I2CDevice returns self; SPIDevice returns the busio.SPI object. Hmmm.... ALso the example code in SPIDevice is wrong, I think.
OK.... ok. It's no longer giving me that error
Instead I have AttributeError: 'SSD1306_SPI' object has no attribute 'dc' which I thought it was a parameter?
So I defined it in my code, but if I just put the pin number in the param it gives issues with Pin object, and if I replace dc with digitalio.DigitalInOut(board.D9) I get P07 or something in use
its a pin, not a pin number. I think it means direction
oh, i see what you mean
are you testing this on a feather?
Yeah
so paste your current test code
import board
import busio
import digitalio
import adafruit_ssd1306
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
dc = digitalio.DigitalInOut(board.D9)
res = digitalio.DigitalInOut(board.D10)
cs = digitalio.DigitalInOut(board.D11)
oled = adafruit_ssd1306.SSD1306_SPI(128, 64, spi, dc, res, cs)
with oled as oledspi:
oled.fill(1)
oled.show()```
wait... or is it failing in the changes you made?
File "code.py", line 12, in <module>
File "adafruit_ssd1306.py", line 183, in __init__
File "adafruit_ssd1306.py", line 46, in __init__
File "adafruit_ssd1306.py", line 72, in init_display
File "adafruit_ssd1306.py", line 186, in write_cmd
AttributeError: 'SSD1306_SPI' object has no attribute 'dc'```
error ^^
look in the edited version of SPIDevice.py. What does write_cmd look like? paste it here
I replaced it with your code
def write_cmd(self, cmd):
"""Send a command to the SPI device"""
self.d_or_c.value = 0
with self.spi_device:
self.spi_device.write(bytearray([cmd]))
def write_framebuf(self):
"""write to the frame buffer via SPI"""
self.d_or_c.value = 1
with self.spi_device:
self.spi_device.write(self.buffer)```
that's what it was
I don't see the self.d_or_c.. I'm not looking in the PR. Hold one.
replace self.dc.value in my replacements with self.d_or_c.value. I was looking at the old code, sorry.
in both def's
Ooh new error!
File "code.py", line 14, in <module>
AttributeError: 'SSD1306_SPI' object has no attribute '__exit__'```
I got it!!
I took out the with you had me add to test earlier!
You figured it out!
Aahhhah! Yes!!!
it displays!?
Yes!!!
OK! Well, that was painful. I didn't really know these libraries. I'm a little weirded out by the non-consistency between the I2C and SPI versions.
I was going in circles with that! Thank you so much!!
And that's why we test code, kids.
I need to file an issue about the bad example. YW!
Ok, I need to edit the SPI code in the lib
...and I need to mind my own business. Didn't mean to get in the way.
No worries. You never know when you can help. Thank you for trying. I appreciate it!
I shouldn't bounce between channels so much and get confused.
@lofty topaz don't worry - this was really confusing - there was a bug in an example and there was a bug in the library under test. Neither @idle owl nor I understood the corect use of the SPIBusDevice lib up front
@tulip sleet Yeah, plus I had just returned from celebrating my daughters 22nd birthday. Helpful frame of mind but not so analytical. 🍸
Nice hack tho.... ><>
I just installed CircuitPython on a Huzzah esp8266. I've connecte to it using Putty. I followed the Adafruit tutorial by Tony DiCola. It is not showing up as a mass storage device. Are there additions steps to install the UF2 files/ability to the Huzzah?
The ESP chips don't support UF2
Thanks. I was thinking something like that would be the answer.
It's something with the hardware not supporting USB like that. Can't be resolved with software.
What would be re recommended method to save code to the Huzzah? FIYI I haven't tried or researched it yet.
FYI...
ampy maybe? I'm not familiar enough with working with the ESP chips. There's a few other people who have done it a bunch.
I'll look into that. Thanks again.
@sacred socket This should help you out.
https://learn.adafruit.com/building-and-running-micropython-on-the-esp8266/overview
I'd found that page but have not read through it yet. Reading https://learn.adafruit.com/micropython-basics-load-files-and-run-code/boot-scripts right now.
for some reason the macbook thinks there isn't enough space on FEATHERBOOT to install a new uf2
@ruby lake try renaming it to current.uf2 to cause it to replace it
hmm, d_or_c is a really confusing name
the pin is labeled "dc" on all the modules
(yes, I know technically it's d/c)
I had to look up that it’s “data/command “
and sometimes it's also marked as A0
or some equally useless marking
I think that if we want to follow Python's style of using whole words, it should be data_or_command
what I'm trying to say is that d_or_c is not really better than dc in terms of clarity
then it would also make sense to use chip_select for cs too
and perhaps also "master_in_slave_out" for miso
data_cmd seems a happy medium...
only if you are a native speaker
miso et al seem like standard terms, cs is kinda that, but I agree data_or_command or data_or_cmd would be a lot clearer, since it's certainly not universal on SPI devices. Happy to entertain a PR.
dc is quite standard in the niche of serially-controlled displays
there is also the question of being consistent with the drivers for other platforms, like arduino etc.
they all use dc
@idle owl where is that code from? I'm looking at https://github.com/adafruit/micropython-adafruit-ssd1306/blob/master/ssd1306.py but can't see any d_or_c?
nevermind, found it, wrong python
I wonder if there is some way to subscribe to changes from all the circuitpython-related repositories somehow
Hello!
Ive just received and plugged in my trinket M0 & Metro express boards to try CircuitPython...
I'm under windows10, I've installed the adafruid drivers 2.0.0, and the trinket M0 is seen as a drive when plugged in.
But when I'm plugging in the Metro Express, It is not seen as a drive, even though it does seem to run the demo python file, since the RGB led is showing some kind of rainbow colors...
I've managed to connect Putty on the newly created COM8, and some numbers are scrolling... but I can't stop the script execution with CTRL-C as for the trinket M0 demo script... :s
I'm looking for any help or suggestion to be able to see the Metro express as a drive and be able to modify the CircuitPython script... thanks! 😃
ok, just found that: "Windows 10
Did you install the Adafruit Windows Drivers package by mistake? You don't need to install this package on Windows 10 for most Adafruit boards. The old version (v1.5) can interfere with recognizing your device. Go to Settings -> Apps and uninstall all the "Adafruit" driver programs."
my mistake... 😦
question: are #elif & #else recognized in the CPy backend? Hoping to use it like:
#ifdef SAMD21
foo = bar;
#elif SAMD51
foo = bar2;
#else
foo = no_bar;
#endif ```
@raven canopy you mean in Python code? Nope, though you could run the .py through cpp yourself. I'm not sure I've seen anyone do this in Python code.
@timber mango are you all set now?
@tulip sleet not in Python. In C...working on the unique ID thing.
In C, yes, we use it ALL the time. But there are also board-specific files where you might want to isolate these routines. Are you doing this on the master branch?
yeah. I thought about using each ports common_hal, but since we're targeting both SAMD & NRF (and ESP uses machine), I'm starting in shared-bindings. if that is the wrong approach, I can go back to the drawing board and figure out how to impl in the ports/boards.
and just thought about recursion to MPy... that's a reason to go the ports/boards route.
shared-bindings is common code; we don't conditionalize by arch there. So use common-hal, but with identical function names across the ports. See atmel-samd/samd21_peripherals.c and samd51_peripherals.c for an example of the same function name with different impls. These files are compiled as appropriate for each arch. The routines in them are called from a common-hal/ routine.
copy that. thanks for the vector correction! 😄
@tulip sleet I just posted a travis-fixing commit to ssd1306, so can you give it a final look and merge it?
@is it worth testing the SPI changes quickly? I have an SSD1306 but I'd have to unsolder the I2C jumpers. Is yours still set up for SPI?
@idle owl @tulip sleet heya Q, for SPI displays, y'all renamed dc to d_or_c?
lol ok whats the name now?
Or whoever linted it had anyway
@meager fog mr mcwethy did, but @stuck elbow thought that was obscure, and submitted a PR to make it clearer. See https://github.com/adafruit/Adafruit_CircuitPython_SSD1306/pull/4
dc_pin - but this change isn't committed yet. So it's d_or_c right now I believe.
and @stuck elbow documented what "dc" means in a docstring comment (per my request)
ooh ok yah dc_pin is good
thx, just checking - d_or_c is not /technically/ correct
dc_pin is best! 😃
yeah, it bothered him; great - we want clearer libraries, and he added a lot of doc as well
np some of these pin names are unclear but i can help since i label the pins on th eboard - just @ me
i have a few minutes to kill, should i put 2.2 on a CPX and test doubletap?
@timber mango Yes please!
@tulip sleet Tested successfully.
I'll merge it then
New release done as well, so that's sorted.
i do want to take a look at framebuf and perhaps change it to be more gfx-like at some point
maybe its very close to done :/
@timber mango Did you get my emails earlier this week about the guide? It's basically done except for those two questions.
Yay cpx.double_tap works for me with 2.2 and the most recent bundle!
Hi all, I've literally started exploring and reading about circuit playground express just now and was going through the adafruit learning page. There's an example to try but I'm getting this error:
No I2C device at address: 40
Anybody have any idea what's the problem? Ta
Yes, in fact, I believe I do. Can you link the code you're looking at?
It's here: https://learn.adafruit.com/adafruit-circuit-playground-express/about-circuitpython-libraries
This is the code:
import adafruit_si7021
import busio
import board
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_si7021.SI7021(i2c)
print("Temperature:", sensor.temperature)
print("Humidity:", sensor.relative_humidity)
I think the issue is in the line where you setup the i2c instance of whatever you're using. So instead of just (i2c), for the Circuit Playground Express you need (i2c, address=0x19)
It was just demonstrating how to and why to install latest libraries and etc
ah. I see
For that to work overall, you need that sensor attached, so while it's walking you through how to install libraries, it won't fully work on your board unless you also have that sensor.
@lucid arch I did the exact same thing when I started with that example, maybe it should be changed to indicate it is demonstrating an error more clearly
@opaque patrol You are correct, and there is currently a guide that's going to replace a lot of those generalised getting started pages.
It's not quite finished but that's the plan.
Ok, that makes more sense now. Is there an onboard address i can use, since 19 is not found either
That should have worked. I'm wondering if the issue is that the example won't work without the sensor breakout board.
@idle owl speaking of guides....I talked to Scott earlier in the week and he said to get with you about helping with guides....
So it's looking for something on that address and it's not finding anything because there's nothing attached.
@opaque patrol Oh nice! Yeah, I can get that sorted.
yeah. I'm assuming you dont use the i2c to read the temperature sensor?
Not the onboard temp sensor, no
I don't think anyway.
The examples further on in that guide will cover a lot of it.
That example is simply showing how to create an error by not having a module installed, and then installing the library you need to resolve the error.
ok
got it
makes sense.
cool, i'm moving on with the next pages then
just one last question. I should just override the code.py everytime with my code and save and that should be it, for uploading to the board?
Thank you for the feedback! I'm adding a couple of sentences to the upcoming guide to make it clearer what's going on. The example is different in the new guide, but still we want it to be as clear as possible.
Yeah that is a way to do it, or you can edit it every time. Whichever way you want to do it. Just be sure to save it somewhere if you want to keep it.
cool .Thanks, you've been really helpful. this forum is 😃
That's great to hear! That's one of the biggest reasons we're here!
i've been exploring the world of flora lately before i came across the CPX and so i'm more used to the arduino ide. I quickly went through a few examples there and was having a hard time getting the sensors working.
i tried the colour example, where the colour sensor senses colour and flashes the neopixels of that colour but that did not work as it should
similarly same result for the light sensor
are those examples massively out of date? or..
circuitpython examples via the arduino ide
I have no idea then. I've never worked with Arduino, so I haven't gone through them, nor would I be able to tell by looking.
ok. no worries. thanks, i guess i'll keep going through the circuit python examples for now and see where they lead.
Ok, sounds like a plan!
Someone else would know better than me, I'm sure. So hopefully someone catches your question.
cool. ta
I am looking at the color_sense example now....It basically uses the buttons to flash colors and detect the amount of light reflected...I might try to convert this to CP
thanks BravoDelta. I basically kept getting medium values, even though i put the board next to stark green felt paper or red paper.
@opaque patrol Yeah it's not really a color sensor, the examples in MakeCode use the LED next to it to flash and then you use that data. Sounds similar. I know there was a plan to add that in CircuitPython, but as far as I know, no one has done anything with it.
@idle owl Do you know off the top of your head what the range (or resolution) of the light sensor on the cpx?
Nope.
here is what I have so far to sense color....
from adafruit_circuitplayground.express import cpx
import time
from simpleio import map_range
LIGHT_SETTLE_MS = 0.1 # 100 ms
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
CLEAR = (0, 0, 0)
def sense_color(verbose_out = False):
cpx.pixels.fill(CLEAR) # clear pixels so they don't interfere
time.sleep(.5)
# Save the current pixel brightness so it can later be restored. Then bump
# the brightness to max to make sure the LED is as bright as possible for
# the color readings.
old_brightness = cpx.pixels.brightness
cpx.pixels.brightness = 1.0
# Set pixel 1 (next to the light sensor) to full red, green, blue
# color and grab a light sensor reading. Make sure to wait a bit
# after changing pixel colors to let the light sensor change
# resistance!
cpx.pixels[1] = RED
time.sleep(LIGHT_SETTLE_MS)
raw_red = cpx.light
cpx.pixels[1] = CLEAR
time.sleep(.01)
if verbose_out:
print("raw red = {}".format(raw_red))
cpx.pixels[1] = GREEN
time.sleep(LIGHT_SETTLE_MS)
raw_green = cpx.light
cpx.pixels[1] = CLEAR
time.sleep(.01)
if verbose_out:
print("raw green = {}".format(raw_green))
cpx.pixels[1] = BLUE
time.sleep(LIGHT_SETTLE_MS)
raw_blue = cpx.light
cpx.pixels[1] = CLEAR
time.sleep(.01)
if verbose_out:
print("raw blue = {}".format(raw_blue))
# Turn off the pixel and restore brightness, we're done with readings.
cpx.pixels.brightness = old_brightness
# Now scale down each of the raw readings to be within 0 to 255.
red = map_range(raw_red, 0, 255, 0, 330)
green = map_range(raw_green, 0, 255, 0, 330)
blue = map_range(raw_blue, 0, 255, 0, 330)
return int(red), int(green), int(blue)
try:
cpx.pixels.brightness = .2
verbose = False
while True:
if cpx.button_a or cpx.button_b:
verbose = cpx.button_b
time.sleep(.05) # debounce
if verbose:
print("button pressed")
while cpx.button_a or cpx.button_b:
time.sleep(.01)
r, g, b = sense_color(verbose)
print("({}, {}, {})".format(r, g, b))
cpx.pixels.fill((r, g, b))
except:
cpx.pixels.fill(CLEAR)
actually works pretty good
Nice!!
i tried your code and i get a memory error:
Traceback (most recent call last):
File "code.py", line 1, in <module>
MemoryError:
So we're super tight on memory with these boards. If you have too much on your board already, you can run into that with beefy code.
Do you have the most updated version of CircuitPython on your board?
yep
And the updated libraries?
Yep
Ok
Not sure then. It's early working code, so we'll have to test it more to see what's up
ah i tried the keyboard exmaple just now and i get another memory error:
Traceback (most recent call last):
File "code.py", line 7, in <module>
File "/lib/adafruit_hid/keyboard.py", line 34, in <module>
MemoryError: memory allocation failed, allocating 896 bytes
Hmm. Did you save a bunch of files to the board or anything? Or you're still working with just one code.py
Also if you put three backticks (the one in the top left corner of your keyboard) on both sides of your code, it will make it a codeblockOne backtick on either side and you get inline code
So when you're posting code or serial errors, it's good to use the backticks for readability.
Hmm.
backticks : got it.
@idle owl When you say the lattest, are you talking about 2.2.rc1 or is there now a definitive 2.2.0?
cpx had an issue for a time with lis3dh causing memory errors
i got this: adafruit-circuitpython-bundle-py-20171216.zip
I actually meant 2.1.0 since that's the latest stable. But, to answer the question, no it's still rc1.
rc1
@opaque patrol Not any more.
It prefers frozen modules over local copies now to eliminate that.
I can change it to not use cpx
@lucid arch That's good, the most updated libraries are best to have. There's a couple of new features that need a newer version of CircuitPython, but they're not in any examples yet.
@opaque patrol That shouldn't be it. But you can give it a try.
@lucid arch is getting memory errors on other things too.
yeah, keyboard module.
@lucid arch Were you using the bundle from 20171216 when you got the memory error?
am defo still working on code.py and with the same lib folder. so it cant be a space issue.
i've had the same bundle since an hour, which is when first installed my cpx latest.
@opaque patrol The cpx class is designed to use the frozen modules now instead of the local copies which was what was causing the memory errors with lis3dh.
havnt changed the lib.
Have you physically reset the board?
I'm not sure it will help but it's an easy step to try. Friendly eject it and then press the reset button.
Then reconnect to serial and see what you get
pressed the reset button? yeah, a bunch of times.
Oh ok
ok, let me try that.
If you've already reset, then I doubt it will help.
I am actually using the lib bundle from the 12th. cpx is version 0.9.1 according to versions.txt
We might need to fully erase the board and start again. Something got unhappy.
That's the newest, @opaque patrol
iirc.
Let me check.
Could try flashing 2.2.0 rc1, it is super easy to flash the circuit playground express
still the same issue. keyboard mem error 😦
Oh there's a 1.0 release, but it only adds another thing to the API, no bug fixes.
@opaque patrol : flash the bundle? how.
Ok, you seem pretty comfortable with all of this, I want you to follow the steps here: https://learn.adafruit.com/adafruit-circuit-playground-express/troubleshooting#for-the-circuit-playground-express-feather-m0-express-and-metro-m0-express
coool
We're going to erase the board completely, so back up everything you want
Then I'm going to link you the release candidate of CircuitPython
Download this and flash it instead of 2.1 (this shouldn't matter, but we would love to have some more testing of this version)
Testing it now 😃
Thanks!
they have different sizes
Should say 2.x
but we created the lib bundle stuff before we released 2.2rc1
Here:
That. If you didn't already get that same one.
works
😃
the keyboard example works
@opaque patrol your code about the colour sensor works as well 😃
Yay!
so the board did get unhappy ... hmm, a bit temperamental, isnt it?
It can happen. They're not always tempermental, but when they are, sometimes it takes a full flash to fix it.
Could have been a memory leak in something and then whatever it was couldn't clear, something like that.
The other thing is you don't want to reset without ejecting
and if you do, files can become corrupted if anything was trying to write at the time
often this corrupts the entire board
but it can affect one file, and then that file can just cause memory issues.
So that also could have been it. Never know. For what it's worth, though, it seems really difficult to actually break anything. Even if it's not showing up at all, as long as you can get to the bootloader, you can reflash it with the steps I sent, and get everything happy again.
cool
pretty cool
ok. its been joy talking to you guys
am off . will continue exploring the cpx more tomorrow.
is the cpx meant to be wearable, like the flora is?
or is it just a tiny board for exploring lights and sensors?
i love that theres so much in the cp as compared to the flora. it means you can start doing small stuff and seeing things really quick, like a rad sort of thing.
It can work as a wearable! There's a bunch of projects where it is.
But it's specifically meant to be a perfect intro to programming and electronics.
So many options to learn different concepts.
😃
well, thanks and good night.
You're welcome and you have a lovely night as well!
Blergh, travis failed on that PR I just did, except I didn't change anything but the one line in travis.yaml so I'm a bit confused.
travis is just upset that you took them out of it
Apparently.
But it means it wasn't linted completely to begin with or they literally just added this check. Which on research says they did that in September.
This:python def _read_register(self, reg, count=1): self.buf[0] = _COMMAND_BIT | reg if count == 2: self.buf[0] |= _WORD_BIT with self.i2c_device as i2c: i2c.write(self.buf, end=1, stop=False) i2c.readinto(self.buf, start=1) if count == 1: return self.buf[1] elif count == 2: return (self.buf[1], self.buf[2])Says:Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
I don't understand what it means.
Found this:
```A new Python checker was added to warn about inconsistent-return-statements. A function or a method
- has inconsistent return statements if it returns both explicit and implicit values :
- .. code-block:: python
- def mix_implicit_explicit_returns(arg):
-
if arg < 10: -
return True -
elif arg < 20: -
return - According to PEP8_, if any return statement returns an expression,
- any return statements where no value is returned should explicitly state this as return None,
- and an explicit return statement should be present at the end of the function (if reachable).
- Thus, the previous function should be written:
- .. code-block:: python
- def mix_implicit_explicit_returns(arg):
-
if arg < 10: -
return True -
elif arg < 20: -
return None```
But I don't see how that's what's happening, so...
I'm lost to fix it.
It thinks you are returning an expression in the second because of the parens
What does the calling class expect? The second is returning a tuple (right?)
I think so... and I have no idea. I didn't do anything else with this.
This is beyond my knowledge of python...I think you could put parens on the first return but I am not sure what any side effects might be by doing that
Suppose count == 3, then there's no return statement that's operative
I don't understand
Like I said, all I did was update that same travis.yaml issue
And then the build failed on the actual driver file.
if count == 1:
return self.buf[1]
elif count == 2:
return (self.buf[1], self.buf[2])
suppose count is not 1 or 2, if there's no further statements, then the code just falls off the end. I don't know why pylint didn't catch this before with travis; that's a different q
but i think that's what's wrong with the code
Good catch,
bye - sorry - on our way out
Later!
Hmm ok... I'm going to close the PR and delete the branch, then clone it locally and try to deal with it because I don't know how to do multiple changes on a GitHub created branch with an active PR in place.
I do believe you could change the first to return (self.buf[1],) but I might be wrong
PyCharm disagrees, whatever linter it's using says those are redundant.
Wants me to remove the parens from the last one instead. But I don't think that's the problem.
Need to clone it, brb
Any idea how that's supposed to look?
What?.... pylint locally doesn't catch it.
Ok now I'm super confused.
It has if count == 1 elif count == 2, what if count < 1 or > 2? Probably unlikely but the linter just sees that you have an if, elif and no else.
can't type tonight....what *if count.... keep forgetting there is an edit mode
the example has no else either so I am not sure
yeah. hmm.
I don't think this is something I can do, heh.
So it gets to wait.
And that's weird that travis ci fails, but pylint passes. They're usually in unison.
you could try setting a variable in the if..., then return the variable at the end.
def _read_register(self, reg, count=1):
self.buf[0] = _COMMAND_BIT | reg
if count == 2:
self.buf[0] |= _WORD_BIT
with self.i2c_device as i2c:
i2c.write(self.buf, end=1, stop=False)
i2c.readinto(self.buf, start=1)
if count == 1:
buff_read = self.buf[1]
elif count == 2:
buff_read = (self.buf[1], self.buf[2])
return buff_read
might have to eval buff_read before the return...
or just use return None
yeah
if not buff_read:
return None
else:
return buff_read
note: structure illustration...i'm losing all my syntax from all the lang switching I'm doing lately. 😄
I'm not even sure where that would go.
at the end, when returning the buffer read.
def _read_register(self, reg, count=1):
self.buf[0] = _COMMAND_BIT | reg
if count == 2:
self.buf[0] |= _WORD_BIT
with self.i2c_device as i2c:
i2c.write(self.buf, end=1, stop=False)
i2c.readinto(self.buf, start=1)
if count == 1:
return self.buf[1]
elif count == 2:
return (self.buf[1], self.buf[2])
return None # this could actually be un-indented one as well
Won't let me edit twice
def _read_register(self, reg, count=1):
self.buf[0] = _COMMAND_BIT | reg
if count == 2:
self.buf[0] |= _WORD_BIT
with self.i2c_device as i2c:
i2c.write(self.buf, end=1, stop=False)
i2c.readinto(self.buf, start=1)
if count == 1:
return self.buf[1]
elif count == 2:
return (self.buf[1], self.buf[2])
else:
return None
You get the idea....
R:183, 8: Unnecessary "else" after "return" (no-else-return)
Is the new error.
Ooh it works the first way
Let's commit and push and see how travis ci likes it! pylint is happy.
I forked it so I can break it all I want 😄
Hmm should test it first. I'll need to get that sensor going first.
the beauty of source control, easy rollback of changes
Truth, but I can't get travis ci to check it specifically without creating a PR, so I'll test it first and then do the PR.
gee-wiz question: is it intentional to return an expression if [1], and a tuple if [2]? From the pydocs:
A single expression without a trailing comma doesn’t create a tuple, but rather yields the value of that expression
I have zero clue on that one.
I removed parens on the second one
I think it might still be a tuple though
yeah. from what I'm reading, the parens won't make a difference.
so if you put a comma after a single item, the return will be a singleton (1 deep tuple)
I remember that from testing code a while back, yeah
@slender iron thanks, this code is working well!
@raven canopy @opaque patrol The update works!
sweet! how did it end up?
Need to do the PR to find out if travis passes, but I tested it with the sensor and that works
they should rename travis to zoul. "Are you the gatekeeper?" 😄
I don't even know how you'd change that count anyway. or why. So I'm not sure how to even see if that part is working or failing. Does the example code even use it? No idea.
Now we wait for a bit.
For travis ci.
Hey! It passed!
Thanks for the help!
@lucid arch I believe you are having memory troubles because you are using the py bundle instead of a mpy bundle. Try this: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20171216/adafruit-circuitpython-bundle-2.1.0-20171216.zip
@split ocean 👍
My fun for the evening; with any luck they'll run 3.0 with some tweaks
@pastel panther Is this the right reset button for the metrowings? https://www.adafruit.com/product/1489
Nm, evidently it should work 😃
@pastel panther @solar whale did and is sending me one. Turns out he already has those so it wasn't an issue.
@idle owl Here's the BOM for future reference: https://octopart.com/bom-tool/s72yPqrf
Oh nice! Thanks
The only thing of note is the switch since the footprint is made to fit that one, but any switch that can bridge the appropriate pads will work
It needs to short one of the pairs of pads on the 'short' side of the square
err rectangle
brb
I’ll try to test the tactile switch tomorrow and let you know if it works.
Ok
Oh @solar whale Do you have mk2? I was looking at the wrong one I think.
Would have messed that up even more looking at the wrong one. Oops. Good thing you're on it.
I just un-shared the mki from OSHpark
hah
It's here too: https://github.com/siddacious/metrowing
Ok, a lot of things make a lot more sense. I was looking at the wrong one. Needs a reet button with 4 feet instead of 2 now, it seems.
It only really needs two
Oh nice!
Yes , I am sending mkii. Reset pin is different. So @pastel panther the tactile switch wold go between two pins on”short” side?
There are two pairs of feet that are essentially shorted together
I see
Yes; If you follow the trace from the last pin in the nearby row, it goes to the two closest pads
Ah yes it does
meaning they're already connected so you need to short two pads on either of the short sides
If you're really itching for the 'right' button you can always steal one from a metro; it's the same switch
6mm x 3mm though it looks like, so any that size would work as long as the feet matched the pads?
Ok yeah
Ok, I’ll see if it works and if not re-evaluate. I did not want to place a order for just the switches.
I think even one of those normal breadboard compatible tactile switches would work
You'd just need to bend the leads flat
Right
Good night all!
night @solar whale
Funny brainless CPX CircuitPython toy. Accelerometer direction tells the Servo to swing hard the other way. Direction indicated by NeoPixel color. I didn’t expect it to look so freaky.
lol
If you shorten the cable it might be a little bit more predictable, then again maybe that's not the point
Haha or lengthen the arm.
Having a point is overrated
Really whip it around!
The point was just to entertain/inspire a 6yr old for an hour. Mission accomplished!
Nice!
It feels like the kind of quickie thing Circuit Python is perfect for, so I thought I’d share.
Thank you!
@tulip sleet https://github.com/adafruit/Adafruit_CircuitPython_TSL2561/pull/9 is the PR for the code from earlier
Thanks!
ahhh. my old friend, debugging. this is the fun part, right? 😐
Yeah already have it. Do I just need to test it on 2.1?
I tested it on both 2.1 and 2.2
Ok, I tested it on 2.1, no errors. Was it failing using the class in general? Or did it fail specifically using lis3dh for something
the init fails
Excellent, tested on both.
wanna approve?
thanks @idle owl! I'll release it
Great! Thanks for catching that and getting it resolved!
https://github.com/wa1tnr/cpx-basic-studies
Got a bunny sketch going on CPX using lis3dh accel. 😉
yup, np
@slender iron I went through and updated the lint all the libraries issue with what's pending, what's done and what's remaining. I'm not sure the difference between "PRs needing review" and "Pending PRs" but I didn't make that change so I didn't alter it. Everything that has an outstanding PR that I found went into "Pending PRs" and I tested some more today too.
And I did releases on a few that had been finished and merged, but no release was done.
thanks @idle owl !
screenshot!
Anyone up for a robotic remote haircut? 😉 It's weird to have something in your hand that makes the screen image do the same thing your hand is doing, when it's entirely rotational, rather than mouse movements on an x-y grid.
@tulip sleet : yes, thanks!
<@&356864093652516868> anyone dealt with this error when compiling (background: adding a parameter to microcontroller.cpu):
In function '_sbrk_r': sbrkr.c:(.text._sbrk_r+0xc): undefined reference to '_sbrk'
That's a linker error... looks like it's missing a library
well, I found a syscall that handles '_sbrk', but it is in a dir different that the location given for the compile error. hmm.
And it built fine before your change?
yeah. even built during changes.... back to regressing to maybe narrow this down.
narrowed it down to my property getter. now to try and understand why...😵
@idle owl There is no difference between the Pending Review and Pending RPs. You can move RGB_Display into the Pending PRs section and delete Pending Review. Sorry.
I am running into an issue with my new Circuit Playground Express where when I add the latest bundle, I get an error in the serial terminal. Can someone help me out?
@indigo hazel what is the error?
how large is your code? if it's not too large, paste it here.
import adafruit_si7021
import busio
import board
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_si7021.SI7021(i2c)
print("Temperature:", sensor.temperature)
print("Humidity:", sensor.relative_humidity)
how do you have the SI7021 attached to the CPX?
Oops, I am following the online guide, and ran into this error. Now I see that I do not have that hardware, hence the error.😶
yep. that's it. which guide are you following?
hmmm. i think that could be updated a little to make it more explicit that the example is for an additional hardware item .
yes, a little confusing when starting out for the first time.
and even more so when you have a CPX that does have a lot of sensors already on it
i was just going to suggest that. NOTE: this example will not work properly without an external SI7021 sensor connected to the CPX. This is just an illustration of how to import libraries.
that really is the hard part about writing guides focusing on early users. you wan't to keep it fun, simple, and light-hearted (which ladyada does SO well), without getting too technical and littered with if...s, notes, and such.
thanks @indigo hazel for bringing the issue up. as has been echoed time and again, this is what makes open source work.
No problem.
i sent in a suggestion to have that looked at
@tidal kiln a user in the forums was similarly confused. I think we might use Adafruit_CircuitPyton_HID as the example instead, since it requires no external hardware. I'll revise that section.
thanks @tulip sleet
might be good to have both, a generic nothing additional required example, but then also one that does show how one would get and install the library to go with whatever new gadget they bought (more or less like the existing one)
@tidal kiln @idle owl realized HID is not a good example, because it's one of the libraries included in lib for Trinket and Gemma M0. I like your phrasing and will add it for now.
@tulip sleet @tidal kiln The example that's replacing that one uses simpleio and blinky, so the example for installing libraries will work once it's done. It's much more clearly explained.
@indigo hazel ladyada just updated the guide pages, take a look and let us know how it goes. hopefully it helps out better now.
@idle owl i think i did a fair job re-orging that page, dunno if there's anything you want to grab!
@meager fog All of the libraries page has been integrated into the Welcome guide already, do I need to go through it and compare it again?
Ah I could update the images.
nah, ill get to revewing the guide maybe later today, still getting thru emails
The libs page is split between the libs page in the Welcome guide and the Troubleshooting page in all the other guides
im doing cpx text now
Nice! np
so instead of set_click...whats the current cpx lis3dh api? 😃
That was updated, it skips it if you're running 2.1.0
im on 2.2-rc`
i was using
Set up the accelerometer to detect tapping ('click')
TAP_THRESHOLD = 20 # Accelerometer tap threshold.
cpx._lis3dh.set_click(1, TAP_THRESHOLD) # detect single tap only
not single? 😃
Yeah that was what I was saying I Could explain if needed
yah
Turns out you can't have a double click event without two single click events, it's a hardware/software thing, it's not possible. A double click event is two single click events, so if you wanted to have double click do one thing and single do another, you would have conflicting responses, so if one was red LEDs and double was blue, you'd get red or purple.
So after a huge discussion about it, we decided to include only double_click
yah
You can do both with LIS3DH, it's based on setting single or double, but you can't do both
yah i remember this from the arduino driver
Double is harder to have accidental clicks as well
so how do i detect a single click then?
so we decided double made the most sense.
You'd have to set it up using lis3dh, not cpx class...
ok
In this line: lis3dh.set_tap(2, 18, time_limit=4, time_latency=17, time_window=110)
You would set 2 to 1
and it detects single instead
Having both in cpx wouldn't have worked and would have had that huge caveat of both being present with double
so Scott redesigned LIS3DH to only detect single OR double based on what that line is. The line that reads the tap returns "true" instead of single/double, and what that event is translated to is based on what you set in set_tap
kk
Yeah because the idea was that double_tap would have worked instead of needing _lis3dh being public.
We didn't know you'd want to stick for sure with single tapping instead of double_tap working.
i think, its a little confusing still 😃
Basically, express only has double_tap capabilities built in.
why not have it either single or double?
cpx.detect_taps = 1 or 2
then cpx.tapped
?
I'm not sure, it was a design decision, but I think it could be done.
Issue is if you try to do both I guess
That was what we were trying to avoid was the huge caveat, but I guess since the driver was redesigned it might be different.
I can look into it tonight if you'd like
k i can also try both, double-tapping is just really hard to time
so i usually just have single-tap detection! i can also try changing i tup
see if i can get both working. do i need to mpy the library to fit, still?
It tested pretty well, I had other people do it too. The idea being that if random people could pick it up and get near 100% response from the board, it was the right idea.
Yeah
It's an easy change to get it to single.
k let me try it, see what i can get!
Getting it to double is a variable.
Ok!
I'll take a look at it later if needed, and I can test it for you later as well if you'd like
You can check the data sheet for what the rest of those numbers are for, it took tweaking them solidly to get it to where it worked consistently.
looks like you cannot use with mpy?
How so?
huh! thats odd, on 2.2?
oi yes ok.
k np ill do that!
I'm back on the right page. Yes it needs mpy
ha! ok - yah this is what i wrote for arduino https://github.com/adafruit/Adafruit_LIS3DH/blob/master/examples/tapdemo/tapdemo.ino
Yeah that's the idea, but it always returns a single around the doubles on circuitpython
interrupts aren't implemented
the way we have it now, it returns true when a click event happens, and then tells you whether it was single or double based on what you set it to be in the set_tap
yah
It's nearly dinner time here so I'm going to head off for a bit. I'll be back later. Ping me if you have any other questions though, I'll have my phone.
@idle owl @pastel panther I don't htink the tactile switch will work very well on the metrowing. At least, not with my soldering skills. I think I'll just tack on two wires and use a pushbutton until I can get some of the correct switches.
@idle owl pr is sent, small change but i think will be good. its really annoying to time the double tap 😄
What is supposed to be the library bundle release matching the 2.2.0rc1 firmware release?
By the way, I changed my nick name from Instinctive to DavidGlaude. That is best because it is my name. 😃
And another question, is there a plan to release the big demo code from Tony for the Circuit Playground Express.
@half sedge the latest 2.x Bundle should be what you want - in this case it is silt lableed as 2.1.0-20171217.
Doc seems to say lattest... https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/tag/20171217
Thanks @solar whale
2x matches all 2x
@half sedge New Bundles are now released daily if one of the libraries has been updated, so check back often!
The only difference (I think) betwen the 2.x and 3.x bundles is the version of mpy-cross used to build them.
Just checking, but is this https://github.com/mrmcwethy/Adafruit_CircuitPython_APDS9960 some kind of official to be driver?
Like to be in the bundle one day?
If it work (and I was planning to test), that would be great an there are some issue to be updated.
I am cleaning my useless and now empty place holder (with a typo): https://github.com/dglaude/adps9960-circuit-python
it looks like its in-progresss, @fading solstice has been working really hard with us to clean up our existing drivers, so there is no ETA 😃
in-progress is better than the nothing I had on my side...
Some work in progress from @mrmcwethy here: https://github.com/mrmcwethy/Adafruit_CircuitPython_APDS9960
Some work in progress from @mrmcwethy here: https://github.com/mrmcwethy/Adafruit_CircuitPython_APDS9960
success!
@pastel panther Is that a Roman numeral pin numbering system? 
@meager fog Thanks, it is indeed! It's my bitsy-ish m4 express board. It's got QSPI on the top and a spare 'normal' SPI underneith for ease of porting; Once I get CP working on it I'm going to try getting QSPI going
@errant grail Yes, on one side. I had to use a X for a 10 for space issues and then ran with it. I moved things around so the 10 would fit but I'm digging the roman numerals
@errant grail I'm working on my '11 livewell board now also. I should have the board layed out by the end of the week
I saw someone using safety pins to program a ESP8266 via the castillated pins so I might try that with this rev of the motor board as to not squander valueable mm^2
@pastel panther I'm looking forward to seeing that design. Haven't played much with castillated pins yet. Have you done that with other projects?
@errant grail nope! I'll be following OSHPark's guidelines and hoping for the best. For the first version I'll probably have some pads for redundancy
... that would be a good way to make a smaller StringCar PCB and still use a stock Trinket M0 and 8833 motor controller. Thanks for the idea!
@pastel panther I'm working on PCBs for StringCarGen2CPy and one for a secret retro-inspired project. Should have them done tonight if the prototypes work as designed.
@errant grail cool, I'd love to check them out when you're done
They're pretty simple, but could lead the way to a custom M0-based board similar to the SMD aTtiny85 controller I made a year ago.
@pastel panther Okay, mebbee an M4-based board..
@pastel panther nice work on the bitsy-m4 board.
The SAMD21E can be had in a 32 pin format which is pretty small
@errant grail I'm happy to share my m4 board as a starting point once I've squashed any bugs
Thanks @raven canopy!
@pastel panther I'll take you up on that offer! Especially since it has Roman numerals. M-IV.
@errant grail Almost right...
<@&356864093652516868> We're on for our normal meeting tomorrow at 11am Pacific / 2pm Eastern here on Discord. The following few weeks will be weird due to the holidays and I'll post later what the plan is. (We'll discuss it tomorrow.)
Rather not 😃
Man, no fun at all!
I was thinking we should do one the week in between
There is no Monday between Christmas and New Years? Or do you mean sometime Tuesday the 26th to Sunday the 31st?
Yeah, some other day is what I'm thinking
Friday might be a good one. Might not, though.
my girlfriend has friday off so I should probably avoid it
I expect Tuesday wouldn't be a grand idea - people traveling and all
yeah, I figure we can discuss it during the meeting
I'll be working, which is why I'm putting my thoughts down.
A weekend day might be able to grab a bunch of people, but then again - it's a weekend day.
Odds are I wouldn't be able to come anyway though.
Stupid work and holidays and stuff.
yeah, which day would be best for you?
(anyone else who can't make the meeting please post as well)
Monday, Tuesday, and Friday are the days I'd be able to make it, unless it was done later.
I'll be off work after the 22nd so I can likely attend for once whenever it is, unless there is an impromptu fishing trip
After 5pm Eastern I'd be able to do Wednesday/Thursday. Saturday's right out for me.
kk
Unless you want to hold it absurdly late (>10pm Eastern) or stupid early (<9am Eastern)
kk, good to know since I'm 3 hours behind
Yeah, I'm keeping that in mind. I don't think a 7pm would be too bad for you, but 6am would be... not the best.
yeah, 6am won't happen with me 😃
@meager fog I'm looking at the PR now
@slender iron I see that I'm a CP helper. I'll start showing up for the meetings, that time will typically work well. Alas, tomorrow I will be watching Star Wars then.
@umbral dagger Congrats. Enjoy SW.
Just received my circuit playground express, but I'm having trouble getting circuit python on it. I'm on a Macbook Pro running Mac OS High Sierra version 10.13.2 . When I first plug it in it shows up as CPLAYBOOT. I followed the guide and downloaded the latest version of circuitpython. adafruit-circuitpython-circuitplayground_express-2.1.0.uf2 I drag it over and drop it in CPLAYBOOT. It ejects and then remounts as a camera I own that is not plugged in "Nikon D3400". I went ahead and tried to load the adafruit library as suggested in the guide, but then I get an error message "The operation can’t be completed because one or more required items can’t be found. (Error code -43)". I've tried other files just to see if something would work, but the same error message pops up. I have even used the erase file to completely erase everything flash_erase_express.ino.circuitplay.uf2 still no luck. The process repeats itself. I have also downloaded all files again, but I run into the same problem. Does anyone have any ideas? #circuitpython-dev #help-with-projects
@keen urchin so you don't see CIRCUITPY in a finder window, but only "Nikon D3400"?
@keen urchin if you see this later, see https://forums.adafruit.com/viewtopic.php?f=57&t=128112 aboout checking the drivers on your Mac and removing any that may be interfering (certainly sounds like the camera driver might be).
hey @slender iron; I'm I correct in thinking that the dotstar for the trinket m0 is not supported yet in 3.0?
it should be since we have SPI support now
so it should work? It looks like it's still commented out in the trinket_m0 mpconfigboard.h
kk; I put a dotstart on my board so I'll throw that into the file for my board
If it works I'll re-enable the one for the trinket m0
thanks!
I got uf2 loaded and working so I know the hardware is good
I was honestly surprised
👍 nice work!
Thanks! I have no idea if the flash works but I guess we'll see in a few
@atletika5#4704 FWIW I just went through getting my first Circuit Playground Express running circuit python on my MacBook Pro on Saturday, with High Sierra, and it worked fine. Hopefully @tulip sleet advice will help.
@slender iron @idle owl i updated the library list as a result of merging bus_device and register https://github.com/adafruit/circuitpython/issues/475
the meeting is in 45 minutes, right?
Yes
thanks
@umbral dagger you don't have to join the meeting regularly though you are welcome. Enjoy Star Wars!
tap tap tap tappity tap
@cunning crypt Weekly if you're around
At work!
Ok!
NEXT = ??
NEXT NEXT = Jan. 8th
and normal after that
<@&356864093652516868> Next meeting is: Thursday December 28th, 6pm Eastern / 3pm Pacific. If you can't make it thats OK! Enjoy the holidays.
hiya - couldn't make the weekly, was busy with some other meetings, thanks everyone 😃
@meager fog no worries!
Thanks! Happy Holidays!
Happy Holidays errbody!
while True:
cpx.detect_taps = 2
if cpx.tapped:
cpx.pixels.fill((0, 0, 30))
cpx.play_tone(292, 0.1)
print("doubletap")
else:
cpx.pixels.fill((0, 0, 0))
cpx.detect_taps = 1
if cpx.tapped:
cpx.pixels.fill((30, 0, 0))
cpx.play_tone(262, 0.1)
print("singletap")
else:
cpx.pixels.fill((0, 0, 0))```
while True:
lis3dh.set_tap(2, 80, time_limit=4, time_latency=17, time_window=110)
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
lis3dh.set_tap(1, 80, time_limit=4, time_latency=17, time_window=110)
last_tap = False
tap = lis3dh.tapped
if tap and not last_tap:
print("tapped!")
pixels.fill((0, 0, 30))
else:
pixels.fill((0, 0, 0))
last_tap = tap```
@detect_taps.setter
def detect_taps(self, value):
self._detect_taps = value
try:
self._lis3dh.set_tap(value, 80, time_limit=4, time_latency=17, time_window=110)
except AttributeError:
pass
self._last_tap = False```
Gotta run - talk to everyone later.
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
RE: Google SoC - definitely an OS who's who list of participants for last year. Python participated, as well as BeagleBone, so there is some relevance for CPy. Thought for discussion: if Adafruit/CPy were to apply to participate, would a discussion be needed/desired with the MPy guys? I may be closer related to the student side in GSoC, so I'm not advocating either way.
@raven canopy I asked Damien last year about gsoc, but by the time we got to it it was already too late to apply - but the conclusion was that he doesn't mind doing it if someone will do all the paperwork for it
cpx.detect_taps = 2
while True:
if cpx.tapped:
print("tapped")
I have to run
bye
later!
@tulip sleet and @idle owl I'm back
Have a lovely lunch?
haha
@tidal kiln what are you up to?
playing with accelo on cpx
what are you going for? sounds like I missed some conversation about it when I was at lunch
Has anyone worked on converting the Circuit Playground Accelerometer Mouse Example to CircuitPython yet?
at this point i'm just testing it's behavior
but yah, dan, kattni, and i had a big follow on discussion w.r.t tap detect
Its in the Arduino Example list when you install Circuit Playground, give me a minute and I will see if I can find it on github
@slender iron Its in this repo https://github.com/adafruit/Adafruit_CircuitPlayground/tree/master/examples
thanks!
@slender iron I already created a color_sense version in circuit python, thought i would tackle some more
great!
<@&356864093652516868> Here is the recording from the meeting today: https://youtu.be/vp5_u3oV9Ro We'll do our next meeting for those who are available on Thursday December 28th at 3pm Pacific / 6pm Eastern here on Discord. Have a great holidays and new year!
Join here for the chat all week: http://adafru.it/discord The weekly happens normally at 2pm ET/11am PT on Mondays. Check the #circuitpython channel for noti...
@timber lion why won't this work with 3.0? https://github.com/adafruit/Adafruit_CircuitPython_MAX31865/releases/tag/2.0
@idle owl been any further discussion on tap?
don't need to if you think you're getting it done. don't need to get too many cooks.
cool.
finished accel_mouse.py example https://github.com/BravoDelta151/CircuitPython_Misc/blob/master/accel_mouse.py
@opaque patrol Have a few minutes for a chat?
@idle owl sure
@opaque patrol I'm looking at your color sense code. This looks great! I changed the last bit to this: ```python
cpx.pixels.brightness = .2
verbose = False
while True:
if cpx.button_a or cpx.button_b:
verbose = cpx.button_b
time.sleep(.05) # debounce
if verbose:
print("button pressed")
while cpx.button_a or cpx.button_b:
time.sleep(.01)
r, g, b = sense_color(verbose)
print("({}, {}, {})".format(r, g, b))
cpx.pixels.fill((r, g, b))
else:
cpx.pixels.fill(CLEAR)
@idle owl I think that will clear the pixels immediately after setting the color. What I can do is store the color variables and just update them on the button press
Oh it does do that! I couldn't get it to work the other way though. I wonder what I was doing wrong?
not sure, I am playing with it now and trying to see if I can add gamma correction to get a little closer to the color
Oh! It's working for me now the way you had it. I see!
I have the clear in the except block to clear if you hit ctrl-c, I plan to change that to clear on KeyboardInterrupt and another except block for other exceptions
Ah ok
If an exception is thrown with the current code, it will hide the error message
Got ya. Yeah that could be frustrating 😃
except KeyboardInterrupt:
cpx.pixels.fill(CLEAR)
except Exception as e:
print("Exception", str(e))
like this
oh ok yeah
you may need to adjust the brightness, with it set at .2, colors with all values below roughly 55 will not appear to work
Right, I've run into that multiple times before I remember I can't set it to (0, 0, 10) with brightness set super low.
@tulip sleet I'm testing AMG88XX. I'm getting an error - TypeError: 'float' object not iterable on the first print line:```python
import time
import busio
import board
import adafruit_amg88xx
i2c_bus = busio.I2C(board.SCL, board.SDA)
amg = adafruit_amg88xx.AMG88XX(i2c_bus)
while True:
for row in amg.pixels:
#pad to 1 decimal place
print(['{0:.1f}'.format(temp) for temp in row])
print("")
print("\n")
time.sleep(1)
@idle owl what library is that?
this one?
https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx/blob/master/adafruit_amg88xx.py
Yeah I'm working off the PR version
try this in repl, what does it show?
import busio
import board
import adafruit_amg88xx
i2c_bus = busio.I2C(board.SCL, board.SDA)
amg = adafruit_amg88xx.AMG88XX(i2c_bus)
amg.pixels
[[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], 24.5, 23.0, 22.0, 22.75, 22.75, 22.5, 22.75, 23.0, 22.25, 22.5, 22.5, 22.25, 22.75, 22.75, 23.5, 23.25, 22.25, 22.25, 22.25, 22.25, 23.25, 23.5, 24.5, 23.25, 22.5, 21.75, 22.5, 22.25, 22.75, 24.0, 25.0, 23.75, 21.5, 22.25, 22.25, 22.5, 23.25, 23.75, 24.25, 24.25, 21.75, 21.25, 22.25, 22.25, 22.5, 22.75, 23.25, 22.75, 22.0, 22.0, 21.75, 21.75, 22.75, 22.75, 23.0, 23.0, 22.25, 21.75, 22.25, 21.75, 22.75, 23.0, 23.5, 24.75]
yeah, the buffer is initialized to 0's and then appended to
Ok.. so something is wrong with the code then? It's not appending properly?
yah. think so.
try changing this line:
https://github.com/tannewt/Adafruit_CircuitPython_AMG88xx/blob/3a0b88ed989c3f7fa01da46f86366ebc89a0d535/adafruit_amg88xx.py#L152
to:
retbuf = []
and run that above example again
yep. it's just a list, not a list of lists.
based on the code comment, looks like that was the intent. just need to add a little more code....
try this:
@property
def pixels(self):
"""Temperature of each pixel across the sensor in Celsius.
Temperatures are stored in a two dimensional list where the first index is the row and
the second is the column. The first row is on the side closest to the writing on the
sensor."""
retbuf = []
buf = bytearray(3)
with self.i2c_device as i2c:
for row in range(0, _PIXEL_ARRAY_HEIGHT):
rowbuf = []
for col in range(0, _PIXEL_ARRAY_WIDTH):
i = row * _PIXEL_ARRAY_HEIGHT + col
buf[0] = _PIXEL_OFFSET + (i << 1)
i2c.write(buf, end=1, stop=False)
i2c.readinto(buf, start=1)
raw = (buf[2] << 8) | buf[1]
converted = _signed_12bit_to_float(raw) * _PIXEL_TEMP_CONVERSION
rowbuf.append(converted)
retbuf.append(rowbuf)
return retbuf
Ah! Yah!
works?
Yep!
My hands are apparently so cold, I had to grab someone else to make sure it was actually working 😄
see the issue?
I... don't
who wrote the original?
Looks like Dean Miller
i'm mean that PR version
Scott
need to talk to him about it, cause he's doing some changes and not sure what his intent was
Ok
looks like the original version was just a single list:
https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx/blob/master/adafruit_amg88xx.py#L155
like what my fix to the code did:
[value value value etc...]
but looks like Scott wants to make that more like a 2D array (which makes sense):
[ [value value value ... ], [value value value ...], etc...]
like row,col
Yeah
but not sure why he needed to init it to all zeros, and he can probably come up with a more clever way of creating the retbuf list
mine was just a simple fix / hack
and then you were getting that error because this:
for row in amg.pixels:
was returning a float, instead of a list of floats
Oh ok
and then you were trying to iterate on that float:
print(['{0:.1f}'.format(temp) for temp in row])
Do you want to review as well? Otherwise I can do line by line and relay what we talked about.
you can do it
Ok
guess it's kind of a question back to scott, cause i'm not sure what he's was trying to do.
Yeah I'm going to request changes and let him respond
since he pre-allocated the buffer, maybe he intended to directly index things instead of using .append? dunno.
like retbuf[row][col] = converted or something
I'm going to tag you in fyi since you helped.
k
interesting...
>>> buf = [[0]*4]*4
>>> buf[1][3] = 'foo'
>>> buf
[[0, 0, 0, 'foo'], [0, 0, 0, 'foo'], [0, 0, 0, 'foo'], [0, 0, 0, 'foo']]
>>>
updates all of them.
hmm
yes, the * operator doesn't make copies
it repeats a reference to the same object
you want:
buf = [[0] * 4 for _ in range(4)]
what you did is the same as:
x = [0] * 4
buf = [x, x, x, x]
thanks @stuck elbow , now if i can just remember that!
hi all, has anyone had a problem where code.py has become corrupted and is unreadable? I've tried deleting it, but that doesn't work. Even tried reflashing the circuitplayground, the file is still there after, and still can't be deleted or edited
Yep! You'll need to use the flash eraser on it. This will erase the board entirely and you'll need to reflash CircuitPython and add your libraries once completed. Follow the steps here: https://learn.adafruit.com/adafruit-circuit-playground-express/troubleshooting#circuitpy-drive-issues
Yeah for sure!
@timber mango You can also end up in a situation where the CICUITPY drive is read only. The flash erare & reinstall circuit python works to fix that as well.
@timber mango Loading an arduino sketch and then reinstalling circuit python seems to work in many cases as well.
Keep in mind the SPI flashROM is a separate chip and is often ignored by the SAMD21G18A microcontroller. That's why its contents persist even after loading an Arduino sketch, 'on top of' a CircuitPython .UF2 boot file -- the Arduino sketch completely ignores the SPI flashROM chip, unless you specifically tell it not to ignore it, in some way.
Right... i was thinking of non-external flash boards.
I'm still pleased and surprised every single time I find that my files have remained present on the SPI flashROM of an Express target board, after a major operation (such as loading a different .UF2).
It hasn't sunk in yet, that my files are going to be there, unless something unplanned has happened.
@timber mango I think it's a good practice to be prepared for them to be gone, though
This makes it clear to RTD where to get the config files from and fixes the build.
@slender iron I was finally able to compile 3.0 for my m4 board, however when I load it my dotstar turns purple and I have no MSC or CDC; since it's not flashing after the purple, I'm assuming it's the bootloader and not CP that is setting it?
@pastel panther yeah, that sounds suspect
I'm not sure why it'd be purple. I think that might be an arduino thing
Someone might call it pink?
¯_(ツ)_/¯
I should look at uf2-samd for a decoder ring?
I'd expect it to be red or green if actually in the bootloader
calling gdb with firmware.elf doesn't seem to do what I want. Is there something I can do to get source lines showing? gdb is saying No symbol table is loaded
right
ah, this is more informative: HardFault_Handler () at supervisor/port.c:264
backtrace is only so useful; @slender iron The '51 datasheet mentions a Embedded Trace Buffer which I assume is different from the Micro Trace Buffer so the MTB setup in your GDB tutorial won't apply here?
nah, I haven't been able to get it going
try breaking at main() and see if it gets that far
@slender iron With AMG88XX, I'm now getting IndexError: list index out of range with the example. Traceback (most recent call last): File "code.py", line 10, in <module> File "adafruit_amg88xx.py", line 164, in pixels File "adafruit_amg88xx.py", line 164, in pixels IndexError: list index out of range
what do I need to change to test that
I amended the commit twice
I can try again
@slender iron yea, it's getting to main; I'll have to play around with it after work. On a positive note, it would seem that maybe (maybe?) the dotstar changes I wrote worked?
But I am pretty sure I did
@pastel panther maybe, it might be whats crashing 😃
@idle owl whats the pre-allocation line for you?
@slender iron that's where the smart money is ;P
thanks for the help 👋
should retbuf = [[0]*_PIXEL_ARRAY_WIDTH for _ in range(_PIXEL_ARRAY_HEIGHT)]
np @pastel panther good work!
retbuf = [[[0]*_PIXEL_ARRAY_WIDTH] for _ in range (_PIXEL_ARRAY_HEIGHT)]
extra brackets in mine
yeah, I fixed that 😃
yeah, I was sneaky and amended. you just were super fast
👍
I went through and found all the circuitpython-travis-build typos left and fixed them. There's a PR in for one of them that I didn't catch until after I merged it, so I went and found all the rest, fixed and committed them.
thank you!
https://github.com/adafruit/Adafruit_CircuitPython_CCS811/pull/8 if you want to nab it and I'll do the release when you get to it
updated file path
merged
😃
Helps #386. I can still erase the filesystem in pathological cases, but this is a lot better than not checking. Besides @tdicola, @ladyada had this happen once, apparently with USB.
Going to put in the fix I have, because it's a lot better than nothing. PR #
@slender iron adafruit_irremote isn't autogenerating the zip/mpy files, and isn't autobundling, is that intentional?
Ok
Oi, see? Same exact thing that it caught the other day. That must have been added in the update.
it must skip the deploy when the build fails
Ah ok
JP's code stopped working. I just redid it to not use CPX at all, and it's working again.
define stopped working
Every time you press a button on the remote: Memory allocation failure: 512 bytes and it would pick up 3 pulses only, fail to decode, and repeat because you wrote it into the code to continue after a memory allocation failure.
I had it happen before he did but assumed it was me.
right
did he send you the updated version?
Unless you posted another version, yes
You had "here is the latest version that I got working" or something like that?
That's what I was using. From a gist.
right, I imagine he changed it though
He didn't imply that he did
or did you just use it with 2.2?
yeah, perhaps
I mean it's back and works great without using cpx
Which is what I altered before you posted a better option with the memory allocation exception
ya, with less code loaded
He's ok with running it without cpx afaik
kk, thanks for helping him out!
I specifically loaded it all fresh - that's how I noticed the lib wasn't in the bundle
so double bonus discovery there.
it not being in the bundle could be a different problem
Ah ok
I'll have to mention that to him, since at the moment the only way to get the .mpy version of it is to make it yourself.
are you gonna try fixing the irremote build or should I?
oh, I can try, but I'll need help. I fixed that issue in another lib the other day but I doubt it's exactly the same issue.
I'll take a look
ok
I haven't seen that issue so it'll be a good thought process
I had a lot of help on the lib I fixed before. If you search for inconsistent-return-statements in discord you'll find the convo if you want to see it
looks like it was just confused by the infinite loop in r ead_pulses
ah
Merged. Want me to try another release?
yes please
(for the record, I tested it first)