Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build on ESP32-s3 and RGBCT light #4

Open
evlo opened this issue Mar 31, 2023 · 1 comment
Open

Cannot build on ESP32-s3 and RGBCT light #4

evlo opened this issue Mar 31, 2023 · 1 comment

Comments

@evlo
Copy link

evlo commented Mar 31, 2023

Hi,

I get this error for hub on esp32-c3 when I try to build, so maybe only the base esp32 is supported?

Compiling /data/eh-switch-m5-shop/.pioenvs/eh-switch-m5-shop/app_trace/app_trace_util.o
In file included from src/main.cpp:69:
src/MeshRC.h:10:10: fatal error: WiFi.h: No such file or directory

**************************************************************
* Looking for WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:WiFi.h"
* Web  > https://registry.platformio.org/search?q=header:WiFi.h
*
**************************************************************

 #include <WiFi.h>
          ^~~~~~~~
compilation terminated.
*** [/data/eh-switch-m5-shop/.pioenvs/eh-switch-m5-shop/src/main.o] Error 1
========================= [FAILED] Took 189.73 seconds =========================

i have tried only this

esphome:
  name: $hostname
  comment: $comment
  includes:
    - lib/MeshRC.h
    - lib/esp_now_light.h  
  libraries:
    - WiFi

to resolve, but no luck.

Also I think on light side esp32 is not supported at all, right? (and my light is not even base esp32, but esp32-s3 so I guess it is even worse in chances of getting esp-now to work)

Update:

I also noticed I do build for esp-idf so I will do more testing with arduino framework build etc.

esp32:
  board: esp32dev
  framework: 
    type: esp-idf

Update2:
on arduino framework it does build

@evlo evlo changed the title Cannot build on ESP32-c3 Cannot build on ESP32-c3 (src/MeshRC.h:10:10: fatal error: WiFi.h: No such file or directory) Mar 31, 2023
@evlo
Copy link
Author

evlo commented Mar 31, 2023

the switch config now builds, but on the light side I have

custom_component:
  - lambda: |-    
      MeshRC::begin();
      ESP_LOGD("custom", "Initialising MeshRC");      
      MeshRC::on(">SETLIGHT1", [](uint8_t* data, uint8_t size) {
        LightState* dest = id(light_shop_ceiling);
        parseLight(data, size, dest);
      });
      return {};

and when I try to build

/config/esphome/eh-light-ceiling-rectangle-02-ESPNOWtest.yaml: In lambda function:
/config/esphome/eh-light-ceiling-rectangle-02-ESPNOWtest.yaml:50:8: error: no matching function for call to 'on(const char [11], setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>)'
       });
        ^
In file included from src/main.cpp:40:
src/MeshRC.h:79:6: note: candidate: 'void MeshRC::on(String, MeshRC::esp_rc_callback_t)'
 void on(String prefix, esp_rc_callback_t callback) {
      ^~
src/MeshRC.h:79:6: note:   no known conversion for argument 2 from 'setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>' to 'MeshRC::esp_rc_callback_t' {aka 'std::function<void()>'}
src/MeshRC.h:82:6: note: candidate: 'void MeshRC::on(String, MeshRC::esp_rc_data_callback_t)'
 void on(String prefix, esp_rc_data_callback_t callback) {
      ^~

Only thing I tried is replacing ">SETLIGHT1" for "#>SETLIGHT1"

Maybe because light is actually - platform: rgbct and even thought I just want to set toggle it does not work? I have tried changing parseLight(data, size, dest); forparseLightRGBWW(data, size, dest);, but result is same

But that is probably because rgbww and rgbct are different things.

I would try to do new function in esp_now_light.h even thought i do not know c++, but I do not even understand how the CT works, one channel for brightness and other for color, but what are the values i should even set ...

I would have hopped it at least compile, as both rgbww and rgbct use same argument types?
https://esphome.io/api/classesphome_1_1rgbct_1_1_r_g_b_c_t_light_output.html
https://esphome.io/api/classesphome_1_1rgbww_1_1_r_g_b_w_w_light_output.html

guess it needs some c++ knowledge.

I still don't really get why instead of mixing WW and CW channels they did brightness + temperature in the light driver.

UPDATE:
Ok, maybe I now see the difference WW does have CW WW AND Brightness and CT does have only CT and Brightness, so one argument less.
https://esphome.io/api/rgbct__light__output_8h_source.html

BTW This is my attempt, but again, i just tried to copy RGBWW function, so not surprising that it does not work

class esp_now_light_RGBCT : public esp_now_light{
  public:
    esp_now_light_RGBCT(uint8_t *mac_address, int number) : esp_now_light(mac_address, number){};
 
    LightTraits get_traits() override {
      // return the traits this light supports
      auto traits = LightTraits();
      traits.set_supported_color_modes({ColorMode::RGB_COLOR_TEMPERATURE, ColorMode::COLOR_TEMPERATURE});
      return traits;
    }

    std::string toFormat(float red, float green, float blue, float white_temperature, float white_brightness, uint32_t transition, std::string effect, char delimiter)
    {
      return ">SETLIGHT" + to_string(number).substr(0,1) + to_string(red).substr(0,4) + delimiter + to_string(green).substr(0,4) + delimiter + to_string(blue).substr(0,4) + delimiter + to_string(white_temperature).substr(0,4)
                + delimiter + to_string(white_brightness).substr(0,4) + delimiter + to_string(transition).substr(0,4) + delimiter + effect;
    }

    void write_state(LightState *state) override {
      // Get the light values:
      float red, green, blue, white_temperature, white_brightness, color_temperature_cw, color_temperature_ww, color_temperature;
      uint32_t transition = state->get_default_transition_length();
      state->remote_values.as_rgbct(color_temperature_cw, color_temperature_ww, &red, &green, &blue, &color_temperature, &white_brightness);
      // Process the light values:
      std::string newCommand = toFormat(red, green, blue, color_temperature, white_brightness, transition, state->get_effect_name(),';');
      send_command(newCommand, state);
    } 
};

void parseLightRGBCT(uint8_t* data, uint8_t size, LightState* dest)
{
  ESP_LOGD("custom", "Receiving RGBCT Light command");
  // Process data
  String values = "";
  for (auto i=0; i<size; i++) 
    values.concat((const char)data[i]);

  float red = parseFloat(values, ';');
  float green = parseFloat(values, ';');
  float blue = parseFloat(values, ';');
  float white_temperature = parseFloat(values, ';');
  float white_brighntness = parseFloat(values, ';');
  float transition = parseFloat(values, ';');
  String effect = parseString(values, ';');

  // Change Light
  auto call = dest->turn_on();
  call.set_rgb(red, green, blue);
  call.set_color_temperature(white_temperature);
  call.set_brightness(white_brighntness);
  call.set_transition_length(transition); 
  call.set_effect(effect.c_str());
  call.perform();
}

So the error I can't overcome for now is unchanged
no matching function for call to 'on(const char [11], setup()::<lambda()>::<lambda(uint8_t, uint8_t)>)'*

/config/esphome/eh-light-ceiling-rectangle-02-ESPNOWtest.yaml: In lambda function:
/config/esphome/eh-light-ceiling-rectangle-02-ESPNOWtest.yaml:52:8: error: no matching function for call to 'on(const char [11], setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>)'
       });
        ^
In file included from src/main.cpp:40:
src/MeshRC.h:79:6: note: candidate: 'void MeshRC::on(String, MeshRC::esp_rc_callback_t)'
 void on(String prefix, esp_rc_callback_t callback) {
      ^~
src/MeshRC.h:79:6: note:   no known conversion for argument 2 from 'setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>' to 'MeshRC::esp_rc_callback_t' {aka 'std::function<void()>'}
src/MeshRC.h:82:6: note: candidate: 'void MeshRC::on(String, MeshRC::esp_rc_data_callback_t)'
 void on(String prefix, esp_rc_data_callback_t callback) {
      ^~
src/MeshRC.h:82:6: note:   no known conversion for argument 2 from 'setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>' to 'MeshRC::esp_rc_data_callback_t' {aka 'std::function<void(const unsigned char*, int)>'}

this is the code it is complaining about:

custom_component:
  - lambda: |-
      MeshRC::begin();
      
      ESP_LOGD("custom", "Initialising MeshRC");

      MeshRC::on(">SETLIGHT1", [](uint8_t* data, uint8_t size) {
        LightState* dest = id(light_shop_ceiling);
        parseLightRGBCT(data, size, dest);
      });
      return {};

I have defined light like

light:
  - platform: rgbct
    id: light_shop_ceiling
    name: "${hostname} light"
    red: output_red
    green: output_green
    blue: output_blue
    white_brightness: output_brightness
    color_temperature: output_temperature
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2000 K
    restore_mode: ALWAYS_ON

MeshRC::on("", [](uint8_t* data, uint8_t size) {
        ESP_LOGD("custom", "Receiving any MeshRC message");
      });

also results in

no matching function for call to 'on(const char [1], setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>)'

@evlo evlo changed the title Cannot build on ESP32-c3 (src/MeshRC.h:10:10: fatal error: WiFi.h: No such file or directory) Cannot build on ESP32-s3: no matching function for call to 'on(const char [11], setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>)' Mar 31, 2023
@evlo evlo changed the title Cannot build on ESP32-s3: no matching function for call to 'on(const char [11], setup()::<lambda()>::<lambda(uint8_t*, uint8_t)>)' Cannot build on ESP32-s3 and RGBCT light Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant