Add support for key backlighting to bfake
If BACKLIGHT_ENABLE is set to `yes` in `rules.mk`, then the user can use the `BL_*` keycodes to adjust the backlight. At the moment, only on/off is supported.
This commit is contained in:
		
							parent
							
								
									38ab86e8f2
								
							
						
					
					
						commit
						9584db055b
					
				
					 3 changed files with 26 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -16,7 +16,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
#include "bfake.h"
 | 
			
		||||
#ifdef BACKLIGHT_ENABLE
 | 
			
		||||
#include "backlight.h"
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef RGBLIGHT_ENABLE
 | 
			
		||||
#include "rgblight.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <avr/pgmspace.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +29,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#include "i2c.h"
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
#ifdef RGBLIGHT_ENABLE
 | 
			
		||||
extern rgblight_config_t rgblight_config;
 | 
			
		||||
 | 
			
		||||
void rgblight_set(void) {
 | 
			
		||||
| 
						 | 
				
			
			@ -38,8 +44,23 @@ void rgblight_set(void) {
 | 
			
		|||
    i2c_init();
 | 
			
		||||
    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_scan_user(void) {
 | 
			
		||||
    rgblight_task();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void backlight_init_ports(void) {
 | 
			
		||||
	DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6);
 | 
			
		||||
	PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void backlight_set(uint8_t level) {
 | 
			
		||||
	if (level == 0) {
 | 
			
		||||
		// Turn out the lights
 | 
			
		||||
		PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6);
 | 
			
		||||
	} else {
 | 
			
		||||
		// Turn on the lights
 | 
			
		||||
		PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue