#circuitpython-dev
1 messages Β· Page 173 of 1
meh. it pretty much works.
maybe put both? you can say "just program it. if that doesn't seem to work, then double reset to bootloader and try that."
That works
Hmm, anyone able to give me advice on the appropriate way to temporarily allocate the initializer bytes for mp_obj_new_bytearray()? is it m_new or m_alloc or..?
@marble hornet Sure. My approach is verbatim from TonyD's excellent learning guides. I tried the OLED FeatherWing and the TFT FeatherWing. The OLED was much faster than the TFT, but was still too slow and memory hungry for the real-time MIDI sniffer project. Here's the TFT code. Note that the learning guide links are included in the header. ```# 2018-05-30 DSP MIDI sniffer v05 TFTwing.py
https://learn.adafruit.com/micropython-hardware-ili9341-tft-and-featherwing?view=all#circuitpython
https://learn.adafruit.com/micropython-displays-drawing-text
### Setup
import board
import busio
import bitmapfont
uart = busio.UART(board.TX, board.RX, baudrate=31250)
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.A3)
dc = digitalio.DigitalInOut(board.D10)
from adafruit_rgb_display import ili9341, color565
tft = ili9341.ILI9341(spi, cs=cs, dc=dc)
tft.fill(0)
tft.scroll(0)
bf = bitmapfont.BitmapFont(120, 320, tft.pixel)
bf.init()
bf.text('2018-05-30 DSP MIDI sniffer v05 TFTwing.py', 0, i, color565(255, 255, 255))```
@marble hornet ... and the OLED code. ```# 2018-05-29 DSP MIDI sniffer v05 OLED.py
https://learn.adafruit.com/micropython-hardware-ssd1306-oled-display?view=all
### Setup
import board
import busio
import adafruit_ssd1306
uart = busio.UART(board.TX, board.RX, baudrate=31250)
i2c = busio.I2C(board.SCL, board.SDA)
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
oled.fill(0)
oled.show()
oled.text('DSP MIDI sniffer',0,0)
oled.show()```
(the UART setup is for the MIDI serial connection and has nothing to do with the display)
To overcome the display blocking, scrolling, and text display speed issues, I'm planning to implement a VT-100 -like emulator in Arduino code and driving a TFT display of some sort. I'll send the VT-100 emulator characters serially from the CircuitPython MIDI sniffer code running on a Trinket M0 or Feather M0 Express.
Also considering one of these for the VT-100 emulator to offload character generation and framebuffer requirements. https://www.adafruit.com/product/1590
@errant grail FYI I put my CP midi stuff up a while back, https://github.com/cs80/module-playground-v1
@ruby lake Thank you for the link! I'm sure I'll learn a lot from your approach. Your MIDI CC state and note buffer methods are getting me to rethink a few things already...
@errant grail cool. i altered the rgb tft display to open a file i made. the file contains a text dict named text_dict. example of contents: ```text_dict = {
'Height' : 7,
'Width' : 5,
"A" :(0b10111111,
0b11000100,
0b11000100,
0b11000100,
0b10111111),
"B" :(0b11111111,
0b11000001,
0b11001001,
0b11001001,
0b10110110),
"C" :(0b10111110,
0b11000001,
0b11000001,
0b11000001,
0b10100010),
then in the rgb display library the added 'text' method goes through the inputed string and stripes the text. I also added support for special characters like' battery symbol's, and an 'unknown' character.
@marble hornet https://bitbucket.org/thesheep/font454/src
sure, I was just hinting at a more efficient way of storing the font data
you can make a buffer, draw the pixels in that, and send it as a block
Could I ask for your help with sending blocks of data later ? I looked at the core. It seems like raw data but the formatting... Do you have experience with that ?
@stuck elbow are you Radomir Dopieralski? If you don't mind my asking
yes
to both ?
yes
Either of you to review is fine. Simple fix noticed by @ladyada. Was an extra GND pin on M0 boards.
@ruby atlas m_new is just a convenience macro:
#define m_new(type, num) ((type*)(m_malloc(sizeof(type) * (num), false)))
But do you need to allocate it on the heap? Could you just allocate an array on the stack, fill it, and then call mp_obj_new_bytearray()?
@tulip sleet the stack would be fine... though i don't know the size of it in advance, which is why i thought i have to allocate it on the heap? I may have a hole in my C/embedded knowledge here - is there a way to dynamically allocate stack?
though i'm tempted to just manually do the bytearray initialization and use memset() instead of using mp_obj_new_bytearray()
(or add a new mp_obj_new_bytearray_zeroed() or mp_obj_new_bytearray_filled())
@marble hornet Clever approach. Does it improve character rendering speed on the TFT?
@stuck elbow Excellent algorithm. I'm going to add it to my experimental/learning tests. Do you use this on your gaming platform?
@errant grail yes
@ruby atlas you can allocate an array on the stack whose size isn't known until runtime: https://en.wikipedia.org/wiki/Variable-length_array#C99. Example in CircuitPython: first_buffer and second_buffer in https://github.com/adafruit/circuitpython/blob/74ced174cec7aebe8852e8308dfac10ecde2bd19/ports/atmel-samd/common-hal/audiobusio/PDMIn.c#L365
Thanks dan!
@wraith tiger @strong violet just pinged me about https://forums.adafruit.com/viewtopic.php?f=60&t=136549
I tried essentially the same program on a Trinket M0 to rule SPI flash presence in or out. Had to hack things up a bit to provide I2S on a Trinket, but I get same kinds of hangs (not examined in gdb). Not clear if coincident with filesystem operations: sometimes seems synchronized, and sometimes operation does not provoke a hang. Often hangs by itself (more quickly than on Metro M0).
@tulip sleet please do the full release notes on library release (https://github.com/adafruit/Adafruit_CircuitPython_IRRemote/releases/tag/3.1.0)
they should always include instructions on usage and link to docs
sure - can you point to a good example?
yup, lemme look
yup, matrix looks good too
usually I start with the previous release's notes but some repos don't have the format
new headshot looks good btw!
tnx!
@tulip sleet I feel like I'm seeing a similar hang with the pulsein stuff
is it also DMA?
I was experimenting with detection yesterday and theres a spot between the symptom and the detection
no, its interrupts
does it have a MICROPY_VM_HOOK?
it is weird. only solid clue I have is smashed MSC ASF4 device descriptor when I add I2S->DATA[0].reg = I2S->DATA[0].reg;. Maybe I'll try to set a watchpoint on the MSC struct
yeah, that could be good if its consistent
do you remember why you added that I2S write to itself and then why you took it out?
it seems to work fine without
with, it might trigger an early write into the DMA with premature data
I think it had to do with a note in the datasheet
but it might have been to trigger the dma
yes, I saw that, that doing the write would trigger the peripheral
k, i will keep looking too
watchpoint soudns like a good idea to me
@errant grail it does over the built in buf of cir-py. and i am able to add special character. plus it is only buffering 1s and 0s not whole numbers for color. so a little. what kind of tft are you using ?
@slender iron @strong violet Cool. I just noticed earlier today that https://bitbucket.org/plas/thonny-circuitpython/src/master/ had appeared on bitbucket. Am I correct to assume that is you, Aivar? That was a project I was looking to start myself, so I can see what I can do to contribute.
amg8833 libraries. is there still a difference between 3.0 and the 2.2.1 ? or is the code now cross compatible?
i though i heard tell of 2.x code running on 3.0
@marble hornet The 2.4-inch TFT FeatherWing.
@wraith tiger yup, aivar is the thonny dev (based in europe so timezones can be tricky)
Yeah, I have the world clock set up in Gnome with Florence, Nairobi, Bangalore, Jakarta & Manila across the top of my screen.
@marble hornet the .mpy files are formatted differently for 2.x vs 3.x so you have to use the correct versions. the underlying code in the .py files are "usually" the same
ah, so i'm looking for the source file. thanks!
there should only be one source file.
there are, .zip and tar.zip
if you want to convert to .mpy later just use the correct version of mpy-cross for 3.x or 2.x
π¬ #0 0x0001d43c in EIC_Handler () at peripherals/samd21/external_interrupts.c:82 #1 <signal handler called> #2 __get_PRIMASK () at asf4/samd21/CMSIS/Include/cmsis_gcc.h:313 #3 common_hal_mcu_disable_interrupts () at common-hal/microcontroller/__init__.c:51 #4 0x0001d5b6 in SysTick_Handler () at tick.c:42
handler in a handler
yup, as the handler is trying to disable interrupts
i think i need to read about the interrupt system and whether an interrupt can be set to mask other interrupts when handler is called
hmmmm...thoughts anyone?
matrix.blink_rate = 2
or
matrix.blink = 2
blink_rate is more descriptive
yah, blink is more likely to be just True or False
works for me. thanks.
@slender iron I think there needs to be some kind of "test and set" operation for nesting_count, cause right now there's a race condition to increment it.
yup, looking at that right now
current page: https://community.nxp.com/thread/419939
Content originally posted in LPCWare by wlamers on Fri Jul 18 01:06:35 MST 2014 I have an application in which both the M4 and M0 core (of an LPC4357) are
asf4 handles it by storing interrupt state every disable and resetting it on enable
I think we can just always disable
since its idempotent
disable first and then decide if we can re-enable
@tulip sleet I search Discord for "library releases" and Scott pasted a raw markdown example previously that you can change the URLs and library name in and then it's an easier paste into new release notes. That's how I've been doing it.
how does asf3 do it?
@idle owl - thanks yes, I pretended to edit another release and got the markdown from that and changed the url. (I suggested to github a while ago they add wysiwyg to the release message text editor, but nothing happened yet...)
looking in asf3 now
looking in yiu
@tulip sleet Searching Discord might be easier than editing another release, but I figured I'd let you know how I was doing it in case it was simpler for you.
@tidal kiln Maybe even blinks_per_sec or similar to be even more explicit.
@wraith tiger maybe. it's not continuously settable. there are four options: off, 0.5Hz, 1Hz, 2Hz
@tulip sleet asf3 grabs flags and then disables
nope, seems like it should suffer from the same bug actually
that file has a volatile cpu_irq_critical_section_counter but it's not mentioned elsewhere in the file, and it's static (?!)
i was thinking of maybe adding some consts to make it a little more readable:
BLINK_RATE_OFF = 0
BLINK_RATE_0_5HZ = 1
BLINK_RATE_1HZ = 2
BLINK_RATE_2HZ = 3
or some such...
I think we'll be fine if we always disable first
and then do the count math
volatile uint32_t nesting_count = 0;
void common_hal_mcu_disable_interrupts(void) {
__disable_irq();
__DMB();
nesting_count++;
}
void common_hal_mcu_enable_interrupts(void) {
if (nesting_count == 0) {
// This is very very bad because it means there was mismatched disable/enables so we
// "HardFault".
HardFault_Handler();
}
nesting_count--;
if (nesting_count > 0) {
return;
}
__DMB();
__enable_irq();
}
yes. it's not necessarily a problem that common_hal_mcu_disable_interrupts gets interrupted. it's a problem only if the two interrupt handlers access shared storage before disabling interrupts
i think m0 has no hardware divide
ya
prob not THAT slow
but removing it doesn't actually help this case becaues you could just input a faster signal
we could have the vm track the last time it ran "background" tasks and give a mechanic for interrupt to check its happening from time to time
a non-hardware watch dog
you mean have systick check that? i thought it ran background tasks always as part of MICROPY_VM_HOOK_LOOP
to prevent it from starving the background tasks
like if the background tasks haven't run for a second and pulsein is active then pulsein is starving them, and it should give up
the pulsein handler does not block other interrupts, but the systick handler does. do we use interrupt priorities at all or are they all the same priority
we don't use any priorities but the systick is special because its in the core
looks like tracking the last run of the background is a pretty good metric
I'll try bumping systick to top priority
I'm thinking that systick can't get starved by pulsein even if they're the same level because the pulsein handler doesn't disable interrupts but the systick handler does. so if the systick handler is at the same level, it will interrupt pulsein and then is guaranteed to finish its work
current_tick does turn off interrupts
actually, not true, according to Yiu:
_"An interrupt request can be accepted by the processor if:
- The pending status is set,
- The interrupt is enabled, and
- The priority of the interrupt is higher than the current level (including interrupt masking register configuration)."_
right, so equal priorities wait
yes, so systick should be higher, as you say
the cmsis SysTick_Config function sets it lowest by default
so it was lower than everything else π
$9 = 11725
(gdb) p last_finished_tick
$10 = 61```
those should be equal?
yeah
ooh bad
but pipe in a 50khz signal to pulsein and it falls over
I think its useful to track
good idea
interesting that right now with all interrupts at the same prio (except for faults that are fixed at higher prio), the "interrupt disable/enable" stuff isn't actually protecting against anything ... not that we should take it out
its not protecting when an interrupt is active
and systick in master is lowest priority
right, not counting systick.
In the Adafruit Daily you are asking for links to PyGame games.
I have a bunch here: http://sheep.art.pl/Games
yay!
by the way, I think it's a very bad idea to base the library on pygame
no, it's not possible
pygame is based on SDL, which is really designed with large PCs with large memory in mind
right but we could use the same api right? someone has done it for pokkito
I would rather look at the consoles like NES, GameBoy, etc.
you probably could, but it would be very wasteful
sure
plus, pygame doesn't make it easy to make games
thats why I like the approach of good C helpers with a python/pygame layer
pygame has a lot of docs and tutorials already
not really
nothing good quality anyways
it has a lot of very basic stuff
but that doesn't let you make an actual game
I've been writing games using PyGame for the last 10 years :)
well, I'm all for another api too but I think we'll want pygame support somehow
I made Β΅Game precisely because PyGame sucks
in any case, most games on that page I linked are in pygame
and they are all open source, so you can take a look
awesome
I'm hoping to have some dedicated cycles for it after 3.0.0 is in release candidate and soaking
there are some libraries with better api: lΓΆve2d, haxe, pyglet
and definitely want to think about portability to modern handhelds and retro ones
oh, there is also the pico8, which is a fantasy console
as in, an emulator for a non-existing console
neat!
there is an awesome community making games for that
if you could tap into that, it would be great
I need to make an issue for it
Improve our existing APIs for game creation and add more as needed.
Please dump links and ideas here!
@stuck elbow lets brainstorm there so ladyada gets emails about it π
There is a very nice fantasy console with a big community called pico8 (https://www.lexaloffle.com/pico-8.php), but it's closed-source and LUA. Then again, there is a similar open source project with Python support written in Rust: https://github.com/Gigoteur/UnicornConsole
The lΓΆve2d engine (https://love2d.org/) is also LUA, but they are very popular and have good API.
Added some links
thanks!
@tulip sleet I bumped the usb priority and it doesn't freeze as hard either
I also need to add a 2x2 pixel mode to the Stage library (https://github.com/python-ugame/circuitpython-stage) so that it can be used with those huge 320x240 displays without having to strain your eyesight to see the 16x16 sprites.
if you push that stuff I could try the PDMIn tests again, though I'm not sure it's releated
sure
i can just try your repo
If you want to see some examples of PyGame games, there is a bunch that I wrote over the years: http://sheep.art.pl/Games
goes to eat lunch
oh man I need to eat too.
i had lunch but that was a while ago, need a snack
@slender iron PDMIn hangs as usual, unfortunately. Also NeoPixel is blindingly bright, not pulsing as it should.
That was an easter egg.
With the previous PulseIn/SysTick issue, and FrequencyIn, I was wondering if the NVIC priorities could be looked at. Didn't think they were causing any issues, though. While catching up, I was going to mention something along the lines of setting "secondary" interrupts (EIC) to a lower priority. But, setting SysTick from lowest to highest seems more logical.
@tulip sleet on what board? I only tested it on metro m0
metro m0 π
@raven canopy hey, i borrowed this range check:
https://github.com/adafruit/Adafruit_CircuitPython_Trellis/blob/master/adafruit_trellis.py#L175
but it doesn't work on the low end. it doesn't catch negative numbers.
@tidal kiln how bout if not (0 <= x <= 3):
that was my guess for most pythonic, just not a check for being in range
and it works
@tulip sleet is your bright neopixel yellow?
white
a op b op c in python is short for a op b and b op c
it is just stuck white, even if i mon reset
are you using jlink?
there's also if x not in range(0,4) but that would waste some memory creating the range, right?
yeah, that would be really slow, since it will check all the elements, I think
@tidal kiln hmm. I'll have to look at that later, since the same conditional is used elsewhere (in other libraries as well). Thanks for the heads up.
@raven canopy yep. it's used elsewhere in that same lib too. i'm going to use what dan suggested for now.
it's if 0 < rate > 3 which would be 0 < rate and rate > 3 which is only true if rate > 3
i was wondering what that expand out to. so it's basically an implicit and ?
yeah
any pythonic way to make it an or?
@tidal kiln if not 0 >= rate >= 3:
@raven canopy @cunning crypt @slender iron I've pushed an update to the CoC, if you could give it a look when you get a chance. Thank you.
so parens not needed?
@stuck elbow if not 0 <= rate <= 3:
right, sorry
@idle owl pinned in my inbox. thanks!
@raven canopy created an issue in the trellis repo for that. too bad it doesn't work. the syntax looks cool.
I was just about to do that! Haha. Thanks! @tidal kiln
@slender iron neopixel_write calls wait_until(next_start_tick_ms, next_start_tick_us)' and then disables interrupts.
I forgot, it didn't used to work either with the jlink, except it was just dark, not bright. some issue about pin assignments, if i remember right
it works ok on the m4
I was getting a weird bright yellow pixel when off jlink on the m0
looking at the schematic, now I remember. problem is that noepixel is run off pa30, which is also SWCLK. pa31 is rxled and SWDIO. Due to not enough pins, had to share
right
https://github.com/adafruit/circuitpython/blob/master/shared-module/os/__init__.c#L106 is wrong, right? It's calling mp_obj_get_type on a const char*
Either that's wrong or there's something real magical happening here, heh
I think it just needs to be "true", tbh
os.listdir should return strings, not bytes.
is that what os does in cpython?
Hm, no, you're right - os.listdir(b'.') gives bytes, os.listdir('.') gives strings
TIL...
@idle owl Had a quick glance. Seems solid.
@cunning crypt Thank you, if you could note that on the PR that would be great
Duplicated the CPX CP quickstart install into the Crickit Guide. Only changed the name of the UF2 referred to in one of the side2s to match the special UF2 for crickit.
A bit busy right now. Fixing brother's website (I accidentally deleted his database. Good thing I backed it up), and then heading out to D&D
Ok
I'll give it a proper review/read tomorrow
hi hi @slender iron
hi!
should i ... POST a LEEK ... HERE or in general ... game thingie PCBs
DEALERS CHOICE
(calling it ArcADA for now)
general I think
ok folks, go to #general-tech for a leek'
it is related to circuitpython but it'll blow out our other conversations π
And also a nice play on words.
I'm unable to reproduce the problem in #894, but I was able to get another one.
I order to get the tests running at all I first had to do a:
storage.erase_filesystem()
Otherwise I got the same hung error mentioned further down.
I've run the tests 3 times in a row, no problem.
.../tests $ CPBOARD_EXEC_MODE=disk python3 run-tests --device=metro_m4_express --target=pyboard -d basics circuitpython
<snip>
413 tests performed (12423 individual testcases)
401 test...
@tulip sleet When you get a minute, I need your help with adding a piece of information to the CP Expectations page about ints and limits. You explained it in the issue, but you explained it super technically and I'm not sure that's the best way to put it into the guide page, so I wanted to discuss it with you.
@slender iron I'm also not sure what to add regarding heap memory usage. That's all that was added to the list and I don't know where to go with expanding that into useful information.
whats the note actually say?
Thanks for the issue! Maybe there is state that isn't reset across button presses. I'll look more into it.
I'm trying to write that now and struggling. I'll finish writing it up and have you look at it. I don't think it's right.
just think about the common issues people hit around it and tips to help
mpy-cross is one
We now track the last time the background task ran and bail on the
PulseIn if it starves the background work. In practice, this
happens after the numbers from pulsein are no longer accurate.
This also adjusts interrupt priorities so most are the lowest level
except for the tick and USB interrupts.
Fixes #516 and #876
My first guess with the above test -> reset button -> improper unmount is that one of the tests is running an operation on the FS, and when the board isn't properly unmounted from the host that is gumming up the reset. Which is a documented problem, of course.
I don't have any experience with the tests, so I may be off on that theory.
@tulip sleet finally read the wiki link. Apparently I need to read up on C99 and C11. I appear to have failed to learn the new features of C and am stuck in the mid 90s.
@slender iron small builds are running out of space again. try setting -finline-limit=50 That worked for me when trying to fit rotaryio in (no PR for that yet).
i'm adding __setitem__ access to the ht16k33 driver, so you can do things like this:
matrix[3,6] = 1
but this doesn't make sense for non-matrix displays like seven seg and alphanumeric.
i'm thinking of overriding and throwing a RuntimeError for those displays
make sense? so if someone tried:
seven_seg[3,6] = 1
it would throw an exception.
@tidal kiln - it could make sense: on the 3rd digit/alpha display turn on/off the 6th segment
kinda convenient maybe actually
But how are the segments numbered in that case?
there is a numbering
Ah
Thought maybe it was arbitrary.
@tulip sleet Did you see my message earlier about int and float limits for the CP Expectations page?
I have not written anything for that one yet
I can show you what I have so far
I guess it's already said in there rather concisely under "Things to watch out for!"
non-Express boards only have 31-bit integers (you could give the range: -2^31 to 2^31-1). As of 3.0 Express boards have arbitrary long integers like CPython.
If I want to add that to the FAQ section, how would I word the question that your info answers?
What integers are supported in CircuitPython? ?
Seems weird.
floating point numbers are single precision (not double precision like CPython), They have 8 bits of exponent and 22 bits of mantissa (not 24 like regular single precision floating point)
"What are the int and float limitations of CircuitPython?" ?
"How large can integers be in CircuitPython?" "How large can floating point numbers be?" "How many digits of precision for floats?"
Ok
a=1, b=2, for decimal points, 0 could be the decimal point light
what's the current API for arbitrary segment access?
they don't have it, for the segmenets
@idle owl largest FP number is about 3.4e38 (most neg is about -3.4e38) smallest is about 5.6e-45 (pos or neg)
@tidal kiln I thought I saw something about arbitrary access in the arduino libs
will look
`class Adafruit_AlphaNum4 : public Adafruit_LEDBackpack {
public:
Adafruit_AlphaNum4(void);
void writeDigitRaw(uint8_t n, uint16_t bitmask);`
^^ yep. that.
I added it to the list at the bottom. Can you read through it quickly and make sure it sounds ok?
same for 7-segment, plus drawColon(bool)
not really beginner friendly. i've had to walk people through creating bitmask before.
may not be worth implementing if you want to save space, but people might want to do it. People like to do animations, etc.
big brother python has this:
https://github.com/adafruit/Adafruit_Python_LED_Backpack/blob/master/Adafruit_LED_Backpack/SevenSegment.py#L84
basically just a port from the arduino idea
@idle owl I don't think these are really FAQ's. I think there might be a section like "Differences between regular Python and CircuitPython"
some of that is in "Things to watch out for !" now
@tidal kiln yah, so bitmask is a pain, and if there was an array syntax, it might be easier, which is why it appealed to me. You'd have to have a picture showing the mapping. And the 0 digit or the 4 digit could be the colon
i could get fancy, what's passed in is just an arbitrary key. so, in theory, could support:
seven_seg[3,'D'] = 1
@tulip sleet will look now. just got back from climbing
@tidal kiln - it's kinda wordy, i guess, when you want to set multiple ones. does arduino have bit constants for the different segmeents you can "or" together?
maybe I am revising my idea of that it's a good idea. so right now seven_seg[3] = 2 would display a "2" on the third (or fourth?) digit?
or is seven_seg[3] = "2"
yes. there will be something like that.
seven_seg[3] = "ACD." turns on those segments
with the general idea of just being able to throw text and numbers at the segment displays
right, at the whole display, not a subscripted digit
"seven_seg[3] = "ACD." turns on those segments" is lousy for the alphnumeric ones, so that's not good
current lib is already like that
it only allows the seven seg to accept numbers (but does have hex support)
yeah, and I want it to be able to say "uhoh"
π
or at least turn on the segments to say that
so, back to your original question, what should it throw? Are you using subclasses or just separate classes?
for the different displays on ht16k33, or is it all one class
so __setitem__ would be implemented differently in the different subclasses. You could just not handle the multiple subscripts on the 7seg and alpha, or do you want to check for that and fail gracefully?
Dalek Poetry, courtesy of the micro:bit tutorials.
I think ValueError is the correct exception. RuntimeError implies a failure of some kind in the code, not that it was called wrong
lol "(Actually, as weβll learn below, itβs The Doctorβs fault DALEKs like limericks, much to the annoyance of Davros.)" -- http://microbit-micropython.readthedocs.io/en/latest/tutorials/speech.html
right. that's what i was doing. and then for the seven_seg / alpha_num, basically turn it off (override, throw expection), since it doesn't seem to make sense.
i could just leave it there. it's benign. user would just be turning on/off random non-obvious segments.
the class hierarchy could be:
HTK1633
pixeldisplays
8x16, etc.
segmentdisplays
7seg
alpha
and only implement [a,b] for pixeldisplays
they don't have to be random, a could be the digit and b could be the segment in that digit
@wraith tiger such sweet sounds... now just need a Vogon to join in
@stuck elbow scroll back π
@wraith tiger I wrote a poetry program in FORTRAN in 1971.
it did not talk
I generally don't like the idea of forcing the segment displays and the pixel displays to have a common base class β there is almost nothing to share
i think it's kind of working out ok doing that
by the way, instead of doing meaningless api changes, we could change the way the font is stored in the segment displays, to save ram
@tidal kiln http://edsu.github.io/vogon/#Vogon
you could have an ht16k33 helper class that does the low-level i/o, and have the other classes just call it as necessary
done in the i2c_register lib
@tidal kiln I actually watched that Hitchhiker's episode the other day. It's free to watch with Amazon Prime.
like _write_cmd() in the current lib
but those are not registers on the device
this is just pure overhead
and every class is going to have a different size anyways
@tidal kiln in that wip, why are you not using framebuf?
they call the base class and pass in their size
can't they just set the size in their own class?
I know that building complex hierarchies is exciting, but do we gain anything here from it?
there would be redundant size code in all the classes, let the base take care of it
size code?
size checking, for example
it's literally:
class Foo:
size = x, y
no need to make it a property
you never modify it
(also, separate width and height attributes would make more sense)
but each class would have that
yes, because each has it different
you don't save anything by putting it also in the base class
it's only in the base class
the sub classes pass in their size when they are created. it's not meant to change.
so the base class has all this code for passing and setting the attribute, and the subclasses in addition have the code to pass the size to the base class
instead of just setting it in the subclasses
without any extra code, only the thing that changes
G'day all! Nick Moore here ... looking forward to doing some CircuitPython development π
hi hi @crude fossil !
@tidal kiln compare:
class Matrix8x8(HT16K33):
"""Class for using a 8x8 LED matrix."""
def __init__(self, i2c, address=0x70):
super(Matrix8x8, self).__init__(i2c, address, size=(8, 8))
and
class Matrix8x8:
width = 8
height = 8
and then what? what would the rest of the Matrix8x8 code look like?
you also save memory, because the size is per class, not per instance, and you don't need extra memory for the tuple
@tidal kiln it would have code for creating the correct framebuf, and a 1-line show() function for sending that to the display
@crude fossil hi!
@crude fossil hey hey. you're in the right place for that.
and two register defintions for brightness and blinking
i bow to deshipu for further discussion: he is expert on minimal python for this kidn of thing
the core work on that issue was simply splitting the classes into separate files afaict
but that doesn't save you anything if you still import all those files
and getting away from get/set style methods
@stuck elbow who would import all of the different displays at once?
exactly
@tidal kiln may be better served in two steps
you would only import the files for your display
and those would import the files for their base classes
one file - ht16k33
i'm shooting for this layout:
https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/issues/8#issuecomment-389943705
so for example, you'd only import something like matrix8x8 (which imports ht16k33)
but the others wouldn't get imported
sounds good to me
please start with that and propose API changes separately
definitely good to brainstorm how to evolve it
@stuck elbow i haven't used framebuf yet, is it this?
https://github.com/adafruit/micropython-adafruit-framebuf/blob/master/framebuf.py
from adafruit_bus_device import i2c_device
from adafruit_register import i2c_bits
import framebuf
class Matrix8x8:
width = 8
height = 8
brightness = i2c_bits.RWBits(4, 0xe0, 0)
blink_rate = i2c_bits.RWBits(2, 0x81, 1)
def __init__(self, i2c, address=0x70):
self.i2c_device = i2c_device.I2CDevice(i2c, address)
self._bufffer = bytearray(self.width * self.height // 8)
self.framebuf = framebuf.FrameBuffer(self._buffer,
self.width, self.height, framebuf.MONO_HLSB)
def show(self):
self.i2c_device.write_to_mem(0x00, self._buffer)
this is how I think this class should look like, roughly
Matrix16x8 would be the same, only with width=16
and possibly it would need to do some post-processing in show()
the .framebuf already has all the methods for drawing pixels, lines, text and whatever else is needed
@crude fossil Hello and welcome!
yah, that drawing stuff would be useful for the matrix ones. then for the segmented ones, would there even be a framebuf?
Travis build succeeded (took a couple of hours).
@tidal kiln no, the segmented ones would have completely different code, except for the the registers
@tulip sleet Ok thank you, I'll move the page around.
that's why I don't see sense in having a common superclass
i can see that for the matrix vs. segment displays
but there's enough matrix displays, i was thinking / hoping they could share stuff with a common superclass
well, it's 5 lines of common code
not sure it's worth creating a class for that
especially since you are going to import only one of them at once usually
so you don't save any memory by sharing that code
show() is going to be custom for every one of them, __init__ is going to be pretty much identical each time
except for the bi-color one, where the framebuf type is going to be different
this parameter? framebuf.MONO_HLSB
yes
not sure if we have 2-bit color mode implemented already, there was a pull request for MicroPython, but I don't know if it's merged
we can use 4-bit color in the worst case, and do post-processing in show()
https://github.com/adafruit/micropython-adafruit-ht16k33/blob/master/ht16k33_matrix.py <-- this is the MP code for that driver
so the show() would be more like:
def show(self):
buffer = bytearray(17)
buffer[0] = 0x00 # pixel register
for y in range(8):
b = self._buffer[y]
buffer[1 + 2 * y] = (b >> 1) | (b << 7)
self.i2c_device.write(buffer)
because the 8x8 backpack has arbitrarily arranged the pixels: shifted by one column and using every other row
probably was easier to route the pcb that way
how'd the current CP version end up without framebuf in it?
it was added after Tony forked it
ah
we will be probably overhauling the framebuf module in the near future anyways
for the arcade wing
looking through that MP version helps with understanding it. thanks for that link.
sorry, I forget that people don't have all the context I have in my head
@idle owl doing a bit of editing, but looks great!
i'm slowly learning the necessary incantations to make the pixelbuf class exist π
@ruby atlas is it similar to framebuf?
maybe. it's purpose is to handle the bytearray for neopixels and dotstars in a speedy manner.
specifically the tuple to bytes conversions
I see
we should get a 5-10x speedup.
yeah, using the right data types can help a lot
@tulip sleet Thank you on both counts
@idle owl k, check out the "Differences" section again
@tulip sleet That's wonderful, thank you so much!
np
I'm calling it good to go.
I'm guessing it's not safe to return a mp_obj_new_bytearray_by_ref to a bytearray held on the object instance from within a property getter?
(and that there really is no safe zero-copy way to do that)
though it'd be nice to allow access to the underlying bytearray directly.
@ruby atlas, not a bytearray, but maybe a bytes? does it neeed to be changable?
ok, i missed the context, never mind, I read back
ideally, yes it should be changeable
i would think you would create the bytearray in python and then pass it into the c library
hmmmmm.... that's probably the best way.
instead of creating it in the c code
and have the c code check that the bytearray is of the appropriate size.
sure, or use the length of the bytearray as the defined size
this way you can keep reusing the same buffer
yeah, exactly.
it's not like this class is supposed to be used directly. it's okay for it to be a little low level.
i keep trying to make it's interfaces pythonic π
bad me.
deshipu has a good point, maybe separate the length, just make sure it's at least as long as needed
right.
i'm not quite sure how reference counting is handled yet in the code. if I pass a bytearray during construction, is it going to exist until destruction of the instance?
MicroPython/CircuitPython uses garbage collection, not reference counting.
so as long as the object holds it, it will be safe
ok cool.
I found that on my metro m4 I could reproduce a weird hang with the following interactively, freeing me from repeatedly reinitializing the SPI flash or other long debugging cycles:
>>> exec("def f(): yield from f()\ntry: list(f())\nexcept: raise")
When I run this, serial terminal hangs but I can break in gdb:
Program received signal SIGINT, Interrupt.
HardFault_Handler () at supervisor/port.c:295
295 asm("");
(gdb) where
#0 HardFault_Handler () at supervisor/p...
whee I think I cracked what's going on .. waiting for my fork's CI build to complete before popping the champagne and actually opening a PR though.
also, for anyone wondering, I got openocd to work on metro m4 express. My commandline is $ openocd -f interface/jlink.cfg -c 'transport select swd' -f target/at91samg5x.cfg -c 'gdb_memory_map disable' and my openocd version is Open On-Chip Debugger 0.10.0. It was mentioned that the support status of the metro m4 with openocd was unknown.
hmmm as dhalbert already noticed, travis is going slow today...
.. setting it based on the ad-hoc stack pointer calculation of mp_stack_ctrl_init() meant that the stack used above main() counts against the 1KiB safety factor that the mp_stack_set_limit call tries to establish. It turns out, at least on M4, that over half of the safety factor is used up by stack-above-main()!
In the case of the basics/gen_stack_overflow.py test, which blows the stack on purpose, it turns out that gc would be called while handling the "maximum recursion depth ex...
I've started working on this over at https://github.com/nickzoic/micropython/tree/circuitpython-nickzoic-716-pulseio-esp8266 ... still super sketchy at the moment and missing a lot of the API features.
@idle owl Congratulations on the release of the CPX guide -- Well done! 
the crict just arrived, but I have a question about it
when I connected my circuit playground express to it, I noticed that the pin labels don't match
the VBATT is connected to VOUT, the A8 to A0 and A9 to A1
is this correct? will it blow up when I power it?
your CPX is "differnent" than the one in https://www.adafruit.com/product/3333
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! ...
yeah, that's why I'm asking
I couldn't find any information about it
or schematics
mine agrees with https://learn.adafruit.com/adafruit-circuit-playground-express/pinouts - was yours an "early release"
I can't check mine now - at work - hopefully someone else can look at one.
in current boards vout is connected "to either the USB power or the battery input" according to https://cdn-learn.adafruit.com/assets/assets/000/047/156/original/circuit_playground_Adafruit_Circuit_Playground_Express_Pinout.png?1507829017
if in your rev VBATT means that the connector never sees USB +5V then it will not power the CRICKIT
.. from USB
I'm just guessing here
The crickit is not powere by VUSB is it -- it has to be powered on its connectors
you're right, the guide is quite clear about that
still - siince so many pads are differents, I wonder if the correct signals are going to the CriCkit -- like A0. SDA/SCL/GND look OK so the seesaw will probalbly work but I would not try it!
without some clarifcation or a schematic of your version.
OK now I'm more worried about the VOUT vs VBAT connector, once I start thinking about the direction power is flowing in -- the CRICKIT might drive +5V right into the battery charger circuitry of the CPX and that can't be good.
you could leave that post off and independently power the CPX, .. maybe
Can I have your input on this: I have been into Arduino, Pi, and Micro:bit for the past 2+ years, now I have seen this massive CircuitPython community, so my question is, should I get into CircuitPython?
@stuck elbow I have the old board files and think I can come up with a schematic for you. hold one
@agile plover In general the answer is "yes", but it depends a lot on your projects and on your level of expertise. You shouldn't be afraid to pick up a CircuitPython compatible board like the feather m0 express, since you can take it right over to Arduino if CP isn't the right choice for your project..
@agile plover For a simple project, I think CircuitPython will let you develop much more quickly than Arduino, but if you are doing sophisticated stuff or large projects then you may find that CP is not the best match.
@tulip sleet thanks!
I noticed that when I flashed recent firmware on it and tried to use the audio, the transistor next to the speaker started smoking, so now I'm careful...
@onyx hinge CP is a whole new world of software and hardware. And if I get into CP: an Arduino Uno is a beginner level board, what board is the one I can get for CP as a beginner?
@agile plover https://www.adafruit.com/product/3727 the ItsyBitsy is a good balance between low price and high features
What's smaller than a Feather but larger than a Trinket? It's an Adafruit ItsyBitsy M0 Express! Small, powerful, with a rockin' ATSAMD21 Cortex M0 processor running at 48 MHz - ...
Thank you! I will consider this!
@agile plover It is a great community and a very nice way to be able to "poke around" with sensors. It is rapidly evolving and you have to be comfortable with that. Also be aware that for the M0 (SAMD21) boards, the limited RAM will make it harder to implmentd some projects taht work under Arduino. That said, jump in and have fun!
and the Metro M0 Express is literally in the classic Arduino form factor https://www.adafruit.com/product/3505
Thank you!
and both of those can be re-flashed between Arduino and CircuitPython at any time
whoops, second link should have been https://www.adafruit.com/product/3505
@agile plover as @onyx hinge points out, you can easily go back and forth between Arduino and CP so there is no downside to trying it out.
Ohh, ok, I will be sure to try it out now!
hmmmm.. I am not a pro at reading ARM assembly yet but it looks like main is allocating quite a bit of stack:
(gdb) disas main
Dump of assembler code for function main:
0x0000fb9c <+0>: stmdb sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}
...
0x0000fbda <+62>: sub.w sp, sp, #612 ; 0x264
somewhat confirmed by looking at the stack pointer on arrival in main:
Breakpoint 2, main () at ../../main.c:236
236 int __attribute__((used)) main(void) {
1: $sp = (void *) 0x2002ff...
@umbral dagger are the biscuit supportive with crict board?
@sick creek Not for direct breadboard use,the pins wonβt reach past the Crikit. But you could connect a cable to the pins. You would have to sandwich it between the CPX and Crikit, for the 6 Crikit pads anyway. The others could would just connect as normal to the CPX.
@sick creek Oh wait. It does fit fine!
Once I actually tried it π
I initially diagnosed #900 as being due to the stack above main being hundreds of bytes on Metro M4. However, on further investigation, it is actually the stack of main itself being over 600 bytes. This is primarily due to f486ead84a44846996c66d117de391fab048b01b which added a 512-byte on stack buffer for checking whether the contents of the boot_out.txt file matched what was already written to flash.
I think this could be greatly improved if the code which allocates the char[512] ...
main() reads the first 512 bytes of boot_out.txt to see whether the version information in the file is the same as what would be written to boot_out.txt. This could be reduced to, say, 160 bytes, without harm. But I thought C semantics is that the lifetime of file_contents[] would be just inside the if { } block. This could be checked by looking at the stack pointer for a call inside the if { } block vs just after it.
@sick creek photo or it didnβt happen
The only thing thatβs blocked is the seesaw programming port.
so you could make otherside for like that arduino photo above
.. this reduces stack usage in main() substantially, because the 512 byte stack allocation will only exist during the new run_boot_py function's duration.
Closes: #904
@sick creek I'm having trouble parsing that.
where Crickr board is in the middle
You could... but you wouldn't have access to the other connections.
And the seesaw port is only needed to reflash the seesaw chip.
I'll blame not thinking of trying this on my cold. This solves a problem for me in a clean/nonintrusive way (tapping into the I2C signals).
I guess the maximum stack used by main() is the important thing.
I agree that under the semantics of C, the storage duration of file_contents is limited to the body of the if() block. But I think gcc is doing something clever to minimize the number of operations on the stack pointer, by finding the largest amount of storage that is ever required, and adjusting the stack pointer just once based on that value. This is probably controlled by this optimizer flag, which is turned on at any optimization level:
'-fcombine-stack-adjustments'
Trac...
thanks @slender iron and @tulip sleet for the attention to my recent PRs!
@slender iron @tulip sleet I'll be out until ~2pm.
roger
This is ready to go! We can always add more as more common questions or important information come up.
reviewed and this is gooood!
I commented out escaping to the VM while filling the before, hoping that one of the background routines might be the issue. But I get the same kinds of hangs still :frowning_face:
while (!event_interrupt_active(event_channel)) {
#ifdef MICROPY_VM_HOOK_LOOP
// COMMENTED OUT MICROPY_VM_HOOK_LOOP
#endif
}
CPX back in stock! https://www.adafruit.com/product/3333 (just ordered myself a few)
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! ...
@stuck elbow make sure and pick up a new CPX or few the next free order you make. the one you have looks like a pre-production version
roger
@onyx hinge I'll poke rosie to do a test run today and see how it goes
thanks for the fixes!
@stuck elbow thank you for the fantasy console links. I dove more into them last night. they look very cool
awesome
@slender iron toying with an ESP feather today for MQTT stuff. Are we going to move AMPY's tutorial (https://learn.adafruit.com/micropython-basics-load-files-and-run-code/) to circuitpython-basics?
@prime flower I don't think so. Its not the workflow I want to promote for circuitpython
ok
In addition to removing the MICROPY_VM_HOOK_LOOP, as described in the previous comment. I wrapped the entire insides of common_hal_audiobusio_pdmin_record_to_buffer() in disable/enable interrupts, so it would be completely synchronous, and it still hangs the same way. When a hang happens, the first word of first_buffer contains good data, but the rest has not been filled in. So only one word was transferred.
Also checked settings of I2S peripheral. The settings are the same when a g...
yep, trying that out with some of the Adafruit IO Arduino examples
@slender iron could you approve https://github.com/adafruit/circuitpython/pull/902 when you get a chance? Limor did once but then I had to push another commit.
@tulip sleet I can do it if you like
sure, thanks!
Looks like most of the fantasy consoles have single files they use to distribute. Should we have ours be zip files that can live zipped on the fs or require they be unzipped into a folder?
Should I cut Beta.1 today or wait?
I don't see a reason to wait. There's some really solid fixes in already that I think would be good to get out.
yeah, I've got another fix but I don't think its critical
personally - i think its ok to tell people they need to put raw files down in a folder, that way we dont have to write to the FS which can cause corruption
eh, I think I should get my stuff in first
I have interrupt changes that should help things
That does sound like a good thing to have
we can always release tomorrow π
That statement is probably almost always valid.
Friday is the traditional day for deploying to production
π
Friday at 4:59 pm, to be exact...
Monday over lunch. Best time.
props to @cerulean pine for the MQTT library, just got it pushing to my IO + made a lil' dash for it
i have eliminated a lot of possibilities but still haven't fixed PDMIn. I need a break and will go to the crafts store to buy cardboard and popsicle sticks.
Yes!
@tulip sleet you'll figure it out while deciding which popsicle sticks to get. π enjoy the break!
@wraith tiger I got a shirt from one of the vendors at PyCon that says "I deploy on Fridays" on it.
...and on the weekends, I run with scissors...
Bummer, I can't fit all the interesting /amusing microbit demos into one file without a memory error.
@slender iron I responded to your comment and also pushed updates to the CoC for whenever you get to it
Write up a guide using a rotary encoder and the new rotaryio in CircuitPython.
if you frame the intro text generically, id like to add in a page on using with arduino too just cause it comes up
see https://learn.adafruit.com/using-servos-with-circuitpython for an example!
ok i think this can be closed then?
Time to add audio to the CircuitPython Essentials guide! We'll be using a headphone jack and analog audio for the example.
Write up a guide for I2S using UDA1334 or MAX98357 breakouts.
Use the same fritzing, etc, and add a CircuitPython example to the current PDM microphone breakout guide.
Check out any of the breakout guides that have Arduino and CircuitPython included for an idea of how this is usually done.
Can I add WiFi functionality to a Circuit Playground board (the ATSAMD21 version) running Circuit Python by hooking up a generic ESP8266? I know I could do this with regular Arduino & I appreciate that the ESP8266 is a capable microcontroller by itself, but the Circuit Playground is such a convenient board with all of the sensors & outputs built in... if it also had WiFi!
yes, but you will have to write the library to support it yourself
ah okay, so Circuit Python doesn't have the same out-of-the-box library support for it that an older atmega32u4 Circuit Playground running Arduino code would?
precisely
you have the UART to send the commands, but you have to construct the commands yourself
Okay, thanks π
I've used Arduino for years, but have only very recently discovered Circuit Python so I'm not as aware of the library ecosystem as with Arduino
welcome to 
you can also program the esp8266 with circuitpython to implement the processing of the network data, and just send the results to your circuit playground
the esp8266 has more memory for this stuff
Good point - I always find it entertaining when people use an ESP8266 to add wifi functionality to something like an Arduino Uno that then runs their actual project code... at a quarter the clockspeed & with substantially less memory :3
hey @stuck elbow , I have a ampy-weirdness question for you when you're free
shoot
I'm banging against the age-old "could not enter raw repl"
I changed ampy's timeout as well, and keep hitting it whenever I do an ampy command
@prime flower just to check, you don't have a terminal session connected to i somewhere do you? Is this an esp8266?
@prime flower make sure you are using a recent version of ampy too
it was fixed fairly recently
If you have a teminal session open, ampy will just fail to connect so that is probably not it. Try renaming main.py. import os os.rename("main.py","notmain.py") and see if ampy is happier
@tulip sleet this is why I think we could compress type structs: ```00029304 <mp_type_fun_bc>:
29304: 0002f3d0 ldrdeq pc, [r2], -r0
29308: 00000120 andeq r0, r0, r0, lsr #2
29304: 0002f3d0 ldrdeq pc, [r2], -r0
29308: 00000120 andeq r0, r0, r0, lsr #2
2930c: 00000000 andeq r0, r0, r0
29310: 00000000 andeq r0, r0, r0
29314: 0001d515 andeq sp, r1, r5, lsl r5
29318: 0001c73d andeq ip, r1, sp, lsr r7
2931c: 00000000 andeq r0, r0, r0
29320: 00000000 andeq r0, r0, r0
29324: 00000000 andeq r0, r0, r0
29328: 00000000 andeq r0, r0, r0
2932c: 00000000 andeq r0, r0, r0
29330: 00000000 andeq r0, r0, r0
29334: 00000000 andeq r0, r0, r0
29338: 00000000 andeq r0, r0, r0
2933c: 00000000 andeq r0, r0, r0
00029340 <mp_type_gen_wrap>:
29340: 0002f3d0 ldrdeq pc, [r2], -r0
29344: 00000123 andeq r0, r0, r3, lsr #2
29348: 00000000 andeq r0, r0, r0
2934c: 00000000 andeq r0, r0, r0
29350: 0001d4b1 ; <UNDEFINED> instruction: 0x0001d4b1
29354: 0001c73d andeq ip, r1, sp, lsr r7
29358: 00000000 andeq r0, r0, r0
2935c: 00000000 andeq r0, r0, r0
29360: 00000000 andeq r0, r0, r0
29364: 00000000 andeq r0, r0, r0
29368: 00000000 andeq r0, r0, r0
2936c: 00000000 andeq r0, r0, r0
29370: 00000000 andeq r0, r0, r0
29374: 00000000 andeq r0, r0, r0
29378: 00000000 andeq r0, r0, r0```
@tulip sleet Ping me when you get back, question about the Crickit 3.0 build.
Is there an easy way to go back and forth from using circuit python to Arduino code on a Feather M0 RFM69 Packet Radio? I have CP loaded and want to go back to using Arduino.
yes, press reset twice to get to the bootloader and then just flash your arduino program
@solar whale worked briefly, then failed grr
@stuck elbow - Thank you.
Yeah, reloaded one (using Screen to connect to the serial repl) and whenever I detatch screen, ampy's unable to access...am I using screen wrong?
Ive just been testing the mqtt stuff - but not using main.py and ampy has been working OK for me - no delay set.
I always exit screen (Control-a \ on linust) Ithink it is (control-a crontol \ ) on mac
(ctrl-a, ctrl-k, y) also kills screen on a Mac.
hmm contol-a K does not work on my mac, control-a control-k does - with prompt
or control-a k also works - with prompt
Mmm... same, actually.
ctrl+a, ctrl+\ offers to "really quit and kill all your windows?" So there's still a prompt there too. ctrl+a, \ does nothing.
yep, two control presses did it
on linux control-a \ is the same as control-a control-\ on mac.
@prime flower @stuck elbow It looks like the
main.py" issue is still present -- @prime flower are you using ampy 1.0.4?
1.0.3 from pip
ah -- I have 1.0.4
hmm, why isn't 1.04 installing as latest
not sure. trying to recall how I got it...
https://pypi.org/search/?q=ampy lists 1.0.3 as the adafruit version latest
hm adafruit has no ampy releaes. https://github.com/adafruit/ampy/releases
I think I installed it from the github source
first remove the old version from pip then install
ok, i'll try that
@slender iron Noticed that the RTD page for rotaryio is formatted wrong. I think I know what's wrong with it, but I'm kind of guessing. //| :param ~microcontroller.Pin pin_b: Second pin to read pulses from. //| //| For example:: //| //| import rotaryio //| import time //| from board import * //| //| enc = rotaryio.IncrementalEncoder(D1, D2) //| last_position = None //| while True; //| position = enc.position //| if last_position == None or position != last_position: //| print(position) //| last_position = position
I think "For Example" and everything under it in that section should be 3 more spaces indented. At the moment, everything after that is included in the code example (deinit etc).
I can submit a PR, but I wanted to see if I was on the right track with the problem.
@idle owl I'm not sure what the problem is. Testing it locally should help
I apparently don't know how to build sphinx on the CP repo.
I don't know where the conf.py for Sphinx is stored, which I thought was needed to run it locally.
@idle owl back after multpile stores
@tulip sleet Did you find all of the things?
of course not, but i have enough and i bought food too
Good on all counts then.
Ok so Brent was trying to use the cpx lib with the crickit build and ran into Module not found: ucollections. Is LIS3DH not updated in that build?
it should be, but there multiple builds, depends on which .uf2 he was using
i built one for Limor a while ago that had old libs
Is cpx frozen into those builds?
yes!
Ok.
@prime flower So a couple of things: first of all, make sure you're using the most recent Crickit build. Second of all, you don't need to have the cpx lib on the board in the /lib folder, it's frozen into the build.
@prime flower what's the version in boot_out.txt?
@tulip sleet Thanks for the info.
no guarantees. I can double-check the latest version.
True, but it's a start.
also you can find out the version of the library by importing it and doing whatever.__version__
oh right. You had me do that the other day.
Maybe I'll remember it now that it's come up twice. π
Any idea how to run Sphinx on the CP repo?
research shows that at least 15 repetitions are needed before humans assimilate a pattern ;-)
Aw well I guess it's going to be a while then.
@stuck elbow Thank you!!
if you didn't know, then who put it there?
Only leaves one person.
Also, I only partially fixed the issue I was trying to fix.
Fixed!
@tulip sleet Adafruit CircuitPython 3.0.0-alpha.6-91-g54293397c-dirty on 2018-05-20; Adafruit CircuitPlayground Express with samd21g18
@prime flower that is from mid-May, so it's pretty old. Get a fresh build from https://adafruit-circuit-python.s3.amazonaws.com/index.html?prefix=bin/circuitplayground_express_crickit/
Hrm thats the one on the guide @tulip sleet
we should update it
ill add it to my todo tomorrow
hello
I've got some Pimoroni bearables and I was thinking of using CircuitPython to talk to their i2c port, are you aware of any prior work in this space? There's a Raspberry Pi module already for it
@tulip sleet ok updated verson on learn
@simple pulsar it's not hard to adapt RPi Python code that uses I2C to CircuitPython. If you search on GitHub for Adafruit_CircuitPython_ you 'll find a lot of libraries (like dozens) that use I2C.
Thanks, I'm not sure whether to enhance their library to allow the i2c object to be passed or to write a new one that's more in the style of existing CircuitPython libs. I'll have a look over next week and ponder this. Just thought I'd check in case you knew of any work going on in this area.
none that I know of - but please ask any question you have in here π
@idle owl On a different subject, re: the page we were discussing the other day about internal RGB LED updates, there's a forum post saying a rather simple code snippet does not work on the ItsyBitsy, have a look at https://forums.adafruit.com/viewtopic.php?f=60&t=136420 if you have not seen it
@idle owl ah, actually it wasn't using the library code it was using abbreviated code based on the same approach - still odd it doesn't work though
@simple pulsar It looks like the issue was resolved.
@idle owl there was an alternate solution which was a good one but there was never an explanation of why the other code didn't work
@idle owl so nothing critical just a bit of a mystery
It's possible that it was trying to use the pins incorrectly. That was some lower level code.
@simple pulsar turns out there was a typo in the pins file; fixing; thanks for raising this
Thanks to Bill_r in the Adafruit forums and kjw on discord for pointing this out.
NP
Time for bed for me, goodnight
I appear to be either a) corrupting memory b) running into GC freeing things in use or c) all of the above π I wonder if it's time to use a VM with Atmel studio or try to keep going with gdb.
Have to go deeper!
breakpoints time!
@ruby atlas I use gdb so I can help navigate if needed
i seem to mostly just need n, s, c, start, break File.c:99, print, and bt, so far π
watchpoints can be handy too
I have a script that can chart all the memory too but thats not simple
the svd stuff is worth it to look at register values
@simple pulsar pins were not reversed; they are different on the board; bitbangio will work
the script to chart memory would likely be handy at some point.
does GC only run when an allocation failure happens, or is it more often?
@ruby atlas on failure or if gc.collect() is called from python
thanks, and is there a specific function i should breakpoint to catch if gc is running? (I'm sure I can find it, if you know it off the top of your head that'll save me time)
i'll spam breakpoints π
π
also it got cold outside again, i think i'll go back inside to my desktop. π
Blankets and heat from the laptop!
@meager fog ah the serial and i2s on differnt sercpms, easy then
@ruby lake well, you cant use the RX and TX pins but you can use other pins. something had to get shared
aww i wish i'd checked new before my order today, the black magic looks awesome.
total crashes : 11.5k (208 unique)
hm I thought I'd found all the trivial crashes in micropython. For some reason, ubsan is finding a lot more than previously
(that's just a run a few minutes long!)
must have slightly varied the ubsan flags from the last long running test I did...?
ubsan is a script or something?
The Undefined Behavior Sanitizer, a feature of the clang C compiler
in the C language standard, a lot of things are defined as being undefined. For instance, using the "<<" shift operator on a negative number.
when you "build with ubsan", there are lots of runtime checks added for things like this
oh nice
nifty. now if only i could figure out why i'm crashing in my own code π
@slender iron is there a way to find out what python instruction was executing and/or to get serial console output over gdb (or another way). I can't keep the metro m0 connected to USB and debug or my usb goes haywire π
(checking for serial pins on the metro m0 express docs)
@ruby atlas I can usually tell through the call stack
thats why I like separate power to the metro, to keep it running off usb
it's during a subscr i'm not expecting.
#3 0x0000e10a in mp_obj_subscr (base=0x20001c60 <heap+5216>, index=0x1,
value=0x200026b0 <heap+7856>) at ../../py/obj.c:470```
0x0001b71c supervisor/port.c 295 256 times```
is that the full call stack?
nope
Program received signal SIGTRAP, Trace/breakpoint trap.
HardFault_Handler () at supervisor/port.c:295
295 asm("");
(gdb) bt
#0 HardFault_Handler () at supervisor/port.c:295
#1 <signal handler called>
#2 0x20666f20 in ?? ()
#3 0x0000e10a in mp_obj_subscr (base=0x20001c60 <heap+5216>, index=0x1,
value=0x200026b0 <heap+7856>) at ../../py/obj.c:470
#4 0x000184c8 in mp_execute_bytecode (
code_state=code_state@entry=0x20000b80 <heap+896>,
inject_exc=<optimized out>, inject_exc@entry=0x0) at ../../py/vm.c:475
#5 0x00010362 in fun_bc_call (self_in=0x20000ae0 <heap+736>, n_args=0,
n_kw=536873696, args=0xc4ed <mp_call_function_n_kw+44>)
at ../../py/objfun.c:267
#6 0x0000c4ec in mp_call_function_n_kw (
fun_in=fun_in@entry=0x20000ae0 <heap+736>, n_args=n_args@entry=0,
n_kw=n_kw@entry=0, args=args@entry=0x0) at ../../py/runtime.c:658
#7 0x0000c500 in mp_call_function_0 (fun=fun@entry=0x20000ae0 <heap+736>)
at ../../py/runtime.c:632
#8 0x00020c12 in parse_compile_execute (source=source@entry=0x39abd,
input_kind=input_kind@entry=MP_PARSE_FILE_INPUT,
exec_flags=exec_flags@entry=32, result=result@entry=0x20007d44)
at ../../lib/utils/pyexec.c:103
#9 0x00020f14 in pyexec_file (filename=filename@entry=0x39abd "main.py",
result=result@entry=0x20007d44) at ../../lib/utils/pyexec.c:516
#10 0x0001b1dc in maybe_run_list (filenames=filenames@entry=0x20007d50,
exec_result=exec_result@entry=0x20007d44) at ../../main.c:122
#11 0x0001b318 in start_mp (safe_mode=safe_mode@entry=NO_SAFE_MODE)
at ../../main.c:158
#12 0x0001b4b0 in main () at ../../main.c:368
(gdb) mtb
0x0001b71c supervisor/port.c 295 256 times```
I think there is an extra loop in the hardfault handler
thats why the mtb is garbage
is Serial1 on pins 0 and 1 the same serial that's avail on usb?
if yes, time for my FTDI
no, usb doesn't go through a serial port
469 if (type->subscr != NULL) {
470 mp_obj_t ret = type->subscr(base, index, value);
looks like type is not a very good type
or type->subscr actually
if you break at HardFault_Handler maybe the mtb won't be trashed yet?
... cpy2 has this block in HardFault_Handler, but its equivalent isn't in the current version (not right code for samd51?)
{
#ifdef ENABLE_MICRO_TRACE_BUFFER
// Turn off the micro trace buffer so we don't fill it up in the infinite
// loop below.
REG_MTB_MASTER = 0x00000000 + 6;
#endif
@meager fog EAgle 7.3 complained about something but the brd/sch loaded ok
@onyx hinge likely the case. that's where i've been focussing on the code.
@slender iron doesn't look like there's an easy way in the code to make it either π
ooh, gdbgui
ugh, my index = 0x2 rather than a legit pointer just before the crash.
@slender iron I was reading through the SAMD21 errata, and found this, which is still true on the latest chip rev (D). Not sure if you are using the event system for TC's in this way.
hm, will have to try one of these M5stack things
@onyx hinge you want to break after it turns it off. Otherwise it fills with jumps from the infinite loop
@tulip sleet yup, I use the TC events to clock audio out
- to the dac
Any idea when the Feather M4 Express will be available?
does anyone know what kind of inductor is used on m4 boards? it looks like a capacitor but the schematic says there is a inductor there. thanks for all the help either way.
it's just a coil
10Β΅H if I remember correctly
any 10Β΅H inductor should be fine
also, if I remember correctly, it's not currenly enabled by the firmware
so it's not used, you can skip it
Hi,
I finally received my J-link and programmed three different NRF52 boards, but on the one I want to use it most (Ruuvi tag), I am not sure how to load the code. It does not have a serial connection that is enabled(and I have no idea how to get it running), nor a USB port. The WebREPL via webBluetooth is working, but none of the REPL file transfer programs (or Ampy) supports that. I do have a Bluefruit LE Friend (UART) but for that I first need the NRF52 to connect etc.
Is it possible...
I think the WebREPL had a file upload functionality?
@deshipu I'm an idiot. I was using the Espruino webREPL - just googled micropython WebREPL - and yes it has that functionality. The documentation on the NRF52 could use some editing - a few steps were missing/unexplained. Thanks.
https://micropython.org/webrepl/? does not allow me to use WebBluetooth :(
This is what I was using: https://glennrub.github.io/webbluetooth/micropython/repl/
There are instructions for adding support for the WebBluetooth here.
https://github.com/adafruit/circuitpython/tree/master/ports/nrf
It is not enabled by default so you will have to create a custom build.
I have done so, and I can access the REPL with this: (https://glennrub.github.io/webbluetooth/micropython/repl/), but unlike (https://micropython.org/webrepl/), there is no option to upload a file so I can get my code running.
Ah - sorry -- I just reread your earlier posts and see that.
Its's not pretty, but I suppose you could compile your code in as a "frozen" module.
rotaryio time!
@jerryneedell Apologies for my ignorance - but how do I create a frozen module?
It's been awhile since I played with this, but there is an example here:
https://github.com/adafruit/circuitpython/tree/master/ports/nrf/freeze
This is compiled into your build. I think any .py file in the "freeze" folder will also get compiled in. You can then invoke it from the REPL. I don't recall if it gets stored as "freeze/test" or as test.
If you look at '''
help('modules') '''
should should see it. I'll try to provide an example tonight or tomorrow if you have not gotten it wor...
see: https://github.com/adafruit/circuitpython/blob/master/ports/nrf/Makefile#L360
for how the Mkefile handles it.
in line 36 FROZEN_MPY_DIR = freeze
@tulip sleet I thought rotaryio was built in?
@slender iron just curious if you found the time to try rosie
Is it only in master and not the current beta.0 release?
@tulip sleet just tested the CPX code I was messing with last night for dano, works on latest seesaw firmware build so that's good
also wow. the seesaw takes up some srs space on the cpx when you start adding in cpx specific things on top of it like neopixels, audioio, etc.
@prime flower All of that is beefy. We've been trimming from everywhere to get any of it to fit into the builds in the first place.
Ok I just built from master and it still says ImportError: no module named 'rotaryio'
Still says I'm running 3.0.0-beta.0 though...
Not sure if that should be different.
π€¦
Somehow it copied the firmware.uf2 to CIRCUITPY. That does not install it.
@tulip sleet When you're around, I need some help with HID multimedia.
just got back from the Y, go ahead
I don't understand it. The only example is in the doc string and it doesn't work as is. I would like to control volume.
rotaryio is only in Express builds right now
This is an Itsy
it wasn't in the beta0 release.
I built a new build for it and it works.
ah ok, good. lemme look at the docstring
hmm, it's not in rtd, I'll look at teh source
I can't find it now in the code
I found it in the PR.
which is the only way I found this at all.
It's not documented anywhere.
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
cc = ConsumerControl()
# Raise volume.
cc.send(ConsumerControlCode.VOLUME_INCREMENT)
# Pause or resume playback.
cc.send(ConsumerControlCode.PLAY_PAUSE)
from the README
Ok the version I found was wrong then
that's different than what I have pasted
let me try the change
There it is!
yeah, you don't talk to Keyboard at all - it's a different device
but I don't understand why rtd is out of date
that was a typo that somebody pointed out that I fixed a while ago, so there's some version skew going on here
Ok, I couldn't find anything else about it so I was going with what I found
Works now.
I now have a rotary encoder volume knob that plays/pauses on press.
there are lot of ConsumerControlCodes I could have added, but most of them don't seem to work! I added the ones that worked on all platforms. http://www.usb.org/developers/hidpage/Hut1_12v2.pdf?page=75
@tulip sleet You added the ones that make the most sense anyway
@idle owl ok, I forgot to add the new files to api.rst in HID, so they weren't included. So I'll fix that. I thought they were included automatically - I forgot I had to do that.
@tulip sleet Ah ok
@tulip sleet In all the CP build stuff, other than the board name in /ports/atmel-samd/boards, ItsyBitsy is two words, Itsy Bitsy. Should we fix that?
Adafruit Itsy Bitsy M0 Express with samd21g18
It's that way in the REPL too.
The product name is two words, though it's not always used consistently
Looks like one word to me.
There's no space there.... It's an Adafruit ItsyBitsy M0 Express!
We could ask. π
who you gonna trust, me or your lying eyes π Seriously, it's kinda inconsistent. From Learn:
Hah!
but the text says "ItsyBitsy" a lot
so yeah, we could change it. Maybe ask Limor in that other chat place
Will do.
no space on silk
you have to pick the names carefully, if you name the smallest board "Gabelstaplerfahrer" it might not fit...
Chinese characters might be easier
I always omit the space.
@idle owl it wasn't checked in for beta.0. Its another reason we should release Beta.1
@slender iron This guide can't be published until it is. I'm going to write it as though the latest release includes it. I'm thinking it'll take longer for the guide than the Beta.1 release.
@onyx hinge I did and it passed! Click the little green arrows next to the latest release here: https://github.com/adafruit/circuitpython/commits/master
@idle owl makes sense. I'm hoping it'll be today or tomorrow. I just need to go heads down and work through this code size exploration π
@slender iron Like I said, I'm sure the guide will take longer. No pressure from me.
you never know π
Ok that's fair.
Either way I'll have things to move onto if I finish it before beta.1 is released. So it's all good.
totally!
@nickzoic Looks like a good start! You may be interested in my pending changes here too: https://github.com/adafruit/circuitpython/compare/master...tannewt:pulseio_too_fast
It's adding some handling for gracefully failing when the input signal causes the interrupt to swamp the main code.
@tulip sleet One word.
k - I can fix that in a future PR for adafruit/circuitpython or you can now if you want.
I can try. I have no idea where it is.
In the boards/itsybitsy_m0_express directory somewhere is my guess.
ports/atmel-samd/boards/itsybitsy_m{0,4}_express/mpconfigboard.{mk,h}
ooh I was right
there's an itsy m4 dir as well. there are strings in both files
Ok
grep Itsy */*
itsybitsy_m0_express/mpconfigboard.h:#define MICROPY_HW_BOARD_NAME "Adafruit Itsy Bitsy M0 Express"
itsybitsy_m0_express/mpconfigboard.mk:USB_PRODUCT = "Itsy Bitsy M0 Express"
itsybitsy_m4_express/mpconfigboard.h:#define MICROPY_HW_BOARD_NAME "ItsyBitsy M4 Express"
itsybitsy_m4_express/mpconfigboard.mk:USB_PRODUCT = "ItsyBitsy M4 Express"
M4 is correct
@tulip sleet Do we want Adafruit on the front of them for consistency? As long as I'm in here.
I assume the .h file string is what shows up in the REPL and maybe boot_out.txt
@idle owl Yes, that's right. You can check all the boards. I think they should say "Adafruit"
Removed space in ItsyBitsy for M0, and added "Adafruit" to M4 name.
@idle owl can you add "Adafruit" to the other boards that are missing it:
$ grep BOARD_NAME */mpconfigboard.h
...
***feather_m4_express/mpconfigboard.h:#define MICROPY_HW_BOARD_NAME "Feather M4 Express"
***itsybitsy_m4_express/mpconfigboard.h:#define MICROPY_HW_BOARD_NAME "ItsyBitsy M4 Express"
***metro_m4_express/mpconfigboard.h:#define MICROPY_HW_BOARD_NAME "Metro M4 Express"
...
Just push another commit - it will update automatically.
k thanks I'll wait for travis and then merge
keen
@slender iron updated: https://github.com/adafruit/CircuitPython_Community_Bundle/pull/9
@reef seal looks like you tagged 7149579 but the pr is for c24f56
in your repo change into the submodule directory and git pull
then change out and it should show in git status
Got it, done
So, in the future when I make a new release of the library, I need to do another pull request into github.com/adafruit/CircuitPython_Community_Bundle in order for it to be included? Is that right?
I don't think so. adabot should update automatically
but keep an eye on it to make sure
Cool ππΌ
π thanks!
Here is an example executing the freeze/test.py build into the current master
Adafruit CircuitPython 3.0.0-beta.0-43-gde61bd0 on 2018-06-02; Bluefruit nRF52 Feather with NRF52832
>>>
>>>
>>> import test
>>> test.hello()
Hello nrf52!
>>>
better example- I copied thhese files to the freeze folder"
erryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_master/ports/nrf$ cat freeze/blinky.py
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED2)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
jerryneedell@Ubuntu-Macmini:~/projects/adafruit_github/circuitpython_maste...
building code tnit "freze" is certainly not ideal for testing but it does work if you have no other way to get code uploaded. It would be great to have upload capability added to the BLE REPL
Good luck!
We've added travisci to the Learn guide repo which changed the workflow needed to submit code to the repo. I am going to build on the current GitHub/git guide to outline an example workflow for CircuitPython and Learn.
I think this may work better as a standalone guide that lists the current guide as required reading, and then links to it when needed instead of explaining the concepts. The workflow I'm going to include should be included in full which means some duplication of the info in ...
Is the rotary encoder we sell mechanical?
yes
@slender iron are you available for a video chat about the PDMIn problem?
sure
sure
how many pwm channels can I have on the samd21?
with CP
I guess I have to try and see
hmm, test inconclusive
Hey folks, the NEW Crickit boards that work with Adafruit Feather microcontrollers are fresh into the shop https://www.adafruit.com/product/3343
Hmm. I feel like that was discussed in a guide somewhere. But it's fuzzy.
in any case, I doubt I can get 12
@stuck elbow for what? all of the same base frequency?
@stuck elbow did you get geektrapped by the "top octave oscillator" problem, or is it just coincidence that you're looking for 12 independent timers?
@slender iron all 50Hz, for servos
ah nevermind then
@stuck elbow you should be able to do more with TCC sharing
how do I do that?
@tulip sleet I was wondering about that, seemed like it took forever for travis to run.
it's been terrible. There was another PR that I hard to restart three jobs on.
@stuck elbow it should do it automatically. what code and board are you using?
I tested with Fether M0 Express, with this code:
import board, pulseio
pins = [board.D1, board.D5, board.D6, board.D9, board.D10, board.D11, board.D12, board.D13, board.SDA, board.SCL, board.RX, board.TX, board.D0, board.MOSI, board.MISO, board.SCK]
pwms = []
for pin in pins:
print(pin)
pwms.append(pulseio.PWMOut(pin, frequency=50))
and it errors out after 3rd pin
board.D1
board.D5
board.D6
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
RuntimeError: All timers in use
so only creates 2 pwms
hrm, I think thats a bug
@stuck elbow could also be influenced by the order of the pins, since you can't map all tc's to all pins
I checked the multiplexing of the first four pins and it seems ok