X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Scan%2FISSILed%2Fled_scan.c;h=a091b8624d3788528618ef42fe9b25d64add8272;hb=074134c47442fa28559598209e3d7d3f30326177;hp=8a92b768c67122b4b3e69b5dd037cb550a1f48d7;hpb=a10afbcc6aa52ef7ec0150802126a2efa053e7a8;p=kiibohd-controller.git diff --git a/Scan/ISSILed/led_scan.c b/Scan/ISSILed/led_scan.c index 8a92b76..a091b86 100644 --- a/Scan/ISSILed/led_scan.c +++ b/Scan/ISSILed/led_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2015 by Jacob Alexander +/* Copyright (C) 2014-2016 by Jacob Alexander * * This file is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -406,8 +406,14 @@ inline void LED_setup() // Set default brightness LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 ); - // Disable Software shutdown of ISSI chip - LED_writeReg( 0x0A, 0x01, 0x0B ); + // Do not disable software shutdown of ISSI chip unless current is high enough + // Require at least 150 mA + // May be enabled/disabled at a later time + if ( Output_current_available() >= 150 ) + { + // Disable Software shutdown of ISSI chip + LED_writeReg( 0x0A, 0x01, 0x0B ); + } } @@ -633,17 +639,40 @@ uint8_t I2C_Send( uint8_t *data, uint8_t sendLen, uint8_t recvLen ) // LED State processing loop +unsigned int LED_currentEvent = 0; inline uint8_t LED_scan() { + // Check for current change event + if ( LED_currentEvent ) + { + // TODO dim LEDs in low power mode instead of shutting off + if ( LED_currentEvent < 150 ) + { + // Enable Software shutdown of ISSI chip + LED_writeReg( 0x0A, 0x00, 0x0B ); + } + else + { + // Disable Software shutdown of ISSI chip + LED_writeReg( 0x0A, 0x01, 0x0B ); + } - // I2C Busy - // S & I2C_S_BUSY - //I2C_S_BUSY + LED_currentEvent = 0; + } return 0; } +// Called by parent Scan Module whenver the available current has changed +// current - mA +void LED_currentChange( unsigned int current ) +{ + // Delay action till next LED scan loop (as this callback sometimes occurs during interrupt requests) + LED_currentEvent = current; +} + + // ----- Capabilities -----