supla-espressif-esp/src/user
W pliku supla_esp.h dopisujemy
Kod: Zaznacz cały
#include "supla_esp_board_set.h"
Kod: Zaznacz cały
void supla_esp_board_gpio_init(void);
Kod: Zaznacz cały
void Setting_Up_Channel_Relay(TDS_SuplaDeviceChannel_B *channels, uint8 relays_gpio);
void Setting_Up_Channel_Temperature(TDS_SuplaDeviceChannel_B *channels, int type);
void Setting_Up_Channel_Relay_RS(TDS_SuplaDeviceChannel_B *channels);
void Setting_Up_Sensor(uint8 sensor_gpio, uint8 flaga, TDS_SuplaDeviceChannel_B *channels);
void Setting_Up_Button( uint8 button_gpio, uint8 relay_gpio, uint8 monobistable, uint8 flaga_button, uint8 flaga_relay, TDS_SuplaDeviceChannel_B *channels);
void Setting_Up_Relay(uint8 relay_gpio, uint8 flaga_relay, TDS_SuplaDeviceChannel_B *channels);
void Setting_Up_Button_Configure(uint8 gpio, uint8 stable);
void Setting_Up_Buttons_RS( uint8 gpio_buton_up, uint8 gpio_buton_down, uint8 relay_up, uint8 relay_down, uint8 mono_bistable, uint8 flaga_button, TDS_SuplaDeviceChannel_B *channels);
void Setting_Up_Relay_RS(uint8 relay_up, uint8 relay_down, TDS_SuplaDeviceChannel_B *channels);
void Setting_Up_Temperature(uint8 gpio, int type, TDS_SuplaDeviceChannel_B *channels);
Poniżej przykład dla lightswitch
Kod: Zaznacz cały
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "supla_esp.h"
#include "supla_dht.h"
#include "supla_ds18b20.h"
void supla_esp_board_set_device_name(char *buffer, uint8 buffer_size) {
#if defined(__BOARD_lightswitch_x2) || defined(__BOARD_lightswitch_x2_54)
ets_snprintf(buffer, buffer_size, "SUPLA-LIGHTSWITCH-x2-DS");
#elif defined(__BOARD_lightswitch_x2_DHT11) || defined(__BOARD_lightswitch_x2_54_DHT11)
ets_snprintf(buffer, buffer_size, "SUPLA-LIGHTSWITCH-x2-DHT11");
#elif defined(__BOARD_lightswitch_x2_DHT22) || defined(__BOARD_lightswitch_x2_54_DHT22)
ets_snprintf(buffer, buffer_size, "SUPLA-LIGHTSWITCH-x2-DHT22");
#endif
}
void ICACHE_FLASH_ATTR supla_esp_board_set_channels_gpio(TDS_SuplaDeviceChannel_B *channel_set, uint8 channels_gpio) {
switch_chanell_gpio = channels_gpio;
Setting_Up_Button(B_CFG_PORT, \
B_RELAY1_PORT, \
supla_esp_cfg.CfgButtonType == BTN_TYPE_BISTABLE ? INPUT_TYPE_BTN_BISTABLE : INPUT_TYPE_BTN_MONOSTABLE, \
INPUT_FLAG_PULLUP, \
RELAY_FLAG_RESTORE_FORCE, \
channel_set);
Setting_Up_Button(B_BTN2_PORT, \
B_RELAY2_PORT, \
supla_esp_cfg.CfgButtonType == BTN_TYPE_BISTABLE ? INPUT_TYPE_BTN_BISTABLE : INPUT_TYPE_BTN_MONOSTABLE, \
INPUT_FLAG_PULLUP, \
RELAY_FLAG_RESTORE_FORCE, \
channel_set);
#if defined(DS18B20)
Setting_Up_Temperature(2, SUPLA_CHANNELTYPE_THERMOMETERDS18B20, channel_set);
#elif defined(SENSOR_DHT11)
Setting_Up_Temperature(2, SUPLA_CHANNELTYPE_DHT11, channel_set);
#elif defined(SENSOR_DHT22)
Setting_Up_Temperature(2, SUPLA_CHANNELTYPE_DHT22, channel_set);
#endif
// ---------------------------------------
Setting_Up_Button_Configure(B_CFG_PORT, supla_esp_cfg.CfgButtonType == BTN_TYPE_BISTABLE ? INPUT_TYPE_BTN_BISTABLE : INPUT_TYPE_BTN_MONOSTABLE);
}
void supla_esp_board_send_channel_values_with_delay(void *srpc) {
}
Kod: Zaznacz cały
void ICACHE_FLASH_ATTR supla_esp_board_set_channels_gpio(TDS_SuplaDeviceChannel_B *channel_set, uint8 channels_gpio) {
switch_chanell_gpio = channels_gpio;
Setting_Up_Buttons_RS(B_BTN1_PORT, B_BTN2_PORT, B_RELAY1_PORT, B_RELAY2_PORT, INPUT_TYPE_BTN_MONOSTABLE, INPUT_FLAG_PULLUP, channel_set );
Setting_Up_Sensor(B_SENSOR_PORT1, INPUT_FLAG_PULLUP, channel_set);
// ---------------------------------------
Setting_Up_Button_Configure(B_BTN_CFG_PORT, INPUT_TYPE_BTN_MONOSTABLE);
}