Commit Graph

215 Commits

Author SHA1 Message Date
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
Radomir Dopieralski 0ff128ec03 Fix example for gamepad
The example code for the gamepad module would skip detected
button presses in the code that waits for a button to be released,
because it would run it even when no button is pressed.

Also updated the example pin names to not use RX and TX.
2018-01-11 17:06:53 +01:00
Dan Halbert 065e82015f merge from 2.2.0 + fix up board defs 2018-01-02 21:25:41 -05:00
sommersoft 881fa8e2b9 shared-bindings/index.rst: added audiobusio
shared-bindings/index.rst: added `aduiobusio` to Support Matrix. Used `audiobusio/_init_.c` to verify applicable ports; SAMD21 was the only one listed...ESP8266 wasn't. This fixes issue #448.
2017-12-30 01:36:23 -06:00
sommersoft 36ec29d4e8 Documentation Updates (mcu.delay() and Design Guide) (#481)
/docs/design_guide: added links to firmware build learning guides for SAMD21 & ESP8266. Changes were placed in the "Adding native modules" section, since that seemed to me the best place based on target audience.

Updated documentation for `delay()` which fixes #243.
2017-12-14 10:02:43 -08:00
Dan Halbert 43650b6896 Fix PDMIn MEMS microphone support (#479)
Changes:

    * New faster filter loop, by @ladyada. New filter coefficients as well.
    * Turn on microphone clock when PDMIn object is created, and run it all the time, so the user code doesn't have to wait for microphone startup, which can be 10ms or even 100ms.
    * Wait for microphone startup when PDMIn is first created, based on new optional parameter microphone_startup in seconds (takes a float).
    * record() returns number of samples actually recorded, so you can see if it's not keeping up.
    * Fix buffer overflow errors when buffer size was not a multiple of 16 or something like that.
    * Tweak a few peripheral settings.
    * Minimum sampling frequency is now 16kHZ or so, because 8kHz runs microphone at only 0.5MHz, which is too slow for many mics.

Note: I tried 128x oversampling instead of 64x, but the code cannot keep up at 24kHz or above sampling. 128x would reduce the high-frequency noise by 6db.
2017-12-13 10:12:49 -08:00
Scott Shawcroft a91e1cb682 Fix a couple spelling errors. 2017-12-05 16:04:47 -08:00
Scott Shawcroft b4d3699047 Introduce reset mechanics to microcontroller.
This allows one to configure how a subsequent reset will behave and
also trigger a reset.

Fixes #350 and fixes #173
2017-12-05 14:50:58 -08:00
Dan Halbert e75fd0e166 add SPI.write_readinto() - bidirectional SPI 2017-12-05 11:17:16 -08:00
Dan Halbert 72c911be97 Support SPI flash chips for CIRCUITPY, using non-DMA SPI for now. 2017-11-27 21:00:24 -05:00
Kattni 4902f0937f Resolved formatting issue in doc 2017-11-22 21:44:18 -05:00
Kattni 1d6bf8e04a Updated frequency minimum requirements in docs and examples (#444)
Updated frequency minimum requirements in docs and examples
2017-11-19 22:19:22 -08:00
Dan Halbert a9f75a71c5
Merge pull request #443 from dhalbert/3.0_spi
non-DMA SPI working; adding this now for testing; will continue with DMA
2017-11-16 19:28:24 -05:00
Dan Halbert 312444bbd2 non-DMA SPI working; adding this now for testing; will continue with DMA
Also, fixed pin mappings for rev B Metro M4:
swap PA12 and PA13 on SPI 2x3 header
swap A3 and A5

Comment out all frozen modules in CPX again to make room while waiting
for SPI flash.
2017-11-16 19:09:35 -05:00
Scott Shawcroft ecc47d5258 Create supervisor module.
It can control autoreload and the rgb status led.
2017-11-16 09:04:17 -08:00
Radomir Dopieralski 216fcedfbb Add a _stage module (#398)
This is a C module with some low-level functions required for the
CircuitPython "stage" library. It provides support for fast
rendering of tile grids and sprites on SPI-based RGB displays.
2017-11-07 10:05:25 -08:00
Dan Halbert 7292984204 Implement busio.I2c.
* Added asf4_conf/samd*/hpl_sercom_config.h
* Adjusted clocks in peripheral_clk_config.h.
* Put some frozen libs back in CPX for testing.
* Implement common-hal I2C
* Add samd*_peripherals.h in parallel with samd*_pins.h for common
  functions and data.
* Store SERCOM index in pins table for convenience.
* Canonicalize some #include guard names in various .h files.

simpler reset of SERCOMs; remove unused routine
2017-11-07 09:59:54 -08:00
Radomir Dopieralski 78f6c2232c Allow empty reads and writes for busio.SPI
This is mostly for convenience, so that user code doesn't
need to add additional checks.

Also, bring the bitbangio into compatibility with busio wrt. empty
buffers.
2017-11-03 17:33:37 +01:00
Scott Shawcroft 8c1f5427bc atmel-samd: Add empty line for RST docs
Right now calcsize is being grouped with the doc above: https://circuitpython.readthedocs.io/en/latest/shared-bindings/struct/__init__.html
2017-10-30 18:57:28 -07:00
Dan Halbert f738996164 Allow writing buffer of length zero to I2C device; it can be used to poll for existence. 2017-10-30 18:32:36 -07:00
mrmcwethy 1893669833 calcsize90 should be documented now 2017-10-27 23:25:00 -07:00
Scott Shawcroft bd7abcda97 shared-bindings: Check that I2C and SPI reads and writes are given a buffer of at least 1. (#370)
Fixes #358
2017-10-25 17:28:23 -04:00
Scott Shawcroft d2ddf36c1d shared-bindings: Use unary_op type. 2017-10-25 10:52:03 -07:00
Dan Halbert 6df99b5d0e Merge 2.1.0 changes into master. 2017-10-23 15:26:36 -07:00
mrmcwethy bb008cdbc9 First attempt to move py/modmath.c to shared-bindings/math 2017-10-21 10:34:25 -07:00
Josh Gadeken 3ba5ba6e66 shared-bindings/storage/__init__.c: Change remount() readonly to kw arg (#286).
The readonly arg to storage.remount() is now a keyword arg that
defaults to False. To maintain backwards compatibility, readonly
can be passed as a positional arg or keyword arg.
2017-10-19 17:11:30 -07:00
Michael McWethy b41cbe9256 CircuitPython now has struct instead of ustruct (#302)
Added struct module to shared-bindings and shared-module.  removed ustruct
2017-10-18 12:50:20 -07:00
Dan Halbert a1409d1432 redo time.monotonic() to avoid double precision 2017-10-17 10:02:16 -07:00
Dan Halbert 1709fbb65a Turn on pulseio now that there's room.
https://github.com/adafruit/circuitpython/issues/325#issuecomment-336733842
2017-10-16 12:51:55 -07:00
Radomir Dopieralski f4981677b0 Add a `gamepad` module for handling buttons in the background. (#295)
The `GamePad` singleton monitors buttons in the background to make sure a button press is never missed and debouncing happens consistently.
2017-10-03 13:35:57 -07:00
Dan Halbert c478c10923 Do not allow a *io object to be used after deinit().
Fixes #278, #277, #276, #275.
2017-10-03 12:07:17 -07:00
Dan Halbert 7f74412882 Make touch more sensitive. Add .raw_value and .threshold attributes. 2017-10-02 11:15:51 -07:00
Dan Halbert e0ddd528c8 Add Processor to microcontroller documentation TOC (#237) 2017-09-06 17:50:00 -04:00
Scott Shawcroft 6467e3d40b shared-bindings: Prevent check_lock from being optimized away. (#240)
Fixes #229
2017-09-06 17:49:30 -04:00
Scott Shawcroft 6d9d683443 atmel-samd: Enable 8-bit audio recording support even though it'll be
quiet. Also update the examples.

Fixes #226
2017-09-05 16:37:02 -07:00
Dan Halbert fdb97eda09 Add microcontroller.cpu.temperature, for use as a simple sensor on minimal boards. (#211)
* Add microcontroller.cpu, the sole instance of microcontroller.Processor.
microcontroller.cpu.frequency is the clock frequency, in Hz.
microcontroller.cpu.temperature is the reading from the internal temperature sensor, in Celsius. None if not available.

* Squeeze firmware size by using -finline-limit. Otherwise non-Express builds were slightly too big.

* Update submodules.

* Fix documentation glitches
2017-08-31 13:48:30 -04:00
Scott Shawcroft aa700a8b42 shared-bindings: Clarify that UART.read() is slow. (#209) 2017-08-29 14:06:59 -04:00
Scott Shawcroft 447a4b1ecd Merge pull request #208 from adafruit/merge-v1.9.2
Merge MicroPython v1.9.2
2017-08-28 13:59:26 -07:00
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