mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-10-17 16:41:28 +08:00

* Remove all output flags * Masse replace name function / class to sync with ESP3D-TFT * Create ESP3DMessageManager class to handle messages creation / deletion (import functions of ESp3DClient from ESp3D-TFT) * Move to new messaging API of ESP3D-TFT * Remove empty line from remote screen dispatching * Replace \n to space and \r to nothing in remote screen dispatching * Add missing default entry for sensor device * Fix buzzer for ESP32 missing ledc initialization with latest core * Move formatBytes to esp3d_string * Add welcome message to telnet connection\ * Add display to the new messaging API * Add sticky authentication on Serial / SerialBridge /Telnet/Data web socket and BT * Log simplification * Use enum class instead of typdef enum for ESP3DAuthenticationLevel to be sure correct enum is used * (v3) Home Assistant notification support (#971) * Add notification via post request * Extend t1 size to 255 bytes * Hide Home Assistant notifications from web UI (#974) * Sync with ESP3DLib on serial_socket * Add some sanity check to avoid unnecessary message copies * Update ESP0.cpp --------- Co-authored-by: David Buezas <dbuezas@users.noreply.github.com>
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
/*
|
|
esp3d_hal.h - esp3d hal class
|
|
|
|
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
|
|
|
This code is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This code 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with This code; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _ESP3D_HAL_H
|
|
#define _ESP3D_HAL_H
|
|
// be sure correct IDE and settings are used for ESP8266 or ESP32
|
|
#if !(defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32))
|
|
#error Oops! Make sure you have 'ESP8266 or ESP32' compatible board selected from the 'Tools -> Boards' menu.
|
|
#endif // ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32
|
|
#if defined(ARDUINO_ARCH_ESP8266)
|
|
#include <ESP8266WiFi.h>
|
|
#endif // ARDUINO_ARCH_ESP8266
|
|
#if defined(ARDUINO_ARCH_ESP32)
|
|
#include <WiFi.h>
|
|
#include <esp_task_wdt.h>
|
|
#endif // ARDUINO_ARCH_ESP32
|
|
#include <Arduino.h>
|
|
|
|
class ESP3DHal {
|
|
public:
|
|
static bool begin();
|
|
static void end();
|
|
static void wait(uint32_t milliseconds);
|
|
static uint16_t getChipID();
|
|
static bool has_temperature_sensor();
|
|
static float temperature();
|
|
static bool is_pin_usable(uint pin);
|
|
static void clearAnalogChannels();
|
|
static void pinMode(uint8_t pin, uint8_t mode);
|
|
static int analogRead(uint8_t pin);
|
|
static bool analogWrite(uint8_t pin, uint value);
|
|
static void analogWriteFreq(uint32_t freq);
|
|
static void analogRange(uint32_t range);
|
|
#if defined(ARDUINO_ARCH_ESP32)
|
|
static TaskHandle_t xHandle;
|
|
#endif // ARDUINO_ARCH_ESP32
|
|
private:
|
|
static void wdtFeed();
|
|
static uint32_t _analogRange;
|
|
static uint32_t _analogWriteFreq;
|
|
};
|
|
|
|
class Esp3dTimout {
|
|
public:
|
|
Esp3dTimout(uint64_t timeout) { _start = millis(); };
|
|
void reset() { _start = millis(); };
|
|
bool isTimeout() { return (millis() - _start > _timeout); };
|
|
uint64_t getTimeout() { return _timeout; };
|
|
|
|
private:
|
|
uint64_t _start = 0;
|
|
uint64_t _timeout = 0;
|
|
};
|
|
#endif //_ESP3D_HAL_H
|