-
Notifications
You must be signed in to change notification settings - Fork 1
/
Opaq_c1.h
130 lines (96 loc) · 3.04 KB
/
Opaq_c1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Opaq is an Open AQuarium Controller firmware. It has been developed for
* supporting several aquarium devices such as ligh dimmers, power management
* outlets, water sensors, and peristaltic pumps. The main purpose is to
* control fresh and salt water aquariums.
*
* Copyright (c) 2015 Andre Pedro. All rights reserved.
*
* This file is part of opaq firmware for aquarium controllers.
*
* opaq firmware is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opaq firmware is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opaq firmware. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef OPENAQ_H
#define OPENAQ_H
#include "Opaq_com.h"
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <RtcDateTime.h>
#include <Ticker.h>
#include <Wire.h>
#include <atomic>
#include "opaq.h"
// ESP8266 specific headers
extern "C" {
#include "os_type.h"
#include "user_interface.h"
}
// permanent storage settings signature (if value is changed then permanent
// settings will be overwritten by factory default settings)
#define SIG 0x07
#define OPAQ_VERSION "1.0.7"
// configuration parameters
#define OPAQ_MDNS_RESPONDER 1
#define OPAQ_OTA_ARDUINO 0
#define deviceTaskPrio 2
#define deviceTaskQueueLen 1
#define _10hzLoopTaskPrio 1
#define _10hzLoopTaskQueueLen 1
#define NUM_TASKS 6
extern char *stack_start;
extern char *stack_task[NUM_TASKS];
#ifdef OPAQ_C1_SCREEN
#include "Opaq_iaqua_pages.h"
extern Opaq_iaqua_page_welcome wscreen;
#endif
class OpenAq_Controller {
private:
AsyncWebServer server;
AsyncWebSocket ws;
// Set up alarms to call periodic tasks
Ticker timming_events;
Ticker t_evt;
// real-time clock initialization
bool clockIsReady;
// manages flash memory block for permanent settings
// Opaq_storage storage;
// temporary string container
String str;
// stores current real time clock
RtcDateTime clock;
// stores event that triggers deviceTask
os_event_t deviceTaskQueue[deviceTaskQueueLen];
os_event_t _10hzLoopQueue[deviceTaskQueueLen];
void ota();
void run_programmer();
public:
OpenAq_Controller();
void setup_controller();
void setClockReady() { clockIsReady = true; };
bool isClockReady() { return clockIsReady; };
RtcDateTime getClock() { return clock; };
void run_controller();
void run_task_ds3231();
void run_touch();
void run_tft();
Opaq_com &getCom() { return communicate; };
void syncClock();
AsyncWebServer &getServer() { return server; }
AsyncWebSocket &getWs() { return ws; }
void reconnect();
};
extern OpenAq_Controller opaq_controller;
#endif // OPENAQ_H