Guest User

Untitled

a guest
Jan 7th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.53 KB | None | 0 0
  1. #ifdef CONFIG_TOP
  2. #include "proffieboard_config.h"
  3. #define NUM_BLADES 8//Uses seven blades, the main blade and the crystal chamber
  4. #define NUM_BUTTONS 2//Uses two button.
  5. #define VOLUME 2800 //Max volume
  6. const unsigned int maxLedsPerStrip = 170;
  7. #define CLASH_THRESHOLD_G 3.0
  8. #define ENABLE_AUDIO
  9. #define ENABLE_MOTION
  10. #define ENABLE_WS2811
  11. #define ENABLE_SD
  12. #define SAVE_PRESET
  13. #define SAVER_VOLUME
  14. #define COLOR_CHANGE_DIRECT
  15. #define DISABLE_DIAGNOSTIC_COMMANDS
  16. #define BLADE_DETECT_PIN 8 //pin on proffieboard that determines whether the emitter is connecte or not.
  17. //#define IDLE_OFF_TIME 60 * 5 * 1000//shuts off all power to blades after 5 minutes of standby to help preserve battery
  18. #define SHARED_POWER_PINS
  19.  
  20. #define ENABLE_SERIAL
  21. #define ENABLE_SSD1306
  22. #define OLED_FLIP_180
  23.  
  24. #endif
  25. //uses a special file for button functions. Located in prop folder
  26. #ifdef CONFIG_PROP
  27. #include "../props/saber_sa22c_buttons.h"
  28. #endif
  29.  
  30. #ifdef CONFIG_PRESETS
  31. // Code for charging indicator
  32. //-------------------------------------------------------------------------------------
  33. class ChargingFSVF {
  34. public:
  35. ChargingFSVF() { pinMode(chargeDetectPin, INPUT_PULLUP); }
  36. int calculate(BladeBase* blade) { return digitalRead(chargeDetectPin) ? 0 : 32768; }
  37. void run(BladeBase* blade) {}
  38. };
  39.  
  40. using ChargingF = SingleValueAdapter<ChargingFSVF>;
  41. //-------------------------------------------------------------------------------------
  42.  
  43. //Battery level indicator style
  44. using BLI = Mix<SmoothStep<BatteryLevel,Int<-10>>, Black, Mix<BatteryLevel, Red, Green>>;
  45.  
  46. //Preset configuration for a fully assembled saber and normal function.
  47. Preset presets[] =
  48. {
  49. //PRESET=============================================================================================================
  50.  
  51. {
  52. "Blind_Cowboy", "",
  53.  
  54. //Crystal Chamber
  55. StylePtr<Layers<RandomFlicker<RotateColorsX<Variation,DeepSkyBlue>,RotateColorsX<Variation,Rgb<0,20,128>>> ,LockupTrL<BrownNoiseFlickerL<White,Int<200>>,TrConcat<TrInstant,White,TrFade<300>>,TrFade<300>,SaberBase::LOCKUP_NORMAL>,LockupTrL<BrownNoiseFlickerL<White,Int<200>>,TrConcat<TrInstant,White,TrFade<300>>,TrFade<300>,SaberBase::LOCKUP_LIGHTNING_BLOCK>,BlastL<Moccasin>,SimpleClashL<Moccasin>,InOutTrL<TrInstant,TrFade<300>,Pulsing<RotateColorsX<Variation,DeepSkyBlue>,RotateColorsX<Variation,Rgb<0,4,10>>,3000>>>>(),
  56. //LED STRIP
  57. StylePtr<InOutHelper<SimpleClash<BlastFadeout<Lockup<ColorCycle<Rgb<100,100,100>,10,70>, ColorCycle<Orange,20,80,Red,20,200,2000>>,Orange>, Orange, 80>, 800, 800, ColorCycle<Rgb<100,100,100>, 20,33>>>(),
  58.  
  59. StylePtr<Black>(),
  60.  
  61. //Extra LED accents past strip
  62. StylePtr<Blinking<Blue,Black,300,500>>(),
  63. StylePtr<Blinking<Black,Red,500,500>>(),
  64.  
  65. //Main Blade
  66. StylePtr<Layers<RandomFlicker<RotateColorsX<Variation,DeepSkyBlue>,RotateColorsX<Variation,Rgb<0,20,128>>>,LockupTrL<Layers<AlphaL<AudioFlickerL<White>,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>>,Scale<SwingSpeed<100>,Int<14000>,Int<18000>>>>,AlphaL<White,Bump<Scale<BladeAngle<>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>>,Int<10000>>>>,TrConcat<TrInstant,White,TrFade<400>>,TrConcat<TrInstant,White,TrFade<400>>,SaberBase::LOCKUP_NORMAL>,ResponsiveLightningBlockL<Strobe<White,AudioFlicker<White,Blue>,50,1>,TrConcat<TrInstant,AlphaL<White,Bump<Int<12000>,Int<18000>>>,TrFade<200>>,TrConcat<TrInstant,HumpFlickerL<AlphaL<White,Int<16000>>,30>,TrSmoothFade<600>>>,ResponsiveStabL<Red,TrWipeIn<600>,TrWipe<600>>,ResponsiveBlastL<White,Int<400>,Scale<SwingSpeed<200>,Int<100>,Int<400>>,Int<400>>,ResponsiveClashL<White,TrInstant,TrFade<400>,Scale<BladeAngle<0,16000>,Int<4000>,Int<26000>>,Int<6000>,Int<20000>>,LockupTrL<AlphaL<BrownNoiseFlickerL<White,Int<300>>,SmoothStep<Int<30000>,Int<5000>>>,TrWipeIn<400>,TrFade<300>,SaberBase::LOCKUP_DRAG>,LockupTrL<AlphaL<Mix<TwistAngle<>,Red,Orange>,SmoothStep<Int<28000>,Int<5000>>>,TrWipeIn<600>,TrFade<300>,SaberBase::LOCKUP_MELT>,InOutTrL<TrWipeSparkTip<White,300>,TrWipeIn<500>,Black>>>(),
  67.  
  68.  
  69. //GREEN LED
  70. StylePtr<InOutHelper<Rgb<0,125,0>,200,200,Blinking<Black,Rgb<0,125,0>,750,500>>>(),
  71. //RED LED
  72. StylePtr<InOutHelper<Blinking<Black,Rgb<255,0,0>,750,500>,200,200,Rgb<255,0,0>>>(),
  73.  
  74.  
  75. },
  76. };
  77.  
  78. //Preset configuration for the mode when the emitter is detached from the rest of the hilt.
  79. Preset detached[] =
  80. {
  81. //PRESET=============================================================================================================
  82.  
  83. {
  84. "PKA Detached", "",
  85.  
  86. //Crystal Chamber
  87. StylePtr<Layers<RandomFlicker<RotateColorsX<Variation,DeepSkyBlue>,RotateColorsX<Variation,Rgb<0,20,128>>> ,LockupTrL<BrownNoiseFlickerL<White,Int<200>>,TrConcat<TrInstant,White,TrFade<300>>,TrFade<300>,SaberBase::LOCKUP_NORMAL>,LockupTrL<BrownNoiseFlickerL<White,Int<200>>,TrConcat<TrInstant,White,TrFade<300>>,TrFade<300>,SaberBase::LOCKUP_LIGHTNING_BLOCK>,BlastL<Moccasin>,SimpleClashL<Moccasin>,InOutTrL<TrInstant,TrFade<300>,Pulsing<RotateColorsX<Variation,DeepSkyBlue>,RotateColorsX<Variation,Rgb<0,4,10>>,3000>>>>(),
  88.  
  89. //LED STRIP
  90. StylePtr<Layers<InOutHelper<SimpleClash<BlastFadeout<Lockup<ColorCycle<White,10,70>, ColorCycle<Orange,40,80,Stripes<100000,150,Blue,Green,DarkOrange,Red>,40,200,2000>>,Orange>, Orange, 80>, 800, 800,Cylon<Stripes<100000,300,White,DarkOrange,DarkOrange,White>, 20,33>>, AlphaL<BLI, ChargingF>>>(),
  91.  
  92. StylePtr<Black>(),
  93.  
  94. //Extra LED accents past strip
  95. StylePtr<Layers<Blinking<Blue,Black,300,500>,AlphaL<Black, ChargingF>>>(),
  96. StylePtr<Layers<Blinking<Black,Green,500,500>,AlphaL<Red, ChargingF>>>(),
  97.  
  98. //Main Blade
  99. StylePtr<IgnitionDelay<2000, StyleFire<DodgerBlue,White,0,5,FireConfig<50,1500,0>,FireConfig<15,1500,0>,FireConfig<15,1500,10>,FireConfig<0,0,5>>>>(),
  100.  
  101.  
  102. //GREEN LED
  103. StylePtr<InOutHelper<Rgb<0,125,0>,200,200,Blinking<Black,Rgb<0,125,0>,750,500>>>(),
  104. //RED LED
  105. StylePtr<InOutHelper<Blinking<Black,Rgb<255,0,0>,750,500>,200,200,Rgb<255,0,0>>>(),
  106.  
  107.  
  108. },
  109. };
  110.  
  111. //Blade definitions to specify the deteachable emitter function
  112. BladeConfig blades[] =
  113. {
  114. //==========================================================================
  115. //EMITTER ATTACHED, NORMAL BLADE FUNCTION
  116. {
  117. // blade ID resistor not used
  118. 0,
  119. //CC
  120. SubBlade(0,0, WS2811BladePtr<8, WS2811_800kHz|WS2811_GRB, bladePin, PowerPINS<bladePowerPin1>>()),
  121. //LED Strip
  122. DimBlade(25.0, SubBlade(1, 4, NULL)),
  123. //blank
  124. SubBlade(5, 5, NULL),
  125. //LED Strip
  126. SubBlade(6, 6, NULL),
  127. //LED Strip
  128. SubBlade(7, 7, NULL),
  129.  
  130. //Main Blade
  131. WS2811BladePtr<153, WS2811_800kHz|WS2811_GRB, blade2Pin, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
  132.  
  133. //GREEN Control Box Accent LED, 1 LED, power on LED4, 22 Ohm Resistor
  134. SimpleBladePtr<NoLED, CreeXPE2GreenTemplate<0>, NoLED, NoLED, -1, bladePowerPin5, -1, -1>(),
  135. //RED Control Box Accent LED, 1 LED, power on LED5, 82 Ohm Resistor
  136. SimpleBladePtr<CreeXPE2RedTemplate< 82000>, NoLED, NoLED, NoLED, bladePowerPin4, -1, -1, -1>(),
  137.  
  138.  
  139.  
  140. CONFIGARRAY(presets)
  141. },
  142.  
  143. //==========================================================================
  144. //EMITTER NOT ATTACHED, SPECIAL MODE FUNCTION
  145. {
  146. NO_BLADE,
  147. //CC
  148. SubBlade(0,0, WS2811BladePtr<8, WS2811_800kHz|WS2811_GRB, bladePin, PowerPINS<bladePowerPin1>>()),
  149. //LED Strip
  150. DimBlade(25.0, SubBlade(1, 4, NULL)),
  151. //blank
  152. SubBlade(5, 5, NULL),
  153. //LED Strip
  154. SubBlade(6, 6, NULL),
  155. //LED Strip
  156. SubBlade(7, 7, NULL),
  157.  
  158. //Main Blade
  159. WS2811BladePtr<153, WS2811_800kHz|WS2811_GRB, blade2Pin, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
  160.  
  161. //GREEN Control Box Accent LED, 1 LED, power on LED4, no resistor
  162. SimpleBladePtr<NoLED, CreeXPE2GreenTemplate<0>, NoLED, NoLED, -1, bladePowerPin5, -1, -1>(),
  163. //RED Control Box Accent LED, 1 LED, power on LED5, 82 Ohm Resistor
  164. SimpleBladePtr<CreeXPE2RedTemplate<82000>, NoLED, NoLED, NoLED, bladePowerPin4, -1, -1, -1>(),
  165.  
  166.  
  167. CONFIGARRAY(detached)
  168.  
  169. },
  170.  
  171. };
  172.  
  173. #endif
  174.  
  175. #ifdef CONFIG_BUTTONS
  176. Button PowerButton(BUTTON_POWER, powerButtonPin, "pow");
  177. Button AuxButton(BUTTON_AUX, auxPin, "aux");
  178. #endif
  179.  
Add Comment
Please, Sign In to add comment