Browse Source

More cleaning up

pull/463/head
Xose Pérez 6 years ago
parent
commit
7204c46d26
6 changed files with 2255 additions and 2247 deletions
  1. +1
    -0
      code/espurna/config/arduino.h
  2. +6
    -3
      code/espurna/config/general.h
  3. BIN
      code/espurna/data/index.html.gz
  4. +3
    -0
      code/espurna/espurna.ino
  5. +10
    -10
      code/espurna/scheduler.ino
  6. +2235
    -2234
      code/espurna/static/index.html.gz.h

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

@ -80,6 +80,7 @@
//#define NOFUSS_SUPPORT 1
//#define NTP_SUPPORT 0
//#define RF_SUPPORT 1
//#define SCHEDULER_SUPPORT 0
//#define SPIFFS_SUPPORT 1
//#define SSDP_SUPPORT 1
//#define TELNET_SUPPORT 0


+ 6
- 3
code/espurna/config/general.h View File

@ -675,9 +675,12 @@ PROGMEM const char* const custom_reset_string[] = {
// SCHEDULER
// -----------------------------------------------------------------------------
#define SCHEDULER_SUPPORT 1
#define SCH_UPDATE_SEC 5 // Scheduler perform switch at hh:mm:05
#define MAX_SCHEDULED 10
#ifndef SCHEDULER_SUPPORT
#define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
#endif
#define SCHEDULER_UPDATE_SEC 5 // Scheduler perform switch at hh:mm:05
#define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
// -----------------------------------------------------------------------------
// NTP


BIN
code/espurna/data/index.html.gz View File


+ 3
- 0
code/espurna/espurna.ino View File

@ -173,6 +173,9 @@ void welcome() {
#if RF_SUPPORT
DEBUG_MSG_P(PSTR(" RF"));
#endif
#if SCHEDULER_SUPPORT
DEBUG_MSG_P(PSTR(" SCHEDULER"));
#endif
#if SENSOR_SUPPORT
DEBUG_MSG_P(PSTR(" SENSOR"));
#endif


+ 10
- 10
code/espurna/scheduler.ino View File

@ -15,9 +15,9 @@ Adapted by Xose Pérez <xose dot perez at gmail dot com>
void _schWebSocketOnSend(JsonObject &root){
root["maxScheduled"] = MAX_SCHEDULED;
root["maxScheduled"] = SCHEDULER_MAX_SCHEDULES;
JsonArray &sch = root.createNestedArray("schedule");
for (byte i = 0; i < MAX_SCHEDULED; i++) {
for (byte i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) {
if (!hasSetting("schSwitch", i)) break;
JsonObject &scheduler = sch.createNestedObject();
scheduler["schSwitch"] = getSetting("schSwitch", i, "");
@ -34,7 +34,7 @@ void _schConfigure() {
bool delete_flag = false;
for (unsigned char i = 0; i < MAX_SCHEDULED; i++) {
for (unsigned char i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) {
int sch_switch = getSetting("schSwitch", i, 0xFF).toInt();
if (sch_switch == 0xFF) delete_flag = true;
@ -69,7 +69,7 @@ void _schConfigure() {
}
bool _isThisWeekday(String weekdays){
bool _schIsThisWeekday(String weekdays){
// Monday = 1, Tuesday = 2 ... Sunday = 7
int w = weekday(now()) - 1;
@ -85,7 +85,7 @@ bool _isThisWeekday(String weekdays){
}
int _diffTime(unsigned char schedule_hour, unsigned char schedule_minute){
int _schMinutesLeft(unsigned char schedule_hour, unsigned char schedule_minute){
unsigned char now_hour;
unsigned char now_minute;
@ -118,7 +118,7 @@ void schSetup() {
}
void schLoop(){
void schLoop() {
static unsigned long last_update = 0;
static int update_time = 0;
@ -132,19 +132,19 @@ void schLoop(){
NTP.getTimeDateString().substring(6, 8).toInt() :
second(now())
;
update_time = (SCH_UPDATE_SEC + 60 - current_second) * 1000;
update_time = (SCHEDULER_UPDATE_SEC + 60 - current_second) * 1000;
for (unsigned char i = 0; i < MAX_SCHEDULED; i++) {
for (unsigned char i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) {
int sch_switch = getSetting("schSwitch", i, 0xFF).toInt();
if (sch_switch == 0xFF) break;
String sch_weekdays = getSetting("schWDs", i, "");
if (_isThisWeekday(sch_weekdays)) {
if (_schIsThisWeekday(sch_weekdays)) {
int sch_hour = getSetting("schHour", i, 0).toInt();
int sch_minute = getSetting("schMinute", i, 0).toInt();
int minutes_to_trigger = _diffTime(sch_hour, sch_minute);
int minutes_to_trigger = _schMinutesLeft(sch_hour, sch_minute);
if (minutes_to_trigger == 0) {
int sch_action = getSetting("schAction", i, 0).toInt();
if (sch_action == 2) {


+ 2235
- 2234
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


Loading…
Cancel
Save