-
-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathesp32.h
More file actions
106 lines (83 loc) · 2.56 KB
/
esp32.h
File metadata and controls
106 lines (83 loc) · 2.56 KB
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
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_ESP32_H
#define HASP_DEVICE_ESP32_H
#include "hasp_conf.h"
#include "../device.h"
#if defined(ESP32)
#include "driver/ledc.h"
#ifndef BACKLIGHT_FREQUENCY
#define BACKLIGHT_FREQUENCY 20000
#endif
#define BACKLIGHT_FADEMS 200
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(CONFIG_IDF_TARGET_ESP32S2)
uint8_t temprature_sens_read();
#endif
#ifdef __cplusplus
}
#endif
namespace dev {
class Esp32Device : public BaseDevice {
public:
Esp32Device();
void reboot() override;
void show_info() override;
const char* get_core_version();
const char* get_chip_model();
const char* get_hardware_id();
void set_backlight_pin(uint8_t pin) override;
void set_backlight_invert(bool invert) override;
void set_backlight_level(uint8_t val) override;
uint8_t get_backlight_level() override;
void set_backlight_power(bool power) override;
bool get_backlight_invert() override;
bool get_backlight_power() override;
size_t get_free_max_block() override;
size_t get_free_heap() override;
uint8_t get_heap_fragmentation() override;
uint16_t get_cpu_frequency() override;
void get_info(JsonDocument& doc) override;
void get_sensors(JsonDocument& doc) override;
long get_uptime();
bool is_system_pin(uint8_t pin) override;
protected:
/** For board-specific subclasses (e.g. I2C virtual backlight). Base = LEDC when pin is a real GPIO. */
virtual void update_backlight();
uint8_t get_backlight_pin() const
{
return _backlight_pin;
}
private:
std::string _hardware_id;
std::string _chip_model;
uint32_t _sketch_size; // cached because function is slow
uint8_t _backlight_pin;
uint8_t _backlight_level;
uint8_t _backlight_power;
uint8_t _backlight_invert;
bool _backlight_pending;
bool _backlight_fading;
bool _backlight_fade;
static bool cb_backlight(const ledc_cb_param_t *param, void *user_arg);
void end_backlight_fade();
};
} // namespace dev
#if defined(LANBONL8)
// #warning Building for Lanbon L8
#include "lanbonl8.h"
#elif defined(M5STACK) || defined (M5STACKLGFX)
// #warning Building for M5Stack core2
#include "m5stackcore2.h"
#elif defined(TWATCH)
#include "twatch.h"
#elif defined(HASP_ESP32_DEVICE_I2C_BACKLIGHT) && defined(HASP_USE_I2C_GPIO)
#include "esp32_i2c_ledc.h"
#else
using dev::Esp32Device;
extern dev::Esp32Device haspDevice;
#endif
#endif // ESP32
#endif // HASP_DEVICE_ESP32_H