113 lines
No EOL
3.2 KiB
C++
113 lines
No EOL
3.2 KiB
C++
#ifndef MAIN_HPP
|
|
#define MAIN_HPP
|
|
|
|
//#define MACHINE_RESTART
|
|
#define DUMMY_DATA
|
|
|
|
#define EEPROM_NAME_TICK "hall_tick"
|
|
#define EEPROM_NAME_TIMESTAMP "timestamp"
|
|
#define EEPROM_NAME_RUN_TIME "runtime"
|
|
#define EEPROM_NAME_START_EPOCHTIME "starttime"
|
|
#define EEPROM_STORE_RUNTIME_ALL_MS 1000 * 60 //* 5
|
|
|
|
#include <NTPClient.h>
|
|
#include <ESP32Servo.h>
|
|
#include <Arduino.h>
|
|
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
|
|
#include "eeprom.hpp"
|
|
#include "oled.hpp"
|
|
#include "capportal.hpp"
|
|
#include <esp32-hal-timer.h>
|
|
|
|
//#define HAS_MQTT
|
|
#ifdef HAS_MQTT
|
|
#include "mqtt.hpp"
|
|
#include "json.hpp"
|
|
Mymqtt mqtt;
|
|
Myjson json;
|
|
|
|
|
|
/*makerlab*/
|
|
const char* mqttServer = "mqtt.makerlab-murnau.de";
|
|
const int mqttPort = 8883;
|
|
const char* mqttUser = "";
|
|
const char* mqttPassword = "";
|
|
|
|
/*hivemq*/
|
|
/*
|
|
const char* mqttServer = "ccb0edef424149d4b3d2ee2ee503b87d.s1.eu.hivemq.cloud";
|
|
const int mqttPort = 8883;
|
|
const char* mqttUser = "infinity";
|
|
const char* mqttPassword = "12345678";
|
|
*/
|
|
#endif
|
|
|
|
WiFiUDP ntpUDP;
|
|
//NTPClient timeClient(ntpUDP);
|
|
NTPClient timeClient( ntpUDP,"pool.ntp.org", 3600);
|
|
|
|
// Variables to save date and time
|
|
String timeStamp;
|
|
|
|
Eeprom Store;
|
|
Cap capportal;
|
|
Servo ESC; // Der ESC-Controller (Electronic Speed Controller bzw. elektronischer Fahrtregler) wird als Objekt mit dem Namen "ESC" festgelegt.
|
|
Oled display;
|
|
|
|
const unsigned long UPDATE_TURN_VALUES_EVERY_MS = 1000;
|
|
const unsigned long UPDATE_ESC_EVERY_MS = 500;
|
|
|
|
const uint8_t HALL_SENSORS_COUNT = 8; // input, sec, min, hour, day, week, month, year
|
|
const uint8_t ALL_DATA_COUNT = HALL_SENSORS_COUNT;
|
|
|
|
const uint8_t HALL_TICKS_PER_TURN = 4;
|
|
const uint8_t HALL_NR_TURN = 4;
|
|
const uint8_t HALL_MIN_PULSE_MS = 50;
|
|
|
|
volatile DataStruct AllData[ALL_DATA_COUNT];
|
|
volatile DataStruct *HallData = AllData;
|
|
|
|
const char *Data_names[ALL_DATA_COUNT] =
|
|
{
|
|
// Hall sensors
|
|
"cascade_input", "cascade_sec", "cascade_min", "cascade_hour", "cascade_day", "cascade_week", "cascade_month", "cascade_year",
|
|
};
|
|
const char *Data_units[ALL_DATA_COUNT] =
|
|
{
|
|
// Hall sensors
|
|
"U/min", "sec", "min", "hour", "day", "week", "month", "year",
|
|
};
|
|
const float Data_units_factor[ALL_DATA_COUNT] =
|
|
{
|
|
//Hall sensors
|
|
60000.0, 1.0/HALL_TICKS_PER_TURN, 1.0/HALL_TICKS_PER_TURN, 1.0/HALL_TICKS_PER_TURN, 1.0/HALL_TICKS_PER_TURN, 1.0/HALL_TICKS_PER_TURN, 1.0/HALL_TICKS_PER_TURN, 1.0/HALL_TICKS_PER_TURN
|
|
};
|
|
|
|
const char ** Hall_names = Data_names;
|
|
const char ** Hall_units = Data_units;
|
|
const float * Hall_units_factor = Data_units_factor;
|
|
|
|
const uint8_t LED_BUILTIN = 2;
|
|
const uint8_t POTI_PIN = 36; // never use ADC2 (GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27) if Wifi is active ... use ADC1 instead (GPIO32-GPIO39)
|
|
const uint8_t ESC_PIN = 16;
|
|
|
|
|
|
const uint8_t HALL1_PIN = 34;
|
|
const uint8_t HALL2_PIN = 35;
|
|
const uint8_t HALL3_PIN = 32;
|
|
const uint8_t HALL4_PIN = 33;
|
|
const uint8_t HALL5_PIN = 25;
|
|
const uint8_t HALL6_PIN = 26;
|
|
const uint8_t HALL7_PIN = 27;
|
|
const uint8_t HALL8_PIN = 14;
|
|
|
|
const uint8_t TIME_PER_ROUND_VALS = 10;
|
|
|
|
const uint16_t MIN_SPEED = 500;
|
|
const uint16_t MAX_SPEED = 5000;
|
|
const uint8_t MAX_ESC_SPEED = 180;
|
|
const uint8_t MIN_ESC_SPEED = 0;
|
|
const uint16_t MAX_POTI_VALUE = 4095;
|
|
const uint16_t JITTER_POTI_PERCENT = 10;
|
|
|
|
#endif //MAIN_HPP
|