Commit Graph

2934 Commits

Author SHA1 Message Date
Dan Halbert c679c80c71 Modernize module and class static dicts; update freetouch 2017-08-27 15:02:50 -04:00
Scott Shawcroft 4e63d55d8d Fix blinky example
Thanks to @Kurticus and @scruffynerf from [discord](http://adafru.it/discord) for finding it.
2017-08-26 22:24:17 -07:00
Dan Halbert ef61b5ecb5 Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
2017-08-25 22:17:07 -04:00
Scott Shawcroft 266be30777 atmel-samd: Introduce a nvm module for non-volatile byte-level memory access. (#203)
* atmel-samd: Introduce a nvm module for non-volatile byte-level memory access.

This allows for persisting small configuration values even when the file system
is read-only from CircuitPython.

Fixes #160

* Review feedback:
* Add tests.
* Fix non-zero index.
* Fix len()
2017-08-25 16:00:27 -04:00
Scott Shawcroft 16ef611b0b shared-bindings: Check that extra args aren't provided to digitalio.DigitalInOut on construction. (#189) 2017-08-22 15:54:01 -04:00
Scott Shawcroft f570b53d44 shared-bindings: Update DigitalIO.pull docs and validate that third (#188)
state is None and not anything.

Fixes #187
2017-08-22 15:41:04 -04:00
Scott Shawcroft 42156484ae shared-bindings/atmel-samd: Fix and improve trigger duration timing on PulseIn.resume. 2017-08-10 11:55:34 -07:00
Scott Shawcroft 2e155bcc31 shared-bindings: Add stub documentation of storage.VfsFat so other docs can link to it. 2017-08-07 16:20:19 -07:00
Scott Shawcroft 6ace744667 esp8266: Introduce `multiterminal` module for managing a secondary
serial connection such as WebREPL.

Fixes #181.
2017-08-07 14:30:11 -07:00
Scott Shawcroft 557ceded00 atmel-samd: Introduce audiobusio.PDMIn for recording audio from PDM
microphones.
2017-07-28 12:12:38 -07:00
brentru 48375ba954 fixed naming on pulseIn example for docs 2017-07-27 19:15:51 -07:00
Dan Halbert f91493c97e Measure and report maximum stack usage. (#175)
Add max stack usage tracking, visible via debug module ustack.
Add separate cpp flag for enabling modules: MICROPY_DEBUG_MODULES
2017-07-23 15:32:05 -04:00
Scott Shawcroft b69507fc64 shared-bindings: Fix neopixel_write example. I forgot to save in the editor. Fixes #163 2017-07-12 14:59:26 -07:00
Scott Shawcroft f878bc4efc atmel-samd: Fix AudioOut buffer playback by supporting bytes_per_sample.
Thanks to @ntoll for finding this bug!
2017-07-12 11:55:49 -07:00
Scott Shawcroft 5e231bd8f9 shared-bindings: Add neopixel_write example. Fixes #163 2017-07-12 11:55:17 -07:00
Scott Shawcroft 725d715a1b shared-bindings: Introduce storage.remount() so you can set root as
writeable and prevent USB from editing it.
2017-06-28 16:18:13 -07:00
Scott Shawcroft a0058e6712 Introduce a random module that is a subset of CPython's random. It
also initializes in the same way where it takes from a true random
source when available through os.urandom(). After initializing, it
produces deterministic results until the seed is set.

This replaces urandom!

Fixes #139.
2017-06-27 17:37:24 -07:00
Scott Shawcroft 778e975936 Split uos module into os and storage.
os is a subset of CPython's os. storage contains additional
file system mounting functionality based on UNIX's mount
management.

Fixes #140
2017-06-27 15:17:30 -07:00
Scott Shawcroft 30ee7019ca Merge tag 'v1.9.1'
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions

This release provides an important fix for the USB mass storage device in
the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which
is now require by some Operating Systems.  There are also fixes for the
lwIP bindings to improve non-blocking sockets and error codes.  The VFS has
some regressions fixed including the ability to statvfs the root.

All changes are listed below.

py core:
- modbuiltins: add core-provided version of input() function
- objstr: catch case of negative "maxsplit" arg to str.rsplit()
- persistentcode: allow to compile with complex numbers disabled
- objstr: allow to compile with obj-repr D, and unicode disabled
- modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled
- provide mp_decode_uint_skip() to help reduce stack usage
- makeqstrdefs.py: make script run correctly with Python 2.6
- objstringio: if created from immutable object, follow copy on write policy

extmod:
- modlwip: connect: for non-blocking mode, return EINPROGRESS
- modlwip: fix error codes for duplicate calls to connect()
- modlwip: accept: fix error code for non-blocking mode
- vfs: allow to statvfs the root directory
- vfs: allow "buffering" and "encoding" args to VFS's open()
- modframebuf: fix signed/unsigned comparison pendantic warning

lib:
- libm: use isfinite instead of finitef, for C99 compatibility
- utils/interrupt_char: remove support for KBD_EXCEPTION disabled

tests:
- basics/string_rsplit: add tests for negative "maxsplit" argument
- float: convert "sys.exit()" to "raise SystemExit"
- float/builtin_float_minmax: PEP8 fixes
- basics: convert "sys.exit()" to "raise SystemExit"
- convert remaining "sys.exit()" to "raise SystemExit"

unix port:
- convert to use core-provided version of built-in import()
- Makefile: replace references to make with $(MAKE)

windows port:
- convert to use core-provided version of built-in import()

qemu-arm port:
- Makefile: adjust object-file lists to get correct dependencies
- enable micropython.mem_*() functions to allow more tests

stmhal port:
- boards: enable DAC for NUCLEO_F767ZI board
- add support for NUCLEO_F446RE board
- pass USB handler as parameter to allow more than one USB handler
- usb: use local USB handler variable in Start-of-Frame handler
- usb: make state for USB device private to top-level USB driver
- usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command
- convert from using stmhal's input() to core provided version

cc3200 port:
- convert from using stmhal's input() to core provided version

teensy port:
- convert from using stmhal's input() to core provided version

esp8266 port:
- Makefile: replace references to make with $(MAKE)
- Makefile: add clean-modules target
- convert from using stmhal's input() to core provided version

zephyr port:
- modusocket: getaddrinfo: Fix mp_obj_len() usage
- define MICROPY_PY_SYS_PLATFORM (to "zephyr")
- machine_pin: use native Zephyr types for Zephyr API calls

docs:
- machine.Pin: remove out_value() method
- machine.Pin: add on() and off() methods
- esp8266: consistently replace Pin.high/low methods with .on/off
- esp8266/quickref: polish Pin.on()/off() examples
- network: move confusingly-named cc3200 Server class to its reference
- uos: deconditionalize, remove minor port-specific details
- uos: move cc3200 port legacy VFS mounting functions to its ref doc
- machine: sort machine classes in logical order, not alphabetically
- network: first step to describe standard network class interface

examples:
- embedding: use core-provided KeyboardInterrupt object
2017-06-20 10:56:05 -07:00
Scott Shawcroft c7efd2cae9 shared-bindings: Move enum-like classes out of DigitalInOut into digitalio.
Also, rename Direction.IN to Direction.INPUT and Direction.OUT to Direction.OUTPUT.

This simplifies using them. Prior to the nativeio split this would have led to
clutter in the top-level namespace but having digitalio prevents this.

Fixes #152
2017-06-16 13:47:01 -07:00
Scott Shawcroft 714521a4c7 shared-bindings: Update docs to remove with statements from examples but add more detail to the design guide about their use. 2017-06-07 14:39:12 -07:00
Scott Shawcroft c5e515b8fe docs: Add module support matrix. 2017-06-07 12:00:15 -07:00
Scott Shawcroft 2ecb9a3dbf docs: Fix header lines that are too short. 2017-06-07 11:58:04 -07:00
Scott Shawcroft c0e1f58b67 shared-bindings: Allow for switching direction with the attribute. 2017-06-06 17:45:39 -07:00
Scott Shawcroft c8dc091288 shared-bindings: Fix duty_cycle parameter description and error message. 2017-06-06 16:23:06 -07:00
Scott Shawcroft 1280e9122b Doc tweaks to clarify external libraries, new boards and add HID library. 2017-05-24 11:44:23 -07:00
Scott Shawcroft 3f5028c666 atmel-samd: Support wav file playback. Tested up to 16bit 22.1khz. Must be mono file!
SD card support may work but likely needs buffer tuning. Its untested.

Fixes #105
2017-05-15 19:52:38 -07:00
Scott Shawcroft ef1a4847b3 shared-bindings: Correct PulseIn.resume to match docs. Fixes #125 2017-05-08 11:14:23 -07:00
Scott Shawcroft 58b9789d0c atmel-samd: Introduce audio sample playback via audioio.AudioOut. 2017-05-01 13:10:03 -07:00
Scott Shawcroft 939c0045db Switch to a shared piece of code to compute start and length of a
buffer from start, end and length. The old code miscomputed length
leading to writing and reading from memory past the end of the buffer.
Consolidating the code should make it easier to get right everywhere.
2017-04-20 11:24:05 -07:00
Scott Shawcroft b653c3c8fc Correct PulseOut example code 2017-04-13 17:52:13 -07:00
Scott Shawcroft 4a4f29b8f9 atmel-samd: Rework status LED implementation
* Track status pin use by user code separately so it can take over the pins and then give them back.
* Switch to hardware SPI for APA102 on Gemma and Trinket.
* Merge microcontroller/types.h into microcontroller/Pin.h to better match approach going forwards.
2017-04-12 15:24:50 -07:00
Scott Shawcroft f28f8ba568 Split up nativeio.
This was done to allow greatly granularity when deciding what functionality
is built into each board's build. For example, this way pulseio can be
omitted to allow for something else such as touchio.
2017-04-10 13:32:19 -07:00
Scott Shawcroft ff208d7677 Add low-level OneWire support class.
This class focuses on the timing sensitive parts of the protocol.
Everything else will be done by Python code.

This also establishes that its OK to back a nativeio class with a
bitbang implementation when no hardware acceleration exists. When
it does, then bitbangio should be used to explicitly bitbang a
protocol.
2017-03-25 12:04:49 +00:00
Scott Shawcroft 7cb54864aa Add PulseIn support which can be used to measure a series of pulse widths.
This is useful for infrared input and DHT sensors.
2017-03-24 10:30:15 +00:00
Scott Shawcroft d200a62164 Add PulseOut which can pulse a PWMOut for IR remote transmission. 2017-03-10 19:17:54 +01:00
Scott Shawcroft bccfbe4e00 Fix duty_cycle constructor argument to PWMOut. 2017-03-10 18:55:17 +01:00
Scott Shawcroft 4aaa0ea008 shared-bindings: Do a pass on the docs and make sure keyword only arguments make sense and are documented correctly. Fixes #109 2017-03-07 12:58:57 +01:00
Scott Shawcroft 3891dde7ff shared-bindings: Reenable struct_time. It was turned off when playing with LTO and never re-enabled. 2017-03-07 12:47:26 +01:00
Scott Shawcroft 7ecbc3a148 shared-bindings: Fix two more try_locks. Copy and paste failed me. 2017-02-28 12:31:27 +01:00
Scott Shawcroft d598c2a919 atmel-samd: Add USB HID mouse and keyboard support. 2017-02-27 15:43:58 +01:00
Scott Shawcroft 062fac1d43 atmel-samd: Use link time optimization to reduce code size of builds which
share space with the file system.

"Express" builds with SPI flash crash the compiler for some reason so its
currently disabled for them.
2017-02-26 01:00:33 +01:00
Scott Shawcroft baf3ff377e Make more type structures const to save RAM. 2017-02-24 15:23:26 +01:00
Scott Shawcroft 12fa5b3a66 Switch exception throwing to mp_raise helpers. It saves a little code space each time to share the call. 2017-02-24 15:13:07 +01:00
Scott Shawcroft 75d0b02b3f Throw an error when sleep time is negative. 2017-02-22 20:41:00 +01:00
Scott Shawcroft 4c05086661 Check that neopixel write is actually given a DigitalInOut. 2017-02-22 20:10:10 +01:00
Scott Shawcroft f0b62a2b0e Save space by only supporting 800khz neopixels. 2017-02-19 17:22:42 +01:00
Scott Shawcroft 710b5d8aff Two I2C fixes:
1) Bus error will be thrown on read/write errors with errno set. (Read didn't used to fail at all.)
2) try_lock correctly returns boolean whether lock was grabbed.

Fixes #87
2017-02-19 17:02:29 +01:00
Scott Shawcroft e9659e61f8 Switch enum-like attributes to all caps and add print support for them. Make room for this functionality by adding a shared __enter__ function object. #76 2017-02-19 16:11:33 +01:00
Scott Shawcroft d67968e3c3 Add print support to Pin. #83 #76 2017-02-19 14:23:29 +01:00
Scott Shawcroft 3dda38c8ab Fix pin free check to ignore None objects. Fixes #89 2017-02-19 12:59:31 +01:00
Scott Shawcroft 1a3bd67833 nativeio.SPI: Remove extraneous constructor args because they are in configure. 2017-02-19 12:57:00 +01:00
Scott Shawcroft 370d1dec88 SPI tweaks for SD Cards:
* Always init SPI to 250k to start for SD cards.
* Add ability to configure byte written during read.
* Add ability to read and write to portions of buffers like existing I2C API.
2017-02-10 05:09:17 -08:00
Scott Shawcroft 9f6da7b2fe Add more PWMOut examples and rename the duty constructor argument
to duty_cycle so that its consistent with the attribute.

Fixes #84
2017-02-01 15:07:31 -08:00
Scott Shawcroft e3f9ee839a Add frequency changing support to PWMOut.
You can either set it once up front, or set variable_frequency on custruction to
indicate that the frequency must be able to change. This informs whether a timer
can be shared amongst pins.

This also adds persistent clock calibration on atmel-samd. Once the device has
synced its clock frequency over USB it will remember that config value until USB
is used again. This helps ensure the clock frequency is similar on and off USB.

Lastly, this also corrects time.sleep() when on USB by correcting the tick counter.
2017-01-30 15:02:01 -08:00
Scott Shawcroft d239dbdc28 More fixes to pin pull thanks to jerryn:
* Correct atmel-samd pin pull state.
* Correct conversion from python pull objects to C enum.
2017-01-16 15:32:23 -08:00
Scott Shawcroft df96823dee Fix pull kwarg DigitalInOut.switch_to_input and add example use to docs.
Thanks to jerryn from the Adafruit Forum for finding the bug!
2017-01-16 10:35:46 -08:00
Scott Shawcroft cea5503ca0 Fixup warnings from merge about undefined macro values, switch to
VM keyboard exception and switch to FATFS reader.
2017-01-12 12:46:18 -08:00
Scott Shawcroft 161ab018ba Correct monotonic.
Fixes #69.
2017-01-08 22:10:33 -08:00
Scott Shawcroft 63681a736a Link to the Bus Device docs. 2017-01-05 18:43:22 -08:00
Scott Shawcroft 7c302c395e Improve docs and update to CircuitPython. 2017-01-05 16:20:46 -08:00
Scott Shawcroft e52fbf2e6a Add time.struct_time support. 2017-01-05 14:00:48 -08:00
Scott Shawcroft f48d2df634 atmel-samd: Improve TouchIn to allow for multiple simultaneous touch pads. 2016-12-20 16:39:32 -08:00
Scott Shawcroft 427d33c706 atmel-samd: Add help() and remove mem_info functions from smallest builds to make room. 2016-12-19 16:38:35 -08:00
Sebastian Plamauer 1598e44231 atmel-samd: Add preliminary support for UART 2016-12-19 13:03:50 -08:00
Scott Shawcroft 781633c716 Fix up Analog classes: unify them at 16 bits and adds reference_voltage member
to make for easy conversion. Fixes #14.
2016-12-13 16:09:00 -08:00
Scott Shawcroft 3972bc19c7 atmel-samd: Basic capacitive touch button support.
Currently only works on a single channel and is only enabled for boards with
SPI flash. Only really designed for hardware testing at this point.
2016-12-12 15:11:25 -08:00
Scott Shawcroft 0ae344841f atmel-samd & esp8266: Make sure pins are not already in use.
This prevents corrupting previous functional objects by stealing their pins
out from under them. It prevents this by ensuring that pins are in default
state before claiming them. It also verifies pins are released correctly and
reset on soft reset.

Fixes #4, instantiating a second class will fail.
Fixes #29, pins are now reset too.
2016-12-07 15:21:14 -08:00
Scott Shawcroft 26229efe78 Add try_lock and unlock to I2C and SPI classes to make sure things
are shared well between threads and underlying MicroPython (SPI Flash
for example.)

It is recommended to use the bus device classes to manage the locks
and other transaction state.

https://github.com/adafruit/Adafruit_MicroPython_BusDevice

Fixed #58
Fixed #59
Fixed #60
2016-12-02 15:46:12 -08:00
Scott Shawcroft 8ef0dd095a Fix two bugs found by clang:
* PWMOut enter and exit weren't hooked up.
* end couldn't be negative in I2C.
2016-12-01 10:33:50 -08:00
Scott Shawcroft 9b3afc7b37 shared-bindings: Make MOSI and MISO optional for SPI. 2016-11-29 16:54:20 -08:00
Scott Shawcroft 4933fa1c27 shared-bindings: Ensure pin objects are actually pins.
Fixes #12
2016-11-29 15:50:01 -08:00
Scott Shawcroft 16764dfa31 shared-bindings: Fix blinky example. Fixes #55 2016-11-29 14:37:25 -08:00
Scott Shawcroft d2aa05a9fe shared-bindings: Stop using negative length at all. Having uint and int mixed is confusing. 2016-11-28 19:57:05 -08:00
Scott Shawcroft bda6ee9a14 shared-bindings: Stop using max and min because C doesn't define them. 2016-11-28 19:48:48 -08:00
Scott Shawcroft 78f8565270 Add start and end kwargs to writeto and readfrom_into so a single buffer can be used to save memory. 2016-11-28 18:35:19 -08:00
Scott Shawcroft ea1320bee7 Add uheap for debugging the size of objects. Still not perfect though. 2016-11-22 17:32:28 -08:00
Scott Shawcroft ccbb5e84f9 This introduces an alternative hardware API called nativeio structured around different functions that are typically accelerated by native hardware. Its not meant to reflect the structure of the hardware.
Docs are here: http://tannewt-micropython.readthedocs.io/en/microcontroller/

It differs from upstream's machine in the following ways:

* Python API is identical across ports due to code structure. (Lives in shared-bindings)
* Focuses on abstracting common functionality (AnalogIn) and not representing structure (ADC).
* Documentation lives with code making it easy to ensure they match.
* Pin is split into references (board.D13 and microcontroller.pin.PA17) and functionality (DigitalInOut).
* All nativeio classes claim underlying hardware resources when inited on construction, support Context Managers (aka with statements) and have deinit methods which release the claimed hardware.
* All constructors take pin references rather than peripheral ids. Its up to the implementation to find hardware or throw and exception.
2016-11-21 14:11:52 -08:00
Scott Shawcroft 23112a6434 atmel-samd: Merge init into the constructor and check all available
SERCOMs during initialization.

Fixes #16. It was broken because the MISO pin used the second SERCOM.
2016-11-01 17:30:01 -07:00
Scott Shawcroft 0cb0bd0f25 atmel-samd: More updates to the docs including the in-code docs. 2016-10-19 16:49:35 -07:00
Scott Shawcroft 46e7f8e4fb Documentation rework to unify the docs together rather than having them
on a per port basis.

Also enables generating docs from inline RST in C code. Simply omits all
lines except those that start with //|. Indentation after "//| " will be
preserved.
2016-10-18 17:42:47 -07:00
Scott Shawcroft 011056af15 atmel-samd: Add support for SPI.
Also separate out the ASF config headers that are shared across all boards.
2016-10-11 15:48:43 -07:00
Scott Shawcroft afedba5c2f atmel-samd: Support with statements for I2C class.
Also add init/deinit if you want to init/deinit manually.
2016-10-05 18:44:55 -07:00
Scott Shawcroft 7d8929c470 atmel-samd: Add I2C support.
This commit also introduces a new shared-bindings directory which is used to store the common Python -> C binding code. By having a shared directory we can ensure that the Python API across ports is the same. Each port will have a corresponding common-hal directory which provides definitions for the C api used in the shared-bindings code. That way the compiler can enforce the C api.

To migrate to this new shared API create a common-hal directory within your port and change the Makefile to compile both the shared-bindings and common-hal files. See atmel-samd/Makefile SRC_BINDINGS for an example.
2016-09-13 11:46:22 -07:00