Compare commits

..

22 commits

Author SHA1 Message Date
29209ac08a fix energy double loading 2024-06-28 22:37:44 +07:00
3cd7cdaaef Merge branch 'main' of https://git.siwatsystem.com/ise-senior-iot/ise-iot-oop-v2 2024-06-28 21:47:59 +07:00
fff7fdffc8 Update main.cpp 2024-06-28 21:47:37 +07:00
181c1937ee energy auto save 2024-06-28 12:29:59 +07:00
reaw55
a294430c0a debugged for AC to work 2024-06-24 08:01:34 +07:00
reaw55
32c4af34f1 adjust lock check 2024-06-22 06:22:53 +07:00
reaw55
f249dfe314 Merge branch 'all-toggle-fix' 2024-06-22 06:19:04 +07:00
7bda72a930 update library & change debounce 2024-06-21 23:18:40 +07:00
reaw55
f93dbe65f2 changed behavior of system toggle 2024-06-21 21:58:39 +07:00
reaw55
29fc7a054f uncomment switch, add debounce, i to 16 2024-06-21 21:49:58 +07:00
reaw55
d25d16f181 comment out switch again 2024-06-21 13:55:04 +07:00
reaw55
49f6ca0994 add input loop 2024-06-17 21:55:16 +07:00
reaw55
c0867a6f9d un comment switch case 2024-06-17 13:01:21 +07:00
reaw55
afcc360eeb change build flag 2024-06-17 12:57:10 +07:00
reaw55
2fd969fa93 clean up and update time on startup 2024-05-22 01:52:57 +07:00
reaw55
94ed11c335 Merge branch 'lastest-confrimed-working' 2024-05-22 01:42:57 +07:00
reaw55
64adf6dcd5 change standby name 2024-05-22 01:42:01 +07:00
reaw55
2fe7dfeb5f comment out switch 2024-05-07 22:31:58 +07:00
reaw55
257a226f0e noise reject 2024-05-07 22:14:33 +07:00
reaw55
b25c472854 changed debounce 2024-05-07 22:09:58 +07:00
reaw55
0ac6551cdd change fan speed setting 2024-05-07 22:03:26 +07:00
reaw55
559d3b0b53 update dashboard display to not show grey square 2024-04-25 01:04:33 +07:00
11 changed files with 92 additions and 71 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
/.vscode
/.vscode

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

Binary file not shown.

Binary file not shown.

View file

@ -12,6 +12,6 @@
platform = espressif32
board = wt32-eth01
framework = arduino
lib_deps = siwats/ESPMegaPROR3@^2.5.3
lib_deps = siwats/ESPMegaPROR3@^2.9.4
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=0
build_flags = -DCORE_DEBUG_LEVEL=0 -DSW_VERSION='"ise-final-1.3"' -DBOARD_MODEL='"ESPMegaPRO R3.3b"'

View file

@ -535,6 +535,13 @@ void ISEDisplay::updatePMinside(u_int16_t pm25_inside)
void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed)
{
//check pm_lock if true do nothing
this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0;
if (this->pm_lock_state == true)
{
ESP_LOGI("ISEDisplay", "PM lock is on, do nothing");
return;
}
ESP_LOGI("ISEDisplay", "Setting PM state: %d, fan speed: %d", is_pm_on, pm_fan_speed);
char buffer[4];
itoa(pm_fan_speed, buffer, DEC);
@ -562,6 +569,13 @@ void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_te
this->ac_fan_speed = ac_fan_speed;
this->ac_mode = ac_mode;
this->ac_temperature = ac_temperature;
//check ac_lock if true do nothing
this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0;
if (this->ac_lock_state == true)
{
ESP_LOGI("ISEDisplay", "AC lock is on, do nothing");
return;
}
// check ac_temp is within bound of daikin
if (this->ac_temperature < DAIKIN_MIN_TEMP)
{
@ -1152,24 +1166,49 @@ bool ISEDisplay::calculateAllState()
}
void ISEDisplay::toggleSystem()
{
toggleLightGroupState();
// check for ac lock and pm lock, if lock is on do nothing
if (this->ac_lock_state == true)
// toggleLightGroupState();
// // check for ac lock and pm lock, if lock is on do nothing
// if (this->ac_lock_state == true)
// {
// ESP_LOGI("ISEDisplay", "AC lock is on, do nothing");
// }
// else
// {
// toggleAC();
// }
// if (this->pm_lock_state == true)
// {
// ESP_LOGI("ISEDisplay", "PM lock is on, do nothing");
// }
// else
// {
// togglePM();
// }
bool state = calculateAllState();
if (state)
{
ESP_LOGI("ISEDisplay", "AC lock is on, do nothing");
//if AC mode is not zero, toggleAC()
if(ac_mode != 0) {
toggleAC();
}
setLightGroupState(0);
setPMstate(false, pm_fan_speed);
}
else
{
toggleAC();
}
if (this->pm_lock_state == true)
{
ESP_LOGI("ISEDisplay", "PM lock is on, do nothing");
}
else
{
togglePM();
if(ac_mode == 0) {
toggleAC();
}
setLightGroupState(3);
setPMstate(true, pm_fan_speed);
}
}
void ISEDisplay::allToggleStandby()
{

View file

@ -67,9 +67,9 @@ lights have 4 states
#define MOTION_REAR 9
//PM fanspeed setting
#define PM_FAN_SPEED_LOW 3
#define PM_FAN_SPEED_MID 10
#define PM_FAN_SPEED_HIGH 18
#define PM_FAN_SPEED_LOW 1
#define PM_FAN_SPEED_MID 5
#define PM_FAN_SPEED_HIGH 9
//
#define DISPLAY_TIMEOUT 5*60*1000 // 5 minutes
@ -136,6 +136,12 @@ lights have 4 states
#define COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_ON 6
#define COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_ON_PRESSED 7
//Standby adv setting toggle
#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_OFF 88
#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_OFF_PRESSED 89
#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_ON 90
#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_ON_PRESSED 91
//Standby light toggle
#define COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF 8
#define COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF_PRESSED 9

View file

@ -19,6 +19,10 @@ CurrentTransformerCard ct6 = CurrentTransformerCard(&analogCard, 7, &voltage, &a
float adc2current(uint16_t adc_val)
{
// float voltage = adc_val * 0.0007-0.1994;
if (adc_val > 64000) {
// ADC Value is too high, return 0
return 0;
}
float adc_voltage = adc_val * 0.0007;
// 0-10V Output with 30A Current Rating CT
float ct_current = adc_voltage / 10.0 * 30.0;
@ -100,15 +104,6 @@ void mqttSubscribeCallback()
void setup()
{
// ------------ GPIO 2 Factory Reset Check ------------
gpio_config_t gpio_2_conf;
gpio_2_conf.intr_type = GPIO_INTR_DISABLE;
gpio_2_conf.mode = GPIO_MODE_INPUT;
gpio_2_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&gpio_2_conf);
// If GPIO 2 is pulled low, clear the FRAM then reboot (Reset the device to factory defaults)
bool clear_fram = !gpio_get_level(GPIO_NUM_2);
// ------------ End GPIO 2 Factory Reset Check ------------
// ------------ Display Pre Initialization Routine ------------
@ -128,29 +123,14 @@ void setup()
// Give flow of control to OS and scheduler
espmega.begin();
// // ------------ Factory Reset Routine ------------
// Disable factory reset for now
espmega.inputs.loop();
// set debounce time to 200 for pin 0-7
for (uint16_t i = 0; i < 8; i++)
// Set time zone to UTC+7
espmega.setTimezone("ICT-7");
// set debounce time to 500 for pin 0-11
for (uint16_t i = 0; i < 16; i++)
{
espmega.inputs.setDebounceTime(i, 200);
}
// if (clear_fram)
// {
// Serial.print("boot_state.txt=\"Factory Resetting . . .\"");
// sendStopBytes();
// for (uint16_t i = 0; i < 32768; i++)
// {
// espmega.fram.write8(i, 0);
// }
// esp_restart();
// }
// // ------------ End Factory Reset Routine ------------
espmega.inputs.setDebounceTime(i, 75);
}
// ------------ IoT Module Initialization Routine ------------
Serial.print("boot_state.txt=\"IoT Initializing . . .\"");
@ -192,28 +172,10 @@ void setup()
climateCard_daikin.setFRAMAutoSave(true);
espmega.display->bindClimateCard(&climateCard_daikin);
// Current Transformers
#ifdef ANALOG_ENABLE
espmega.installCard(4, &analogCard);
espmega.installCard(5, &ct1);
ct1.bindFRAM(&espmega.fram, 6000);
espmega.iot->registerCard(5);
espmega.installCard(6, &ct2);
ct2.bindFRAM(&espmega.fram, 6100);
espmega.iot->registerCard(6);
espmega.installCard(7, &ct3);
ct3.bindFRAM(&espmega.fram, 6200);
espmega.iot->registerCard(7);
espmega.installCard(8, &ct4);
ct4.bindFRAM(&espmega.fram, 6300);
espmega.iot->registerCard(8);
espmega.installCard(9, &ct5);
ct5.bindFRAM(&espmega.fram, 6400);
espmega.iot->registerCard(9);
espmega.installCard(10, &ct6);
ct6.bindFRAM(&espmega.fram, 6500);
espmega.iot->registerCard(10);
#endif
// Input callbacks
// pre-load the input buffers
ESP_LOGV("ISE IoT OS", "Pre-loading input buffers");
espmega.inputs.preloadInputBuffer();
// ------------ Climate Cards Initialization Routine ------------
ESP_LOGD("ISE OS", "Setting up climate cards");
@ -249,16 +211,28 @@ void setup()
ESP_LOGV("ISE OS", "Analog card available, installing current transformer cards");
espmega.installCard(5, &ct1);
ct1.bindFRAM(&espmega.fram, 5010);
ct1.loadEnergy();
ct1.setEnergyAutoSave(true);
espmega.installCard(6, &ct2);
ct2.bindFRAM(&espmega.fram, 5020);
ct2.loadEnergy();
ct2.setEnergyAutoSave(true);
espmega.installCard(7, &ct3);
ct3.bindFRAM(&espmega.fram, 5030);
ct3.loadEnergy();
ct3.setEnergyAutoSave(true);
espmega.installCard(8, &ct4);
ct4.bindFRAM(&espmega.fram, 5040);
ct4.loadEnergy();
ct4.setEnergyAutoSave(true);
espmega.installCard(9, &ct5);
ct5.bindFRAM(&espmega.fram, 5050);
ct5.loadEnergy();
ct5.setEnergyAutoSave(true);
espmega.installCard(10, &ct5);
ct6.bindFRAM(&espmega.fram, 5060);
ct6.loadEnergy();
ct6.setEnergyAutoSave(true);
espmega.iot->registerCard(5);
espmega.iot->registerCard(6);
espmega.iot->registerCard(7);