Browse Source

Testing core_version.h for PlatformIO

fastled
Xose Pérez 7 years ago
parent
commit
9ac2cad859
8 changed files with 84 additions and 9 deletions
  1. +1
    -0
      code/.gitignore
  2. +51
    -0
      code/core_version.py
  3. +5
    -1
      code/espurna/config/all.h
  4. +1
    -0
      code/espurna/config/prototypes.h
  5. +2
    -2
      code/espurna/espurna.ino
  6. +0
    -1
      code/espurna/light_ir.ino
  7. +18
    -0
      code/espurna/utils.ino
  8. +6
    -5
      code/platformio.ini

+ 1
- 0
code/.gitignore View File

@ -3,3 +3,4 @@
.pioenvs .pioenvs
.piolibdeps .piolibdeps
.vscode/c_cpp_properties.json .vscode/c_cpp_properties.json
core_version.h

+ 51
- 0
code/core_version.py View File

@ -0,0 +1,51 @@
#!/bin/python
import json
import commands
import subprocess
import os
import sys
def core_version(env):
# Get the core folder
fwdir = env["FRAMEWORK_ARDUINOESP8266_DIR"]
# Get the core version
with open(fwdir + '/package.json') as data_file:
data = json.load(data_file)
core_version = data["version"].upper().replace(".", "_").replace("-", "_")
print "CORE VERSION: %s" % core_version
# Get git version
pr = subprocess.Popen(
"git --git-dir .git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff",
cwd = fwdir,
shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
(out, error) = pr.communicate()
git_version = str(out).replace('\n', "")
print "GIT VERSION: %s" % git_version
#env["BUILD_FLAGS"][0] += str(" -DARDUINO_ESP8266_RELEASE=" + core_version)
#env["BUILD_FLAGS"][0] += str(" -DARDUINO_ESP8266_RELEASE_" + core_version)
#env["BUILD_FLAGS"][0] += str(" -DARDUINO_ESP8266_GIT_VER=" + git_version)
with open('espurna/config/core_version.h', 'w') as the_file:
the_file.write('#define ARDUINO_ESP8266_RELEASE "%s"\n' % core_version)
the_file.write('#define ARDUINO_ESP8266_RELEASE_%s\n' % core_version)
the_file.write('#define ARDUINO_ESP8266_GIT_VER "%s"\n' % git_version)
#env.Append(
# CFLAGS = [
# str("-DARDUINO_ESP8266_RELEASE=" + core_version),
# str("-DARDUINO_ESP8266_RELEASE_" + core_version),
# str("-DARDUINO_ESP8266_GIT_VER=" + git_version)
# ]
#)
#print " -DARDUINO_ESP8266_RELEASE=" + core_version +
# " -DARDUINO_ESP8266_RELEASE_" + core_version +
# " -DARDUINO_ESP8266_GIT_VER=" + git_version
Import('env')
core_version(env)

+ 5
- 1
code/espurna/config/all.h View File

@ -5,9 +5,13 @@
#include "sensors.h" #include "sensors.h"
#include "prototypes.h" #include "prototypes.h"
#ifdef USE_CORE_VERSION_H
#include "core_version.h"
#endif
/* /*
If you want to modify the stock configuration but you don't want to touch If you want to modify the stock configuration but you don't want to touch
the repo files you can either define USE_CUSTOM_H or remove the
the repo files you can either define USE_CUSTOM_H or remove the
"#ifdef USE_CUSTOM_H" & "#endif" lines and add a "custom.h" "#ifdef USE_CUSTOM_H" & "#endif" lines and add a "custom.h"
file to this same folder. file to this same folder.
Check https://bitbucket.org/xoseperez/espurna/issues/104/general_customh Check https://bitbucket.org/xoseperez/espurna/issues/104/general_customh


+ 1
- 0
code/espurna/config/prototypes.h View File

@ -4,6 +4,7 @@
#include <AsyncMqttClient.h> #include <AsyncMqttClient.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <functional> #include <functional>
#include <FastLED.h>
AsyncWebServer * webServer(); AsyncWebServer * webServer();


+ 2
- 2
code/espurna/espurna.ino View File

@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config/all.h" #include "config/all.h"
#include <EEPROM.h> #include <EEPROM.h>
#include <FastLED.h> // W.T.H. is this include ALSO needed here ?!?!!
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// METHODS // METHODS
@ -82,7 +81,8 @@ void welcome() {
DEBUG_MSG_P(PSTR("[INIT] CPU chip ID: 0x%06X\n"), ESP.getChipId()); DEBUG_MSG_P(PSTR("[INIT] CPU chip ID: 0x%06X\n"), ESP.getChipId());
DEBUG_MSG_P(PSTR("[INIT] CPU frequency: %d MHz\n"), ESP.getCpuFreqMHz()); DEBUG_MSG_P(PSTR("[INIT] CPU frequency: %d MHz\n"), ESP.getCpuFreqMHz());
DEBUG_MSG_P(PSTR("[INIT] SDK version: %s\n"), ESP.getSdkVersion()); DEBUG_MSG_P(PSTR("[INIT] SDK version: %s\n"), ESP.getSdkVersion());
DEBUG_MSG_P(PSTR("[INIT] Core version: %s\n"), ESP.getCoreVersion().c_str());
DEBUG_MSG_P(PSTR("[INIT] Core version: %s\n"), getCoreVersion().c_str());
DEBUG_MSG_P(PSTR("[INIT] Core revision: %s\n"), getCoreRevision().c_str());
DEBUG_MSG_P(PSTR("\n")); DEBUG_MSG_P(PSTR("\n"));
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------


+ 0
- 1
code/espurna/light_ir.ino View File

@ -21,7 +21,6 @@ Not currently Implemented :
*/ */
#ifdef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR #ifdef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR
#include <FastLED.h> #include <FastLED.h>


+ 18
- 0
code/espurna/utils.ino View File

@ -15,6 +15,24 @@ String getIdentifier() {
return String(buffer); return String(buffer);
} }
String getCoreVersion() {
String version = ESP.getCoreVersion();
#ifdef ARDUINO_ESP8266_RELEASE
if (version.equals("00000000")) {
version = String(ARDUINO_ESP8266_RELEASE);
}
#endif
return version;
}
String getCoreRevision() {
#ifdef ARDUINO_ESP8266_GIT_VER
return String(ARDUINO_ESP8266_GIT_VER);
#else
return String("");
#endif
}
String buildTime() { String buildTime() {
const char time_now[] = __TIME__; // hh:mm:ss const char time_now[] = __TIME__; // hh:mm:ss


+ 6
- 5
code/platformio.ini View File

@ -4,18 +4,16 @@ src_dir = espurna
data_dir = espurna/data data_dir = espurna/data
[common] [common]
platform = espressif8266
#platform = espressif8266_stage
#platform = espressif8266
platform = espressif8266_stage
build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS} build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS}
debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM
build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld
build_flags_1m = ${common.build_flags} -Wl,-Tesp8266.flash.1m0.ld build_flags_1m = ${common.build_flags} -Wl,-Tesp8266.flash.1m0.ld
#https://github.com/me-no-dev/ESPAsyncTCP#9b0cc37 // 2.3.0 compatible
#https://github.com/me-no-dev/ESPAsyncTCP#289a681 // 2.4.0-rc2 compatible
lib_deps = lib_deps =
https://github.com/xoseperez/Time https://github.com/xoseperez/Time
ArduinoJson ArduinoJson
https://github.com/me-no-dev/ESPAsyncTCP#9b0cc37
https://github.com/me-no-dev/ESPAsyncTCP#a57560d
https://github.com/me-no-dev/ESPAsyncWebServer#313f337 https://github.com/me-no-dev/ESPAsyncWebServer#313f337
https://github.com/marvinroger/async-mqtt-client#v0.8.1 https://github.com/marvinroger/async-mqtt-client#v0.8.1
PubSubClient PubSubClient
@ -36,6 +34,8 @@ lib_deps =
https://github.com/FastLED/FastLED#v3.1.6 https://github.com/FastLED/FastLED#v3.1.6
https://github.com/markszabo/IRremoteESP8266#v2.2.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0
lib_ignore = lib_ignore =
#extra_scripts = post:core_version.py
extra_scripts =
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -48,6 +48,7 @@ lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH build_flags = ${common.build_flags} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH
upload_speed = 460800 upload_speed = 460800
monitor_baud = 115200 monitor_baud = 115200
extra_scripts = ${common.extra_scripts}
[env:wemos-d1mini-relayshield-ssl] [env:wemos-d1mini-relayshield-ssl]
platform = espressif8266_stage platform = espressif8266_stage


Loading…
Cancel
Save