Commit Graph

571 Commits

Author SHA1 Message Date
Lionel Debroux b0c2c3c756 A couple build fixes for mp_float_t = double (MICROPY_FLOAT_IMPL_DOUBLE).
Signed-off-by: Lionel Debroux <lionel_debroux@yahoo.fr>
2019-02-17 11:21:48 +01:00
sommersoft ea9200a042 starting again; initial addition of 'frequencyio.FrequencyIn' 2019-02-16 19:26:24 -06:00
Dan Halbert a345ef28f2 finish Makefile refactoring; nrf builds work 2019-02-15 18:55:10 -05:00
Dan Halbert 5154e0581e WIP: atmel-samd trinket build works 2019-02-15 00:28:20 -05:00
Dan Halbert 379258112a
Merge pull request #1548 from tannewt/shape_arg_check
Arg check width and height into Shape.
2019-02-14 07:42:39 -05:00
Scott Shawcroft b13adfc228
Arg check width and height into Shape.
Fixes #1537
2019-02-13 17:34:39 -08:00
Scott Shawcroft 473bdf48f6
A safe mode fix and displayio fixes
* Fixes safe mode on the SAMD51. The "preserved" value was being
clobbered by the bootloader.
* Fixes auto-reload loop when in safe mode.
* Fixes reading Group children with [].
* Check that a TileGrid actually moves before queueing a refresh.
2019-02-13 15:31:06 -08:00
TG-Techie e674f11df2
Update Shape.c 2019-02-12 19:16:27 -05:00
Scott Shawcroft 1e16b3e134
Tweaks based on dhalbert's feedback. 2019-02-12 14:18:53 -08:00
Scott Shawcroft b4306314aa
Move terminal font to terminalio from board. 2019-02-12 10:10:02 -08:00
Scott Shawcroft 5258bc4318
Fixup doc reference 2019-02-11 20:55:06 -08:00
Scott Shawcroft c17f147be9
A variety of displayio improvements
This changes a number of things in displayio:
* Introduces BuiltinFont and Glyph so the built in font can be used by libraries. For boards with
  a font it is available as board.TERMINAL_FONT. Fixes #1172
* Remove _load_row from Bitmap in favor of bitmap[] access. Index can be x/y tuple or overall index. Fixes #1191
* Add width and height properties to Bitmap.
* Add insert and [] access to Group. Fixes #1518
* Add index param to pop on Group.
* Terminal no longer takes unicode character info. It takes a BuiltinFont instead.
* Fix Terminal's handling of [###D vt100 commands used when up arrowing into repl history.
* Add x and y positions to Group plus scale as well.
* Add bitmap accessor for BuiltinFont
2019-02-11 20:55:05 -08:00
Craig Forbes de43911a68 Remove usb_midi.PortIn and PortOut constructors. 2019-02-06 22:22:15 -06:00
Scott Shawcroft 845783a457
Clarify rotation parameter 2019-02-01 09:33:33 -08:00
Scott Shawcroft 448ae64d8e
Add support for display rotation and raw commands
Display rotation is relative to the scan order of the display.
The scan order can be found by scrolling the display with command
0x37 `display_bus.send(0x37, struct.pack(">H", i % 128))`

Fixes #1504
2019-02-01 00:32:03 -08:00
Scott Shawcroft d72cd5b2d6
Correct TileGrid class name. 2019-01-31 11:42:15 -08:00
Scott Shawcroft 354a26963b
Correctly handle no backlight pin. 2019-01-31 11:42:15 -08:00
Scott Shawcroft 2c069a5685
Polish up comments 2019-01-31 11:42:15 -08:00
Scott Shawcroft 73bc614a4b
Remove doc reference to Sprite 2019-01-31 11:42:15 -08:00
Scott Shawcroft ec03887040
Fix hallowing and nrf builds 2019-01-31 11:42:15 -08:00
Scott Shawcroft 4672866eec
Remove Sprite references 2019-01-31 11:42:14 -08:00
Scott Shawcroft 601a910f4e
More improvements to Terminal:
* Fix Hallowing.
* Fix builds without displayio.
* Fix y bounds that appears as untrollable row of pixels.
* Add scrolling to TileGrid.
* Remove Sprite to save space. TileGrid is a drop in replacement.
2019-01-31 11:42:14 -08:00
Scott Shawcroft 6145f08cc8
Support adjustable backlight brightness 2019-01-31 11:42:14 -08:00
Scott Shawcroft 69bc5e189b
Rudamentary backlight support 2019-01-31 11:42:14 -08:00
Scott Shawcroft 1a1dbef992
Hook up the terminal based on the first display. 2019-01-31 11:42:14 -08:00
Scott Shawcroft fb0970ec6e
Add terminalio 2019-01-31 11:42:13 -08:00
Scott Shawcroft 73cf490635
Add TileGrid 2019-01-31 11:42:13 -08:00
Jerry Needell 44bd9d1013 fix kw_arg checking for time.struct_time() 2019-01-25 14:57:31 -05:00
Dan Halbert 04aa906fac fix a few ble-related doc issues 2019-01-24 00:13:15 -05:00
Scott Shawcroft a380865655
Merge remote-tracking branch 'adafruit/master' into HEAD 2019-01-22 14:02:07 -08:00
Dan Halbert e170e03f8c Merge remote-tracking branch 'adafruit/master' into bleio2 2019-01-21 20:38:26 -05:00
Scott Shawcroft 2bcf81fb9e
Merge pull request #1479 from siddacious/master
adding height and width to OnDiskBitmap for #1460
2019-01-21 00:32:49 -08:00
Bryan Siepert ab2ad7ba45 adding height and width to OnDiskBitmap for #1460 2019-01-20 22:33:22 -08:00
Dan Halbert a8f4aa4796 Merge remote-tracking branch 'adafruit/master' into struct-compat 2019-01-20 21:47:13 -05:00
Dan Halbert 7a09af73ec Improve struct compatibility with CPython 2019-01-20 15:12:34 -05:00
Dan Halbert 62df7ab730 Improve struct compatibility with CPython 2019-01-20 15:10:09 -05:00
Dan Halbert 28cfd8a513 CharacteristicBuffer: make it be a stream class; add locking 2019-01-19 19:45:35 -05:00
Roy Hooper 02266eafd8 adjust comment 2019-01-19 17:04:24 -05:00
Roy Hooper 8fa81fe003 move headers to __init__.h 2019-01-19 17:03:16 -05:00
Roy Hooper 79d9c9cd56 remove fill_wheel 2019-01-19 17:01:31 -05:00
Roy Hooper b82e1d7fcb Fix build to work with constructor calling convention. 2019-01-19 16:54:21 -05:00
Roy Hooper 50af08a6f3 Merge branch 'master' into pixelbuf 2019-01-19 16:33:59 -05:00
Scott Shawcroft b41d386d02
simplify arg checking for display 2019-01-18 17:04:18 -08:00
Scott Shawcroft edc8383e22
Improvements thanks to danh's review 2019-01-18 16:37:06 -08:00
Scott Shawcroft dc024cf411
Add a bit more to the docs 2019-01-18 12:59:23 -08:00
Scott Shawcroft 6404aaf411
Fix up nrf and using board.SPI in FourWire 2019-01-17 18:19:07 -08:00
Scott Shawcroft 760bd8d8a4
share fourwire and make nrf compile 2019-01-17 15:15:59 -08:00
Scott Shawcroft 2d136d58bf
Fix other builds and hallowing 2019-01-17 14:45:29 -08:00
Scott Shawcroft 84292ad890
External fourwire works and blinka splash after 2019-01-17 00:20:16 -08:00
Dan Halbert 7a33e588d4 Put back native C UUID string parsing and printing (complete rewrite) 2019-01-16 20:41:01 -05:00
Scott Shawcroft 05d8885a1a
Rework displays in prep for dynamic support and 8bit parallel. 2019-01-16 12:05:20 -08:00
Scott Shawcroft bd3c36ce6d
fixup m0 and nrf 2019-01-14 18:08:45 -08:00
Scott Shawcroft 747f2cfe26
Add subclass support to displayio.
Also, swap make_news to accept a kwarg map and refine param checking.

Fixes #1237
2019-01-14 17:29:19 -08:00
Scott Shawcroft 619bc4caae
Support subclasses of Shape as bitmaps. 2019-01-14 17:29:18 -08:00
Scott Shawcroft a14762a16c
Add support for rendering a shape.
Fixes #1171
2019-01-14 17:29:15 -08:00
Roy Hooper ffe734edf7 Fresh combined checkin of _pixelbuf library. 2019-01-13 23:51:13 -05:00
Dan Halbert 50ee5ef24c merge translations; add bleio comments; fix minor sphinx issues in midi 2019-01-10 21:12:17 -05:00
Scott Shawcroft 3dd59c3d5f
Polish thanks to Dan's feedback 2019-01-10 11:00:40 -08:00
Dan Halbert d3b8581ce0 fix merge conflicts; address some comments 2019-01-09 19:59:48 -05:00
Scott Shawcroft b5e40f52c2
Add USB MIDI support for SAMD and nRF.
The API should be identical to using a UART for MIDI.

Fixes #672
2019-01-09 14:02:11 -08:00
Dan Halbert e47decbdc5 improve travis fold status reporting; fix sphinx build; fix sphinx errors 2019-01-09 13:32:45 -05:00
Dan Halbert 89af666093 fix sphinx complaint; more travis fold status reporting 2019-01-09 10:36:38 -05:00
Dan Halbert f66f55b4ed add CharacteristicBuffer; UART seems to work! 2019-01-07 22:46:20 -05:00
Dan Halbert a77b2363ef evt handler list bugs; unique evt handler names; remove uuid128_reference 2019-01-03 21:42:42 -05:00
Dan Halbert ccb3c6fac6 Remove print methods from bleio; Python lib will do it 2019-01-03 10:51:49 -05:00
Dan Halbert c46d06f34c Move 128-bit UUID string parsing to Python; simplify UUID API 2019-01-02 23:11:03 -05:00
Dan Halbert 87c6f33bcc Broadcaster now takes whole packet. Also should be scannable 2019-01-01 14:11:59 -05:00
Dan Halbert b6b5ed9c89 Remove nRF52832 support 2018-12-30 22:49:20 -05:00
Dan Halbert 1dc3957e72 LocalPeripheral is now Peripheral; more work on basic GATTS support; UART not working yet 2018-12-30 22:33:49 -05:00
Dan Halbert ef39e72c7c free event handlers on reset; fix typo in Broadcaster 2018-12-29 13:55:10 -05:00
Dan Halbert 4d1f0ec07b Add Broadcaster. Reset correctly on reload. 2018-12-28 23:34:23 -05:00
Dan Halbert 4167bf5b24 wip: advertising works, but not connection 2018-12-27 00:04:04 -05:00
Dan Halbert a7a24096f4 bleio WIP: redo for more immutability; use sd_* routines for internal flash write 2018-12-07 16:52:47 -05:00
Dan Halbert 125901e4e2 Merge remote-tracking branch 'adafruit/master' into bleio-rev 2018-12-06 12:41:38 -05:00
Dan Halbert 63cd9209f1 allow KeyboardInterrupt on UART read; fix nrf UART pin claiming; rename feather 52840 UART pins 2018-12-04 15:05:39 -05:00
Scott Shawcroft 1b4359eaec
Merge pull request #1372 from dhalbert/pyserial-compat-for-uart
UART changes: timeout in secs, write bytes, etc.
2018-12-03 14:20:44 -08:00
Dan Halbert 80db2cec99 UART changes: timeout in secs, write bytes, etc. 2018-12-03 12:04:32 -05:00
Dan Halbert 72e3cfdfb8 Fix arg type for AudioOut(..., quiescent_value=...) 2018-12-03 11:20:33 -05:00
Dan Halbert 3164b16196 WIP: debug; add hash and __eq__ to UUID 2018-11-26 21:09:17 -05:00
Dan Halbert 1763ffe245 More UUID work; use mp_raise for exceptions 2018-11-20 23:04:58 -05:00
Dan Halbert c424ad844b Merge remote-tracking branch 'adafruit/master' into bleio-rev 2018-11-20 14:47:05 -05:00
Dan Halbert 31cc71f7fb WIP: bleio revisions 2018-11-20 09:36:45 -05:00
Carlos 060b84a0fa Remove reference to clock_id on the function descriptiions 2018-11-18 10:43:28 -06:00
Carlos 55a9e2d697 Fix time.monotonic_ns docstring 2018-11-18 10:41:35 -06:00
Scott Shawcroft 355abc835e
Fix output overflow and make help translatable 2018-11-09 16:41:08 -08:00
Scott Shawcroft 9d91111b1b
Move atmel-samd to tinyusb and support nRF flash.
This started while adding USB MIDI support (and descriptor support is
in this change.) When seeing that I'd have to implement the MIDI class
logic twice, once for atmel-samd and once for nrf, I decided to refactor
the USB stack so its shared across ports. This has led to a number of
changes that remove items from the ports folder and move them into
supervisor.

Furthermore, we had external SPI flash support for nrf pending so I
factored out the connection between the usb stack and the flash API as
well. This PR also includes the QSPI support for nRF.
2018-11-08 17:25:30 -08:00
Dan Halbert 64d457dad9 bring bleio PR up to date 2018-11-07 14:12:22 -05:00
caternuson 55cbeb6fc6 in doc string as well 2018-11-05 14:49:24 -08:00
caternuson 85fbdefe77 change channels to channel_count 2018-11-05 08:05:43 -08:00
caternuson 46f1a0719e add channels and bits_per_sample to audioio.WaveFile 2018-10-31 18:08:10 -07:00
Nick Moore f6482699a0 Merge remote-tracking branch 'origin/master' into circuitpython/nickzoic/703-wiznet-5500-native 2018-10-25 12:20:50 +11:00
Nick Moore b714f5d650 Add "dhcp" property to turn DHCP on and off 2018-10-25 11:29:27 +11:00
Jeff Epler ec1aec1921 shared-bindings/time: introduce time.monotonic_ns
This is intended to be compatible with Python 3.7's time.monotonic_ns.
The "actual resolution" is 1ms due to this being the unit at which
common_hal_time_monotonic ticks.

Closes #519
2018-10-21 10:22:52 -05:00
arturo182 4bc24c4f60 bleio: Fix errors after rebase 2018-10-21 17:15:27 +02:00
arturo182 c62b708012 bleio: Fix docs error 2018-10-21 16:00:15 +02:00
arturo182 5354aeab4c bleio: Allow using len() on UUID 2018-10-21 16:00:12 +02:00
arturo182 13dd27a047 bleio: Remove UUID static variables 2018-10-21 16:00:08 +02:00
arturo182 eceb21a017 bleio: Don't register the services until needed
Because of the very specific way nRF requires service registration
(characteristics can be added only to last added service), we would
have to write the Python code in a specific way. With this patch the
user has more freedom.
2018-10-21 16:00:04 +02:00
arturo182 ad466b3edb bleio: Let Characteristic inherit the Services UUID length 2018-10-21 16:00:01 +02:00
arturo182 beee58a56f bleio: Add scan_entry as an param for the Device constructor 2018-10-21 15:59:57 +02:00
arturo182 684f2673ce bleio: Remove unneeded TODO 2018-10-21 15:59:53 +02:00
arturo182 19fab4af5a bleio: Remove deep copy constructor for UUID 2018-10-21 15:59:50 +02:00
arturo182 b5e5805bb4 bleio: Remove redundant struct field 2018-10-21 15:59:46 +02:00
arturo182 c7b42d80b3 bleio: A bit of cleanup 2018-10-21 15:59:42 +02:00
arturo182 17f13ecc2c nrf: Cleanup of the ble driver
Moved the functions to classes that they belong to.
2018-10-21 15:54:13 +02:00
arturo182 a126897f52 bleio: Fix incorrect role detection 2018-10-21 15:51:08 +02:00
arturo182 5412bf66c3 bleio: Improve type documentation 2018-10-21 15:50:53 +02:00
arturo182 3bd65fbae5 nrf: Move the Peripheral class to bleio as Device
This was the last class from ubluepy and so that module is now gone.
The Device class offers both Peripheral and Central functionality.
See the inline docs for more info.
2018-10-21 15:50:45 +02:00
arturo182 bda734223e nrf: Move the Service class from ubluepy to the shared bleio module 2018-10-21 15:43:51 +02:00
arturo182 cc78249226 nrf: Move the Characteristic class from ubluepy to the shared bleio module 2018-10-21 15:43:48 +02:00
arturo182 1c6bf9a150 bleio: Move the Scanner class to a shared module 2018-10-21 15:43:29 +02:00
arturo182 7390dc7dab bleio: Move ScanEntry to shared module and add a new AdvertisementData class 2018-10-21 15:43:24 +02:00
arturo182 345334aaf1 bleio: Add a new Address class
Use the new in the Adapter singleton.
2018-10-21 15:43:21 +02:00
arturo182 d5f942a971 bleio: Add a AddressType enum-like class 2018-10-21 15:43:17 +02:00
arturo182 20b8d5169d nrf: Move the Descriptor class from ubluepy to the shared bleio module 2018-10-21 15:43:13 +02:00
arturo182 f4940c9aec nrf: Move the UUID class from ubluepy to the shared bleio module
Also added a UUIDType enum-like class for determining UUID type.
2018-10-21 15:43:08 +02:00
Scott Shawcroft 4eb1fe18e5
Tweaks from feedback:
* default_value is now quiescent_value
* Use step = -step format for sign switch
* Add note about analogout_reset being empty
2018-10-17 11:31:08 -07:00
Scott Shawcroft c209165d43
Ramp values to and from a default value while active.
This reduces the popping sound on initial playback of an audio
sample.

The M4 DAC has a pop on startup that cannot be prevented. It also
does not allow readback so current values of the DAC are ignored.

Fixes #1090
2018-10-16 16:23:29 -07:00
Dan Halbert 2262efc311 PulseOut working 2018-10-16 11:05:02 -04:00
Nick Moore 06894be294 timer ticks for DHCP state machine for wiznet 2018-10-16 23:10:18 +11:00
Nick Moore 5bb12793a0 update documentation and translations again 2018-10-11 22:19:46 +11:00
Nick Moore a4a0cf826b fix doc comments, translations again 2018-10-11 17:02:29 +11:00
Nick Moore bb239052ea Split wiznet driver into shared-bindings vs shared-module 2018-10-11 15:05:25 +11:00
Nick Moore aab28748bb Merge remote-tracking branch 'origin/master' into circuitpython/nickzoic/703-wiznet-5500-native 2018-10-11 14:19:10 +11:00
Nick Moore 823ff779ca network module c api into shared-module 2018-10-11 14:02:18 +11:00
Dan Halbert 8d58093328
Merge pull request #1259 from dhalbert/nrf-pwmout
Allow variable freq PWMOut; use multiple channels if same freq
2018-10-10 12:27:27 -04:00
Scott Shawcroft df80ad8e6e
Merge pull request #1193 from ATMakersBill/master
Add supervisor.runtime.serial_bytes_available so that input() can be used without blocking.
2018-10-09 23:58:43 -07:00
Scott Shawcroft 0688709c4f
Move the docs next to the implementation 2018-10-09 23:15:25 -07:00
ATMakersBill 05d4b8cf50 Added Documentation for the serial_bytes_available attribute 2018-10-09 22:50:59 -04:00
Dan Halbert 91a88cf568 Allow variable freq PWMOut; use multiple channels if same freq 2018-10-09 20:52:55 -04:00
ATMakersBill 9f94712ad1 replacing change to input() with separate method to check for USB Serial input 2018-10-09 18:37:52 -04:00
Scott Shawcroft 6da25c8893
Rename stop to stop_voice in case we want stop to stop everything later. 2018-10-09 13:28:00 -07:00
Nick Moore 6d9c2c5254 Documentation builds (though has no real content yet) 2018-10-09 22:37:49 +11:00
Nick Moore a60700b1c5 Get DHCP working ... 2018-10-09 16:28:30 +11:00
Nick Moore 9b36d33df1 move random mac address function into network module 2018-10-09 13:12:04 +11:00
Nick Moore 6e624b9c6a Split wiznet.WIZNET5K off into its own file 2018-10-09 13:05:58 +11:00
Nick Moore 4b767ff080 Change WIZNET5K.isconnected to connected property 2018-10-09 12:24:24 +11:00
Scott Shawcroft 15d80a8c46
Fix doc build 2018-10-05 15:19:08 -07:00
Scott Shawcroft 76008ce304
Introduce audioio.Mixer which can mix multiple audio samples
to produce a single sample.

Only works with 16 bit samples on the M4.

Fixes #987
2018-10-05 15:12:23 -07:00
Nick Moore 15b59bee1b change initialization method + mod_network names 2018-10-04 22:31:47 +10:00
Nick Moore d33f6214f1 modify modnetwork and modusocket for circuitpython 2018-10-04 22:02:25 +10:00
Nick Moore f4c32139f5 Copy modnetwork and modusocket across from MicroPython 2018-10-04 22:02:25 +10:00
Nick Moore 27fc84a157 Modify wiznet module for circuitpython 2018-10-04 22:02:25 +10:00
Nick Moore 3c32d046bf Copy wiznet module across from MicroPython 2018-10-04 21:22:09 +10:00
Dan Halbert 21d331c8cc round SPI freq down; check max freq 2018-10-02 21:06:40 -04:00
Dan Halbert aa95526428 nrf: remove error check for SPI baudrate too high; round to nearest baudrate 2018-10-01 18:54:13 -04:00
Dan Halbert bc510e714f merge 3.0.2 to master 2018-09-18 15:38:12 -04:00
Scott Shawcroft f21cf15c38
Add OnDiskBitmap which loads pixel data straight from disk.
Also, renamed Sprite's palette to pixel_shader so it can be
anything that produces colors based on values (including color values).
Added a ColorConverter that converts RGB888 (found in bitmaps) to
RGB565 for the display.

Fixes #1182
2018-09-12 15:25:59 -07:00
Dan Halbert 6a046f55c4 UART fixes and enhancements; default board object fix 2018-09-12 17:19:43 -04:00
Scott Shawcroft 06a610fd0c
Merge pull request #1166 from dfarning/clean-up-docs
Reorder status matrix and module list in shared-bindings for increase…
2018-09-07 12:02:23 -07:00
David Farning 62fab2e9c4 Reorder status matrix and module list in shared-bindings for increase user read ability 2018-09-07 03:30:28 -05:00
Scott Shawcroft 86288f14f1
Merge translations and update title underline 2018-09-06 14:56:26 -07:00
Scott Shawcroft 1683eb913d
Minor tweaks based on feedback 2018-09-06 14:49:49 -07:00
Scott Shawcroft 121903b6ee
Tweaks based on feedback 2018-08-31 14:21:48 -07:00
Scott Shawcroft 6697544cdf
Introduce displayio to render graphics to displays.
It's designed to minimize RAM footprint by using Sprites to
represent objects on the screen. The object model also facilitates
partial screen updating which reduces the bandwidth needed to display.

This is all handled in C. Python simply manipulates the objects with
the ability to synchronize to frame timing.
2018-08-31 12:31:52 -07:00
Noralf Trønnes 39ee12d1ac Fix os.stat() to use 1970 epoch
Commit 95e70cd0ea 'time: Use 1970 epoch' changed epoch for the time
module, but not for other users. This patch does the same for the only
other core timeutils user: extmod/vfs_fat.c:fat_vfs_stat().
Other timeutils users: cc3200, esp8266 and stm32, are not changed.

Ports that don't use long ints, will still get wrong time values from
os.stat().
2018-08-25 20:43:02 +02:00
Noralf Trønnes eefb6842a0 i2cslave: Fix missing translate() when raising exceptions
The translate() changes where applied after travis had checked the
i2cslave PR so this wasn't caught.
2018-08-18 16:00:06 +02:00
Scott Shawcroft 4a4d84ba42
Merge pull request #1064 from notro/i2cslave
Add busio.I2CSlave
2018-08-17 16:51:45 -07:00
Scott Shawcroft de5a9d72dc
Compress all translated strings with Huffman coding.
This saves code space in builds which use link-time optimization.
The optimization drops the untranslated strings and replaces them
with a compressed_string_t struct. It can then be decompressed to
a c string.

Builds without LTO work as well but include both untranslated
strings and compressed strings.

This work could be expanded to include QSTRs and loaded strings if
a compress method is added to C. Its tracked in #531.
2018-08-16 17:40:57 -07:00
Noralf Trønnes 11cbeb87ad ports/atmel-samd: Implement i2cslave.I2CSlave
This adds support for SAMD acting as a I2C slave in polled mode.
2018-08-16 17:20:49 +02:00
Noralf Trønnes 1ed0e45fc2 Add i2cslave.I2CSlave bindings 2018-08-16 17:11:20 +02:00
Scott Shawcroft 96ebf5bc3f
Two fixes and translate more strings.
* Fix finding translations with escaped characters.
* Add back \r to translations since its needed by screen.
2018-08-09 13:29:30 -07:00
Jeff Epler e1b4e9b7c7 UART: Always allocate UART objects in the long-lived pool
Particularly when they have buffers that are written via IRQ or DMA,
UART objects do not relocate gracefully.  If such an object is
relocated to the long-lived pool after its original creation, the
IRQ or DMA will write to an unexpected location within the Python
heap, leading to a variety of symptoms.  The most frequent symptom
is inability to read from the UART.

Consider the particular case of atmel-samd: usart_uart_obj_t
contains a usart_async_descriptor contains a _usart_async_device.
In _sercom_init_irq_param the address of this contained
_usart_async_device is assigned to a global array
sercom_to_sercom_dev which is later used from the interrupt context
_sercom_usart_interrupt_handler to store the received data in the
right ring buffer.

When the UART object is relocated to the long-lived heap, there's no
mechanism to re-point these internal pointers, so instead take the
cowardly way and allocate the UART object as long-lived.

Happily, almost all UART objects are likely to be long-lived, so
this is unlikely to have a negative effect on memory usage or heap
fragmentation.

Closes: #1056
2018-08-08 19:21:57 -05:00
Scott Shawcroft 933add6cd8
Support internationalisation. 2018-08-07 14:58:57 -07:00
Dan Halbert dfa2581ffd
Merge pull request #1057 from tannewt/flexible_heap
Add basic memory allocation outside Python runtime
2018-08-02 18:43:06 -04:00
Scott Shawcroft 168aa394db
Move pin struct to the peripherals library.
Its slimmed down by removing the qstr and bit packing TCC info.

The trinket m0 build actually grows by 20 bytes. The arduino zero
build shrinks by 188 bytes.
2018-08-02 13:59:05 -07:00
Dan Halbert 761f9a938e
Merge pull request #1075 from tannewt/more_mp_raise
Use more mp_raise_* to save 28 bytes code size.
2018-07-31 19:09:10 -04:00
Scott Shawcroft 0bf999f52a
Use more mp_raise_* to save 28 bytes code size. 2018-07-31 13:50:48 -07:00
Scott Shawcroft a88cdaca6a
Remove rogue execute bit. Must a common incorrect shortcut for me. :-) 2018-07-31 12:42:21 -07:00
Scott Shawcroft 12cf5e51c2
Allow for resizing the stack area. 2018-07-31 05:18:23 -07:00
Scott Shawcroft 777542c716
Add basic memory allocation outside Python runtime
This allows for the heap to fill all space but the stack. It also
allows us to designate space for memory outside the runtime for
things such as USB descriptors, flash cache and main filename.

Fixes #754
2018-07-31 05:18:03 -07:00
Dan Halbert f48b70050e merge finished 2018-07-28 13:29:47 -04:00
Dan Halbert 2809b4f9dd Merge branch 'master' into micropython-25ae98f-merge 2018-07-16 19:36:40 -04:00
Dan Halbert e2e01efa84 compiles and runs; hangs on import storage;storage.VfsFat.<tab> 2018-07-13 22:51:10 -04:00
arturo182 05c1384b67 nrf: Split the ble module into a shared part and the port implementation
This allows other ports to implement these shared bindings.
2018-07-13 16:01:15 +02:00
Kattni Rembor a10c61ef89 Fixed issue with code in docs for audioio
Removed incorrect arg from RawSample in AudioOut example code.
Replaced variable sample with dac.
2018-06-29 16:46:25 -04:00
Dan Halbert 327b0f76da fix os.listdir() when current dir is '/' 2018-06-15 10:51:03 -04:00
Scott Shawcroft 2fbab8067a Prevent freezing USB during high frequency PulseIn.
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
2018-06-08 12:56:32 -07:00
Kattni Rembor 3a38172627 Fixed documentation formatting for RTD 2018-06-06 18:28:01 -04:00
Scott Shawcroft 717199018b Adapt for feedback and hack around pIRkey size constraint. 2018-06-01 15:08:52 -07:00
Scott Shawcroft d0fb6e7a2f atmel-samd: Add rotary encoder support.
Fixes #283
2018-06-01 15:08:48 -07:00
Scott Shawcroft fd71e56891 atmel-samd: Re-org helper peripheral files into their own subdirectory.
Ideally in the future they won't depend on ASF4 or MicroPython.
2018-06-01 15:07:31 -07:00
Radomir Dopieralski b219ce6d37 Add gamepad_singleton to root pointers 2018-05-30 23:11:22 +02:00
Radomir Dopieralski c37b69e1a5 Make the gamepad singleton long-lived
So that it is not later moved.
2018-05-30 23:11:22 +02:00
Radomir Dopieralski 42e36a883b Remove volatile from the gamepad struct 2018-05-23 21:49:20 +02:00
Radomir Dopieralski f17a235b40 Raise an error if more than 8 buttons passed to gamepad 2018-05-23 21:41:56 +02:00
Radomir Dopieralski 240678e714 Avoid uninitialized gamepad on exception
Raise exceptions before the gamepad_singleton is created.
Also, use mp_raise for creating the exceptions.
2018-05-23 21:39:06 +02:00
Radomir Dopieralski edf2935ab1 Make gamepad.get_pressed work when gamepad was created from frozen code
For some reason, when the GamePad is created from frozen code, the
get_pressed method would always return 0. This fixes it, and makes it
work properly no matter how the object was created.
2018-05-23 12:44:22 +02:00
Radomir Dopieralski 52d05bbc37 Cache pullup state in gamepad
Don't check the pin's pull direction on every tick, instead cache it
at the beginning. Also avoid a "can't get pull of output pin" error
when one of the pins passed is in output mode.
2018-05-23 11:26:16 +02:00
Scott Shawcroft be12e07d74
Merge pull request #846 from notro/epoch1970
time: Use 1970 epoch
2018-05-19 12:30:34 -05:00
jerryneedell 1d9bcc5ddf
fix doc error in audioOut.c
fixes #851
2018-05-19 10:41:36 -04:00
Noralf Trønnes 95e70cd0ea time: Use 1970 epoch
Use UNIX epoch to match CPython.
This overflows small int so time.{time,localtime,mktime} is only supported with long int.
Also remove some comment cruft in time_time().
2018-05-18 12:35:33 +02:00
Scott Shawcroft 6a8db03ade
Merge pull request #838 from rhooper/master
add supervisor.reload() to soft reboot from code
2018-05-16 17:52:16 -04:00
Scott Shawcroft 918d30cb97
Rephrase the doc 2018-05-16 16:28:43 -05:00
Roy Hooper 92b1cb5743 move reload exception to reload.c 2018-05-14 17:41:17 -04:00
Roy Hooper 698912633f Rename reload_next_character to reload_requested to make it match it's intended use 2018-05-14 17:00:38 -04:00
Roy Hooper 567f3e30a7 Initial implementation of supervisor.reload() 2018-05-14 16:57:50 -04:00
Jerry Needell d6c26942a5 add timeout keyword to I2C - for bitbangio - ignored for busio 2018-05-13 21:54:44 -04:00
dean 82b5efa7bc remove unnecessary comment 2018-05-09 15:14:26 -04:00
dean fba1e221c6 DM: add kwargs to bitbangio spi 2018-05-09 15:12:42 -04:00
Scott Shawcroft fc7c25af6d Make resume idempotent (allowing you to call it twice without complaining.) 2018-05-08 13:00:05 -07:00
Scott Shawcroft 24116eff23 Tweak exception message. 2018-05-08 12:44:27 -07:00
Scott Shawcroft 50fc90bc5f Add pause/resume control to AudioOut and I2SOut
Fixes #808
2018-05-08 11:53:13 -07:00
Jeff Epler 2955ada22f docs: fix references to uhashlib 2018-05-06 12:31:54 -05:00
Jeff Epler 647ff387d9 docs: fix references to ubinascii 2018-05-03 09:34:43 -05:00
Scott Shawcroft cfea51ec68 Re-enable PDMIn without ASF and using the helpers added with
I2SOut.

The API is almost the same except the frequency attribute has been
renamed to sample_rate so that its less likely to be confused with
frequencies within the audio itself.

Fixes #263.
2018-05-01 14:35:43 -07:00
Scott Shawcroft 81d395d825
Merge pull request #745 from notro/time_rtc
RFC: Add rtc module
2018-04-16 15:26:54 -07:00
Scott Shawcroft 301479cd44
Remove "Get or set" 2018-04-16 15:00:58 -07:00
Scott Shawcroft 84d4be279e
Add a table of contents reference to RTC 2018-04-16 15:00:01 -07:00
Noralf Trønnes 8d1719f190 Add rtc module
Add an rtc module that provides a singleton RTC class with
- a datetime property to set and get time if the board supports it.
- a calbration property to adjust the clock.

There's also an rtc.set_time_source() method to override this RTC object using pure python.

The time module gets 3 methods:
- time.time()
- time.localtime()
- time.mktime()

The rtc timesource is used to provide time to the time module.

lib/timeutils is used for time conversions and thus only supports dates after 2000.
2018-04-16 12:49:10 +02:00
Scott Shawcroft 5af4e79ed3 Correct example. Thanks @jepler! 2018-04-13 16:43:21 -07:00
Scott Shawcroft 812fe0c93f Turn on nvm in 3.0.
Its 256b on M0 and 8k on M4 to match flash erase sizes.

Fixes #758
2018-04-13 16:22:28 -07:00
Scott Shawcroft 22194d5977 Tweaks based on dhalbert's feedback. 2018-04-13 10:51:01 -07:00
Scott Shawcroft 28642ab10d Add audio output support!
This evolves the API from 2.x (and breaks it). Playback devices are now
separate from the samples themselves. This allows for greater playback
flexibility. Two sample sources are audioio.RawSample and audioio.WaveFile.
They can both be mono or stereo. They can be output to audioio.AudioOut or
audiobusio.I2SOut.

Internally, the dma tracking has changed from a TC counting block transfers
to an interrupt generated by the block event sent to the EVSYS. This reduces
the overhead of each DMA transfer so multiple can occure without using up TCs.

Fixes #652. Fixes #522. Huge progress on #263
2018-04-12 16:35:13 -07:00
Dan Halbert 5f98953ed8 esp8266 and nrf: raise NotImplementedError 2018-04-10 12:08:41 -04:00
Dan Halbert aa8c262d14 add storage.erase_filesystem() to erase and reformat CIRCUITPY 2018-04-09 12:52:42 -04:00
Scott Shawcroft 4e053cea0d
Merge pull request #628 from sommersoft/super_status
Added Function To Check the Serial Connection From CircuitPython Layer
2018-04-08 22:06:09 -07:00
Dan Halbert 726d5e52a3 Merge branch 'master' into 3.0_hid 2018-04-08 09:52:29 -04:00
sommersoft cc644032ea Merge branch 'super_status' of https://github.com/sommersoft/circuitpython into super_status 2018-04-06 01:58:29 +00:00
sommersoft d1974e0038 supervisor/Runtime: updated documentation for 'no disconnect' 2018-04-06 01:56:51 +00:00
Jeff Epler 92853e611d RunMode: Fix repr(RunMode.BOOTLOADER) 2018-04-05 08:16:53 -05:00
Dan Halbert 435e894fa0 Merge branch 'master' into 3.0_hid 2018-04-02 19:19:43 -04:00
Radomir Dopieralski 6ca4fd82ed Add a type check to the gamepad module
Make sure that all the arguments passed are indeed DigitalInOut.
This avoids crashes when the users pass something else.
2018-03-31 20:41:16 +02:00
Dan Halbert df91878d2e WIP: works with just keyboard but not complex report descriptor 2018-03-30 23:24:00 -04:00
sommersoft 6ee573c7c9
Merge branch 'master' into super_status 2018-03-30 14:27:39 -05:00
Jeff Epler 34f5498760 Document storage.VfsFat more thoroughly 2018-03-27 21:28:19 -05:00
Jeff Epler c08f5a3a00 Add storage.getmount to retrieve the mount object associated with a path 2018-03-27 21:28:18 -05:00
Dan Halbert 31f5b6a238 WIP: simple working HID 2018-03-24 18:29:12 -04:00
Jeff Epler 002797a3b4 Fix array vs pointer error in declaration of circuitpython_help_text
Building with gcc 5.4.1 (Debian Stretch) with the unsupported
-Wno-error=lto-type-mismatch flag removed, the following diagnostic
occurs:

../../py/builtin.h:121:19: error: type of 'circuitpython_help_text' does not match original declaration [-Werror]
 extern const char MICROPY_PY_BUILTINS_HELP_TEXT[];
                   ^
../../shared-bindings/help.c:38:13: note: previously declared here
 const char *circuitpython_help_text =
             ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/arm-none-eabi-gcc returned 1 exit status
2018-03-19 22:11:40 -05:00
Radomir Dopieralski 493c1452f3 _stage: use 16 bit for coordinates to support larger screens 2018-03-11 12:07:23 +01:00
sommersoft 2569b33c84 1 more sphinx fix; added '.. class::' constructor 2018-03-09 21:00:15 +00:00
sommersoft f21038b913 sphinx fix; incorrect currentmodule ref 2018-03-09 20:24:07 +00:00
sommersoft 01471e1e22 sphinx fix; added toctree to include 'runtime' 2018-03-09 03:22:00 +00:00
sommersoft c1c3a79ec4 atmel-samd: changed Status to Runtime; instituted runtime singleton 2018-03-09 02:19:51 +00:00
Scott Shawcroft bf05183158 Merge remote-tracking branch 'adafruit/2.x' into merge_2x 2018-02-27 15:24:16 -08:00
Dan Halbert 9b4477e1dc Implement UART for 3.0 + related fixes.
1. UART: ported to ASF4. Allow rx-only and tx-only. Add .baudrate r/w property.

2. Make NeoPixel timing deterministic by turning off caches during NeoPixel writes.
3. Incorporate asf4 updates:
  a. async USART driver
  b. bringing Atmel START configuration closer to what we use
  c. Clock initialization order now specified by CIRCUITPY_GCLK_INIT_1ST and _LAST.
4. supervisor/port.c: Move commented-out clock-test pin setting to correct location.
2018-02-21 17:18:49 -05:00
Scott Shawcroft 20dd3b1e43 Delete a bunch of docs, drivers and examples not relevant to CircuitPython.
This fixes #345 and fixes #215.
2018-02-20 17:34:59 -08:00
sommersoft fca9c66c27 added Status submodule to shared-bindings/supervisor; issue #544 2018-02-19 20:40:17 +00:00
Kattni 446a31302c
Merge pull request #600 from tannewt/clarify_property_comments
Clarify style of attribute comments in the Design Guide.
2018-02-14 22:03:37 -05:00
Kevin Townsend 9d191f7f9f
Merge pull request #589 from arturo182/nrf_gamepad
nrf: Implement ticks, add gamepad module and example
2018-02-07 22:17:05 +01:00
Scott Shawcroft 15db02664d Clarify style of attribute comments in the Design Guide.
And update the core attributes to match the style.
2018-02-07 13:08:42 -08:00
arturo182 ff041caa52 shared-bindings: Fix incorrect code comments
Most likely caused by copy-paste.
2018-02-06 22:03:17 +01:00
Scott Shawcroft 6c5cb01b4a
Merge pull request #564 from deanm1278/master
DM: added write_readinto to bitbangio
2018-02-06 09:38:17 -08:00
arturo182 1de2ee6884 nrf: Implement ticks, add gamepad module and example 2018-02-05 20:48:25 +01:00
dean 68309c3fac replace tabs with spaces 2018-02-05 10:44:29 -05:00
dean 0e13aba2fe DM: fix sytling 2018-01-30 17:45:04 -05:00
dean a7f72eb2d8 DM: added write_readinto to bitbangio 2018-01-30 17:18:57 -05:00
Dan Halbert cc87363234 documentation: caution on SPI clock speed for SAMD21 2018-01-30 14:31:20 -05:00
Dan Halbert e550b024c5 atmel-samd: Correct computation of SPI baud rate.
all: Add .frequency read-only property for busio.SPI to return actual frequency.

Fix esp8266/posix_helpers.c, which was not up to date for the new
long-lived/short-lived heap allocation scheme.
2018-01-30 12:08:41 -05:00
sommersoft 44bc1711aa Added Unique ID Functions/Updated Support Matrix (#527)
shared_bindings/index.rst: updated Support Matrix format as discussed in PR #503 & Issue #448.

shared-bindings/microcontroller/Processor.c & .h: added UID lookup functionality for use with all ports. Fixes #462.
2018-01-18 11:39:11 -08:00