From f426c1faeee4ee565d5a4e5a23996a606ffe1ebc Mon Sep 17 00:00:00 2001 From: dnppp Date: Thu, 24 Jan 2019 06:34:16 +0900 Subject: [PATCH 1/5] add a function LED_SetPixels to turn off/on the leds from outside led_scan.c file --- Macro/PixelMap/pixel.h | 2 ++ Scan/Devices/ISSILed/led_scan.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Macro/PixelMap/pixel.h b/Macro/PixelMap/pixel.h index 829d22108..020ef9d69 100644 --- a/Macro/PixelMap/pixel.h +++ b/Macro/PixelMap/pixel.h @@ -277,3 +277,5 @@ void Pixel_setup(); void Pixel_setAnimationControl( AnimationControl control ); +void LED_SetPixels( uint8_t shouldSetOn ); + diff --git a/Scan/Devices/ISSILed/led_scan.c b/Scan/Devices/ISSILed/led_scan.c index 51f1720d8..9d188abab 100644 --- a/Scan/Devices/ISSILed/led_scan.c +++ b/Scan/Devices/ISSILed/led_scan.c @@ -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 ); From 824677fd1ffa4dbc1b43232f97e37a7a937577e7 Mon Sep 17 00:00:00 2001 From: dnppp Date: Thu, 24 Jan 2019 06:37:48 +0900 Subject: [PATCH 2/5] periodically call Screensaver_periodic to check if there was a too long period of inactivity --- Macro/PartialMap/macro.h | 2 ++ Macro/PixelMap/pixel.c | 5 +++++ main.c | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Macro/PartialMap/macro.h b/Macro/PartialMap/macro.h index 8380a4007..f3843566e 100644 --- a/Macro/PartialMap/macro.h +++ b/Macro/PartialMap/macro.h @@ -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(); diff --git a/Macro/PixelMap/pixel.c b/Macro/PixelMap/pixel.c index 06438d4c8..d866b2fa3 100644 --- a/Macro/PixelMap/pixel.c +++ b/Macro/PixelMap/pixel.c @@ -2544,6 +2544,11 @@ inline void Pixel_process() Latency_end_time( pixelLatencyResource ); } +//Screensaver periodic activity check to block animations/disable LEDs +void Screensaver_periodic() +{ + //TODO +} inline void Pixel_setup() { diff --git a/main.c b/main.c index 28256bcc6..9ab8e95ec 100644 --- a/main.c +++ b/main.c @@ -46,6 +46,7 @@ typedef enum PeriodicStage { PeriodicStage_Scan, PeriodicStage_Macro, PeriodicStage_Output, + PeriodicStage_Screensaver, } PeriodicStage; @@ -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 ----- @@ -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; @@ -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); From 4f303acf0a5654b0ae0a87879594a6cf3a106f67 Mon Sep 17 00:00:00 2001 From: dnppp Date: Thu, 24 Jan 2019 06:38:47 +0900 Subject: [PATCH 3/5] add a new pixel capability Pixel_AnimationScreensaverUpdate to update screensaver non-idle time; fill Screensaver_periodic function; define screensaver default parameters (disabled by default) --- Macro/PixelMap/capabilities.kll | 10 ++++++++- Macro/PixelMap/pixel.c | 39 ++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Macro/PixelMap/capabilities.kll b/Macro/PixelMap/capabilities.kll index 384294242..f2076f98b 100644 --- a/Macro/PixelMap/capabilities.kll +++ b/Macro/PixelMap/capabilities.kll @@ -26,7 +26,15 @@ pixel => Pixel_Pixel_capability(); gamma => Pixel_GammaControl_capability( func : 1 ); LEDGamma = 2.2; gamma_enabled => Pixel_gamma_default_define; -gamma_enabled = "0"; # 0 - Disabled, 1 - Enabled +gamma_enabled = "1"; # 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 +U[4-101,103-164,176-221,224-231,240-289] :+ animation_screensaver_update(); #key codes counting as an 'action' to stop screensaver to go to sleep (here all keys) # Animation Control # 0 - Pause/Resume diff --git a/Macro/PixelMap/pixel.c b/Macro/PixelMap/pixel.c index d866b2fa3..720ceb1eb 100644 --- a/Macro/PixelMap/pixel.c +++ b/Macro/PixelMap/pixel.c @@ -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; @@ -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 ----- @@ -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 ); @@ -2547,7 +2570,21 @@ inline void Pixel_process() //Screensaver periodic activity check to block animations/disable LEDs void Screensaver_periodic() { - //TODO + 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() From 950ef148ef6c99063b0616d69290a3705336eaf8 Mon Sep 17 00:00:00 2001 From: dnppp <46958885+dnppp@users.noreply.github.com> Date: Thu, 24 Jan 2019 07:13:14 +0900 Subject: [PATCH 4/5] revert gamma_enabled to default value (0) --- Macro/PixelMap/capabilities.kll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Macro/PixelMap/capabilities.kll b/Macro/PixelMap/capabilities.kll index f2076f98b..17b7f9e2e 100644 --- a/Macro/PixelMap/capabilities.kll +++ b/Macro/PixelMap/capabilities.kll @@ -26,7 +26,7 @@ pixel => Pixel_Pixel_capability(); gamma => Pixel_GammaControl_capability( func : 1 ); LEDGamma = 2.2; gamma_enabled => Pixel_gamma_default_define; -gamma_enabled = "1"; # 0 - Disabled, 1 - Enabled +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(); From 248730804932c6e809c643504476dc24ff3d9c9f Mon Sep 17 00:00:00 2001 From: dnppp <46958885+dnppp@users.noreply.github.com> Date: Thu, 24 Jan 2019 07:34:43 +0900 Subject: [PATCH 5/5] remove default animation_screensaver_update (CI) non Kira keyboards builds seems to fail with the proposed 'U[4-101,103-164,176-221,224-231,240-289]' (although the numbers are taken from the doc?), so disable it and put it only on Kira specific layout (kll repository) --- Macro/PixelMap/capabilities.kll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Macro/PixelMap/capabilities.kll b/Macro/PixelMap/capabilities.kll index 17b7f9e2e..98019534d 100644 --- a/Macro/PixelMap/capabilities.kll +++ b/Macro/PixelMap/capabilities.kll @@ -34,7 +34,7 @@ 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 -U[4-101,103-164,176-221,224-231,240-289] :+ animation_screensaver_update(); #key codes counting as an 'action' to stop screensaver to go to sleep (here all keys) +# 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