Arduino oop adding functions from the original aduino code
This commit is contained in:
@@ -17,10 +17,11 @@
|
|||||||
#define SCREEN_WIDTH 128
|
#define SCREEN_WIDTH 128
|
||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_HEIGHT 64
|
||||||
#define i2c_adress 0x3c
|
#define i2c_adress 0x3c
|
||||||
|
#define OLED_RESET -1 // QT-PY / XIAO
|
||||||
#define USE_SERIAL Serial
|
#define USE_SERIAL Serial
|
||||||
|
|
||||||
// make new objects
|
// make new objects
|
||||||
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
|
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||||
DHT dht(DHTPIN, DHTTYPE);
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
WiFiMulti WiFiMulti;
|
WiFiMulti WiFiMulti;
|
||||||
Adafruit_SGP30 sgp;
|
Adafruit_SGP30 sgp;
|
||||||
|
@@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
nodeReadings esp32Node();
|
nodeReadings esp32Node();
|
||||||
|
|
||||||
|
void setup()
|
||||||
void setup() {
|
{
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
esp32Node.setup();
|
esp32Node.setup();
|
||||||
|
esp32Node.websocketSetup();
|
||||||
|
esp32Node.resetValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop()
|
||||||
// put your main code here, to run repeatedly:
|
{
|
||||||
esp32Node.loop();
|
// put your main code here, to run repeatedly:
|
||||||
|
esp32Node.loop();
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,6 @@ void nodeReadings::setup(){
|
|||||||
pinMode(MICPIN, INPUT);
|
pinMode(MICPIN, INPUT);
|
||||||
pinMode(DHTPIN, INPUT);
|
pinMode(DHTPIN, INPUT);
|
||||||
|
|
||||||
websocketSetup();
|
|
||||||
resetValues();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nodeReadings::loop() {
|
void nodeReadings::loop() {
|
||||||
@@ -38,8 +35,6 @@ void nodeReadings::loop() {
|
|||||||
currentMillis = millis();
|
currentMillis = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void nodeReadings::resetValues() {
|
void nodeReadings::resetValues() {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
eCO2 = 0;
|
eCO2 = 0;
|
||||||
@@ -52,3 +47,17 @@ void nodeReadings::resetValues() {
|
|||||||
errorDHT11 = false;
|
errorDHT11 = false;
|
||||||
noise = false;
|
noise = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hexdump function for websockets binary handler
|
||||||
|
void hexdump(const void *mem, uint32_t len, uint8_t cols = 16) {
|
||||||
|
const uint8_t* src = (const uint8_t*) mem;
|
||||||
|
USE_SERIAL.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
|
||||||
|
for(uint32_t i = 0; i < len; i++) {
|
||||||
|
if(i % cols == 0) {
|
||||||
|
USE_SERIAL.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
|
||||||
|
}
|
||||||
|
USE_SERIAL.printf("%02X ", *src);
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
USE_SERIAL.printf("\n");
|
||||||
|
}
|
@@ -2,13 +2,15 @@
|
|||||||
#define nodeReading_h
|
#define nodeReading_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#
|
#include "headerFile.h"
|
||||||
|
|
||||||
class nodeReadings() {
|
|
||||||
|
class nodeReadings {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nodeReadings();
|
nodeReadings();
|
||||||
void setup();
|
void setup();
|
||||||
|
void loop();
|
||||||
void resetValues();
|
void resetValues();
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user