2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  "wled.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Methods  to  handle  saving  and  loading  presets  to / from  the  filesystem 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef ARDUINO_ARCH_ESP32 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  char  * tmpRAMbuffer  =  nullptr ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  volatile  byte  presetToApply  =  0 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  volatile  byte  callModeToApply  =  0 ;  
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  volatile  byte  presetToSave  =  0 ;  
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  volatile  int8_t  saveLedmap  =  - 1 ;  
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  char  * quickLoad  =  nullptr ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  char  * saveName  =  nullptr ;  
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  bool  includeBri  =  true ,  segBounds  =  true ,  selectedOnly  =  false ,  playlistSave  =  false ; ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 16:08:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  const  char  presets_json [ ]  PROGMEM  =  " /presets.json " ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  const  char  tmp_json [ ]  PROGMEM  =  " /tmp.json " ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  char  * getPresetsFileName ( bool  persistent )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  persistent  ?  presets_json  :  tmp_json ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  void  doSaveState ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  bool  persist  =  ( presetToSave  <  251 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-22 14:39:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  unsigned  long  start  =  millis ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-25 11:27:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  while  ( strip . isUpdating ( )  & &  millis ( ) - start  <  ( 2 * FRAMETIME_FIXED ) + 1 )  yield ( ) ;  // wait 2 frames
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( ! requestJSONBufferLock ( 10 ) )  return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  initPresetsFile ( ) ;  // just in case if someone deleted presets.json using /edit
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-21 20:30:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  JsonObject  sObj  =  pDoc - > to < JsonObject > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  DEBUG_PRINTLN ( F ( " Serialize current state " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( playlistSave )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    serializePlaylist ( sObj ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( includeBri )  sObj [ " on " ]  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    serializeState ( sObj ,  true ,  includeBri ,  segBounds ,  selectedOnly ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( saveName )  sObj [ " n " ]  =  saveName ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  else           sObj [ " n " ]  =  F ( " Unkonwn preset " ) ;  // should not happen, but just in case...
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( quickLoad  & &  quickLoad [ 0 ] )  sObj [ F ( " ql " ) ]  =  quickLoad ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( saveLedmap  > =  0 )  sObj [ F ( " ledmap " ) ]  =  saveLedmap ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 10:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # ifdef WLED_DEBUG 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    DEBUG_PRINTLN ( F ( " Serialized preset " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-21 20:30:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    serializeJson ( * pDoc , Serial ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    DEBUG_PRINTLN ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 10:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*/  
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # if defined(ARDUINO_ARCH_ESP32) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ! persist )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( tmpRAMbuffer ! = nullptr )  free ( tmpRAMbuffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    size_t  len  =  measureJson ( * pDoc )  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    DEBUG_PRINTLN ( len ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // if possible use SPI RAM on ESP32
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 15:03:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( psramSafe  & &  psramFound ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      tmpRAMbuffer  =  ( char * )  ps_malloc ( len ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      tmpRAMbuffer  =  ( char * )  malloc ( len ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( tmpRAMbuffer ! = nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      serializeJson ( * pDoc ,  tmpRAMbuffer ,  len ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      writeObjectToFileUsingId ( getPresetsFileName ( persist ) ,  presetToSave ,  pDoc ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  writeObjectToFileUsingId ( getPresetsFileName ( persist ) ,  presetToSave ,  pDoc ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( persist )  presetsModifiedTime  =  toki . second ( ) ;  //unix time
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  releaseJSONBufferLock ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  updateFSInfo ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  // clean up
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  saveLedmap    =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetToSave  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  delete [ ]  saveName ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  delete [ ]  quickLoad ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  saveName  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  quickLoad  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  playlistSave  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-06 08:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  getPresetName ( byte  index ,  String &  name )  
						 
					
						
							
								
									
										
										
										
											2022-10-25 21:42:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-02-17 10:30:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( ! requestJSONBufferLock ( 19 ) )  return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-25 21:42:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  bool  presetExists  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( readObjectFromFileUsingId ( getPresetsFileName ( ) ,  index ,  pDoc ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-21 20:30:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    JsonObject  fdo  =  pDoc - > as < JsonObject > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-25 21:42:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( fdo [ " n " ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      name  =  ( const  char * ) ( fdo [ " n " ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      presetExists  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  releaseJSONBufferLock ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  presetExists ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  initPresetsFile ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  char  fileName [ 33 ] ;  strncpy_P ( fileName ,  getPresetsFileName ( ) ,  32 ) ;  fileName [ 32 ]  =  0 ;  //use PROGMEM safe copy as FS.open() does not
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( WLED_FS . exists ( fileName ) )  return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  StaticJsonDocument < 64 >  doc ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  JsonObject  sObj  =  doc . to < JsonObject > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  sObj . createNestedObject ( " 0 " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  File  f  =  WLED_FS . open ( fileName ,  " w " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( ! f )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    errorFlag  =  ERR_FS_GENERAL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  serializeJson ( doc ,  f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  f . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-22 19:49:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  applyPresetFromPlaylist ( byte  index )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-09-10 13:20:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  DEBUG_PRINTF_P ( PSTR ( " Request to apply preset: %d \n " ) ,  index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 08:43:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetToApply  =  index ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-22 19:49:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  callModeToApply  =  CALL_MODE_DIRECT_CHANGE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 19:17:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  applyPreset ( byte  index ,  byte  callMode )  
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-03-18 19:01:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  unloadPlaylist ( ) ;  // applying a preset unloads the playlist (#3827)
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-10 13:20:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  DEBUG_PRINTF_P ( PSTR ( " Request to apply preset: %u \n " ) ,  index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 08:43:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetToApply  =  index ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  callModeToApply  =  callMode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-22 08:06:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// apply preset or fallback to a effect and palette if it doesn't exist
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  applyPresetWithFallback ( uint8_t  index ,  uint8_t  callMode ,  uint8_t  effectID ,  uint8_t  paletteID )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  applyPreset ( index ,  callMode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  //these two will be overwritten if preset exists in handlePresets()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  effectCurrent  =  effectID ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  effectPalette  =  paletteID ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 19:17:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  handlePresets ( )  
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-10-19 16:43:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  byte  presetErrFlag  =  ERR_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( presetToSave )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-22 14:39:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    strip . suspend ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    doSaveState ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-22 14:39:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    strip . resume ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( presetToApply  = =  0  | |  ! requestJSONBufferLock ( 9 ) )  return ;  // no preset waiting to apply, or JSON buffer is already allocated, return to loop until free
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-13 13:27:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-24 17:30:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  bool  changePreset  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  uint8_t  tmpPreset  =  presetToApply ;  // store temporary since deserializeState() may call applyPreset()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  uint8_t  tmpMode    =  callModeToApply ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-24 17:30:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  JsonObject  fdo ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetToApply  =  0 ;  //clear request for preset
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  callModeToApply  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-10 13:20:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  DEBUG_PRINTF_P ( PSTR ( " Applying preset: %u \n " ) ,  ( unsigned ) tmpPreset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # ifdef ARDUINO_ARCH_ESP32 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( tmpPreset = = 255  & &  tmpRAMbuffer ! = nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    deserializeJson ( * pDoc , tmpRAMbuffer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 16:43:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetErrFlag  =  readObjectFromFileUsingId ( getPresetsFileName ( tmpPreset  <  255 ) ,  tmpPreset ,  pDoc )  ?  ERR_NONE  :  ERR_FS_PLOAD ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  fdo  =  pDoc - > as < JsonObject > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 16:43:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // only reset errorflag if previous error was preset-related
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ( errorFlag  = =  ERR_NONE )  | |  ( errorFlag  = =  ERR_FS_PLOAD ) )  errorFlag  =  presetErrFlag ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 21:23:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  //HTTP API commands
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  char *  httpwin  =  fdo [ " win " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( httpwin )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-24 17:47:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    String  apireq  =  " win " ;  // reduce flash string usage
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    apireq  + =  F ( " &IN& " ) ;  // internal call
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 21:23:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    apireq  + =  httpwin ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    handleSet ( nullptr ,  apireq ,  false ) ;  // may call applyPreset() via PL=
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-16 14:28:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    setValuesFromFirstSelectedSeg ( ) ;  // fills legacy values
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-24 17:30:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    changePreset  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 21:23:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! fdo [ " seg " ] . isNull ( )  | |  ! fdo [ " on " ] . isNull ( )  | |  ! fdo [ " bri " ] . isNull ( )  | |  ! fdo [ " nl " ] . isNull ( )  | |  ! fdo [ " ps " ] . isNull ( )  | |  ! fdo [ F ( " playlist " ) ] . isNull ( ) )  changePreset  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 18:56:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! ( tmpMode  = =  CALL_MODE_BUTTON_PRESET  & &  fdo [ " ps " ] . is < const  char  * > ( )  & &  strchr ( fdo [ " ps " ] . as < const  char  * > ( ) , ' ~ ' )  ! =  strrchr ( fdo [ " ps " ] . as < const  char  * > ( ) , ' ~ ' ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      fdo . remove ( " ps " ) ;  // remove load request for presets to prevent recursive crash (if not called by button and contains preset cycling string "1~5~")
 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    deserializeState ( fdo ,  CALL_MODE_NO_NOTIFY ,  tmpPreset ) ;  // may change presetToApply by calling applyPreset()
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-03 21:23:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 13:03:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( ! errorFlag  & &  tmpPreset  <  255  & &  changePreset )  currentPreset  =  tmpPreset ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # if defined(ARDUINO_ARCH_ESP32) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  //Aircoookie recommended not to delete buffer
 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( tmpPreset = = 255  & &  tmpRAMbuffer ! = nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    free ( tmpRAMbuffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    tmpRAMbuffer  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  releaseJSONBufferLock ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-05 21:56:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( changePreset )  notify ( tmpMode ) ;  // force UDP notification
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  stateUpdated ( tmpMode ) ;   // was colorUpdated() if anything breaks
 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-01 20:11:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  updateInterfaces ( tmpMode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//called from handleSet(PS=) [network callback (sObj is empty), IR (irrational), deserializeState, UDP] and deserializeState() [network callback (filedoc!=nullptr)]
  
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  savePreset ( byte  index ,  const  char *  pname ,  JsonObject  sObj )  
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( ! saveName )  saveName  =  new  char [ 33 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ! quickLoad )  quickLoad  =  new  char [ 9 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ! saveName  | |  ! quickLoad )  return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-15 08:55:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( index  = =  0  | |  ( index  >  250  & &  index  <  255 ) )  return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( pname )  strlcpy ( saveName ,  pname ,  33 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( sObj [ " n " ] . is < const  char * > ( ) )  strlcpy ( saveName ,  sObj [ " n " ] . as < const  char * > ( ) ,  33 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else                              sprintf_P ( saveName ,  PSTR ( " Preset %d " ) ,  index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-29 21:07:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-10 13:20:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  DEBUG_PRINTF_P ( PSTR ( " Saving preset (%d) %s \n " ) ,  index ,  saveName ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 13:52:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetToSave  =  index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  playlistSave  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-26 02:57:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( sObj [ F ( " ql " ) ] . is < const  char * > ( ) )  strlcpy ( quickLoad ,  sObj [ F ( " ql " ) ] . as < const  char * > ( ) ,  9 ) ;  // client limits QL to 2 chars, buffer for 8 bytes to allow unicode
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  else  quickLoad [ 0 ]  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-13 13:27:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-11 16:59:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  char  * bootPS  =  PSTR ( " bootps " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ! sObj [ FPSTR ( bootPS ) ] . isNull ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bootPreset  =  sObj [ FPSTR ( bootPS ) ]  |  bootPreset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sObj . remove ( FPSTR ( bootPS ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    doSerializeConfig  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-18 17:24:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( sObj . size ( ) = = 0  | |  sObj [ " o " ] . isNull ( ) )  {  // no "o" means not a playlist or custom API call, saving of state is async (not immediately)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    includeBri    =  sObj [ " ib " ] . as < bool > ( )  | |  sObj . size ( ) = = 0  | |  index = = 255 ;  // temporary preset needs brightness
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    segBounds     =  sObj [ " sb " ] . as < bool > ( )  | |  sObj . size ( ) = = 0  | |  index = = 255 ;  // temporary preset needs bounds
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    selectedOnly  =  sObj [ F ( " sc " ) ] . as < bool > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 19:55:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    saveLedmap    =  sObj [ F ( " ledmap " ) ]  |  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-13 13:27:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // this is a playlist or API call
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( sObj [ F ( " playlist " ) ] . isNull ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 10:27:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      // we will save API call immediately (often causes presets.json corruption)
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-13 13:27:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      presetToSave  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      if  ( index  < =  250 )  {  // cannot save API calls to temporary preset (255)
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        sObj . remove ( " o " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sObj . remove ( " v " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sObj . remove ( " time " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sObj . remove ( F ( " error " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sObj . remove ( F ( " psave " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( sObj [ " n " ] . isNull ( ) )  sObj [ " n " ]  =  saveName ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        initPresetsFile ( ) ;  // just in case if someone deleted presets.json using /edit
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 16:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        writeObjectToFileUsingId ( getPresetsFileName ( ) ,  index ,  pDoc ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        presetsModifiedTime  =  toki . second ( ) ;  //unix time
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        updateFSInfo ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      delete [ ]  saveName ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      delete [ ]  quickLoad ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      saveName  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      quickLoad  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-01 11:52:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      // store playlist
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 10:27:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      // WARNING: playlist will be loaded in json.cpp after this call and will have repeat counter increased by 1
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      includeBri    =  true ;  // !sObj["on"].isNull();
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      playlistSave  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-29 21:07:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 16:25:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  deletePreset ( byte  index )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  StaticJsonDocument < 24 >  empty ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 13:36:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  writeObjectToFileUsingId ( getPresetsFileName ( ) ,  index ,  & empty ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 07:59:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  presetsModifiedTime  =  toki . second ( ) ;  //unix time
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 21:12:48 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  updateFSInfo ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}