Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Macro/PartialMap/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void Macro_rotationState( uint8_t index, int8_t increment );
uint8_t Macro_tick_update( TickStore *store, uint8_t type );

void Macro_periodic();
void Screensaver_periodic();

void Macro_poll();
void Macro_setup();

Expand Down
8 changes: 8 additions & 0 deletions Macro/PixelMap/capabilities.kll
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ LEDGamma = 2.2;
gamma_enabled => Pixel_gamma_default_define;
gamma_enabled = "0"; # 0 - Disabled, 1 - Enabled

# Keyboard screensaver settings: block animations on a given key press for some ms/shut down LEDs after some s of inactivity
animation_screensaver_update => Pixel_AnimationScreenSaverUpdate();
screensaver_led_shutdown => Pixel_screensaver_default_led_shutdown;
screensaver_led_shutdown = "0"; # number of seconds before the leds are shutdown; if 0, screensaver is disabled
screensaver_block_animation => Pixel_screensaver_default_block_animation;
screensaver_block_animation = "0"; #number of MILLIseconds to block animation when key is pressed; if 0, animation is not blocked, if screensaver disabled this is ignored
# enable screensaver with 'U[4-101,103-164,176-221,224-231,240-289] :+ animation_screensaver_update();' , the key codes counting as an 'action' to stop screensaver to go to sleep (here all kira keys)

# Animation Control
# 0 - Pause/Resume
# 1 - ForwardOne
Expand Down
42 changes: 42 additions & 0 deletions Macro/PixelMap/pixel.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ CLIDict_Def( pixelCLIDict, "Pixel Module Commands" ) = {
extern const uint8_t gamma_table[];
static uint8_t gamma_enabled;

//Keyboard screensaver
static uint32_t screensaver_led_shutdown;
static uint32_t screensaver_block_animation;

//ms when the last keystroke happened (valid iff screensaver is enabled)
static volatile uint32_t last_key_stroke_time_ms;


// Debug states
PixelTest Pixel_testMode;
volatile uint16_t Pixel_testPos = 0;
Expand Down Expand Up @@ -588,6 +596,17 @@ void Pixel_FadeLayerHighlight_capability( TriggerMacro *trigger, uint8_t state,
}
}

void Pixel_AnimationScreenSaverUpdate( TriggerMacro *trigger, uint8_t state, uint8_t stateType, uint8_t *args )
{
if ( screensaver_led_shutdown ) {
last_key_stroke_time_ms = Time_now().ms;
LED_SetPixels(1);
if ( screensaver_block_animation ) {
Pixel_animationControl = AnimationControl_Pause;
}
}
}



// ----- Functions -----
Expand Down Expand Up @@ -1969,6 +1988,10 @@ void Pixel_SecondaryProcessing_setup()
// Set default gamma setting
gamma_enabled = Pixel_gamma_default_define;

// Set default screensaver settings
screensaver_block_animation = Pixel_screensaver_default_block_animation;
screensaver_led_shutdown = Pixel_screensaver_default_led_shutdown;

// Disable all fade profiles (active defaults afterwards)
memset( Pixel_pixel_fade_profile, 0, Pixel_TotalPixels_KLL );

Expand Down Expand Up @@ -2544,6 +2567,25 @@ inline void Pixel_process()
Latency_end_time( pixelLatencyResource );
}

//Screensaver periodic activity check to block animations/disable LEDs
void Screensaver_periodic()
{
if ( screensaver_led_shutdown ) {
const uint32_t now = Time_now().ms;
if ( now <= last_key_stroke_time_ms+screensaver_block_animation ) {
return;
}

if ( now <= last_key_stroke_time_ms+(screensaver_led_shutdown*1000) ) {
if ( screensaver_block_animation ) {
Pixel_animationControl = AnimationControl_Forward;
}
return;
}

LED_SetPixels(0);
}
}

inline void Pixel_setup()
{
Expand Down
2 changes: 2 additions & 0 deletions Macro/PixelMap/pixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,5 @@ void Pixel_setup();

void Pixel_setAnimationControl( AnimationControl control );

void LED_SetPixels( uint8_t shouldSetOn );

8 changes: 8 additions & 0 deletions Scan/Devices/ISSILed/led_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,14 @@ void LED_control( LedControl control, uint8_t arg )
#endif
}

void LED_SetPixels( uint8_t shouldSetOn )
{
if ( shouldSetOn )
LED_control( LedControl_on, 0 );
else
LED_control( LedControl_off, 0 );
}

void LED_control_capability( TriggerMacro *trigger, uint8_t state, uint8_t stateType, uint8_t *args )
{
CapabilityState cstate = KLL_CapabilityState( state, stateType );
Expand Down
17 changes: 16 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum PeriodicStage {
PeriodicStage_Scan,
PeriodicStage_Macro,
PeriodicStage_Output,
PeriodicStage_Screensaver,
} PeriodicStage;


Expand All @@ -55,6 +56,9 @@ typedef enum PeriodicStage {
// Periodic Stage Tracker
static volatile PeriodicStage stage_tracker;

//Number of times a complete periodic function rotation need to be run to try to check screensaver timing
static volatile uint8_t screensaver_div;



// ----- Functions -----
Expand Down Expand Up @@ -92,8 +96,16 @@ int main_periodic()
// Send periodic USB results
SEGGER_SYSVIEW_OnTaskStartExec(TASK_OUTPUT_PERIODIC);
Output_periodic();
stage_tracker = PeriodicStage_Scan;
stage_tracker = PeriodicStage_Screensaver;
SEGGER_SYSVIEW_OnTaskTerminate(TASK_OUTPUT_PERIODIC);
break;

case PeriodicStage_Screensaver:
if ( !screensaver_div-- ) {
screensaver_div = 100;
Screensaver_periodic();
}
stage_tracker = PeriodicStage_Scan;

// Full rotation
return 1;
Expand Down Expand Up @@ -143,6 +155,9 @@ int main()
// Start scanning on first periodic loop
stage_tracker = PeriodicStage_Scan;

// Fill defautl screensaver div value
screensaver_div = 100;

#if DEBUG_RESETS
// Blink to indicate a reset happened
errorLED(0);
Expand Down