Merge pull request #389 from cyberman54/master

sync dev to master
This commit is contained in:
Verkehrsrot 2019-07-09 21:09:24 +02:00 committed by GitHub
commit 293895055f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 96 additions and 91 deletions

View File

@ -3,6 +3,8 @@
Tutorial (in german language): https://www.heise.de/select/make/2019/1/1551099236518668 Tutorial (in german language): https://www.heise.de/select/make/2019/1/1551099236518668
**IMPORTANT: MUST USE PLATFORMIO V4 (not v3.x)**
<img src="img/Paxcounter-title.jpg"> <img src="img/Paxcounter-title.jpg">
<img src="img/Paxcounter-ttgo.jpg"> <img src="img/Paxcounter-ttgo.jpg">
<img src="img/Paxcounter-lolin.gif"> <img src="img/Paxcounter-lolin.gif">
@ -410,8 +412,8 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
bits 4..7 time status bits 4..7 time status
0x00 = timeNotSet (never synched) 0x00 = timeNotSet (never synched)
0x10 = timeNeedsSync (last sync failed) 0x01 = timeNeedsSync (last sync failed)
0x20 = timeSet (synched) 0x02 = timeSet (synched)
0x87 set time/date 0x87 set time/date

View File

@ -1,5 +1,5 @@
# build.py # build.py
# pre-build script, setting up build environment # pre-build script, setting up build environment and fetch hal file for user's board
import sys import sys
import os import os
@ -55,8 +55,20 @@ if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK):
else: else:
sys.exit("Missing file " + otakeyfile + ", please create it! Aborting.") sys.exit("Missing file " + otakeyfile + ", please create it! Aborting.")
# parse ota key file # parse hal file
mykeys = {} mykeys = {}
with open(halconfigfile) as myfile:
for line in myfile:
line2 = line.strip("// ")
key, value = line2.partition(" ")[::2]
mykeys[key.strip()] = str(value).strip()
myboard = mykeys["board"]
myuploadspeed = mykeys["upload_speed"]
env.Replace(BOARD=myboard)
env.Replace(UPLOAD_SPEED=myuploadspeed)
print '\033[94m' + "TARGET BOARD: " + myboard + " @ " + myuploadspeed + "bps" + '\033[0m'
# parse ota key file
with open(otakeyfile) as myfile: with open(otakeyfile) as myfile:
for line in myfile: for line in myfile:
key, value = line.partition("=")[::2] key, value = line.partition("=")[::2]

View File

@ -5,103 +5,43 @@
; http://docs.platformio.org/page/projectconf.html ; http://docs.platformio.org/page/projectconf.html
; ---> SELECT TARGET PLATFORM HERE! <--- ; ---> SELECT THE TARGET PLATFORM HERE! <---
[board] [board]
halfile = generic.h
;halfile = ebox.h ;halfile = ebox.h
;board = esp32dev
;upload_speed = 115200
;halfile = eboxtube.h ;halfile = eboxtube.h
;board = esp32dev
;upload_speed = 115200
;halfile = ecopower.h ;halfile = ecopower.h
;board = esp32dev
;upload_speed = 921600
;halfile = heltec.h ;halfile = heltec.h
;board = heltec_wifi_lora_32
;upload_speed = 921600
;halfile = heltecv2.h ;halfile = heltecv2.h
;board = heltec_wifi_lora_32_V2
;upload_speed = 921600
;halfile = ttgov1.h ;halfile = ttgov1.h
;board = ttgo-lora32-v1
;upload_speed = 115200
;halfile = ttgov2.h ;halfile = ttgov2.h
;board = ttgo-lora32-v1
;upload_speed = 921600
;halfile = ttgov21old.h ;halfile = ttgov21old.h
;board = esp32dev
;upload_speed = 921600
;halfile = ttgov21new.h ;halfile = ttgov21new.h
;board = esp32dev
;upload_speed = 921600
;halfile = ttgofox.h ;halfile = ttgofox.h
;board = esp32dev ;halfile = ttgobeam.h
;upload_speed = 921600
halfile = ttgobeam.h
board = ttgo-t-beam
upload_speed = 921600
;halfile = fipy.h ;halfile = fipy.h
;board = esp32dev
;upload_speed = 921600
;halfile = lopy.h ;halfile = lopy.h
;board = lopy
;upload_speed = 921600
;halfile = lopy4.h ;halfile = lopy4.h
;board = lopy4
;upload_speed = 921600
;halfile = lolin32litelora.h ;halfile = lolin32litelora.h
;board = lolin32
;upload_speed = 921600
;halfile = lolin32lora.h ;halfile = lolin32lora.h
;board = lolin32
;upload_speed = 921600
;halfile = lolin32lite.h ;halfile = lolin32lite.h
;board = lolin32
;upload_speed = 921600
;halfile = wemos32oled.h ;halfile = wemos32oled.h
;board = lolin32
;upload_speed = 921600
;halfile = octopus32.h ;halfile = octopus32.h
;board = featheresp32
;upload_speed = 921600
;halfile = generic.h
;board = esp32dev
;upload_speed = 115200
[platformio] [platformio]
; upload firmware to board with usb cable ; upload firmware to board with usb cable
;default_envs = usb default_envs = usb
; upload firmware to a jfrog bintray repository ; upload firmware to a jfrog bintray repository
;default_envs = ota ;default_envs = ota
default_envs = dev ;default_envs = dev
build_cache_dir = /tmp/platformio-shared-cache build_cache_dir = /tmp/platformio-shared-cache
description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around.
[common] [common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c" ; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
release_version = 1.7.71 release_version = 1.7.8
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 3 debug_level = 3
@ -111,7 +51,9 @@ lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@1.9.0 platform_espressif32 = espressif32@1.9.0
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
board = esp32dev
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 115200
lib_deps_lora = lib_deps_lora =
;MCCI LoRaWAN LMIC library@2.3.2 ;MCCI LoRaWAN LMIC library@2.3.2
https://github.com/mcci-catena/arduino-lmic.git https://github.com/mcci-catena/arduino-lmic.git
@ -124,12 +66,12 @@ lib_deps_rgbled =
lib_deps_gps = lib_deps_gps =
1655@>=1.0.2 ;TinyGPSPlus by Mikal Hart 1655@>=1.0.2 ;TinyGPSPlus by Mikal Hart
lib_deps_sensors = lib_deps_sensors =
Adafruit Unified Sensor@^1.0.3 Adafruit Unified Sensor@>=1.0.3
Adafruit BME280 Library@1.0.8 Adafruit BME280 Library@>=1.0.9
lib_deps_basic = lib_deps_basic =
ArduinoJson@^5.13.1 ArduinoJson@^5.13.1
76@^1.2.2 ;Timezone by Jack Christensen 76@>=1.2.2 ;Timezone by Jack Christensen
274@^2.3.3 ;RTC by Michael Miller 274@>=2.3.3 ;RTC by Michael Miller
SimpleButton SimpleButton
lib_deps_all = lib_deps_all =
${common.lib_deps_basic} ${common.lib_deps_basic}
@ -137,6 +79,7 @@ lib_deps_all =
${common.lib_deps_display} ${common.lib_deps_display}
${common.lib_deps_rgbled} ${common.lib_deps_rgbled}
${common.lib_deps_gps} ${common.lib_deps_gps}
${common.lib_deps_sensors}
${common.lib_deps_matrix_display} ${common.lib_deps_matrix_display}
build_flags_basic = build_flags_basic =
-include "src/hal/${board.halfile}" -include "src/hal/${board.halfile}"
@ -154,8 +97,8 @@ build_flags_all =
-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-issue
[env] [env]
board = ${board.board} board = ${common.board}
upload_speed = ${board.upload_speed} upload_speed = ${common.upload_speed}
platform = ${common.platform_espressif32} platform = ${common.platform_espressif32}
framework = arduino framework = arduino
board_build.partitions = ${common.board_build.partitions} board_build.partitions = ${common.board_build.partitions}
@ -173,6 +116,7 @@ upload_protocol = esptool
[env:dev] [env:dev]
upload_protocol = esptool upload_protocol = esptool
build_type = debug
platform = https://github.com/platformio/platform-espressif32.git#develop platform = https://github.com/platformio/platform-espressif32.git#develop
platform_packages = platform_packages =
; use upstream Git version ; use upstream Git version

View File

@ -77,16 +77,24 @@ void gps_storelocation(gpsStatus_t &gps_store) {
// store current GPS timedate in struct // store current GPS timedate in struct
void IRAM_ATTR gps_storetime(gpsStatus_t &gps_store) { void IRAM_ATTR gps_storetime(gpsStatus_t &gps_store) {
gps_store.time_age = gps.time.age(); if (gps.time.isUpdated() && gps.date.isValid() && (gps.time.age() < 1000)) {
if (gps.time.isValid() && gps.date.isValid() && (gps_store.time_age < 1000)) { /* nmea telegram serial delay compensation; not sure if we need this?
if (gps.time.age() > nmea_txDelay_ms)
gps_store.timedate.Second = gps.time.second() + 1;
else
gps_store.timedate.Second = gps.time.second();
*/
gps_store.timedate.Second = gps.time.second();
gps_store.timedate.Minute = gps.time.minute();
gps_store.timedate.Hour = gps.time.hour();
gps_store.timedate.Day = gps.date.day();
gps_store.timedate.Month = gps.date.month();
gps_store.timedate.Year = gps_store.timedate.Year =
CalendarYrToTm(gps.date.year()); // year offset from 1970 in microTime.h CalendarYrToTm(gps.date.year()); // year offset from 1970 in microTime.h
gps_store.timedate.Month = gps.date.month();
gps_store.timedate.Day = gps.date.day();
gps_store.timedate.Hour = gps.time.hour();
gps_store.timedate.Minute = gps.time.minute();
gps_store.timedate.Second = gps.time.second();
} else } else
gps_store.timedate = {0}; gps_store.timedate = {0};
} }
@ -96,11 +104,8 @@ time_t get_gpstime(gpsStatus_t value) {
time_t t = timeIsValid(makeTime(value.timedate)); time_t t = timeIsValid(makeTime(value.timedate));
// if (t)
// t = value.time_age > nmea_txDelay_ms ? t : t - 1;
// show NMEA data in verbose mode, useful for debugging GPS // show NMEA data in verbose mode, useful for debugging GPS
ESP_LOGV( ESP_LOGD(
TAG, TAG,
"GPS time: %d | GPS NMEA data: passed %d / failed: %d / with fix: %d", t, "GPS time: %d | GPS NMEA data: passed %d / failed: %d / with fix: %d", t,
gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix()); gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix());

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 115200
// board esp32dev
#ifndef _EBOX_H #ifndef _EBOX_H
#define _EBOX_H #define _EBOX_H

View File

@ -1,4 +1,7 @@
// clang-format off // clang-format off
// upload_speed 115200
// board esp32dev
#ifndef _EBOXTUBE_H #ifndef _EBOXTUBE_H
#define _EBOXTUBE_H #define _EBOXTUBE_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board esp32dev
#ifndef _GENERIC_H #ifndef _GENERIC_H
#define _GENERIC_H #define _GENERIC_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board esp32dev
#ifndef _FIPY_H #ifndef _FIPY_H
#define _FIPY_H #define _FIPY_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 115200
// board esp32dev
#ifndef _GENERIC_H #ifndef _GENERIC_H
#define _GENERIC_H #define _GENERIC_H

View File

@ -1,5 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board heltec_wifi_lora_32
#ifndef _HELTEC_H #ifndef _HELTEC_H
#define _HELTEC_H #define _HELTEC_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board heltec_wifi_lora_32_V2
#ifndef _HELTECV2_H #ifndef _HELTECV2_H
#define _HELTECV2_H #define _HELTECV2_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board lolin32
#ifndef _LOLINLITE_H #ifndef _LOLINLITE_H
#define _LOLINLITE_H #define _LOLINLITE_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board lolin32
#ifndef _LOLINLITELORA_H #ifndef _LOLINLITELORA_H
#define _LOLINLITELORA_H #define _LOLINLITELORA_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board lolin32
#ifndef _LOLINLORA_H #ifndef _LOLINLORA_H
#define _LOLINLORA_H #define _LOLINLORA_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board lopy
#ifndef _LOPY_H #ifndef _LOPY_H
#define _LOPY_H #define _LOPY_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board lopy4
#ifndef _LOPY4_H #ifndef _LOPY4_H
#define _LOPY4_H #define _LOPY4_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board featheresp32
#ifndef _OCTOPUS_H #ifndef _OCTOPUS_H
#define _OCTOPUS_H #define _OCTOPUS_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board ttgo-t-beam
#ifndef _TTGOBEAM_H #ifndef _TTGOBEAM_H
#define _TTGOBEAM_H #define _TTGOBEAM_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board esp32dev
#ifndef _TTGOFOX_H #ifndef _TTGOFOX_H
#define _TTGOFOX_H #define _TTGOFOX_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 115200
// board ttgo-lora32-v1
#ifndef _TTGOV1_H #ifndef _TTGOV1_H
#define _TTGOV1_H #define _TTGOV1_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board ttgo-lora32-v1
#ifndef _TTGOV2_H #ifndef _TTGOV2_H
#define _TTGOV2_H #define _TTGOV2_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board esp32dev
#ifndef _TTGOV21NEW_H #ifndef _TTGOV21NEW_H
#define _TTGOV21NEW_H #define _TTGOV21NEW_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board esp32dev
#ifndef _TTGOV21OLD_H #ifndef _TTGOV21OLD_H
#define _TTGOV21OLD_H #define _TTGOV21OLD_H

View File

@ -1,4 +1,6 @@
// clang-format off // clang-format off
// upload_speed 921600
// board lolin32
#ifndef _WEMOS32OLED_H #ifndef _WEMOS32OLED_H
#define _WEMOS32OLED_H #define _WEMOS32OLED_H

View File

@ -31,7 +31,7 @@ time_t timeProvider(void) {
time_t t = 0; time_t t = 0;
#if (HAS_GPS) #if (HAS_GPS)
// fetch recent time from last NEMA record // fetch recent time from last NMEA record
t = get_gpstime(gps_pps_status); t = get_gpstime(gps_pps_status);
if (t) { if (t) {
#ifdef HAS_RTC #ifdef HAS_RTC
@ -140,9 +140,11 @@ void IRAM_ATTR CLOCKIRQ(void) {
SyncToPPS(); // advance systime, see microTime.h SyncToPPS(); // advance systime, see microTime.h
// store recent gps time, if we have gps // store recent gps time, and try to get gps time if time is not synced
#if (HAS_GPS) #if (HAS_GPS)
gps_storetime(gps_pps_status); gps_storetime(gps_pps_status);
if (timeSource == _unsynced)
timeSync();
#endif #endif
// advance wall clock, if we have // advance wall clock, if we have