Version numbers done via tags
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -14,6 +14,8 @@ steps:
|
|||||||
- make otaupload
|
- make otaupload
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
- name: release
|
- name: release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
settings:
|
settings:
|
||||||
@ -24,3 +26,5 @@ steps:
|
|||||||
- .pio/build/nodemcu/firmware.bin
|
- .pio/build/nodemcu/firmware.bin
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
|
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#ifndef CONFIG_VERSION
|
||||||
|
#define CONFIG_VERSION "v0.4.4-Dev"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CONFIG_SERIAL_BAUDRATE 115200
|
#define CONFIG_SERIAL_BAUDRATE 115200
|
||||||
|
|
||||||
#define CONFIG_IO_RELAY D1
|
#define CONFIG_IO_RELAY D1
|
||||||
|
@ -1,29 +1,10 @@
|
|||||||
#
|
|
||||||
# Project Configuration File
|
|
||||||
#
|
|
||||||
# A detailed documentation with the EXAMPLES is located here:
|
|
||||||
# http://docs.platformio.org/en/latest/projectconf.html
|
|
||||||
#
|
|
||||||
|
|
||||||
# A sign `#` at the beginning of the line indicates a comment
|
|
||||||
# Comment lines are ignored.
|
|
||||||
|
|
||||||
# Simple and base environment
|
|
||||||
# [env:mybaseenv]
|
|
||||||
# platform = %INSTALLED_PLATFORM_NAME_HERE%
|
|
||||||
# framework =
|
|
||||||
# board =
|
|
||||||
#
|
|
||||||
# Automatic targets - enable auto-uploading
|
|
||||||
# targets = upload
|
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
upload_speed=921600
|
upload_speed=921600
|
||||||
|
|
||||||
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -DCONFIG_VERSION=${sysenv.DRONE_TAG}
|
||||||
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop-v3, DHT sensor library for ESPx
|
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop-v3, DHT sensor library for ESPx
|
||||||
|
|
||||||
[env:nodemcu]
|
[env:nodemcu]
|
||||||
|
24
src/main.cpp
24
src/main.cpp
@ -5,7 +5,6 @@
|
|||||||
DHTesp dht;
|
DHTesp dht;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define OUTPUT_SET(x) digitalWrite(CONFIG_IO_RELAY, x ? LOW : HIGH)
|
#define OUTPUT_SET(x) digitalWrite(CONFIG_IO_RELAY, x ? LOW : HIGH)
|
||||||
unsigned int timer = 0;
|
unsigned int timer = 0;
|
||||||
unsigned int next_timer_update = 0;
|
unsigned int next_timer_update = 0;
|
||||||
@ -14,10 +13,14 @@ HomieNode temperatureNode("temperature", "Temperature", "temperature");
|
|||||||
|
|
||||||
bool powerStateHandler(const HomieRange& range, const String& value)
|
bool powerStateHandler(const HomieRange& range, const String& value)
|
||||||
{
|
{
|
||||||
if (value != "on" && value != "off") return false;
|
if (value != "on" && value != "off")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
powerNode.setProperty("state").send(value);
|
powerNode.setProperty("state").send(value);
|
||||||
powerNode.setProperty("timer").send("0");
|
powerNode.setProperty("timer").send("0");
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
|
||||||
if(value == "on")
|
if(value == "on")
|
||||||
{
|
{
|
||||||
OUTPUT_SET(true);
|
OUTPUT_SET(true);
|
||||||
@ -50,6 +53,7 @@ bool powerTimerHandler(const HomieRange& range, const String& value)
|
|||||||
|
|
||||||
void setupHandler()
|
void setupHandler()
|
||||||
{
|
{
|
||||||
|
|
||||||
pinMode(CONFIG_IO_RELAY, OUTPUT);
|
pinMode(CONFIG_IO_RELAY, OUTPUT);
|
||||||
OUTPUT_SET(false);
|
OUTPUT_SET(false);
|
||||||
powerNode.setProperty("state").send("off");
|
powerNode.setProperty("state").send("off");
|
||||||
@ -58,7 +62,7 @@ void setupHandler()
|
|||||||
dht.setup(CONFIG_IO_DHT11, DHTesp::DHT11); // Connect DHT sensor to GPIO 17
|
dht.setup(CONFIG_IO_DHT11, DHTesp::DHT11); // Connect DHT sensor to GPIO 17
|
||||||
}
|
}
|
||||||
|
|
||||||
void loopHandler()
|
void loopHandleTimer()
|
||||||
{
|
{
|
||||||
if(timer)
|
if(timer)
|
||||||
{
|
{
|
||||||
@ -78,7 +82,10 @@ void loopHandler()
|
|||||||
powerNode.setProperty("timer").send(String(min_left));
|
powerNode.setProperty("timer").send(String(min_left));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loopHandleTemperature()
|
||||||
|
{
|
||||||
static unsigned long lastTemperatureSent = 0;
|
static unsigned long lastTemperatureSent = 0;
|
||||||
if (millis() - lastTemperatureSent >= CONFIG_TEMPERATURE_SEND_INTERVAL * 1000UL || lastTemperatureSent == 0)
|
if (millis() - lastTemperatureSent >= CONFIG_TEMPERATURE_SEND_INTERVAL * 1000UL || lastTemperatureSent == 0)
|
||||||
{
|
{
|
||||||
@ -92,16 +99,25 @@ void loopHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loopHandler()
|
||||||
|
{
|
||||||
|
loopHandleTimer();
|
||||||
|
loopHandleTemperature();
|
||||||
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(CONFIG_SERIAL_BAUDRATE);
|
Serial.begin(CONFIG_SERIAL_BAUDRATE);
|
||||||
|
|
||||||
Homie_setFirmware("deskcontrol", "0.4.2");
|
Homie_setFirmware("deskcontrol", CONFIG_VERSION);
|
||||||
|
|
||||||
Homie.disableResetTrigger();
|
Homie.disableResetTrigger();
|
||||||
|
|
||||||
|
//Power
|
||||||
powerNode.advertise("state").settable(powerStateHandler);
|
powerNode.advertise("state").settable(powerStateHandler);
|
||||||
powerNode.advertise("timer").settable(powerTimerHandler);
|
powerNode.advertise("timer").settable(powerTimerHandler);
|
||||||
|
|
||||||
|
//Temperature
|
||||||
temperatureNode.advertise("humidity");
|
temperatureNode.advertise("humidity");
|
||||||
temperatureNode.advertise("temperature");
|
temperatureNode.advertise("temperature");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user