Skip to content

Commit

Permalink
Merge pull request #516 from ascillato/revert-515-development
Browse files Browse the repository at this point in the history
Revert "Sync to Tasmota"
  • Loading branch information
ascillato authored May 2, 2020
2 parents b9efb27 + cf3a500 commit 3a3f114
Show file tree
Hide file tree
Showing 23 changed files with 1,408 additions and 496 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
- [ ] Only one feature/fix was added per PR.
- [ ] The code change is tested and works on core Tasmota_core
- [ ] The code change is tested and works on core ESP32
- [ ] The code change pass CI tests. **Your PR cannot be merged unless tests pass**
- [ ] The code change pass travis tests. **Your PR cannot be merged unless tests pass**
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
2 changes: 1 addition & 1 deletion .github/workflows/CI_github.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tasmota CI
name: PlatformIO CI

on: [push, pull_request]

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ In addition to the [release webpage](https://github.com/arendst/Tasmota/releases

[![Dev Version](https://img.shields.io/badge/development%20version-v8.2.x.x-blue.svg)](https://github.com/arendst/Tasmota)
[![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://thehackbox.org/tasmota/)
![Tasmota CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20CI/badge.svg)
[![Build Status](https://img.shields.io/travis/arendst/Tasmota.svg)](https://travis-ci.org/arendst/Tasmota)

See [tasmota/CHANGELOG.md](tasmota/CHANGELOG.md) for detailed change information.

Expand Down
1 change: 0 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,3 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add console command history (#7483, #8015)
- Add quick wifi reconnect using saved AP parameters when ``SetOption56 0`` (#3189)
- Add more accuracy to GPS NTP server (#8088)
- Add experimental basic support for Tasmota on ESP32 based on work by Jörg Schüler-Maroldt
42 changes: 1 addition & 41 deletions libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,8 @@
#include <Esp.h>

// Analog

uint8_t pwm_channel[8]={99,99,99,99,99,99,99,99};

inline uint32_t pin2chan(uint32_t pin) {
for (uint32_t cnt=0;cnt<8;cnt++) {
if ((pwm_channel[cnt]<99) && (pwm_channel[cnt]==pin)) {
return cnt;
}
}
return 0;
}

inline void analogWrite(uint8_t pin, int val)
{
uint32_t channel=pin2chan(pin);
ledcWrite(channel,val);
Serial.printf("write %d - %d\n",channel,val);
}

inline void analogWriteFreq(uint32_t freq)
Expand All @@ -55,31 +40,6 @@ inline void analogWriteRange(uint32_t range)
{
}

inline void analogAttach(uint32_t pin, uint32_t channel) {
pwm_channel[channel&7]=pin;
ledcAttachPin(pin,channel);
Serial.printf("attach %d - %d\n",channel,pin);
}

inline uint32_t pow2(uint32_t x) {
uint32_t power = 1,bits=0;
while (power < x) {
power*=2;
bits++;
}
return bits-1;
}
// input range is in full range, ledc needs bits
inline void analogWriteFreqRange(uint32_t channel,uint32_t freq, uint32_t irange) {
uint32_t range=pow2(irange);
for (uint32_t cnt=0;cnt<8;cnt++) {
if (pwm_channel[cnt]<99) {
ledcSetup(cnt,freq,range);
}
}
Serial.printf("freq - range %d - %d\n",freq,range);
}

#define INPUT_PULLDOWN_16 INPUT_PULLUP

typedef double real64_t;
Expand All @@ -97,7 +57,7 @@ typedef double real64_t;
// Serial minimal type to hold the config
typedef int SerConfu8;
typedef int SerialConfig;
//#define analogWrite(a, b)
#define analogWrite(a, b)

//
// WS2812
Expand Down
4 changes: 0 additions & 4 deletions tasmota/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## Unreleased (development)

### 8.2.0.6 20200501

- Add experimental basic support for Tasmota on ESP32 based on work by Jörg Schüler-Maroldt

### 8.2.0.5 20200425

- Breaking Change Device Groups multicast address and port (#8270)
Expand Down
16 changes: 16 additions & 0 deletions tasmota/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,15 @@ struct {
char ex_friendlyname[4][33]; // 3AC
char ex_switch_topic[33]; // 430
#else // ESP32
#ifndef FINAL_ESP32
char ex_friendlyname[4][33]; // 3AC
char ex_switch_topic[33]; // 430
#else // FINAL_ESP32
myio my_gp; // 3AC - 2 x 40 bytes (ESP32)
mytmplt user_template; // 3FC - 2 x 37 bytes (ESP32)

uint8_t free_esp32_446[11]; // 446
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32

char serial_delimiter; // 451
Expand Down Expand Up @@ -410,7 +415,18 @@ struct {
uint32_t ip_address[4]; // 544
unsigned long energy_kWhtotal; // 554

#ifdef ESP8266
char ex_mqtt_fulltopic[100]; // 558
#else // ESP32
#ifndef FINAL_ESP32
myio my_gp; // 558 - 40 bytes (ESP32)
mytmplt user_template; // 580 - 37 bytes (ESP32)

uint8_t free_esp32_5a5[23]; // 5A5
#else // FINAL_ESP32
char ex_mqtt_fulltopic[100]; // 558
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32

SysBitfield2 flag2; // 5BC
unsigned long pulse_counter[MAX_COUNTERS]; // 5C0
Expand Down
7 changes: 0 additions & 7 deletions tasmota/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1386,13 +1386,6 @@ void SettingsDelta(void)
#endif // ESP32
}

if (Settings.version < 0x08020006) {
#ifdef ESP32
Settings.module = WEMOS;
ModuleDefault(WEMOS);
#endif // ESP32
}

Settings.version = VERSION;
SettingsSave(1);
}
Expand Down
54 changes: 47 additions & 7 deletions tasmota/support.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1079,17 +1079,25 @@ uint32_t Pin(uint32_t gpio, uint32_t index) ICACHE_RAM_ATTR;

uint32_t Pin(uint32_t gpio, uint32_t index = 0);
uint32_t Pin(uint32_t gpio, uint32_t index) {
#ifdef LEGACY_GPIO_ARRAY
return pin_gpio[gpio + index]; // Pin number configured for gpio or 99 if not used
#else // No LEGACY_GPIO_ARRAY
#ifdef ESP8266
uint16_t real_gpio = gpio + index;
#else // ESP32
#ifndef FINAL_ESP32
uint16_t real_gpio = gpio + index;
#else // FINAL_ESP32
uint16_t real_gpio = (gpio << 5) + index;
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32
for (uint32_t i = 0; i < ARRAY_SIZE(gpio_pin); i++) {
if (gpio_pin[i] == real_gpio) {
return i; // Pin number configured for gpio
}
}
return 99; // No pin used for gpio
#endif // No LEGACY_GPIO_ARRAY
}

boolean PinUsed(uint32_t gpio, uint32_t index = 0);
Expand All @@ -1098,9 +1106,21 @@ boolean PinUsed(uint32_t gpio, uint32_t index) {
}

void SetPin(uint32_t lpin, uint32_t gpio) {
#ifdef LEGACY_GPIO_ARRAY
pin_gpio[gpio] = lpin;
#else
gpio_pin[lpin] = gpio;
#endif
}

#ifdef LEGACY_GPIO_ARRAY
void InitAllPins(void) {
for (uint32_t i = 0; i < ARRAY_SIZE(pin_gpio); i++) {
SetPin(99, i);
}
}
#endif

void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state)
{
if (PinUsed(gpio_pin, index)) {
Expand Down Expand Up @@ -1152,8 +1172,13 @@ void ModuleGpios(myio *gp)
uint8_t *dest = (uint8_t *)gp;
uint8_t src[ARRAY_SIZE(Settings.user_template.gp.io)];
#else // ESP32
#ifndef FINAL_ESP32
uint8_t *dest = (uint8_t *)gp;
uint8_t src[ARRAY_SIZE(Settings.user_template.gp.io)];
#else // FINAL_ESP32
uint16_t *dest = (uint16_t *)gp;
uint16_t src[ARRAY_SIZE(Settings.user_template.gp.io)];
#endif
#endif // ESP8266 - ESP32

memset(dest, GPIO_NONE, sizeof(myio));
Expand Down Expand Up @@ -1186,15 +1211,24 @@ gpio_flag ModuleFlag(void)
{
gpio_flag flag;

#ifdef ESP8266
if (USER_MODULE == Settings.module) {
flag = Settings.user_template.flag;
} else {
#ifdef ESP8266
memcpy_P(&flag, &kModules[Settings.module].flag, sizeof(gpio_flag));
}
#else // ESP32
memcpy_P(&flag, &kModules.flag, sizeof(gpio_flag));
#endif // ESP8266 - ESP32
if (USER_MODULE == Settings.module) {
/*
gpio_flag gpio_adc0;
memcpy_P(&gpio_adc0, &Settings.user_template.gp + ADC0_PIN - MIN_FLASH_PINS, sizeof(gpio_flag));
flag = Settings.user_template.flag.data + gpio_adc0.data;
*/
memcpy_P(&flag, &Settings.user_template.gp + ADC0_PIN - MIN_FLASH_PINS, sizeof(gpio_flag));
} else {
memcpy_P(&flag, &kModules.gp + ADC0_PIN - MIN_FLASH_PINS, sizeof(gpio_flag));
}
#endif // ESP8266 - ESP32

return flag;
}
Expand Down Expand Up @@ -1243,23 +1277,29 @@ bool ValidGPIO(uint32_t pin, uint32_t gpio)
#ifdef ESP8266
return (GPIO_USER == ValidPin(pin, gpio)); // Only allow GPIO_USER pins
#else // ESP32
#ifndef FINAL_ESP32
return (GPIO_USER == ValidPin(pin, gpio)); // Only allow GPIO_USER pins
#else // FINAL_ESP32
return (GPIO_USER == ValidPin(pin, gpio >> 5)); // Only allow GPIO_USER pins
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32
}

#ifdef ESP8266
bool ValidAdc(void)
{
gpio_flag flag = ModuleFlag();
uint32_t template_adc0 = flag.data &15;
return (ADC0_USER == template_adc0);
}
#endif // ESP8266

#ifdef ESP8266
bool GetUsedInModule(uint32_t val, uint8_t *arr)
#else // ESP32
#ifndef FINAL_ESP32
bool GetUsedInModule(uint32_t val, uint8_t *arr)
#else // FINAL_ESP32
bool GetUsedInModule(uint32_t val, uint16_t *arr)
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32
{
int offset = 0;
Expand Down Expand Up @@ -1346,11 +1386,11 @@ bool JsonTemplate(const char* dataBuf)
}
}
if (obj[D_JSON_FLAG].success()) {
uint32_t flag = obj[D_JSON_FLAG] | 0;
uint8_t flag = obj[D_JSON_FLAG] | 0;
memcpy(&Settings.user_template.flag, &flag, sizeof(gpio_flag));
}
if (obj[D_JSON_BASE].success()) {
uint32_t base = obj[D_JSON_BASE];
uint8_t base = obj[D_JSON_BASE];
if ((0 == base) || !ValidTemplateModule(base -1)) { base = 18; }
Settings.user_template_base = base -1; // Default WEMOS
}
Expand Down
25 changes: 17 additions & 8 deletions tasmota/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,19 @@ void CmndGpio(void)
break;
}
#else // ESP32
#ifndef FINAL_ESP32
uint32_t midx = pgm_read_byte(kGpioNiceList + i);
if (midx == XdrvMailbox.payload) {
present = true;
break;
}
#else // FINAL_ESP32
uint32_t midx = pgm_read_word(kGpioNiceList + i);
if ((XdrvMailbox.payload >= (midx & 0xFFE0)) && (XdrvMailbox.payload < midx)) {
present = true;
break;
}
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32
}
if (present) {
Expand Down Expand Up @@ -1089,6 +1097,9 @@ void CmndGpio(void)
#ifdef ESP8266
uint32_t sensor_name_idx = sensor_type;
#else // ESP32
#ifndef FINAL_ESP32
uint32_t sensor_name_idx = sensor_type;
#else // FINAL_ESP32
uint32_t sensor_name_idx = sensor_type >> 5;
uint32_t nice_list_search = sensor_type & 0xFFE0;
for (uint32_t j = 0; j < ARRAY_SIZE(kGpioNiceList); j++) {
Expand All @@ -1098,6 +1109,7 @@ void CmndGpio(void)
break;
}
}
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32
const char *sensor_names = kSensorNames;
if (sensor_name_idx > GPIO_FIX_START) {
Expand Down Expand Up @@ -1128,8 +1140,13 @@ void CmndGpios(void)
uint32_t midx = pgm_read_byte(kGpioNiceList + i);
uint32_t ridx = midx;
#else // ESP32
#ifndef FINAL_ESP32
uint32_t midx = pgm_read_byte(kGpioNiceList + i);
uint32_t ridx = midx;
#else // FINAL_ESP32
uint32_t ridx = pgm_read_word(kGpioNiceList + i) & 0xFFE0;
uint32_t midx = ridx >> 5;
#endif // FINAL_ESP32
#endif // ESP8266 - ESP32
if ((XdrvMailbox.payload != 255) && GetUsedInModule(midx, cmodule.io)) { continue; }
if (!jsflg) {
Expand Down Expand Up @@ -1211,11 +1228,7 @@ void CmndPwmfrequency(void)
{
if ((1 == XdrvMailbox.payload) || ((XdrvMailbox.payload >= PWM_MIN) && (XdrvMailbox.payload <= PWM_MAX))) {
Settings.pwm_frequency = (1 == XdrvMailbox.payload) ? PWM_FREQ : XdrvMailbox.payload;
#ifdef ESP8266
analogWriteFreq(Settings.pwm_frequency); // Default is 1000 (core_esp8266_wiring_pwm.c)
#else
analogWriteFreqRange(0,Settings.pwm_frequency,Settings.pwm_range);
#endif
}
ResponseCmndNumber(Settings.pwm_frequency);
}
Expand All @@ -1229,11 +1242,7 @@ void CmndPwmrange(void)
Settings.pwm_value[i] = Settings.pwm_range;
}
}
#ifdef ESP8266
analogWriteRange(Settings.pwm_range); // Default is 1023 (Arduino.h)
#else
analogWriteFreqRange(0,Settings.pwm_frequency,Settings.pwm_range);
#endif
}
ResponseCmndNumber(Settings.pwm_range);
}
Expand Down
Loading

0 comments on commit 3a3f114

Please sign in to comment.