Commit Graph

379 Commits

Author SHA1 Message Date
puuu ee12581a35 esp8266: Let RTC work correctly after deepsleep.
By design, at wake up from deepsleep, the RTC timer will be reset, but
the data stored in RTC memory will not [1]. Therefore, we have to adjust
delta in RTC memory before going into deepsleep to get almost correct
time after waking up.

[1] http://bbs.espressif.com/viewtopic.php?t=1184#p4082
2016-06-06 10:51:12 +01:00
Mark 822e9ca8f3 esp8266/modnetwork: Use struct bss_info::ssid_len for ESSID length.
Instead of calling strlen(), which won't work if there're 32 chars in
returned ESSID. struct bss_info::ssid_len is not documented in SDK API
Guide, but is present in SDK headers since 1.4.0. Just in case, previous
code is left commented.
2016-06-04 22:02:01 +03:00
puuu cafdfb7af3 esp8266/modpybrtc: Handle RTC overflow.
ESP-SDK system_get_rtc_time() returns uint32 and therefore overflow
about every 7:45h.  Let's write the last state of system_get_rtc_time()
in RTC mem and use it to check for overflow. This commit require running
pyb_rtc_get_us_since_2000() at least once within 7 hours to avoid
overflow.
2016-06-03 14:37:49 +01:00
Damien George 927388e80e esp8266: Provide a dedicated variable to disable ets_loop_iter.
So ets_loop_iter is now only disabled when using machine.disable_irq.
2016-06-01 17:26:49 +01:00
Damien George 752e952096 esp8266/rtc: Set RTC user memory length to 0 on first boot.
So that RTC.memory() returns b'' on power up if it was never set.

Fixes issue #2138.
2016-06-01 11:33:04 +01:00
Robert HH 4f3fbf09cc esp8266/moduos.c: Add stat() to the module uos of esp8266.
This implementation makes use of vfs.stat() and therefore has the same
properties. Known issues for all ports: uos.stat(".") on the top level
returns the error code 22, EINVAL. The same happens with
uos.stat("dirname/") where dirname IS the name of a directory.
2016-05-31 23:00:38 +03:00
Paul Sokolovsky 15eb1ce52d esp8266: Enable MICROPY_PY_IO_FILEIO to get compliant text/binary streams. 2016-05-31 21:46:02 +03:00
Damien George 33168081f4 extmod/machine: Add MICROPY_PY_MACHINE_PULSE config for time_pulse_us.
Since not all ports that enable the machine module have the pin HAL
functions.
2016-05-31 14:25:19 +01:00
Damien George cff2b7a6e3 esp8266/modmachine: Add machine.time_pulse_us function. 2016-05-31 14:06:50 +01:00
Paul Sokolovsky 225562d915 esp8266/scripts/ntptime: Allow to override NTP server.
This is not part of public API, variable name may change, or it can be
replaced with a function.
2016-05-30 19:16:05 +03:00
Paul Sokolovsky 12401f337e esp8266/moduos: Add chdir() and getcwd() functions. 2016-05-29 19:44:24 +03:00
Damien George 602305b211 esp8266/uart: Properly initialise UART0 RXD pin in uart_config.
Tested and seems to work.  See #1995.
2016-05-29 10:30:27 +01:00
Damien George 6707fc94ae esp8266/modnetwork: Allow to press ctrl-C while scan() is running.
Ctrl-C will raise a KeyboardInterrupt and stop the scan (although it will
continue to run in the background, it won't report anything).  If
interrupted, and another scan() is started before the old one completes
in the background, then the second scan will fail with an OSError.
2016-05-29 09:53:04 +01:00
Damien George 84381fa0fc esp8266/modnetwork: Protect scan() callback against memory errors.
scan() allocates memory so may cause an exception to be raised.
2016-05-29 09:52:07 +01:00
Damien George 55df14f1a4 esp8266/modnetwork: scan() is only supported by STA when it's enabled. 2016-05-29 00:35:24 +01:00
Paul Sokolovsky 74e6c0337d esp8266/Makefile: Document "disable" value for UART_OS. 2016-05-27 00:44:05 +03:00
Damien George 7ebfe09fbd esp8266: Add dht.py script for high-level control of DHT11/DHT22 sensor.
TODO: should go in a more port-neutral place, like drivers/dht, but at the
moment in relies on specific esp module.
2016-05-26 17:13:03 +01:00
Damien George 45f3416816 esp8266: Enable DHT C-level driver.
Exposed as esp.dht_readinto.  Probably should go somewhere less
port-specific.
2016-05-26 17:11:43 +01:00
Damien George 4b37e775ea extmod/machine_i2c: Redo mp_hal_pin macros to use open_drain and od_low.
mp_hal_pin_config_od is renamed mp_hal_pin_open_drain, and mp_hal_pin_low
is mp_hal_pin_od_low.
2016-05-26 17:06:40 +01:00
Damien George 9a368ae831 esp8266/modmachine: Add disable_irq and enable_irq functions. 2016-05-26 15:47:47 +01:00
Damien George 849eb835f0 esp8266/ets_alt_task: Don't run ets_loop_iter if irqs are disabled.
ets_loop_iter processes pending tasks, and tasks are considered lower
priority than interrupts, so tasks shouldn't be processed if interrupts
are disabled.
2016-05-26 15:47:47 +01:00
Damien George 99b14593a6 esp8266/xtirq: Add xtirq.h for controlling xtensa irqs. 2016-05-26 15:47:47 +01:00
Damien George 7e809b4baf esp8266/modpybspi: Configure pins when initialising an SPI object. 2016-05-26 15:42:44 +01:00
Damien George 68e222afdc esp8266: Add mp_hal_pin_input() and mp_hal_pin_output() functions. 2016-05-26 15:42:27 +01:00
Paul Sokolovsky 2b05b60bbc esp8266/esp_mphal: mp_uos_dupterm_deactivate() may raise exception.
So, keep call to it protected via NLR still.
2016-05-24 15:04:59 +03:00
Paul Sokolovsky 4681b86850 esp8266/esp_mphal: Handle Ctrl+C from dupterm (e.g. WebREPL). 2016-05-24 01:37:56 +03:00
Paul Sokolovsky 116eeee6db esp8266/esp_mphal: Fix NLR buffer leak in call_dupterm_read(). 2016-05-24 01:30:28 +03:00
Paul Sokolovsky bc2ba6b2e3 esp8266/scripts/port_diag: Dump network interface IP settings. 2016-05-24 01:27:16 +03:00
Paul Sokolovsky cb7693bab4 esp8266/main: Update _boot module loading for recent frozen modules refactors. 2016-05-22 04:09:15 +03:00
Paul Sokolovsky 9c2217a165 esp8266: Enable collections.OrderedDict. 2016-05-22 02:57:33 +03:00
Paul Sokolovsky 0ab372585f extmod/moduos_dupterm: Dumpterm subsystem is responsible for closing stream.
Make dupterm subsystem close a term stream object when EOF or error occurs.
There's no other party than dupterm itself in a better position to do this,
and this is required to properly reclaim stream resources, especially if
multiple dupterm sessions may be established (e.g. as networking
connections).
2016-05-20 22:20:37 +03:00
misterdanb a0a08b4be1 esp8266: Add APA102 serial individually controllable LEDs support.
APA102 is a new "smart LED", similar to WS2812 aka "Neopixel".
2016-05-19 22:29:11 +03:00
Torwag 6fa60153ea esp8266/README: Add a very first start section.
Adding a very first start section to get people going after flashing.
I tried to condense it to  a minimum to avoid as much as possible
redundancy and bloating.
2016-05-19 21:10:35 +03:00
Paul Sokolovsky 418faae8f7 esp8266/scripts/webrepl_setup: Add max password length check.
modwebrepl truncates password to 9 chars, and that led people to confusion.
2016-05-17 02:21:45 +03:00
Paul Sokolovsky 21ec1fd850 esp8266/scripts/webrepl_setup: Show password placeholder char.
That was the intent for the initial user setup, but didn't work before
due to lwIP issues. Enable now that they're fixed.
2016-05-17 00:01:41 +03:00
Paul Sokolovsky 7327d5f6f7 esp8266/scripts/port_diag: Add network diagnostic output. 2016-05-16 23:52:58 +03:00
Robert HH a676a41cb7 esp8266/moduos.c: Addition of the rename method to module uos.
That one was missing in the module, even if it was available in the
vfs object. The change consist of adding the name and preparing the
call to the underlying vfs module, similar to what was already
implemented e.g. for remove.

Rename is useful by itself, or for instance for a safe file replace,
consisting of the sequence:

    write to a temp file
    delete the original file
    rename the temp file to the original file's name
2016-05-16 13:19:13 +02:00
Damien George 0d6d315ba6 esp8266: Change to use internal errno's. 2016-05-12 12:49:36 +01:00
Damien George 7e1f580910 esp8266: Enable uerrno module, weak linked also as errno. 2016-05-10 23:30:39 +01:00
Damien George 4f2ba9fbdc esp8266: Convert to use new MP_Exxx errno symbols.
These symbols are still defined in terms of the system Exxx symbols, and
can be switched to internal numeric definitions at a later stage.

Note that extmod/modlwip still uses many system Exxx symbols.
2016-05-10 23:30:39 +01:00
Paul Sokolovsky d60cb8e180 esp8266/help: Add "sta_if.active(True)" command.
As reported on the forum by Roberthh.
2016-05-10 23:21:32 +03:00
Paul Sokolovsky f16bec6bc9 esp8266/mpconfigport: Reduce various parser-related allocation params.
This gives noticeable result for parsing simple input (modelled on 32-bit
unix port):

Before:
>>> micropython.mem_total()
3360
>>> micropython.mem_total()
4472

After:
>>> micropython.mem_total()
3072
>>> micropython.mem_total()
4052

However, effect on parsing large input is much less conclusive, e.g.:

Before:
>>> micropython.mem_total()
3376
>>> import pystone_lowmem
>>> micropython.mem_total()
33006

delta=29630

After:
>>> micropython.mem_total()
3091
>>> import pystone_lowmem
>>> micropython.mem_total()
32509

delta=29418
2016-05-10 15:38:31 +03:00
Paul Sokolovsky de5e0ed2e0 esp8266/main: Bump heap size to 28K.
This is kind of compensation for 4K FatFs buffer size which is eaten away
from it on FS mount. This should still leave enough of networking ("OS")
heap.
2016-05-09 19:02:40 +03:00
Paul Sokolovsky 13a1acc7e2 esp8266/scripts/webrepl: Add start_foreground() method.
Starts WebREPL server in foreground and waits for (single) connection.
2016-05-08 20:01:15 +03:00
Noah Rosamilia 2724bd4a94 esp8266/scripts/webrepl: Add optional password argument to webrepl.start()
This commit fixes issue #2045
2016-05-07 22:45:08 +03:00
Mike Causer 13d06a83e1 esp8266/scripts/: Add fill() to NeoPixel 2016-05-07 21:15:33 +03:00
Paul Sokolovsky 8db61e5b5a esp8266/scripts/inisetup: Don't start WebREPL on boot in master branch.
It interferes with running testsuite. master branch should be optimized for
development, so any features which interfere with that, would need to be
disabled by default.
2016-05-07 20:04:45 +03:00
Paul Sokolovsky df2b1a4758 esp8266/scripts/: Remove use of pin.PULL_NONE.
This constant is no longer part of hardware API (replaced with just None),
and is a default, so not needed in calls.
2016-05-05 23:47:37 +03:00
Paul Sokolovsky fb5017f9dc esp8266/main: Set sys.path to ["", "/", "/lib"]. 2016-05-03 18:25:27 +03:00
Damien George 496a601c3b esp8266: Shrink help text by a few lines, to fit in smaller windows. 2016-05-03 15:54:57 +01:00