ct code, idk if it works or not.
This commit is contained in:
parent
7279ae0a62
commit
7e3b0b992a
3 changed files with 41 additions and 2 deletions
30
src/main.cpp
30
src/main.cpp
|
|
@ -7,6 +7,15 @@ RemoteVariable weather = RemoteVariable();
|
|||
RemoteVariable pm_switch = RemoteVariable();
|
||||
RemoteVariable pm_fan_speed = RemoteVariable();
|
||||
|
||||
AnalogCard AnalogCard = AnalogCard();
|
||||
float *voltage = CT_RMS_VOLTAGE;
|
||||
CurrentTransformerCard ct_light_phase1 = CurrentTransformerCard(&AnalogCard, CT_PIN_AC_PHASE1, &voltage, &adcToCurrent, 1000);
|
||||
CurrentTransformerCard ct_light_phase2 = CurrentTransformerCard(&AnalogCard, CT_PIN_AC_PHASE2, &voltage, &adcToCurrent, 1000);
|
||||
CurrentTransformerCard ct_socket = CurrentTransformerCard(&AnalogCard, CT_PIN_SOCKET, &voltage, &adcToCurrent, 1000);
|
||||
CurrentTransformerCard ct_ac_phase1 = CurrentTransformerCard(&AnalogCard, CT_PIN_AC_PHASE1, &voltage, &adcToCurrent, 1000);
|
||||
CurrentTransformerCard ct_ac_phase2 = CurrentTransformerCard(&AnalogCard, CT_PIN_AC_PHASE2, &voltage, &adcToCurrent, 1000);
|
||||
CurrentTransformerCard ct_ac_phase3 = CurrentTransformerCard(&AnalogCard, CT_PIN_AC_PHASE3, &voltage, &adcToCurrent, 1000);
|
||||
|
||||
const char *mode_names[] = {"off", "cool", "fan_only", "dry"};
|
||||
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
|
||||
uint8_t row = 4;
|
||||
|
|
@ -37,6 +46,15 @@ ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
|||
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
||||
AIR_CONDITIONER_RMT_CHANNEL);
|
||||
|
||||
void adc2current(uint16_t adc_value)
|
||||
{
|
||||
// 16 bit ADC value to current in amps
|
||||
// ADC Range is 0-65535, It have an input range of 0-3.3V
|
||||
// However, it have a resistor network that map 0-3.3V to 0-12V
|
||||
// The current transformer output 0-10V with 0V as 0A and 10V as 50A
|
||||
return (adc_value / 65535.0) * 12.0 / 10.0 * 50.0;
|
||||
}
|
||||
|
||||
void handleMqttMessage(char *topic, char *payload)
|
||||
{
|
||||
}
|
||||
|
|
@ -115,6 +133,18 @@ void setup()
|
|||
climateCard.loadStateFromFRAM();
|
||||
climateCard.setFRAMAutoSave(true);
|
||||
espmega.display->bindClimateCard(&climateCard);
|
||||
espmega.installCard(4, &ct_light_phase1);
|
||||
espmega.installCard(5, &ct_light_phase2);
|
||||
espmega.installCard(6, &ct_socket);
|
||||
espmega.installCard(7, &ct_ac_phase1);
|
||||
espmega.installCard(8, &ct_ac_phase2);
|
||||
espmega.installCard(9, &ct_ac_phase3);
|
||||
espmega->iot.registerCard(4);
|
||||
espmega->iot.registerCard(5);
|
||||
espmega->iot.registerCard(6);
|
||||
espmega->iot.registerCard(7);
|
||||
espmega->iot.registerCard(8);
|
||||
espmega->iot.registerCard(9);
|
||||
// auto binded_display_update_on_pm25_out = std::bind(&display_update,0,std::placeholders::_1);
|
||||
// auto binded_display_update_on_pm25_in = std::bind(&display_update,1,std::placeholders::_1);
|
||||
// auto binded_display_update_on_temp_out = std::bind(&display_update,2,std::placeholders::_1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue