mirror of https://github.com/arendst/Tasmota.git
Phase 1 support C2/C6
This commit is contained in:
parent
37a527696a
commit
dd877972be
|
@ -24,8 +24,12 @@
|
|||
#include "esp8266toEsp32.h"
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include <driver/dac_oneshot.h>
|
||||
#else
|
||||
#include <driver/dac.h>
|
||||
#endif
|
||||
#endif
|
||||
/*********************************************************************************************\
|
||||
* Native functions mapped to Berry functions
|
||||
*
|
||||
|
@ -60,8 +64,17 @@ extern "C" {
|
|||
// DAC
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
if (25 == pin || 26 == pin) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
dac_oneshot_handle_t channel_handle;
|
||||
const dac_channel_t channel = (25 == pin) ? DAC_CHAN_0 : DAC_CHAN_1;
|
||||
dac_oneshot_config_t channel_cfg = {
|
||||
.chan_id = channel,
|
||||
};
|
||||
esp_err_t err = dac_oneshot_new_channel(&channel_cfg, &channel_handle);
|
||||
#else
|
||||
dac_channel_t channel = (25 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
|
||||
esp_err_t err = dac_output_enable(channel);
|
||||
#endif
|
||||
if (err) {
|
||||
be_raisef(vm, "value_error", "Error: dac_output_enable(%i) -> %i", channel, err);
|
||||
}
|
||||
|
@ -70,8 +83,17 @@ extern "C" {
|
|||
}
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
if (17 == pin || 18 == pin) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
dac_oneshot_handle_t channel_handle;
|
||||
const dac_channel_t channel = (17 == pin) ? DAC_CHAN_0 : DAC_CHAN_1;
|
||||
dac_oneshot_config_t channel_cfg = {
|
||||
.chan_id = channel,
|
||||
};
|
||||
esp_err_t err = dac_oneshot_new_channel(&channel_cfg, &channel_handle);
|
||||
#else
|
||||
dac_channel_t channel = (17 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
|
||||
esp_err_t err = dac_output_enable(channel);
|
||||
#endif
|
||||
if (err) {
|
||||
be_raisef(vm, "value_error", "Error: dac_output_enable(%i) -> %i", channel, err);
|
||||
}
|
||||
|
@ -129,8 +151,18 @@ extern "C" {
|
|||
uint32_t dac_value = changeUIntScale(mV, 0, 3300, 0, 255); // convert from 0..3300 ms to 0..255
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
if (25 == pin || 26 == pin) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
dac_oneshot_handle_t channel_handle;
|
||||
const dac_channel_t channel = (25 == pin) ? DAC_CHAN_0 : DAC_CHAN_1;
|
||||
dac_oneshot_config_t channel_cfg = {
|
||||
.chan_id = channel,
|
||||
};
|
||||
esp_err_t err = dac_oneshot_new_channel(&channel_cfg, &channel_handle);
|
||||
#else
|
||||
dac_channel_t channel = (25 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
|
||||
esp_err_t err = dac_output_voltage(channel, dac_value);
|
||||
// esp_err_t err = dac_output_voltage(channel, dac_value);
|
||||
esp_err_t err = dac_output_enable(channel);
|
||||
#endif
|
||||
if (err) {
|
||||
be_raisef(vm, "internal_error", "Error: esp_err_tdac_output_voltage(%i, %i) -> %i", channel, dac_value, err);
|
||||
}
|
||||
|
@ -139,16 +171,24 @@ extern "C" {
|
|||
}
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
if (17 == pin || 18 == pin) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
dac_oneshot_handle_t channel_handle;
|
||||
const dac_channel_t channel = (17 == pin) ? DAC_CHAN_0 : DAC_CHAN_1;
|
||||
dac_oneshot_config_t channel_cfg = {
|
||||
.chan_id = channel,
|
||||
};
|
||||
esp_err_t err = dac_oneshot_new_channel(&channel_cfg, &channel_handle);
|
||||
#else
|
||||
dac_channel_t channel = (17 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
|
||||
esp_err_t err = dac_output_voltage(channel, dac_value);
|
||||
// esp_err_t err = dac_output_voltage(channel, dac_value);
|
||||
esp_err_t err = dac_output_enable(channel);
|
||||
#endif
|
||||
if (err) {
|
||||
be_raisef(vm, "internal_error", "Error: esp_err_tdac_output_voltage(%i, %i) -> %i", channel, dac_value, err);
|
||||
}
|
||||
} else {
|
||||
be_raise(vm, "value_error", "DAC only supported on GPIO17-18");
|
||||
}
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
be_raise(vm, "value_error", "DAC unsupported in this chip");
|
||||
#else
|
||||
be_raise(vm, "value_error", "DAC unsupported in this chip");
|
||||
#endif
|
||||
|
|
|
@ -96,7 +96,7 @@ extern "C" {
|
|||
TwoWire & myWire = getWire(vm);
|
||||
if (top == 2 && be_isint(vm, 2)) { // only 1 argument of type string accepted
|
||||
int32_t address = be_toint(vm, 2);
|
||||
myWire.beginTransmission(address);
|
||||
myWire.beginTransmission((int)address);
|
||||
be_return(vm); // Return
|
||||
}
|
||||
be_raise(vm, kTypeError, nullptr);
|
||||
|
|
|
@ -382,8 +382,8 @@ void start_lvgl(const char * uconfig) {
|
|||
// By default set the display color to black and opacity to 100%
|
||||
lv_disp_set_bg_color(NULL, lv_color_from_uint32(USE_LVGL_BG_DEFAULT));
|
||||
lv_disp_set_bg_opa(NULL, LV_OPA_COVER);
|
||||
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_from_uint32(USE_LVGL_BG_DEFAULT), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(lv_scr_act(), LV_OPA_COVER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_from_uint32(USE_LVGL_BG_DEFAULT), static_cast<uint32_t>(LV_PART_MAIN) | static_cast<uint32_t>(LV_STATE_DEFAULT));
|
||||
lv_obj_set_style_bg_opa(lv_scr_act(), LV_OPA_COVER, static_cast<uint32_t>(LV_PART_MAIN) | static_cast<uint32_t>(LV_STATE_DEFAULT));
|
||||
|
||||
#if LV_USE_LOG
|
||||
lv_log_register_print_cb(lvbe_debug);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef ESP32 // ESP32 family only. Use define USE_HM10 for ESP8266 support
|
||||
#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#ifdef USE_BLE_ESP32
|
||||
|
||||
/*
|
||||
|
|
|
@ -132,7 +132,7 @@ print("".join(pin))
|
|||
#define USE_EQ3_ESP32
|
||||
#endif
|
||||
|
||||
#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#ifdef USE_EQ3_ESP32
|
||||
#ifdef ESP32 // ESP32 only. Use define USE_HM10 for ESP8266 support
|
||||
#ifdef USE_BLE_ESP32
|
||||
|
|
|
@ -31,9 +31,16 @@ struct MY92X1 {
|
|||
uint8_t model = 0;
|
||||
} My92x1;
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include "rom/ets_sys.h"
|
||||
#ifndef os_delay_us
|
||||
#define os_delay_us ets_delay_us
|
||||
#endif //os_delay_us
|
||||
#else
|
||||
extern "C" {
|
||||
void os_delay_us(unsigned int);
|
||||
}
|
||||
#endif
|
||||
|
||||
void LightDiPulse(uint8_t times)
|
||||
{
|
||||
|
|
|
@ -545,7 +545,7 @@ void Ade7880Service0(void) {
|
|||
Ade7880.irq0_state = 0;
|
||||
}
|
||||
|
||||
void IRAM_ATTR Ade7880Isr0(void) {
|
||||
static void IRAM_ATTR Ade7880Isr0(void) {
|
||||
// Poll sequence
|
||||
if (!Ade7880.irq0_state) {
|
||||
Ade7880.irq0_state = 1;
|
||||
|
|
|
@ -47,7 +47,8 @@ struct COUNTER {
|
|||
|
||||
} Counter;
|
||||
|
||||
void IRAM_ATTR CounterIsrArg(void *arg) {
|
||||
void IRAM_ATTR CounterIsrArg(void *arg);
|
||||
void CounterIsrArg(void *arg) {
|
||||
uint32_t index = *static_cast<uint8_t*>(arg);
|
||||
|
||||
uint32_t time = micros();
|
||||
|
|
|
@ -165,8 +165,7 @@ uint32_t tx2x_last_available = 0;
|
|||
uint32_t tx23_stage = 0;
|
||||
#endif // USE_TX23_WIND_SENSOR
|
||||
|
||||
void IRAM_ATTR TX2xStartRead(void)
|
||||
{
|
||||
static void IRAM_ATTR TX2xStartRead(void) {
|
||||
/**
|
||||
* La Crosse TX20 Anemometer datagram every 2 seconds
|
||||
* 0-0 11011 0011 111010101111 0101 1100 000101010000 0-0 - Received pin data at 1200 uSec per bit
|
||||
|
@ -279,9 +278,11 @@ void IRAM_ATTR TX2xStartRead(void)
|
|||
}
|
||||
#endif // USE_TX23_WIND_SENSOR
|
||||
|
||||
#ifdef ESP8266
|
||||
// Must clear this bit in the interrupt register,
|
||||
// it gets set even when interrupts are disabled
|
||||
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << Pin(GPIO_TX2X_TXD_BLACK));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Tx2xAvailable(void)
|
||||
|
|
|
@ -152,7 +152,9 @@ void ChirpResetAll(void) {
|
|||
/********************************************************************************************/
|
||||
|
||||
void ChirpClockSet() { // set I2C for this slow sensor
|
||||
#if ESP_IDF_VERSION_MAJOR < 5 // setClockStretchLimit was removed
|
||||
Wire.setClockStretchLimit(4000);
|
||||
#endif
|
||||
Wire.setClock(50000);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
// for testing of BLE_ESP32, we remove xsns_52_ibeacon.ino completely, and instead add this modified xsns_52_ibeacon_BLE_ESP32.ino
|
||||
// in the future this may be more fine-grained, e.g. to allow hm17 for this, and BLE-ESP32 for other
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#ifdef USE_BLE_ESP32
|
||||
|
||||
#define XSNS_52 52
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
#ifndef USE_BLE_ESP32
|
||||
#ifdef ESP32 // ESP32 only. Use define USE_HM10 for ESP8266 support
|
||||
#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
#ifdef USE_MI_ESP32
|
||||
|
||||
|
@ -697,9 +697,7 @@ void MI32PreInit(void) {
|
|||
void MI32Init(void) {
|
||||
if (MI32.mode.init) { return; }
|
||||
|
||||
if (TasmotaGlobal.global_state.wifi_down && TasmotaGlobal.global_state.eth_down) {
|
||||
if (!(WIFI_MANAGER == Wifi.config_type || WIFI_MANAGER_RESET_ONLY == Wifi.config_type)) return;
|
||||
}
|
||||
if (TasmotaGlobal.global_state.wifi_down && TasmotaGlobal.global_state.eth_down) { return; }
|
||||
|
||||
if (!TasmotaGlobal.global_state.wifi_down) {
|
||||
TasmotaGlobal.wifi_stay_asleep = true;
|
||||
|
@ -1294,7 +1292,7 @@ bool MI32StartConnectionTask(){
|
|||
}
|
||||
|
||||
void MI32ConnectionTask(void *pvParameters){
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) //needs more testing ...
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6) //needs more testing ...
|
||||
// NimBLEDevice::setOwnAddrType(BLE_OWN_ADDR_RANDOM,false); //seems to be important for i.e. xbox controller, hopefully not breaking other things
|
||||
// NimBLEDevice::setSecurityAuth(true, true, true);
|
||||
#endif //CONFIG_IDF_TARGET_ESP32C3
|
||||
|
@ -2671,4 +2669,4 @@ bool Xsns62(uint32_t function)
|
|||
#endif // USE_MI_ESP32
|
||||
#endif // CONFIG_IDF_TARGET_ESP32 or CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif // ESP32
|
||||
#endif // USE_BLE_ESP32
|
||||
#endif // USE_BLE_ESP32
|
|
@ -71,7 +71,7 @@
|
|||
#ifdef USE_BLE_ESP32
|
||||
|
||||
#ifdef ESP32 // ESP32 family only. Use define USE_HM10 for ESP8266 support
|
||||
#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3|| defined CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
#ifdef USE_MI_ESP32
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ struct {
|
|||
volatile uint32_t pulse = 0;
|
||||
} as3935_sensor;
|
||||
|
||||
void IRAM_ATTR AS3935Isr(void) {
|
||||
static void IRAM_ATTR AS3935Isr(void) {
|
||||
as3935_sensor.detected = true;
|
||||
as3935_sensor.icount++;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void AS3935WriteRegister(uint8_t reg, uint8_t mask, uint8_t shift, uint8_t data)
|
|||
|
||||
/********************************************************************************************/
|
||||
// Autotune Caps
|
||||
void IRAM_ATTR AS3935CountFreq(void) {
|
||||
static void IRAM_ATTR AS3935CountFreq(void) {
|
||||
if (as3935_sensor.dispLCO)
|
||||
as3935_sensor.pulse++;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,12 @@
|
|||
bool lmt01_initialized = false;
|
||||
float lmt01_temperature = NAN;
|
||||
|
||||
volatile int lmt01_pulseCount = 0;
|
||||
|
||||
static void IRAM_ATTR LMT01_countPulse(void) {
|
||||
lmt01_pulseCount++;
|
||||
}
|
||||
|
||||
void LMT01_Init(void) {
|
||||
if (PinUsed(GPIO_LMT01)) {
|
||||
pinMode(Pin(GPIO_LMT01), INPUT);
|
||||
|
@ -40,12 +46,6 @@ void LMT01_Init(void) {
|
|||
}
|
||||
}
|
||||
|
||||
volatile int lmt01_pulseCount = 0;
|
||||
|
||||
void IRAM_ATTR LMT01_countPulse(void) {
|
||||
lmt01_pulseCount++;
|
||||
}
|
||||
|
||||
void LMT01_GetTemperature(void) {
|
||||
int pulses = 0;
|
||||
pulses = LMT01_getPulses();
|
||||
|
|
Loading…
Reference in New Issue