2020-04-10 10:30:08 +00:00
# include "wled.h"
2021-09-30 14:30:44 +00:00
# include "wled_ethernet.h"
2020-04-10 10:30:08 +00:00
2016-12-30 23:38:51 +00:00
/*
* Sending XML status files to client
*/
2018-11-09 16:00:36 +00:00
//build XML response to HTTP /win API request
2024-09-06 01:13:55 +00:00
void XML_response ( Print & dest )
2016-11-19 18:39:17 +00:00
{
2024-09-07 23:52:30 +00:00
dest . printf_P ( PSTR ( " <?xml version= \" 1.0 \" ?><vs><ac>%d</ac> " ) , ( nightlightActive & & nightlightMode > NL_MODE_SET ) ? briT : bri ) ;
2018-11-09 16:00:36 +00:00
for ( int i = 0 ; i < 3 ; i + + )
{
2025-02-06 13:57:18 +00:00
dest . printf_P ( PSTR ( " <cl>%d</cl> " ) , colPri [ i ] ) ;
2018-11-09 16:00:36 +00:00
}
2019-01-18 00:20:36 +00:00
for ( int i = 0 ; i < 3 ; i + + )
{
2024-09-07 23:52:30 +00:00
dest . printf_P ( PSTR ( " <cs>%d</cs> " ) , colSec [ i ] ) ;
2019-02-19 11:57:50 +00:00
}
2024-09-07 23:52:30 +00:00
dest . printf_P ( PSTR ( " <ns>%d</ns><nr>%d</nr><nl>%d</nl><nf>%d</nf><nd>%d</nd><nt>%d</nt><fx>%d</fx><sx>%d</sx><ix>%d</ix><fp>%d</fp><wv>%d</wv><ws>%d</ws><ps>%d</ps><cy>%d</cy><ds>%s%s</ds><ss>%d</ss></vs> " ) ,
notifyDirect , receiveGroups ! = 0 , nightlightActive , nightlightMode > NL_MODE_SET , nightlightDelayMins ,
nightlightTargetBri , effectCurrent , effectSpeed , effectIntensity , effectPalette ,
2025-02-06 13:57:18 +00:00
strip . hasWhiteChannel ( ) ? colPri [ 3 ] : - 1 , colSec [ 3 ] , currentPreset , currentPlaylist > = 0 ,
2024-09-07 23:52:30 +00:00
serverDescription , realtimeMode ? PSTR ( " (live) " ) : " " ,
strip . getFirstSelectedSegId ( )
) ;
2016-11-19 18:39:17 +00:00
}
2025-01-07 19:33:10 +00:00
static void extractPin ( Print & settingsScript , const JsonObject & obj , const char * key ) {
2021-09-30 14:30:44 +00:00
if ( obj [ key ] . is < JsonArray > ( ) ) {
JsonArray pins = obj [ key ] . as < JsonArray > ( ) ;
for ( JsonVariant pv : pins ) {
2024-09-18 23:19:40 +00:00
if ( pv . as < int > ( ) > - 1 ) { settingsScript . print ( " , " ) ; settingsScript . print ( pv . as < int > ( ) ) ; }
2021-09-30 14:30:44 +00:00
}
} else {
2024-09-18 23:19:40 +00:00
if ( obj [ key ] . as < int > ( ) > - 1 ) { settingsScript . print ( " , " ) ; settingsScript . print ( obj [ key ] . as < int > ( ) ) ; }
2021-09-30 14:30:44 +00:00
}
}
2024-09-18 23:19:40 +00:00
// print used pins by scanning JsonObject (1 level deep)
2025-01-07 19:33:10 +00:00
static void fillUMPins ( Print & settingsScript , const JsonObject & mods )
2021-09-30 14:30:44 +00:00
{
for ( JsonPair kv : mods ) {
// kv.key() is usermod name or subobject key
// kv.value() is object itself
JsonObject obj = kv . value ( ) ;
if ( ! obj . isNull ( ) ) {
// element is an JsonObject
if ( ! obj [ " pin " ] . isNull ( ) ) {
2024-09-18 23:19:40 +00:00
extractPin ( settingsScript , obj , " pin " ) ;
2021-09-30 14:30:44 +00:00
} else {
// scan keys (just one level deep as is possible with usermods)
for ( JsonPair so : obj ) {
const char * key = so . key ( ) . c_str ( ) ;
if ( strstr ( key , " pin " ) ) {
// we found a key containing "pin" substring
if ( strlen ( strstr ( key , " pin " ) ) = = 3 ) {
// and it is at the end, we found another pin
2024-09-18 23:19:40 +00:00
extractPin ( settingsScript , obj , key ) ;
2021-09-30 14:30:44 +00:00
continue ;
}
}
if ( ! obj [ so . key ( ) ] . is < JsonObject > ( ) ) continue ;
JsonObject subObj = obj [ so . key ( ) ] ;
if ( ! subObj [ " pin " ] . isNull ( ) ) {
// get pins from subobject
2024-09-18 23:19:40 +00:00
extractPin ( settingsScript , subObj , " pin " ) ;
2021-09-30 14:30:44 +00:00
}
}
}
}
}
}
2024-09-18 23:19:40 +00:00
void appendGPIOinfo ( Print & settingsScript ) {
settingsScript . print ( F ( " d.um_p=[-1 " ) ) ; // has to have 1 element
2022-09-10 17:27:00 +00:00
if ( i2c_sda > - 1 & & i2c_scl > - 1 ) {
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " ,%d,%d " ) , i2c_sda , i2c_scl ) ;
2022-09-10 17:27:00 +00:00
}
if ( spi_mosi > - 1 & & spi_sclk > - 1 ) {
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " ,%d,%d " ) , spi_mosi , spi_sclk ) ;
2022-09-10 17:27:00 +00:00
}
// usermod pin reservations will become unnecessary when settings pages will read cfg.json directly
if ( requestJSONBufferLock ( 6 ) ) {
// if we can't allocate JSON buffer ignore usermod pins
2024-11-15 18:03:46 +00:00
JsonObject mods = pDoc - > createNestedObject ( " um " ) ;
2024-09-19 19:44:11 +00:00
UsermodManager : : addToConfig ( mods ) ;
2024-09-18 23:19:40 +00:00
if ( ! mods . isNull ( ) ) fillUMPins ( settingsScript , mods ) ;
2022-09-10 17:27:00 +00:00
releaseJSONBufferLock ( ) ;
}
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " ]; " ) ) ;
2022-09-10 17:27:00 +00:00
2024-09-14 12:54:42 +00:00
// add reserved (unusable) pins
2024-11-15 18:03:46 +00:00
bool firstPin = true ;
2024-09-28 01:05:28 +00:00
settingsScript . print ( F ( " d.rsvd=[ " ) ) ;
2024-09-14 12:54:42 +00:00
for ( unsigned i = 0 ; i < WLED_NUM_PINS ; i + + ) {
2024-09-19 19:44:11 +00:00
if ( ! PinManager : : isPinOk ( i , false ) ) { // include readonly pins
2024-11-15 18:03:46 +00:00
if ( ! firstPin ) settingsScript . print ( ' , ' ) ;
settingsScript . print ( i ) ;
firstPin = false ;
2024-09-14 12:54:42 +00:00
}
}
2025-01-16 12:19:25 +00:00
# ifdef WLED_ENABLE_DMX
2024-11-15 18:03:46 +00:00
if ( ! firstPin ) settingsScript . print ( ' , ' ) ;
settingsScript . print ( 2 ) ; // DMX hardcoded pin
firstPin = false ;
2022-09-10 17:27:00 +00:00
# endif
2024-01-22 20:01:57 +00:00
# if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST)
2024-11-15 18:03:46 +00:00
if ( ! firstPin ) settingsScript . print ( ' , ' ) ;
settingsScript . print ( hardwareTX ) ; // debug output (TX) pin
firstPin = false ;
2022-09-10 17:27:00 +00:00
# endif
2024-12-21 18:02:24 +00:00
# if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
2022-09-10 17:27:00 +00:00
if ( ethernetType ! = WLED_ETH_NONE & & ethernetType < WLED_NUM_ETH_TYPES ) {
2024-11-15 18:03:46 +00:00
if ( ! firstPin ) settingsScript . print ( ' , ' ) ;
for ( unsigned p = 0 ; p < WLED_ETH_RSVD_PINS_COUNT ; p + + ) { settingsScript . printf ( " %d, " , esp32_nonconfigurable_ethernet_pins [ p ] . pin ) ; }
if ( ethernetBoards [ ethernetType ] . eth_power > = 0 ) { settingsScript . printf ( " %d, " , ethernetBoards [ ethernetType ] . eth_power ) ; }
if ( ethernetBoards [ ethernetType ] . eth_mdc > = 0 ) { settingsScript . printf ( " %d, " , ethernetBoards [ ethernetType ] . eth_mdc ) ; }
if ( ethernetBoards [ ethernetType ] . eth_mdio > = 0 ) { settingsScript . printf ( " %d, " , ethernetBoards [ ethernetType ] . eth_mdio ) ; }
switch ( ethernetBoards [ ethernetType ] . eth_clk_mode ) {
2022-09-10 17:27:00 +00:00
case ETH_CLOCK_GPIO0_IN :
case ETH_CLOCK_GPIO0_OUT :
2024-11-15 18:03:46 +00:00
settingsScript . print ( 0 ) ;
2022-09-10 17:27:00 +00:00
break ;
case ETH_CLOCK_GPIO16_OUT :
2024-11-15 18:03:46 +00:00
settingsScript . print ( 16 ) ;
2022-09-10 17:27:00 +00:00
break ;
case ETH_CLOCK_GPIO17_OUT :
2024-11-15 18:03:46 +00:00
settingsScript . print ( 17 ) ;
2022-09-10 17:27:00 +00:00
break ;
}
}
# endif
2024-09-28 01:05:28 +00:00
settingsScript . print ( F ( " ]; " ) ) ; // rsvd
2022-09-10 17:27:00 +00:00
// add info for read-only GPIO
2024-09-28 01:05:28 +00:00
settingsScript . print ( F ( " d.ro_gpio=[ " ) ) ;
2024-11-15 18:03:46 +00:00
firstPin = true ;
2024-09-03 15:29:38 +00:00
for ( unsigned i = 0 ; i < WLED_NUM_PINS ; i + + ) {
2024-09-19 19:44:11 +00:00
if ( PinManager : : isReadOnlyPin ( i ) ) {
2024-09-03 15:29:38 +00:00
// No comma before the first pin
2024-11-15 18:03:46 +00:00
if ( ! firstPin ) settingsScript . print ( ' , ' ) ;
2024-09-18 23:19:40 +00:00
settingsScript . print ( i ) ;
2024-09-03 15:29:38 +00:00
firstPin = false ;
}
2024-09-01 19:31:19 +00:00
}
2024-09-28 01:05:28 +00:00
settingsScript . print ( F ( " ]; " ) ) ;
2022-09-10 17:27:00 +00:00
// add info about max. # of pins
2024-11-17 09:47:09 +00:00
settingsScript . printf_P ( PSTR ( " d.max_gpio=%d; " ) , WLED_NUM_PINS ) ;
2022-09-10 17:27:00 +00:00
}
2019-03-11 16:57:06 +00:00
2018-11-09 16:00:36 +00:00
//get values for settings form in javascript
2024-09-18 23:19:40 +00:00
void getSettingsJS ( byte subPage , Print & settingsScript )
2016-11-19 18:39:17 +00:00
{
2018-01-27 22:28:20 +00:00
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
2024-09-10 13:20:34 +00:00
DEBUG_PRINTF_P ( PSTR ( " settings resp %u \n " ) , ( unsigned ) subPage ) ;
2019-08-17 10:27:06 +00:00
2022-05-08 08:50:48 +00:00
if ( subPage < 0 | | subPage > 10 ) return ;
2024-11-15 18:03:46 +00:00
char nS [ 32 ] ;
2022-03-07 08:44:35 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_MENU )
2022-03-07 08:44:35 +00:00
{
2024-02-06 13:47:20 +00:00
# ifdef WLED_DISABLE_2D // include only if 2D is not compiled in
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " gId('2dbtn').style.display='none'; " ) ) ;
2023-01-16 21:09:43 +00:00
# endif
2025-01-16 12:19:25 +00:00
# ifdef WLED_ENABLE_DMX // include only if DMX is enabled
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " gId('dmxbtn').style.display=''; " ) ) ;
2022-03-07 08:44:35 +00:00
# endif
}
2018-02-20 21:29:48 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_WIFI )
2021-09-30 14:30:44 +00:00
{
2024-01-20 23:30:15 +00:00
size_t l ;
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " resetWiFi(%d); " ) , WLED_MAX_WIFI_COUNT ) ;
2024-01-20 23:30:15 +00:00
for ( size_t n = 0 ; n < multiWiFi . size ( ) ; n + + ) {
l = strlen ( multiWiFi [ n ] . clientPass ) ;
char fpass [ l + 1 ] ; //fill password field with ***
fpass [ l ] = 0 ;
memset ( fpass , ' * ' , l ) ;
2024-12-21 18:02:24 +00:00
char bssid [ 13 ] ;
fillMAC2Str ( bssid , multiWiFi [ n ] . bssid ) ;
settingsScript . printf_P ( PSTR ( " addWiFi( \" %s \" , \" %s \" , \" %s \" ,0x%X,0x%X,0x%X); " ) ,
2024-09-07 23:52:30 +00:00
multiWiFi [ n ] . clientSSID ,
fpass ,
2024-12-21 18:02:24 +00:00
bssid ,
2024-09-07 23:52:30 +00:00
( uint32_t ) multiWiFi [ n ] . staticIP , // explicit cast required as this is a struct
( uint32_t ) multiWiFi [ n ] . staticGW ,
( uint32_t ) multiWiFi [ n ] . staticSN ) ;
2018-02-20 21:29:48 +00:00
}
2018-07-20 17:35:31 +00:00
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " D0 " ) , dnsAddress [ 0 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " D1 " ) , dnsAddress [ 1 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " D2 " ) , dnsAddress [ 2 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " D3 " ) , dnsAddress [ 3 ] ) ;
2024-01-20 23:30:15 +00:00
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " CM " ) , cmDNS ) ;
printSetFormIndex ( settingsScript , PSTR ( " AB " ) , apBehavior ) ;
printSetFormValue ( settingsScript , PSTR ( " AS " ) , apSSID ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " AH " ) , apHide ) ;
2019-08-17 10:27:06 +00:00
2018-07-21 21:21:07 +00:00
l = strlen ( apPass ) ;
2018-07-20 17:35:31 +00:00
char fapass [ l + 1 ] ; //fill password field with ***
fapass [ l ] = 0 ;
2019-08-17 10:27:06 +00:00
memset ( fapass , ' * ' , l ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " AP " ) , fapass ) ;
2019-08-17 10:27:06 +00:00
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " AC " ) , apChannel ) ;
2024-06-23 12:08:18 +00:00
# ifdef ARDUINO_ARCH_ESP32
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " TX " ) , txPower ) ;
2024-06-23 12:08:18 +00:00
# else
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " gId('tx').style.display='none'; " ) ) ;
2024-06-23 12:08:18 +00:00
# endif
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " FG " ) , force802_3g ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " WS " ) , noWifiSleep ) ;
2020-02-20 16:08:56 +00:00
2023-06-22 08:06:19 +00:00
# ifndef WLED_DISABLE_ESPNOW
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " RE " ) , enableESPNow ) ;
2025-05-19 18:34:27 +00:00
settingsScript . printf_P ( PSTR ( " rstR(); " ) ) ; // reset remote list
for ( size_t i = 0 ; i < linked_remotes . size ( ) ; i + + ) {
settingsScript . printf_P ( PSTR ( " aR( \" RM%u \" , \" %s \" ); " ) , i , linked_remotes [ i ] . data ( ) ) ; // add remote to list
}
settingsScript . print ( F ( " tE(); " ) ) ; // fill fields
2023-06-22 08:06:19 +00:00
# else
//hide remote settings if not compiled
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " toggle('ESPNOW'); " ) ) ; // hide ESP-NOW setting
2023-06-22 08:06:19 +00:00
# endif
2024-12-21 18:02:24 +00:00
# if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " ETH " ) , ethernetType ) ;
2021-01-15 09:37:45 +00:00
# else
//hide ethernet setting if not compiled in
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " gId('ethd').style.display='none'; " ) ) ;
2021-01-15 09:37:45 +00:00
# endif
2018-07-20 17:35:31 +00:00
2020-11-13 17:25:13 +00:00
if ( Network . isConnected ( ) ) //is connected
2018-02-20 21:29:48 +00:00
{
2020-11-13 17:25:13 +00:00
char s [ 32 ] ;
IPAddress localIP = Network . localIP ( ) ;
2018-07-21 21:21:07 +00:00
sprintf ( s , " %d.%d.%d.%d " , localIP [ 0 ] , localIP [ 1 ] , localIP [ 2 ] , localIP [ 3 ] ) ;
2020-11-13 17:25:13 +00:00
# if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
2024-10-23 23:58:52 +00:00
if ( Network . isEthernet ( ) ) strcat_P ( s , PSTR ( " (Ethernet) " ) ) ;
2020-11-13 17:25:13 +00:00
# endif
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 0 , s ) ;
2018-02-20 21:29:48 +00:00
} else
{
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 0 , ( char * ) F ( " Not connected " ) ) ;
2018-02-20 21:29:48 +00:00
}
2019-08-17 10:27:06 +00:00
2018-07-20 17:35:31 +00:00
if ( WiFi . softAPIP ( ) [ 0 ] ! = 0 ) //is active
2018-02-20 21:29:48 +00:00
{
2018-07-21 21:21:07 +00:00
char s [ 16 ] ;
IPAddress apIP = WiFi . softAPIP ( ) ;
sprintf ( s , " %d.%d.%d.%d " , apIP [ 0 ] , apIP [ 1 ] , apIP [ 2 ] , apIP [ 3 ] ) ;
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 1 , s ) ;
2018-02-20 21:29:48 +00:00
} else
{
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 1 , ( char * ) F ( " Not active " ) ) ;
2018-02-20 21:29:48 +00:00
}
2023-06-22 08:06:19 +00:00
# ifndef WLED_DISABLE_ESPNOW
2023-09-10 16:52:14 +00:00
if ( strlen ( last_signal_src ) > 0 ) { //Have seen an ESP-NOW Remote
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " rlid " ) , 0 , last_signal_src ) ;
2023-06-22 08:06:19 +00:00
}
# endif
2016-11-19 18:39:17 +00:00
}
2019-08-17 10:27:06 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_LEDS )
2021-09-30 14:30:44 +00:00
{
2024-09-18 23:19:40 +00:00
appendGPIOinfo ( settingsScript ) ;
2021-01-16 23:20:31 +00:00
2024-11-17 09:47:09 +00:00
settingsScript . printf_P ( PSTR ( " d.ledTypes=%s; " ) , BusManager : : getLEDTypesJSONString ( ) . c_str ( ) ) ;
2024-08-22 15:15:12 +00:00
2021-05-20 17:54:07 +00:00
// set limits
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " bLimits(%d,%d,%d,%d,%d,%d,%d,%d); " ) ,
2024-09-07 23:52:30 +00:00
WLED_MAX_BUSSES ,
2025-01-22 19:33:56 +00:00
WLED_MIN_VIRTUAL_BUSSES , // irrelevant, but kept to distinguish S2/S3 in UI
2024-09-07 23:52:30 +00:00
MAX_LEDS_PER_BUS ,
MAX_LED_MEMORY ,
MAX_LEDS ,
WLED_MAX_COLOR_ORDER_MAPPINGS ,
WLED_MAX_DIGITAL_CHANNELS ,
WLED_MAX_ANALOG_CHANNELS
) ;
2024-09-06 01:13:55 +00:00
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " MS " ) , strip . autoSegments ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " CCT " ) , strip . correctWB ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " IC " ) , cctICused ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " CR " ) , strip . cctFromRgb ) ;
2025-01-19 10:37:57 +00:00
printSetFormValue ( settingsScript , PSTR ( " CB " ) , Bus : : getCCTBlend ( ) ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " FR " ) , strip . getTargetFps ( ) ) ;
printSetFormValue ( settingsScript , PSTR ( " AW " ) , Bus : : getGlobalAWMode ( ) ) ;
2025-01-19 09:17:33 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " PR " ) , BusManager : : hasParallelOutput ( ) ) ; // get it from bus manager not global variable
2021-01-21 00:21:16 +00:00
2024-05-12 09:30:57 +00:00
unsigned sumMa = 0 ;
2025-04-22 20:37:18 +00:00
for ( size_t s = 0 ; s < BusManager : : getNumBusses ( ) ; s + + ) {
const Bus * bus = BusManager : : getBus ( s ) ;
2025-02-04 07:10:09 +00:00
if ( ! bus | | ! bus - > isOk ( ) ) break ; // should not happen but for safety
2025-04-23 13:06:31 +00:00
int offset = s < 10 ? ' 0 ' : ' A ' - 10 ;
2024-05-12 09:12:13 +00:00
char lp [ 4 ] = " L0 " ; lp [ 2 ] = offset + s ; lp [ 3 ] = 0 ; //ascii 0-9 //strip data pin
char lc [ 4 ] = " LC " ; lc [ 2 ] = offset + s ; lc [ 3 ] = 0 ; //strip length
char co [ 4 ] = " CO " ; co [ 2 ] = offset + s ; co [ 3 ] = 0 ; //strip color order
char lt [ 4 ] = " LT " ; lt [ 2 ] = offset + s ; lt [ 3 ] = 0 ; //strip type
char ls [ 4 ] = " LS " ; ls [ 2 ] = offset + s ; ls [ 3 ] = 0 ; //strip start LED
char cv [ 4 ] = " CV " ; cv [ 2 ] = offset + s ; cv [ 3 ] = 0 ; //strip reverse
char sl [ 4 ] = " SL " ; sl [ 2 ] = offset + s ; sl [ 3 ] = 0 ; //skip 1st LED
char rf [ 4 ] = " RF " ; rf [ 2 ] = offset + s ; rf [ 3 ] = 0 ; //off refresh
char aw [ 4 ] = " AW " ; aw [ 2 ] = offset + s ; aw [ 3 ] = 0 ; //auto white mode
char wo [ 4 ] = " WO " ; wo [ 2 ] = offset + s ; wo [ 3 ] = 0 ; //swap channels
char sp [ 4 ] = " SP " ; sp [ 2 ] = offset + s ; sp [ 3 ] = 0 ; //bus clock speed
char la [ 4 ] = " LA " ; la [ 2 ] = offset + s ; la [ 3 ] = 0 ; //LED current
char ma [ 4 ] = " MA " ; ma [ 2 ] = offset + s ; ma [ 3 ] = 0 ; //max per-port PSU current
2025-06-28 04:57:53 +00:00
char hs [ 4 ] = " HS " ; hs [ 2 ] = offset + s ; hs [ 3 ] = 0 ; //hostname (for network types, custom text for others)
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " addLEDs(1); " ) ) ;
2021-01-21 00:21:16 +00:00
uint8_t pins [ 5 ] ;
2024-05-12 09:30:57 +00:00
int nPins = bus - > getPins ( pins ) ;
for ( int i = 0 ; i < nPins ; i + + ) {
2025-01-19 20:30:17 +00:00
lp [ 1 ] = ' 0 ' + i ;
2024-09-24 19:43:47 +00:00
if ( PinManager : : isPinOk ( pins [ i ] ) | | bus - > isVirtual ( ) ) printSetFormValue ( settingsScript , lp , pins [ i ] ) ;
2021-02-24 13:49:39 +00:00
}
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , lc , bus - > getLength ( ) ) ;
printSetFormValue ( settingsScript , lt , bus - > getType ( ) ) ;
printSetFormValue ( settingsScript , co , bus - > getColorOrder ( ) & 0x0F ) ;
printSetFormValue ( settingsScript , ls , bus - > getStart ( ) ) ;
printSetFormCheckbox ( settingsScript , cv , bus - > isReversed ( ) ) ;
printSetFormValue ( settingsScript , sl , bus - > skippedLeds ( ) ) ;
printSetFormCheckbox ( settingsScript , rf , bus - > isOffRefreshRequired ( ) ) ;
printSetFormValue ( settingsScript , aw , bus - > getAutoWhiteMode ( ) ) ;
printSetFormValue ( settingsScript , wo , bus - > getColorOrder ( ) > > 4 ) ;
2024-05-12 09:30:57 +00:00
unsigned speed = bus - > getFrequency ( ) ;
2024-08-24 09:35:32 +00:00
if ( bus - > isPWM ( ) ) {
2023-04-27 22:27:19 +00:00
switch ( speed ) {
2024-03-08 17:11:40 +00:00
case WLED_PWM_FREQ / 2 : speed = 0 ; break ;
case WLED_PWM_FREQ * 2 / 3 : speed = 1 ; break ;
2023-04-27 22:27:19 +00:00
default :
2024-03-08 17:11:40 +00:00
case WLED_PWM_FREQ : speed = 2 ; break ;
case WLED_PWM_FREQ * 2 : speed = 3 ; break ;
case WLED_PWM_FREQ * 10 / 3 : speed = 4 ; break ; // uint16_t max (19531 * 3.333)
2023-04-27 22:27:19 +00:00
}
2024-08-24 09:35:32 +00:00
} else if ( bus - > is2Pin ( ) ) {
2023-04-27 22:27:19 +00:00
switch ( speed ) {
case 1000 : speed = 0 ; break ;
case 2000 : speed = 1 ; break ;
default :
case 5000 : speed = 2 ; break ;
case 10000 : speed = 3 ; break ;
case 20000 : speed = 4 ; break ;
}
}
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , sp , speed ) ;
printSetFormValue ( settingsScript , la , bus - > getLEDCurrent ( ) ) ;
printSetFormValue ( settingsScript , ma , bus - > getMaxCurrent ( ) ) ;
2025-06-28 04:57:53 +00:00
printSetFormValue ( settingsScript , hs , bus - > getCustomText ( ) . c_str ( ) ) ;
2023-11-15 18:37:07 +00:00
sumMa + = bus - > getMaxCurrent ( ) ;
2021-01-16 23:20:31 +00:00
}
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " MA " ) , BusManager : : ablMilliampsMax ( ) ? BusManager : : ablMilliampsMax ( ) : sumMa ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " ABL " ) , BusManager : : ablMilliampsMax ( ) | | sumMa > 0 ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " PPL " ) , ! BusManager : : ablMilliampsMax ( ) & & sumMa > 0 ) ;
2023-12-29 22:07:29 +00:00
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " resetCOM(%d); " ) , WLED_MAX_COLOR_ORDER_MAPPINGS ) ;
2023-12-29 22:07:29 +00:00
const ColorOrderMap & com = BusManager : : getColorOrderMap ( ) ;
2024-05-12 09:12:13 +00:00
for ( int s = 0 ; s < com . count ( ) ; s + + ) {
2022-01-25 23:42:04 +00:00
const ColorOrderMapEntry * entry = com . get ( s ) ;
2025-01-21 16:50:36 +00:00
if ( ! entry | | ! entry - > len ) break ;
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " addCOM(%d,%d,%d); " ) , entry - > start , entry - > len , entry - > colorOrder ) ;
2022-01-25 23:42:04 +00:00
}
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " CA " ) , briS ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " BO " ) , turnOnAtBoot ) ;
printSetFormValue ( settingsScript , PSTR ( " BP " ) , bootPreset ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " GB " ) , gammaCorrectBri ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " GC " ) , gammaCorrectCol ) ;
dtostrf ( gammaCorrectVal , 3 , 1 , nS ) ; printSetFormValue ( settingsScript , PSTR ( " GV " ) , nS ) ;
printSetFormValue ( settingsScript , PSTR ( " TD " ) , transitionDelayDefault ) ;
printSetFormValue ( settingsScript , PSTR ( " TP " ) , randomPaletteChangeTime ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " TH " ) , useHarmonicRandomPalette ) ;
printSetFormValue ( settingsScript , PSTR ( " BF " ) , briMultiplier ) ;
printSetFormValue ( settingsScript , PSTR ( " TB " ) , nightlightTargetBri ) ;
printSetFormValue ( settingsScript , PSTR ( " TL " ) , nightlightDelayMinsDefault ) ;
printSetFormValue ( settingsScript , PSTR ( " TW " ) , nightlightMode ) ;
2025-04-22 20:37:18 +00:00
printSetFormIndex ( settingsScript , PSTR ( " PB " ) , paletteBlend ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RW " ) , useRainbowWheel ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " RL " ) , rlyPin ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RM " ) , rlyMde ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RO " ) , rlyOpenDrain ) ;
2024-05-12 09:12:13 +00:00
for ( int i = 0 ; i < WLED_MAX_BUTTONS ; i + + ) {
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " addBtn(%d,%d,%d); " ) , i , btnPin [ i ] , buttonType [ i ] ) ;
2021-05-20 17:54:07 +00:00
}
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " IP " ) , disablePullUp ) ;
printSetFormValue ( settingsScript , PSTR ( " TT " ) , touchThreshold ) ;
2024-03-17 19:11:08 +00:00
# ifndef WLED_DISABLE_INFRARED
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " IR " ) , irPin ) ;
printSetFormValue ( settingsScript , PSTR ( " IT " ) , irEnabled ) ;
2024-03-17 19:11:08 +00:00
# endif
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " MSO " ) , ! irApplyToAllSelected ) ;
2016-12-28 23:03:58 +00:00
}
2017-11-19 23:07:37 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_UI )
2019-08-17 10:27:06 +00:00
{
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " DS " ) , serverDescription ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SU " ) , simplifiedUI ) ;
2017-11-19 23:07:37 +00:00
}
2018-02-20 21:29:48 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_SYNC )
2016-11-19 18:39:17 +00:00
{
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " UP " ) , udpPort ) ;
printSetFormValue ( settingsScript , PSTR ( " U2 " ) , udpPort2 ) ;
2023-09-10 16:52:14 +00:00
# ifndef WLED_DISABLE_ESPNOW
2024-09-18 23:19:40 +00:00
if ( enableESPNow ) printSetFormCheckbox ( settingsScript , PSTR ( " EN " ) , useESPNowSync ) ;
else settingsScript . print ( F ( " toggle('ESPNOW'); " ) ) ; // hide ESP-NOW setting
2023-09-10 16:52:14 +00:00
# else
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " toggle('ESPNOW'); " ) ) ; // hide ESP-NOW setting
2023-09-10 16:52:14 +00:00
# endif
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " GS " ) , syncGroups ) ;
printSetFormValue ( settingsScript , PSTR ( " GR " ) , receiveGroups ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RB " ) , receiveNotificationBrightness ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RC " ) , receiveNotificationColor ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RX " ) , receiveNotificationEffects ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RP " ) , receiveNotificationPalette ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SO " ) , receiveSegmentOptions ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SG " ) , receiveSegmentBounds ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SS " ) , sendNotifications ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SD " ) , notifyDirect ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SB " ) , notifyButton ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SH " ) , notifyHue ) ;
printSetFormValue ( settingsScript , PSTR ( " UR " ) , udpNumRetries ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " NL " ) , nodeListEnabled ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " NB " ) , nodeBroadcastEnabled ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RD " ) , receiveDirect ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " MO " ) , useMainSegmentOnly ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RLM " ) , realtimeRespectLedMaps ) ;
printSetFormValue ( settingsScript , PSTR ( " EP " ) , e131Port ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " ES " ) , e131SkipOutOfSequence ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " EM " ) , e131Multicast ) ;
printSetFormValue ( settingsScript , PSTR ( " EU " ) , e131Universe ) ;
2025-01-16 12:19:25 +00:00
# ifdef WLED_ENABLE_DMX
2023-08-14 11:58:22 +00:00
settingsScript . print ( SET_F ( " hideNoDMX(); " ) ) ; // hide "not compiled in" message
2023-08-14 11:28:34 +00:00
# endif
# ifndef WLED_ENABLE_DMX_INPUT
2023-08-14 11:58:22 +00:00
settingsScript . print ( SET_F ( " hideDMXInput(); " ) ) ; // hide "dmx input" settings
2023-08-14 11:28:34 +00:00
# else
2025-01-16 12:48:36 +00:00
settingsScript . print ( SET_F ( " hideNoDMXInput(); " ) ) ; //hide "not compiled in" message
printSetFormValue ( settingsScript , SET_F ( " IDMT " ) , dmxInputTransmitPin ) ;
printSetFormValue ( settingsScript , SET_F ( " IDMR " ) , dmxInputReceivePin ) ;
printSetFormValue ( settingsScript , SET_F ( " IDME " ) , dmxInputEnablePin ) ;
printSetFormValue ( settingsScript , SET_F ( " IDMP " ) , dmxInputPort ) ;
2023-08-14 11:28:34 +00:00
# endif
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " DA " ) , DMXAddress ) ;
printSetFormValue ( settingsScript , PSTR ( " XX " ) , DMXSegmentSpacing ) ;
printSetFormValue ( settingsScript , PSTR ( " PY " ) , e131Priority ) ;
printSetFormValue ( settingsScript , PSTR ( " DM " ) , DMXMode ) ;
printSetFormValue ( settingsScript , PSTR ( " ET " ) , realtimeTimeoutMs ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " FB " ) , arlsForceMaxBri ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RG " ) , arlsDisableGammaCorrection ) ;
printSetFormValue ( settingsScript , PSTR ( " WO " ) , arlsOffset ) ;
2024-08-17 13:09:41 +00:00
# ifndef WLED_DISABLE_ALEXA
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " AL " ) , alexaEnabled ) ;
printSetFormValue ( settingsScript , PSTR ( " AI " ) , alexaInvocationName ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " SA " ) , notifyAlexa ) ;
printSetFormValue ( settingsScript , PSTR ( " AP " ) , alexaNumPresets ) ;
2024-08-17 18:42:44 +00:00
# else
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " toggle('Alexa'); " ) ) ; // hide Alexa settings
2022-11-11 19:20:11 +00:00
# endif
2019-12-10 23:59:15 +00:00
2024-08-15 14:18:34 +00:00
# ifndef WLED_DISABLE_MQTT
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " MQ " ) , mqttEnabled ) ;
printSetFormValue ( settingsScript , PSTR ( " MS " ) , mqttServer ) ;
printSetFormValue ( settingsScript , PSTR ( " MQPORT " ) , mqttPort ) ;
printSetFormValue ( settingsScript , PSTR ( " MQUSER " ) , mqttUser ) ;
2019-08-18 16:14:17 +00:00
byte l = strlen ( mqttPass ) ;
char fpass [ l + 1 ] ; //fill password field with ***
fpass [ l ] = 0 ;
memset ( fpass , ' * ' , l ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " MQPASS " ) , fpass ) ;
printSetFormValue ( settingsScript , PSTR ( " MQCID " ) , mqttClientID ) ;
printSetFormValue ( settingsScript , PSTR ( " MD " ) , mqttDeviceTopic ) ;
printSetFormValue ( settingsScript , PSTR ( " MG " ) , mqttGroupTopic ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " BM " ) , buttonPublishMqtt ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " RT " ) , retainMqttMsg ) ;
2024-11-21 11:04:01 +00:00
settingsScript . printf_P ( PSTR ( " d.Sf.MD.maxLength=%d;d.Sf.MG.maxLength=%d;d.Sf.MS.maxLength=%d; " ) ,
2024-11-21 11:02:55 +00:00
MQTT_MAX_TOPIC_LEN , MQTT_MAX_TOPIC_LEN , MQTT_MAX_SERVER_LEN ) ;
2022-11-11 19:20:11 +00:00
# else
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " toggle('MQTT'); " ) ) ; // hide MQTT settings
2019-12-10 23:59:15 +00:00
# endif
2020-02-25 01:19:12 +00:00
# ifndef WLED_DISABLE_HUESYNC
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " H0 " ) , hueIP [ 0 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " H1 " ) , hueIP [ 1 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " H2 " ) , hueIP [ 2 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " H3 " ) , hueIP [ 3 ] ) ;
printSetFormValue ( settingsScript , PSTR ( " HL " ) , huePollLightId ) ;
printSetFormValue ( settingsScript , PSTR ( " HI " ) , huePollIntervalMs ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " HP " ) , huePollingEnabled ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " HO " ) , hueApplyOnOff ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " HB " ) , hueApplyBri ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " HC " ) , hueApplyColor ) ;
2020-02-25 01:19:12 +00:00
char hueErrorString [ 25 ] ;
switch ( hueError )
{
2022-09-10 17:27:00 +00:00
case HUE_ERROR_INACTIVE : strcpy_P ( hueErrorString , PSTR ( " Inactive " ) ) ; break ;
case HUE_ERROR_ACTIVE : strcpy_P ( hueErrorString , PSTR ( " Active " ) ) ; break ;
case HUE_ERROR_UNAUTHORIZED : strcpy_P ( hueErrorString , PSTR ( " Unauthorized " ) ) ; break ;
case HUE_ERROR_LIGHTID : strcpy_P ( hueErrorString , PSTR ( " Invalid light ID " ) ) ; break ;
case HUE_ERROR_PUSHLINK : strcpy_P ( hueErrorString , PSTR ( " Link button not pressed " ) ) ; break ;
case HUE_ERROR_JSON_PARSING : strcpy_P ( hueErrorString , PSTR ( " JSON parsing error " ) ) ; break ;
case HUE_ERROR_TIMEOUT : strcpy_P ( hueErrorString , PSTR ( " Timeout " ) ) ; break ;
default : sprintf_P ( hueErrorString , PSTR ( " Bridge Error %i " ) , hueError ) ;
2020-02-25 01:19:12 +00:00
}
2023-01-06 08:24:29 +00:00
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 0 , hueErrorString ) ;
2022-11-11 19:20:11 +00:00
# else
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " toggle('Hue'); " ) ) ; // hide Hue Sync settings
2019-12-10 23:59:15 +00:00
# endif
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " BD " ) , serialBaud ) ;
2024-09-17 14:21:52 +00:00
# ifndef WLED_ENABLE_ADALIGHT
2024-10-27 17:47:10 +00:00
settingsScript . print ( F ( " toggle('Serial'); " ) ) ;
2024-09-17 14:21:52 +00:00
# endif
2016-11-19 18:39:17 +00:00
}
2018-02-20 21:29:48 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_TIME )
2016-11-19 18:39:17 +00:00
{
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " NT " ) , ntpEnabled ) ;
printSetFormValue ( settingsScript , PSTR ( " NS " ) , ntpServerName ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " CF " ) , ! useAMPM ) ;
printSetFormIndex ( settingsScript , PSTR ( " TZ " ) , currentTimezone ) ;
printSetFormValue ( settingsScript , PSTR ( " UO " ) , utcOffsetSecs ) ;
2019-03-16 01:09:37 +00:00
char tm [ 32 ] ;
2021-04-12 19:53:22 +00:00
dtostrf ( longitude , 4 , 2 , tm ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " LN " ) , tm ) ;
2021-04-12 19:53:22 +00:00
dtostrf ( latitude , 4 , 2 , tm ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " LT " ) , tm ) ;
2019-08-17 10:27:06 +00:00
getTimeString ( tm ) ;
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " times " ) , 0 , tm ) ;
2023-09-09 18:48:17 +00:00
if ( ( int ) ( longitude * 10.0f ) | | ( int ) ( latitude * 10.0f ) ) {
2021-04-12 19:53:22 +00:00
sprintf_P ( tm , PSTR ( " Sunrise: %02d:%02d Sunset: %02d:%02d " ) , hour ( sunrise ) , minute ( sunrise ) , hour ( sunset ) , minute ( sunset ) ) ;
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " times " ) , 1 , tm ) ;
2021-04-12 19:53:22 +00:00
}
2024-09-18 23:19:40 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " OL " ) , overlayCurrent ) ;
printSetFormValue ( settingsScript , PSTR ( " O1 " ) , overlayMin ) ;
printSetFormValue ( settingsScript , PSTR ( " O2 " ) , overlayMax ) ;
printSetFormValue ( settingsScript , PSTR ( " OM " ) , analogClock12pixel ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " OS " ) , analogClockSecondsTrail ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " O5 " ) , analogClock5MinuteMarks ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " OB " ) , analogClockSolidBlack ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " CE " ) , countdownMode ) ;
printSetFormValue ( settingsScript , PSTR ( " CY " ) , countdownYear ) ;
printSetFormValue ( settingsScript , PSTR ( " CI " ) , countdownMonth ) ;
printSetFormValue ( settingsScript , PSTR ( " CD " ) , countdownDay ) ;
printSetFormValue ( settingsScript , PSTR ( " CH " ) , countdownHour ) ;
printSetFormValue ( settingsScript , PSTR ( " CM " ) , countdownMin ) ;
printSetFormValue ( settingsScript , PSTR ( " CS " ) , countdownSec ) ;
printSetFormValue ( settingsScript , PSTR ( " A0 " ) , macroAlexaOn ) ;
printSetFormValue ( settingsScript , PSTR ( " A1 " ) , macroAlexaOff ) ;
printSetFormValue ( settingsScript , PSTR ( " MC " ) , macroCountdown ) ;
printSetFormValue ( settingsScript , PSTR ( " MN " ) , macroNl ) ;
2024-07-11 19:22:58 +00:00
for ( unsigned i = 0 ; i < WLED_MAX_BUTTONS ; i + + ) {
2024-09-18 23:19:40 +00:00
settingsScript . printf_P ( PSTR ( " addRow(%d,%d,%d,%d); " ) , i , macroButton [ i ] , macroLongPress [ i ] , macroDoublePress [ i ] ) ;
2021-05-20 17:54:07 +00:00
}
2018-09-22 20:49:24 +00:00
2020-11-06 21:12:48 +00:00
char k [ 4 ] ;
2018-09-22 20:49:24 +00:00
k [ 2 ] = 0 ; //Time macros
2021-04-12 19:53:22 +00:00
for ( int i = 0 ; i < 10 ; i + + )
2018-09-22 20:49:24 +00:00
{
k [ 1 ] = 48 + i ; //ascii 0,1,2,3
2024-09-18 23:19:40 +00:00
if ( i < 8 ) { k [ 0 ] = ' H ' ; printSetFormValue ( settingsScript , k , timerHours [ i ] ) ; }
k [ 0 ] = ' N ' ; printSetFormValue ( settingsScript , k , timerMinutes [ i ] ) ;
k [ 0 ] = ' T ' ; printSetFormValue ( settingsScript , k , timerMacro [ i ] ) ;
k [ 0 ] = ' W ' ; printSetFormValue ( settingsScript , k , timerWeekday [ i ] ) ;
2021-12-31 13:09:48 +00:00
if ( i < 8 ) {
2024-09-18 23:19:40 +00:00
k [ 0 ] = ' M ' ; printSetFormValue ( settingsScript , k , ( timerMonth [ i ] > > 4 ) & 0x0F ) ;
k [ 0 ] = ' P ' ; printSetFormValue ( settingsScript , k , timerMonth [ i ] & 0x0F ) ;
k [ 0 ] = ' D ' ; printSetFormValue ( settingsScript , k , timerDay [ i ] ) ;
k [ 0 ] = ' E ' ; printSetFormValue ( settingsScript , k , timerDayEnd [ i ] ) ;
2021-12-31 13:09:48 +00:00
}
2018-09-22 20:49:24 +00:00
}
2018-02-20 21:29:48 +00:00
}
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_SEC )
2016-11-19 18:39:17 +00:00
{
2022-04-27 10:31:47 +00:00
byte l = strlen ( settingsPIN ) ;
char fpass [ l + 1 ] ; //fill PIN field with 0000
fpass [ l ] = 0 ;
memset ( fpass , ' 0 ' , l ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " PIN " ) , fpass ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " NO " ) , otaLock ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " OW " ) , wifiLock ) ;
printSetFormCheckbox ( settingsScript , PSTR ( " AO " ) , aOtaEnabled ) ;
2025-05-26 16:00:45 +00:00
printSetFormCheckbox ( settingsScript , PSTR ( " SU " ) , otaSameSubnet ) ;
2024-09-06 01:13:55 +00:00
char tmp_buf [ 128 ] ;
snprintf_P ( tmp_buf , sizeof ( tmp_buf ) , PSTR ( " WLED %s (build %d) " ) , versionString , VERSION ) ;
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 0 , tmp_buf ) ;
settingsScript . printf_P ( PSTR ( " sd= \" %s \" ; " ) , serverDescription ) ;
2025-04-20 09:44:26 +00:00
//hide settings if not compiled
2025-06-26 09:36:39 +00:00
# ifdef WLED_DISABLE_OTA
settingsScript . print ( F ( " toggle('OTA'); " ) ) ; // hide update section
# endif
# ifndef WLED_ENABLE_AOTA
2025-04-20 09:44:26 +00:00
settingsScript . print ( F ( " toggle('aOTA'); " ) ) ; // hide ArduinoOTA checkbox
# endif
2016-11-19 18:39:17 +00:00
}
2023-01-06 08:24:29 +00:00
2025-01-16 12:19:25 +00:00
# ifdef WLED_ENABLE_DMX // include only if DMX is enabled
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_DMX )
2020-02-23 21:24:51 +00:00
{
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " PU " ) , e131ProxyUniverse ) ;
printSetFormValue ( settingsScript , PSTR ( " CN " ) , DMXChannels ) ;
printSetFormValue ( settingsScript , PSTR ( " CG " ) , DMXGap ) ;
printSetFormValue ( settingsScript , PSTR ( " CS " ) , DMXStart ) ;
printSetFormValue ( settingsScript , PSTR ( " SL " ) , DMXStartLED ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH1 " ) , DMXFixtureMap [ 0 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH2 " ) , DMXFixtureMap [ 1 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH3 " ) , DMXFixtureMap [ 2 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH4 " ) , DMXFixtureMap [ 3 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH5 " ) , DMXFixtureMap [ 4 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH6 " ) , DMXFixtureMap [ 5 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH7 " ) , DMXFixtureMap [ 6 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH8 " ) , DMXFixtureMap [ 7 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH9 " ) , DMXFixtureMap [ 8 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH10 " ) , DMXFixtureMap [ 9 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH11 " ) , DMXFixtureMap [ 10 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH12 " ) , DMXFixtureMap [ 11 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH13 " ) , DMXFixtureMap [ 12 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH14 " ) , DMXFixtureMap [ 13 ] ) ;
printSetFormIndex ( settingsScript , PSTR ( " CH15 " ) , DMXFixtureMap [ 14 ] ) ;
2021-05-11 21:21:57 +00:00
}
2020-02-23 21:24:51 +00:00
# endif
2021-05-11 21:21:57 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_UM ) //usermods
2021-05-11 21:21:57 +00:00
{
2024-09-18 23:19:40 +00:00
appendGPIOinfo ( settingsScript ) ;
2024-09-24 19:43:47 +00:00
settingsScript . printf_P ( PSTR ( " numM=%d; " ) , UsermodManager : : getModCount ( ) ) ;
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " SDA " ) , i2c_sda ) ;
printSetFormValue ( settingsScript , PSTR ( " SCL " ) , i2c_scl ) ;
printSetFormValue ( settingsScript , PSTR ( " MOSI " ) , spi_mosi ) ;
printSetFormValue ( settingsScript , PSTR ( " MISO " ) , spi_miso ) ;
printSetFormValue ( settingsScript , PSTR ( " SCLK " ) , spi_sclk ) ;
settingsScript . printf_P ( PSTR ( " addInfo('SDA','%d'); "
2024-09-07 23:52:30 +00:00
" addInfo('SCL','%d'); "
" addInfo('MOSI','%d'); "
" addInfo('MISO','%d'); "
" addInfo('SCLK','%d'); " ) ,
HW_PIN_SDA , HW_PIN_SCL , HW_PIN_DATASPI , HW_PIN_MISOSPI , HW_PIN_CLOCKSPI
) ;
2024-09-24 19:43:47 +00:00
UsermodManager : : appendConfigData ( settingsScript ) ;
2021-05-11 21:21:57 +00:00
}
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_UPDATE ) // update
2022-03-07 08:44:35 +00:00
{
2024-09-06 01:13:55 +00:00
char tmp_buf [ 128 ] ;
snprintf_P ( tmp_buf , sizeof ( tmp_buf ) , PSTR ( " WLED %s<br>%s<br>(%s build %d) " ) ,
versionString ,
releaseString ,
2022-11-09 19:09:01 +00:00
# if defined(ARDUINO_ARCH_ESP32)
2024-09-06 01:13:55 +00:00
ESP . getChipModel ( ) ,
2022-03-07 08:44:35 +00:00
# else
2024-11-15 18:03:46 +00:00
" esp8266 " ,
2022-03-07 08:44:35 +00:00
# endif
2024-09-06 01:13:55 +00:00
VERSION ) ;
2024-09-18 23:19:40 +00:00
printSetClassElementHTML ( settingsScript , PSTR ( " sip " ) , 0 , tmp_buf ) ;
2025-05-26 16:19:20 +00:00
# ifndef ARDUINO_ARCH_ESP32
settingsScript . print ( F ( " toggle('rev'); " ) ) ; // hide revert button on ESP8266
# endif
2022-03-07 08:44:35 +00:00
}
2022-05-08 08:50:48 +00:00
2023-06-15 21:58:22 +00:00
if ( subPage = = SUBPAGE_2D ) // 2D matrices
2022-05-08 08:50:48 +00:00
{
2024-09-18 23:19:40 +00:00
printSetFormValue ( settingsScript , PSTR ( " SOMP " ) , strip . isMatrix ) ;
2022-07-10 20:23:25 +00:00
# ifndef WLED_DISABLE_2D
2024-11-17 09:47:09 +00:00
settingsScript . printf_P ( PSTR ( " maxPanels=%d;resetPanels(); " ) , WLED_MAX_PANELS ) ;
2022-05-08 08:50:48 +00:00
if ( strip . isMatrix ) {
2025-04-22 20:37:18 +00:00
printSetFormValue ( settingsScript , PSTR ( " PW " ) , strip . panel . size ( ) > 0 ? strip . panel [ 0 ] . width : 8 ) ; //Set generator Width and Height to first panel size for convenience
printSetFormValue ( settingsScript , PSTR ( " PH " ) , strip . panel . size ( ) > 0 ? strip . panel [ 0 ] . height : 8 ) ;
printSetFormValue ( settingsScript , PSTR ( " MPC " ) , strip . panel . size ( ) ) ;
2022-05-08 08:50:48 +00:00
// panels
2025-04-22 20:37:18 +00:00
for ( unsigned i = 0 ; i < strip . panel . size ( ) ; i + + ) {
2024-11-17 13:31:23 +00:00
settingsScript . printf_P ( PSTR ( " addPanel(%d); " ) , i ) ;
2023-01-03 13:17:42 +00:00
char pO [ 8 ] = { ' \0 ' } ;
2025-04-22 20:37:18 +00:00
snprintf_P ( pO , 7 , PSTR ( " P%d " ) , i ) ; // WLED_WLED_MAX_PANELS is less than 100 so pO will always only be 4 characters or less
2023-01-03 13:17:42 +00:00
pO [ 7 ] = ' \0 ' ;
2024-07-11 19:22:58 +00:00
unsigned l = strlen ( pO ) ;
2023-01-03 14:16:45 +00:00
// create P0B, P1B, ..., P63B, etc for other PxxX
2024-09-18 23:19:40 +00:00
pO [ l ] = ' B ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . bottomStart ) ;
pO [ l ] = ' R ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . rightStart ) ;
pO [ l ] = ' V ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . vertical ) ;
pO [ l ] = ' S ' ; printSetFormCheckbox ( settingsScript , pO , strip . panel [ i ] . serpentine ) ;
pO [ l ] = ' X ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . xOffset ) ;
pO [ l ] = ' Y ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . yOffset ) ;
pO [ l ] = ' W ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . width ) ;
pO [ l ] = ' H ' ; printSetFormValue ( settingsScript , pO , strip . panel [ i ] . height ) ;
2022-05-08 08:50:48 +00:00
}
}
2022-07-10 20:23:25 +00:00
# else
2024-09-18 23:19:40 +00:00
settingsScript . print ( F ( " gId( \" somp \" ).remove(1); " ) ) ; // remove 2D option from dropdown
2022-07-10 20:23:25 +00:00
# endif
2022-05-08 08:50:48 +00:00
}
2016-11-19 18:39:17 +00:00
}