Commit 136e0973 authored by Nathaniel Wesley Filardo's avatar Nathaniel Wesley Filardo
Browse files

Merge dev into release

While we intend our release strategy to be that we just fast-forward our
`release` branch to `dev`, things have come a little off the wheels.
This is a "git merge -s recursive -X theirs" of `dev` into `release`
instead.
parents 4f679277 c212b30a
name: Create Release
on:
push:
tags:
- '3.*-release_*'
jobs:
build_luac_cross_win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Build luac.cross.exe
run: |
set
"%programfiles%\git\usr\bin\xargs"
cd msvc
"%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release /p:Platform=x64
mv luac-cross/x64/Release/luac.cross.exe ..
shell: cmd
- name: Upload luac.cross
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
name: luac.cross_51_float_win
path: luac.cross.exe
Create_Release:
name: Create Release
needs: build_luac_cross_win
runs-on: ubuntu-latest
steps:
- name: Set release name
run: |
echo "RELEASE_NAME=${GITHUB_REF/*\/}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{env.RELEASE_NAME }}
release_name: ${{env.RELEASE_NAME }}
body: |
Please note that as per #3164 this project switched the default branch from `master` to `release` with the previous release. For the time being both are kept in sync as to ease the transition for our community. However, expect `master` to disappear sooner or later.
## Breaking Changes
- Description - #<PR_Id>
## New Modules
- [wiegand](https://nodemcu.readthedocs.io/en/latest/modules/wiegand/) C module - #3203
## Bug Fixes
Please see [the release milestone](https://github.com/nodemcu/nodemcu-firmware/milestone/16?closed=1) for details.
## Deprecation
prerelease: false
draft: true
- name: Download luac.cross
uses: actions/download-artifact@v1
with:
name: luac.cross_51_float_win
path: ./
- name: upload luac.cross to release
id: upload-luac-cross
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./luac.cross.exe
asset_name: luac.cross_${{env.RELEASE_NAME }}_x64_float_Lua51.exe
asset_content_type: application/x-msdownload
name: CI
on:
push:
branches: [ release ]
pull_request:
branches: [ dev, release ]
jobs:
build:
strategy:
fail-fast: false
matrix:
lua_ver: [51, 53]
numbers: ['float']
include:
- lua_ver: 51
numbers: 'integral'
- lua_ver: 53
numbers: '64bit'
runs-on: ubuntu-16.04
env:
LUA: ${{ matrix.lua_ver }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: pip install pyserial
shell: bash
- run: sudo apt install srecord
shell: bash
- name: Build firmware
if: matrix.numbers == 'float'
run: make
shell: bash
- name: Build integral firmware
if: ${{ matrix.numbers == 'integral' }}
run: |
make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL"
mv luac.cross.int luac.cross
shell: bash
- name: Build 64bit firmware
if: ${{ matrix.numbers == '64bit' }}
run: |
make EXTRA_CCFLAGS="-DLUA_NUMBER_64BITS"
shell: bash
- name: Upload luac.cross
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}
path: luac.cross
build_luac_cross_win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Build luac.cross.exe
run: |
set
"%programfiles%\git\usr\bin\xargs"
cd msvc
"%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release /p:Platform=x64
mv luac-cross/x64/Release/luac.cross.exe ..
shell: cmd
- name: Upload luac.cross
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
name: luac.cross_51_float_win
path: luac.cross.exe
compile_lua:
strategy:
fail-fast: false
matrix:
lua_ver: [51, 53]
numbers: ['float']
filter: [ 'cat' ]
include:
- lua_ver: 51
numbers: 'integral'
filter: 'grep -v "lua_modules/lm92/lm92.lua\|lua_modules/hdc1000/HDC1000.lua\|lua_examples/u8g2/graphics_test.lua"'
- lua_ver: 53
numbers: '64bit'
filter: 'cat'
needs: build
runs-on: ubuntu-16.04
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: false
- name: Download luac.cross
uses: actions/download-artifact@v1
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}
path: ./
- name: Fix file permission
run: chmod +x luac.cross
- name: compile Lua
run: |
find lua_modules lua_examples tests/NTest* -iname "*.lua" | ${{ matrix.filter }} | xargs --delimiter="\n" echo
find lua_modules lua_examples tests/NTest* -iname "*.lua" | ${{ matrix.filter }} | xargs --delimiter="\n" ./luac.cross -p
shell: bash
compile_lua_win:
strategy:
fail-fast: false
matrix:
lua_ver: [51]
numbers: ['float']
filter: [ 'cat' ]
needs: build_luac_cross_win
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: false
- name: Download luac.cross
uses: actions/download-artifact@v1
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}_win
path: ./
- name: compile Lua
run: |
PATH="/C/Program\ Files/Git/usr/bin:${PATH}"
find lua_modules lua_examples tests/NTest* -iname "*.lua" | ${{ matrix.filter }} | xargs --delimiter="\n" echo
find lua_modules lua_examples tests/NTest* -iname "*.lua" | ${{ matrix.filter }} | xargs --delimiter="\n" ./luac.cross -p
shell: bash
NTest:
strategy:
fail-fast: false
matrix:
lua_ver: [51, 53]
numbers: ['float']
include:
- lua_ver: 51
numbers: 'integral'
- lua_ver: 53
numbers: '64bit'
needs: build
runs-on: ubuntu-16.04
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: false
- name: Download luac.cross
uses: actions/download-artifact@v1
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}
path: ./
- name: Fix file permission
run: chmod +x luac.cross
- name: NTest selfcheck
run: |
cd tests/NTest
../../luac.cross -e ../NTest/NTest_NTest.lua | tee log
grep "failed. 0" log
shell: bash
- name: NTest hosttests
run: |
cd tests
cp NTest/NTest.lua .
../luac.cross -e NTest_lua.lua | tee log
(if grep " ==> " log ; then exit 1 ; fi)
shell: bash
NTest_win:
strategy:
fail-fast: false
matrix:
lua_ver: [51]
numbers: ['float']
needs: build_luac_cross_win
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: false
- name: Download luac.cross
uses: actions/download-artifact@v1
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}_win
path: ./
- name: NTest selfcheck
run: |
cd tests/NTest
../../luac.cross.exe -e ../NTest/NTest_NTest.lua | tee log
grep "failed. 0" log
shell: bash
- name: NTest hosttests
run: |
cd tests
cp NTest/NTest.lua .
../luac.cross.exe -e NTest_lua.lua | tee log
(if grep " ==> " log ; then exit 1 ; fi)
shell: bash
luacheck:
strategy:
fail-fast: false
matrix:
include:
- os: 'linux'
vm: 'ubuntu-16.04'
- os: 'windows'
vm: 'windows-latest'
runs-on: ${{ matrix.vm }}
steps:
- uses: actions/checkout@v2
with:
submodules: false
- run: sudo apt install luarocks
if : matrix.os == 'linux'
shell: bash
- name: get luacheck.exe # is also done in the travis script but in this action it does not run in bash
if : matrix.os == 'windows'
run: |
mkdir cache
C:msys64\usr\bin\wget.exe --tries=5 --timeout=10 --waitretry=10 --read-timeout=10 --retry-connrefused -O cache/luacheck.exe https://github.com/mpeterv/luacheck/releases/download/0.23.0/luacheck.exe
shell: cmd
- name: luacheck
run: |
PATH="/C/Program\ Files/Git/usr/bin:${PATH}"
./tools/travis/run-luacheck-${{ matrix.os }}.sh
shell: bash
doc_check:
strategy:
fail-fast: false
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
with:
submodules: false
- name: all_modules_linked
run: ./tools/check_docs_module_linkage.sh
shell: bash
...@@ -32,7 +32,10 @@ script: ...@@ -32,7 +32,10 @@ script:
- if [ "$OS" = "linux" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/pr-build.sh; fi - if [ "$OS" = "linux" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/pr-build.sh; fi
- cd "$TRAVIS_BUILD_DIR" - cd "$TRAVIS_BUILD_DIR"
- echo "checking:" - echo "checking:"
- find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 echo - find lua_modules lua_examples tests/NTest* -iname "*.lua" -print0 | xargs -0 echo
- find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 $LUACC -p - find lua_modules lua_examples tests/NTest* -iname "*.lua" -print0 | xargs -0 $LUACC -p
- cd tests/NTest
- if [ "$OS" = "linux" ]; then ../../$LUACC -e ../NTest/NTest_NTest.lua; fi
- cd "$TRAVIS_BUILD_DIR"
- if [ "$OS" = "linux" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/run-luacheck-linux.sh; fi - if [ "$OS" = "linux" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/run-luacheck-linux.sh; fi
- if [ "$OS" = "windows" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/run-luacheck-windows.sh; fi - if [ "$OS" = "windows" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/run-luacheck-windows.sh; fi
...@@ -78,7 +78,7 @@ As a Windows or Mac user you could also resort to [GitHub Desktop](https://deskt ...@@ -78,7 +78,7 @@ As a Windows or Mac user you could also resort to [GitHub Desktop](https://deskt
You need to sync your fork with the NodeMCU upstream repository from time to time, latest before you rebase (see flow above). You need to sync your fork with the NodeMCU upstream repository from time to time, latest before you rebase (see flow above).
1. `git fetch upstream` 1. `git fetch upstream`
1. `git checkout dev` but you may do this for `master` as well 1. `git checkout dev` but you may do this for `release` as well
1. `git merge upstream/dev` 1. `git merge upstream/dev`
### Commit messages ### Commit messages
...@@ -114,8 +114,8 @@ Don't forget to [reference affected issues](https://help.github.com/articles/clo ...@@ -114,8 +114,8 @@ Don't forget to [reference affected issues](https://help.github.com/articles/clo
- Add notes to the description of the milestone in the course of the ~2 months it lives. - Add notes to the description of the milestone in the course of the ~2 months it lives.
- Be careful and reluctant to merge PRs once we're past the 6-weeks mark of a milestone. Ideally, we don't merge anything in the last 2 weeks. - Be careful and reluctant to merge PRs once we're past the 6-weeks mark of a milestone. Ideally, we don't merge anything in the last 2 weeks.
- Cutting a release - Cutting a release
- Create a PR for the `master` branch for collaborators to approve. - Create a PR for the `release` branch for collaborators to approve.
- Once approved merge it. :exclamation::boom::exclamation: Make sure you do NOT "squash and merge" but make a regular merge commit! - Once approved merge it. :exclamation::boom::exclamation: Make sure you do NOT "squash and merge" but make a regular merge commit!
- Fetch the changes into your local clone and create an annotated tag like so: `git tag -a <SDK-version>-master_<yyyyMMdd> -m ""`, `git push --tags` - Fetch the changes into your local clone and create an annotated tag like so: `git tag -a <SDK-version>-release_<yyyyMMdd> -m ""`, `git push --tags`
- Create a new [release](https://github.com/nodemcu/nodemcu-firmware/releases) based on the tag you just pushed. The version name is the same as the tag name. - Create a new [release](https://github.com/nodemcu/nodemcu-firmware/releases) based on the tag you just pushed. The version name is the same as the tag name.
- Write release notes. Mention breaking changes explicitly. Since every PR that went into this release is linked to from the milestone it should be fairly easy to include important changes in the release notes. - Write release notes. Mention breaking changes explicitly. Since every PR that went into this release is linked to from the milestone it should be fairly easy to include important changes in the release notes.
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
[![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware) [![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware)
[![Documentation Status](https://img.shields.io/badge/docs-master-yellow.svg?style=flat)](http://nodemcu.readthedocs.io/en/master/) [![Documentation Status](https://img.shields.io/badge/docs-release-yellow.svg?style=flat)](http://nodemcu.readthedocs.io/en/release/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/nodemcu/nodemcu-firmware/blob/master/LICENSE) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/nodemcu/nodemcu-firmware/blob/release/LICENSE)
### A Lua based firmware for ESP8266 WiFi SOC ### A Lua based firmware for ESP8266 WiFi SOC
...@@ -14,9 +14,9 @@ The firmware was initially developed as is a companion project to the popular ES ...@@ -14,9 +14,9 @@ The firmware was initially developed as is a companion project to the popular ES
# Summary # Summary
- Easy to program wireless node and/or access point - Easy to program wireless node and/or access point
- Based on Lua 5.1.4 but without `debug`, `io`, `os` and (most of the) `math` modules - Based on Lua 5.1.4 or Lua 5.3 but without `debug`, `io`, `os` and (most of the) `math` modules
- Asynchronous event-driven programming model - Asynchronous event-driven programming model
- more than **65 built-in modules** - more than **70 built-in C modules** and **close to 20 Lua modules**
- Firmware available with or without floating point support (integer-only uses less memory) - Firmware available with or without floating point support (integer-only uses less memory)
- Up-to-date documentation at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io) - Up-to-date documentation at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io)
...@@ -48,23 +48,23 @@ wifi.sta.config{ssid="SSID", pwd="password"} ...@@ -48,23 +48,23 @@ wifi.sta.config{ssid="SSID", pwd="password"}
The entire [NodeMCU documentation](https://nodemcu.readthedocs.io) is maintained right in this repository at [/docs](docs). The fact that the API documentation is maintained in the same repository as the code that *provides* the API ensures consistency between the two. With every commit the documentation is rebuilt by Read the Docs and thus transformed from terse Markdown into a nicely browsable HTML site at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io). The entire [NodeMCU documentation](https://nodemcu.readthedocs.io) is maintained right in this repository at [/docs](docs). The fact that the API documentation is maintained in the same repository as the code that *provides* the API ensures consistency between the two. With every commit the documentation is rebuilt by Read the Docs and thus transformed from terse Markdown into a nicely browsable HTML site at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io).
- How to [build the firmware](https://nodemcu.readthedocs.io/en/master/en/build/) - How to [build the firmware](https://nodemcu.readthedocs.io/en/release/build/)
- How to [flash the firmware](https://nodemcu.readthedocs.io/en/master/en/flash/) - How to [flash the firmware](https://nodemcu.readthedocs.io/en/release/flash/)
- How to [upload code and NodeMCU IDEs](https://nodemcu.readthedocs.io/en/master/en/upload/) - How to [upload code and NodeMCU IDEs](https://nodemcu.readthedocs.io/en/release/upload/)
- API documentation for every module - API documentation for every module
# Releases # Releases
Due to the ever-growing number of modules available within NodeMCU, pre-built binaries are no longer made available. Use the automated [custom firmware build service](http://nodemcu-build.com/) to get the specific firmware configuration you need, or consult the [documentation](http://nodemcu.readthedocs.io/en/master/en/build/) for other options to build your own firmware. Due to the ever-growing number of modules available within NodeMCU, pre-built binaries are no longer made available. Use the automated [custom firmware build service](http://nodemcu-build.com/) to get the specific firmware configuration you need, or consult the [documentation](http://nodemcu.readthedocs.io/en/release/build/) for other options to build your own firmware.
This project uses two main branches, `release` and `dev`. `dev` is actively worked on and it's also where PRs should be created against. `release` thus can be considered "stable" even though there are no automated regression tests. The goal is to merge back to `release` roughly every 2 months. Depending on the current "heat" (issues, PRs) we accept changes to `dev` for 5-6 weeks and then hold back for 2-3 weeks before the next snap is completed. This project uses two main branches, `release` and `dev`. `dev` is actively worked on and it's also where PRs should be created against. `release` thus can be considered "stable" even though there are no automated regression tests. The goal is to merge back to `release` roughly every 2 months. Depending on the current "heat" (issues, PRs) we accept changes to `dev` for 5-6 weeks and then hold back for 2-3 weeks before the next snap is completed.
A new tag is created every time `dev` is merged back to `master`. They are listed in the [releases section here on GitHub](https://github.com/nodemcu/nodemcu-firmware/releases). Tag names follow the \<SDK-version\>-master_yyyymmdd pattern. A new tag is created every time `dev` is merged back to `release`. They are listed in the [releases section here on GitHub](https://github.com/nodemcu/nodemcu-firmware/releases). Tag names follow the \<SDK-version\>-release_yyyymmdd pattern.
# Support # Support
See [https://nodemcu.readthedocs.io/en/master/en/support/](https://nodemcu.readthedocs.io/en/master/en/support/). See [https://nodemcu.readthedocs.io/en/release/support/](https://nodemcu.readthedocs.io/en/release/support/).
# License # License
[MIT](https://github.com/nodemcu/nodemcu-firmware/blob/master/LICENSE) © [zeroday](https://github.com/NodeMCU)/[nodemcu.com](http://nodemcu.com/index_en.html) [MIT](https://github.com/nodemcu/nodemcu-firmware/blob/release/LICENSE) © [zeroday](https://github.com/NodeMCU)/[nodemcu.com](http://nodemcu.com/index_en.html)
...@@ -16,10 +16,15 @@ TARGET = eagle ...@@ -16,10 +16,15 @@ TARGET = eagle
FLAVOR = debug FLAVOR = debug
# Handle Lua Directory selector # Handle Lua Directory selector
ifeq ("$(LUA)","53") ifeq ("$(LUA)","")
LUA_DIR := lua
else ifeq ("$(LUA)","51")
LUA_DIR := lua
else ifeq ("$(LUA)","53")
LUA_DIR := lua53 LUA_DIR := lua53
else else
LUA_DIR := lua $(error Unsupported value "$(LUA)" for variable "LUA", \
expected "51", "53" or unset/empty)
endif endif
ifndef PDIR # { ifndef PDIR # {
...@@ -158,7 +163,7 @@ DDEFINES += \ ...@@ -158,7 +163,7 @@ DDEFINES += \
# Required for each makefile to inherit from the parent # Required for each makefile to inherit from the parent
# #
INCLUDES := -I $(PDIR)libc -I $(PDIR)$(LUA_DIR) -I $(PDIR)platform \ INCLUDES := -I $(PDIR)libc -I $(PDIR)$(LUA_DIR) -I $(PDIR)platform \
$(INCLUDES) -I $(PDIR) -I $(PDIR)include $(INCLUDES) -I $(PDIR) -I $(PDIR)include
PDIR := ../$(PDIR) PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile sinclude $(PDIR)Makefile
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
// //
// Released to the public domain // Released to the public domain
// //
// #define NODE_DEBUG
#include "user_interface.h" #include "user_interface.h"
#include "platform.h" #include "platform.h"
...@@ -40,21 +41,14 @@ ...@@ -40,21 +41,14 @@
#define HIGH 1 #define HIGH 1
#endif /* ifndef HIGH */ #endif /* ifndef HIGH */
#define COMBINE_HIGH_AND_LOW_BYTE(byte_high, byte_low) ((uint16_t)((byte_high) << 8) | (byte_low))
static double dht_humidity; static double dht_humidity;
static double dht_temperature; static double dht_temperature;
static uint8_t dht_bytes[5]; // buffer to receive data static uint8_t dht_bytes[5]; // buffer to receive data
typedef enum {
Humidity = 0,
Temperature,
Humidity8,
Temperature8
} dht_Signal;
static int dht_readSensor(uint8_t pin, uint8_t wakeupDelay); static int dht_readSensor(uint8_t pin, uint8_t wakeupDelay);
static double getValue(dht_Signal s);
static bool verifyChecksum();
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// //
...@@ -79,10 +73,15 @@ double dht_getTemperature(void) ...@@ -79,10 +73,15 @@ double dht_getTemperature(void)
// DHTLIB_OK // DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM // DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT // DHTLIB_ERROR_TIMEOUT
int dht_read_universal(uint8_t pin) int dht_read(uint8_t pin, dht_type type)
{ {
// READ VALUES // READ VALUES
int rv = dht_readSensor(pin, DHTLIB_DHT_UNI_WAKEUP); int rv = dht_readSensor(pin,
type == DHT22 ? DHTLIB_DHT_WAKEUP :
type == DHT11 ? DHTLIB_DHT11_WAKEUP :
DHTLIB_DHT_UNI_WAKEUP
);
if (rv != DHTLIB_OK) if (rv != DHTLIB_OK)
{ {
dht_humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered? dht_humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
...@@ -90,129 +89,73 @@ int dht_read_universal(uint8_t pin) ...@@ -90,129 +89,73 @@ int dht_read_universal(uint8_t pin)
return rv; // propagate error value return rv; // propagate error value
} }
#if defined(DHT_DEBUG_BYTES) NODE_DBG("DHT registers: %x\t%x\t%x\t%x\t%x == %x\n", dht_bytes[0], dht_bytes[1], dht_bytes[2], dht_bytes[3], dht_bytes[4], (uint8_t)(dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3]));
int i;
for (i = 0; i < 5; i++)
{
DHT_DEBUG("%02X\n", dht_bytes[i]);
}
#endif // defined(DHT_DEBUG_BYTES)
// Assume it is DHT11 // Assume it is special case of DHT11,
// i.e. positive temperature and dht_bytes[3] == 0 ((dht_bytes[3] & 0x0f) * 0.1 to be added to temperature readout)
// If it is DHT11, both temp and humidity's decimal // If it is DHT11, both temp and humidity's decimal
dht_humidity = dht_bytes[0];
dht_temperature = dht_bytes[2];
if ((dht_bytes[1] == 0) && (dht_bytes[3] == 0)) if ((dht_bytes[1] == 0) && (dht_bytes[3] == 0))
{ {
// It may DHT11 // It may DHT11
// CONVERT AND STORE // CONVERT AND STORE
DHT_DEBUG("DHT11 method\n"); NODE_DBG("DHT11 method\n");
dht_humidity = getValue(Humidity8);
dht_temperature = getValue(Temperature8);
// TEST CHECKSUM // TEST CHECKSUM
if (!verifyChecksum()) uint8_t sum = dht_bytes[0] + dht_bytes[2];
{ if (dht_bytes[4] == sum)
// It may not DHT11
dht_humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
dht_temperature = DHTLIB_INVALID_VALUE; // invalid value
// Do nothing
}
else
{ {
return DHTLIB_OK; return DHTLIB_OK;
} }
} }
// Assume it is not DHT11 // Assume it is not DHT11 special case
// CONVERT AND STORE // CONVERT AND STORE
DHT_DEBUG("DHTxx method\n"); NODE_DBG("DHTxx method\n");
dht_humidity = getValue(Humidity);
dht_temperature = getValue(Temperature); switch (type) {
case DHT11:
// TEST CHECKSUM case DHT12:
if (!verifyChecksum()) dht_humidity += dht_bytes[1] * 0.1;
{ break;
return DHTLIB_ERROR_CHECKSUM; default:
dht_humidity = COMBINE_HIGH_AND_LOW_BYTE(dht_bytes[0], dht_bytes[1]) * 0.1;
break;
} }
return DHTLIB_OK;
}
// return values: switch (type) {
// DHTLIB_OK case DHT11:
// DHTLIB_ERROR_CHECKSUM if (dht_bytes[3] & 0x80) {
// DHTLIB_ERROR_TIMEOUT dht_temperature = -1 - dht_temperature;
int dht_read11(uint8_t pin) }
{ dht_temperature += (dht_bytes[3] & 0x0f) * 0.1;
// READ VALUES break;
int rv = dht_readSensor(pin, DHTLIB_DHT11_WAKEUP); case DHT12:
if (rv != DHTLIB_OK) dht_temperature += (dht_bytes[3] & 0x0f) * 0.1;
{ if (dht_bytes[2] & 0x80) // negative dht_temperature
dht_humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered? {
dht_temperature = DHTLIB_INVALID_VALUE; // invalid value dht_temperature *= -1;
return rv; }
} break;
default: // DHT22, DHT_NON11
// CONVERT AND STORE dht_temperature = COMBINE_HIGH_AND_LOW_BYTE(dht_bytes[2] & 0x7F, dht_bytes[3]) * 0.1;
dht_humidity = getValue(Humidity8); if (dht_bytes[2] & 0x80) // negative dht_temperature
dht_temperature = getValue(Temperature8); {
dht_temperature *= -1;
// TEST CHECKSUM }
if (!verifyChecksum()) return DHTLIB_ERROR_CHECKSUM; break;
return DHTLIB_OK;
}
// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht_read(uint8_t pin)
{
// READ VALUES
int rv = dht_readSensor(pin, DHTLIB_DHT_WAKEUP);
if (rv != DHTLIB_OK)
{
dht_humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
dht_temperature = DHTLIB_INVALID_VALUE; // invalid value
return rv; // propagate error value
} }
// CONVERT AND STORE
dht_humidity = getValue(Humidity);
dht_temperature = getValue(Temperature);
// TEST CHECKSUM // TEST CHECKSUM
if (!verifyChecksum()) uint8_t sum = dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3];
if (dht_bytes[4] != sum)
{ {
return DHTLIB_ERROR_CHECKSUM; return DHTLIB_ERROR_CHECKSUM;
} }
return DHTLIB_OK; return DHTLIB_OK;
} }
// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht_read21(uint8_t pin) __attribute__((alias("dht_read")));
// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht_read22(uint8_t pin) __attribute__((alias("dht_read")));
// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht_read33(uint8_t pin) __attribute__((alias("dht_read")));
// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht_read44(uint8_t pin) __attribute__((alias("dht_read")));
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// //
// PRIVATE // PRIVATE
...@@ -236,7 +179,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay) ...@@ -236,7 +179,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)
// volatile uint8_t *PIR = portInputRegister(port); // volatile uint8_t *PIR = portInputRegister(port);
// EMPTY BUFFER // EMPTY BUFFER
memset(dht_bytes, sizeof(uint8_t)*5, 0); memset(dht_bytes, 0, sizeof(uint8_t)*5);
// REQUEST SAMPLE // REQUEST SAMPLE
// pinMode(pin, OUTPUT); // pinMode(pin, OUTPUT);
...@@ -309,32 +252,6 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay) ...@@ -309,32 +252,6 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)
return DHTLIB_OK; return DHTLIB_OK;
} }
// Assembles the high and low byte in a signed 16bit value
static double getValue(dht_Signal s)
{
uint8_t high=0, low=0;
// the '8' variants leave the low byte set to 0
switch(s){
case Humidity:
low = dht_bytes[1];
case Humidity8:
high = dht_bytes[0];
break;
case Temperature:
low = dht_bytes[3];
case Temperature8:
high = dht_bytes[2];
break;
}
return ((high << 8) | low) * 0.1;
}
static bool verifyChecksum(){
uint8_t sum = dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3];
return (dht_bytes[4] == sum);
}
// //
// END OF FILE // END OF FILE
// //
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#define DHTLIB_DHT_WAKEUP 1 #define DHTLIB_DHT_WAKEUP 1
#define DHTLIB_DHT_UNI_WAKEUP 18 #define DHTLIB_DHT_UNI_WAKEUP 18
#define DHT_DEBUG
// max timeout is 100 usec. // max timeout is 100 usec.
// For a 16 Mhz proc 100 usec is 1600 clock cycles // For a 16 Mhz proc 100 usec is 1600 clock cycles
// loops using DHTLIB_TIMEOUT use at least 4 clock cycli // loops using DHTLIB_TIMEOUT use at least 4 clock cycli
...@@ -48,19 +46,18 @@ ...@@ -48,19 +46,18 @@
#define DIRECT_WRITE_LOW(pin) (GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[pin]), 0)) #define DIRECT_WRITE_LOW(pin) (GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[pin]), 0))
#define DIRECT_WRITE_HIGH(pin) (GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[pin]), 1)) #define DIRECT_WRITE_HIGH(pin) (GPIO_OUTPUT_SET(GPIO_ID_PIN(pin_num[pin]), 1))
typedef enum {
DHT11 = 0,
DHT12,
DHT22,
DHT_NON11
} dht_type;
// return values: // return values:
// DHTLIB_OK // DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM // DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT // DHTLIB_ERROR_TIMEOUT
int dht_read_universal(uint8_t pin); int dht_read(uint8_t pin, dht_type type);
int dht_read11(uint8_t pin);
int dht_read(uint8_t pin);
int dht_read21(uint8_t pin);
int dht_read22(uint8_t pin);
int dht_read33(uint8_t pin);
int dht_read44(uint8_t pin);
double dht_getHumidity(void); double dht_getHumidity(void);
double dht_getTemperature(void); double dht_getTemperature(void);
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#define espconn_manual_recv_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) != 0) #define espconn_manual_recv_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) != 0)
#define espconn_manual_recv_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) == 0) #define espconn_manual_recv_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) == 0)
extern int ets_task();
extern int ets_post();
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_kill_oldest_pcb * FunctionName : espconn_kill_oldest_pcb
* Description : A oldest incoming connection has been killed. * Description : A oldest incoming connection has been killed.
......
...@@ -45,6 +45,14 @@ extern "C" { ...@@ -45,6 +45,14 @@ extern "C" {
typedef size_t mem_size_t; typedef size_t mem_size_t;
void *pvPortMalloc (size_t sz, const char *, unsigned, bool);
void vPortFree (void *p, const char *, unsigned);
void *pvPortZalloc (size_t sz, const char *, unsigned);
void *pvPortRealloc (void *p, size_t n, const char *, unsigned);
void* pvPortCalloc(size_t count,size_t size,const char *,unsigned);
void* pvPortCallocIram(size_t count,size_t size,const char *,unsigned);
void *pvPortZallocIram (size_t sz, const char *, unsigned);
/* aliases for C library malloc() */ /* aliases for C library malloc() */
#define mem_init() #define mem_init()
/* in case C library malloc() needs extra protection, /* in case C library malloc() needs extra protection,
......
...@@ -58,6 +58,9 @@ extern "C" { ...@@ -58,6 +58,9 @@ extern "C" {
* \{ * \{
*/ */
void *pvPortCalloc(unsigned int count, unsigned int size, const char*, unsigned);
void vPortFree (void *p, const char *, unsigned);
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -63,6 +63,9 @@ typedef enum{ ...@@ -63,6 +63,9 @@ typedef enum{
NETCONN_STATE_SUMNUM NETCONN_STATE_SUMNUM
}netconn_state; }netconn_state;
extern int __attribute__((weak)) espconn_mbedtls_parse_internal(int socket, sint8 error);
extern int __attribute__((weak)) espconn_mbedtls_parse_thread(int socket, int event, int error);
#if (!defined(lwIP_unlikely)) #if (!defined(lwIP_unlikely))
#define lwIP_unlikely(Expression) !!(Expression) #define lwIP_unlikely(Expression) !!(Expression)
#endif #endif
...@@ -330,4 +333,8 @@ uint32_t lwip_getul(char *str); ...@@ -330,4 +333,8 @@ uint32_t lwip_getul(char *str);
#define close(s) lwip_close(s) #define close(s) lwip_close(s)
#define getul(s) lwip_getul(s) #define getul(s) lwip_getul(s)
extern int system_overclock(void);
extern int system_restoreclock(void);
extern char *sys_itoa(int n);
#endif /* ESPCONN_SOCKT_H_ */ #endif /* ESPCONN_SOCKT_H_ */
...@@ -42,21 +42,34 @@ ...@@ -42,21 +42,34 @@
//#define DISABLE_STARTUP_BANNER //#define DISABLE_STARTUP_BANNER
// Three separate build variants are now supported. The main difference is in the // When using Lua 5.1, two different builds are now supported.
// processing of numeric data types. If LUA_NUMBER_INTEGRAL is defined, then // The main difference is in the // processing of numeric data types.
// If LUA_NUMBER_INTEGRAL is defined, then
// all numeric calculations are done in integer, with divide being an integer // all numeric calculations are done in integer, with divide being an integer
// operations, and decimal fraction constants are illegal. Otherwise all // operation, and decimal fraction constants are illegal.
// numeric operations use floating point, though they are exact for integer // Otherwise all floating point operations use doubles. All integer values
// expressions < 2^53. // can be represented exactly in floating point.
// The main advantage of INTEGRAL builds is that the basic internal storage unit,
// the TValue, is 8 bytes long. We have now reduced the size of FP TValues to
// 12 bytes rather than the previous 16 as this gives a material RAM saving with
// no performance loss. However, you can define LUA_DWORD_ALIGNED_TVALUES and
// this will force 16 byte TValues on FP builds.
//#define LUA_NUMBER_INTEGRAL //#define LUA_NUMBER_INTEGRAL
//#define LUA_DWORD_ALIGNED_TVALUES
// When using Lua 5.3, two different builds are now supported.
// The main difference is in the processing of numeric data types.
// If LUA_NUMBER_64BITS is defined, then doubles are used to hold floating
// point numbers. Integers under 2^53 are representable exactly in doubles.
// Integers are held in 64-bit variables.
// Otherwise all floating point operations use floats. Only integers under 2^24
// can be represented exactly in floating point. Integers are represented in 32 bit variables.
// Note that Lua 5.3 also supports Integers natively, but you have to be careful
// not to promote an integer to a floating point variable if you are using a float build
// as you can lose precision.
//#define LUA_NUMBER_64BITS
// The main advantage of INTEGRAL builds and non 64BITS builds is that the basic internal
// storage unit, the TValue, is 8 bytes long. For 64BITS builds, we have now reduced
// the size of FP TValues to 12 bytes rather than the previous 16 as this gives a
// material RAM saving with no performance loss.
//
// The Lua Flash Store (LFS) allows you to store Lua code in Flash memory and // The Lua Flash Store (LFS) allows you to store Lua code in Flash memory and
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
//#define LUA_USE_MODULES_PCM //#define LUA_USE_MODULES_PCM
//#define LUA_USE_MODULES_PERF //#define LUA_USE_MODULES_PERF
//#define LUA_USE_MODULES_PIPE //#define LUA_USE_MODULES_PIPE
//#define LUA_USE_MODULES_PIXBUF
//#define LUA_USE_MODULES_PWM //#define LUA_USE_MODULES_PWM
//#define LUA_USE_MODULES_PWM2 //#define LUA_USE_MODULES_PWM2
//#define LUA_USE_MODULES_RFSWITCH //#define LUA_USE_MODULES_RFSWITCH
......
...@@ -18,6 +18,20 @@ endif ...@@ -18,6 +18,20 @@ endif
STD_CFLAGS=-std=gnu11 -Wimplicit -Wall STD_CFLAGS=-std=gnu11 -Wimplicit -Wall
# Validate LUA setting
ifeq ("$(LUA)","")
else ifeq ("$(LUA)","51")
# ok
else ifeq ("$(LUA)","53")
$(error Your variable LUA="$(LUA)" looks like you probably want \
app/lua53/Makefile instead)
else
$(error Unsupported value "$(LUA)" for variable "LUA", \
expected empty/unset (recommended) or "51")
endif
############################################################# #############################################################
# Configuration i.e. compile options etc. # Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here! # Target specific stuff (defines etc.) goes in here!
......
...@@ -214,7 +214,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { ...@@ -214,7 +214,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
const char *msg = lua_pushfstring(L, "%s expected, got %s", const char *msg = lua_pushfstring(L, "%s expected, got %s",
tname, lua_typename(L, narg)); tname, luaL_typename(L, narg));
return luaL_argerror(L, narg, msg); return luaL_argerror(L, narg, msg);
} }
...@@ -285,21 +285,25 @@ LUALIB_API int luaL_rometatable (lua_State *L, const char* tname, const ROTable ...@@ -285,21 +285,25 @@ LUALIB_API int luaL_rometatable (lua_State *L, const char* tname, const ROTable
return 1; return 1;
} }
LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud); void *p = lua_touserdata(L, ud);
if (p != NULL) { /* value is a userdata? */ if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ if (!lua_rawequal(L, -1, -2)) /* not the same? */
lua_pop(L, 2); /* remove both metatables */ p = NULL; /* value is a userdata with wrong metatable */
return p; lua_pop(L, 2); /* remove both metatables */
} return p;
} }
} }
luaL_typerror(L, ud, tname); /* else error */ return NULL; /* value is not a userdata with a metatable */
return NULL; /* to avoid warnings */
} }
LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
void *p = luaL_testudata(L, ud, tname);
if (p == NULL) luaL_typerror(L, ud, tname);
return p;
}
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
if (!lua_checkstack(L, space)) if (!lua_checkstack(L, space))
......
...@@ -66,6 +66,7 @@ LUALIB_API void (luaL_checkany) (lua_State *L, int narg); ...@@ -66,6 +66,7 @@ LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
LUALIB_API int (luaL_rometatable) (lua_State *L, const char* tname, const ROTable *p); LUALIB_API int (luaL_rometatable) (lua_State *L, const char* tname, const ROTable *p);
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_where) (lua_State *L, int lvl); LUALIB_API void (luaL_where) (lua_State *L, int lvl);
......
...@@ -15,6 +15,20 @@ CCFLAGS += -Wall ...@@ -15,6 +15,20 @@ CCFLAGS += -Wall
TARGET = host TARGET = host
# Validate LUA setting
ifeq ("$(LUA)","")
else ifeq ("$(LUA)","51")
# ok
else ifeq ("$(LUA)","53")
$(error Your variable LUA="$(LUA)" looks like you probably want \
app/lua53/host/Makefile instead)
else
$(error Unsupported value "$(LUA)" for variable "LUA", \
expected empty/unset (recommended) or "51")
endif
VERBOSE ?= VERBOSE ?=
V ?= $(VERBOSE) V ?= $(VERBOSE)
ifeq ("$(V)","1") ifeq ("$(V)","1")
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
//## Modified for eLua //## Modified for eLua
//## Defaults search modules path to our ROM File System //## Defaults search modules path to our ROM File System
#ifndef LUA_RPC #ifndef LUA_RPC
#define LUA_PATH_DEFAULT "/rfs/?.lua;/rfs/?.lc;/mmc/?.lua;/mmc/?.lc;/rom/?.lua;/rom/?.lc" #define LUA_PATH_DEFAULT "?.lc;?.lua"
#define LUA_CPATH_DEFAULT "" #define LUA_CPATH_DEFAULT ""
#else // #ifndef LUA_RPC #else // #ifndef LUA_RPC
#define LUA_PATH_DEFAULT \ #define LUA_PATH_DEFAULT \
...@@ -181,6 +181,10 @@ ...@@ -181,6 +181,10 @@
#endif // #if !defined LUA_INTEGRAL_LONGLONG #endif // #if !defined LUA_INTEGRAL_LONGLONG
#endif // #if !defined LUA_NUMBER_INTEGRAL #endif // #if !defined LUA_NUMBER_INTEGRAL
#ifdef LUA_NUMBER_64BITS
#error Lua 5.1 does not support 64 bit inetegers.
#endif
/* /*
@@ LUA_API is a mark for all core API functions. @@ LUA_API is a mark for all core API functions.
@@ LUALIB_API is a mark for all standard library functions. @@ LUALIB_API is a mark for all standard library functions.
......
...@@ -18,6 +18,18 @@ endif ...@@ -18,6 +18,18 @@ endif
STD_CFLAGS=-std=gnu11 -Wimplicit -Wall STD_CFLAGS=-std=gnu11 -Wimplicit -Wall
# Validate LUA setting
ifeq ("$(LUA)","53")
# ok
else ifeq ("$(LUA)","51")
$(error Your variable LUA="$(LUA)" looks like you probably want \
app/lua/Makefile instead)
else
$(error Expected environment variable "LUA" to be "53", not "$(LUA)")
endif
############################################################# #############################################################
# Configuration i.e. compile options etc. # Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here! # Target specific stuff (defines etc.) goes in here!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment