diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index ada478e6f..21654bbc3 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -52,7 +52,8 @@ template_t g_templates [] = { { Setup_Device_NedisWIFIP130FWT_10A, "Nedis WIFIP130FWT SmartPlug 10A"}, { Setup_Device_BK7231T_Raw_PrimeWiFiSmartOutletsOutdoor_CCWFIO232PK, "Prime SmartOutlet Outdoor 2x Costco"}, { Setup_Device_EmaxHome_EDU8774, "Emax Home EDU8774 SmartPlug 16A"}, - { Setup_Device_TuyaSmartPFW02G, "Tuya Smart PFW02-G"} + { Setup_Device_TuyaSmartPFW02G, "Tuya Smart PFW02-G"}, + { Setup_Device_AvatarASL04, "Avatar ASL04 5v LED strip"} }; int g_total_templates = sizeof(g_templates)/sizeof(g_templates[0]); diff --git a/src/new_builtin_devices.c b/src/new_builtin_devices.c index bc0926314..14ecc5965 100644 --- a/src/new_builtin_devices.c +++ b/src/new_builtin_devices.c @@ -343,3 +343,40 @@ void Setup_Device_TuyaSmartPFW02G() { PIN_SaveToFlash(); } + + +void Setup_Device_AvatarASL04() { + + // pins are: + // red - PWM2 = P7 + // green - PWM3 = P8 + // blue - PWM1 = P6 + // warm white - PWM5 = P26 + // cold white - PWM4 = P24 + + PIN_ClearPins(); + + // red + PIN_SetPinChannelForPinIndex(24, 1); + PIN_SetPinRoleForPinIndex(24, IOR_PWM); + // green + PIN_SetPinChannelForPinIndex(6, 2); + PIN_SetPinRoleForPinIndex(6, IOR_PWM); + // blue + PIN_SetPinChannelForPinIndex(8, 3); + PIN_SetPinRoleForPinIndex(8, IOR_PWM); + + + // just set to buttons 1/2/3 for the moment + PIN_SetPinRoleForPinIndex(7, IOR_Button); + PIN_SetPinChannelForPinIndex(7, 1); + + PIN_SetPinRoleForPinIndex(9, IOR_Button); + PIN_SetPinChannelForPinIndex(9, 1); + + PIN_SetPinRoleForPinIndex(14, IOR_Button); + PIN_SetPinChannelForPinIndex(14, 1); + + + PIN_SaveToFlash(); +} \ No newline at end of file diff --git a/src/new_pins.c b/src/new_pins.c index b59a9f7d8..bf506f47e 100644 --- a/src/new_pins.c +++ b/src/new_pins.c @@ -5,6 +5,7 @@ #include "new_pins.h" #include "httpserver/new_http.h" #include "logging/logging.h" +#include "new_cmd.h" //According to your need to modify the constants. @@ -1195,6 +1196,37 @@ void PIN_ticks(void *param) } } +static int showgpi(const void *context, const char *cmd, const char *args){ + int i; + unsigned int value = 0; + + for (i = 0; i < 32; i++) { + int val = 0; +#ifdef WINDOWS +#elif PLATFORM_XR809 + int xr_port; // eg GPIO_PORT_A + int xr_pin; // eg. GPIO_PIN_20 + PIN_XR809_GetPortPinForIndex(i, &xr_port, &xr_pin); + + if (HAL_GPIO_ReadPin(xr_port, xr_pin) == GPIO_PIN_LOW) + val = 0; + else + val = 1; +#else + val = bk_gpio_input(i); + if (val){ + val = 1; + } else { + val = 0; + } +#endif + value |= ((val & 1)<