Browse Source

fantastic60: Cleanup code

fantastic60
Kai Ryu 8 years ago
parent
commit
23013088aa

+ 11
- 10
keyboard/fantastic60/config.h View File

@@ -55,9 +55,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define BACKLIGHT_CUSTOM
#define CUSTOM_LED_ENABLE
#define SOFTPWM_LED_FREQ 80

/* number of leds */
#define LED_COUNT 5
#define LED_COUNT 4

/* ledmap in eeprom */
#define EECONFIG_LEDMAP_IN_EEPROM 8
@@ -75,15 +76,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

/* PS2 mouse support */
#ifdef PS2_MOUSE_ENABLE
#define PS2_CLOCK_PORT PORTF
#define PS2_CLOCK_PIN PINF
#define PS2_CLOCK_DDR DDRF
#define PS2_CLOCK_BIT PF0
#define PS2_DATA_PORT PORTF
#define PS2_DATA_PIN PINF
#define PS2_DATA_DDR DDRF
#define PS2_DATA_BIT PF1
#define PS2_CLOCK_PORT PORTF
#define PS2_CLOCK_PIN PINF
#define PS2_CLOCK_DDR DDRF
#define PS2_CLOCK_BIT PF0
#define PS2_DATA_PORT PORTF
#define PS2_DATA_PIN PINF
#define PS2_DATA_DDR DDRF
#define PS2_DATA_BIT PF1
#endif

/*

+ 0
- 3
keyboard/fantastic60/keymap_default.c View File

@@ -132,15 +132,12 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
break;
case AF_RGB_STEP:
rgb_step();
dprintf("RGB Step\n");
break;
case AF_RGB_COLOR_INCREASE:
rgb_color_increase(opt);
dprintf("RGB Increase %d\n", opt);
break;
case AF_RGB_COLOR_DECREASE:
rgb_color_decrease(opt);
dprintf("RGB Decrease %d\n", opt);
break;
}
}

+ 0
- 2
keyboard/fantastic60/ledmap.c View File

@@ -44,8 +44,6 @@ void ledmap_led_init(void)
PORTE |= (1<<PE6);
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
/* shift_register_init(); */
/* shift_register_write_word(0x0000); */
}

void ledmap_led_on(uint8_t index)

+ 0
- 5
keyboard/fantastic60/rgb.c View File

@@ -42,8 +42,6 @@ static void hsb_to_rgb(uint16_t hue, uint8_t saturation, uint8_t brightness, rgb

void rgb_init(void)
{
/* shift_register_init(); */
/* shift_register_write_word(0xFFFF); */
rgb_read_config();
rgb_read_color();
if (rgb_config.raw == RGB_UNCONFIGURED) {
@@ -176,11 +174,9 @@ void rgb_set_level(uint8_t level)
rgb_fading_enable = 0;
rgb_brightness = 0;
rgb_refresh(&rgb_color_off);
/* shift_register_write_word(0xFFFF); */
break;
case RGB_FIXED:
rgb_refresh(&rgb_color);
/* shift_register_write_word(0x0000); */
break;
case RGB_FADE:
if (backlight_config.enable) {
@@ -192,7 +188,6 @@ void rgb_set_level(uint8_t level)
rgb_brightness = 16;
}
rgb_fading_enable = 1;
/* shift_register_write_word(0x0000); */
break;
}
}

+ 0
- 69
keyboard/fantastic60/shift_register.c View File

@@ -1,69 +0,0 @@
/*
Copyright 2014 Kai Ryu <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "shift_register.h"

void shift_register_init(void)
{
SR_DDR |= (1<<SR_CLK_BIT | 1<<SR_DATA_BIT | 1<<SR_LATCH_BIT);
SR_PORT &= ~(1<<SR_CLK_BIT | 1<<SR_DATA_BIT | 1<<SR_LATCH_BIT);
}

void shift_register_write_byte(uint8_t byte)
{
uint8_t i = 7;
do {
shift_register_data((byte >> i) & 1);
shift_register_clk();
} while (i--);
shift_register_latch();
}

void shift_register_write_word(uint16_t word)
{
uint8_t i = 15;
do {
shift_register_data((word >> i) & 1);
shift_register_clk();
} while (i--);
shift_register_latch();
}

inline
void shift_register_clk(void)
{
SR_PORT |= (1<<SR_CLK_BIT);
SR_PORT &= ~(1<<SR_CLK_BIT);
}

inline
void shift_register_data(uint8_t bit)
{
if (bit) {
SR_PORT |= (1<<SR_DATA_BIT);
}
else {
SR_PORT &= ~(1<<SR_DATA_BIT);
}
}

inline
void shift_register_latch(void)
{
SR_PORT &= ~(1<<SR_LATCH_BIT);
SR_PORT |= (1<<SR_LATCH_BIT);
}

+ 0
- 37
keyboard/fantastic60/shift_register.h View File

@@ -1,37 +0,0 @@
/*
Copyright 2014 Kai Ryu <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SHIFT_REGISTER_H
#define SHIFT_REGISTER_H

#include <avr/io.h>
#include <stdint.h>

#define SR_PORT PORTF
#define SR_DDR DDRF
#define SR_CLK_BIT PF6
#define SR_DATA_BIT PF5
#define SR_LATCH_BIT PF4

void shift_register_init(void);
void shift_register_write_byte(uint8_t byte);
void shift_register_write_word(uint16_t word);
void shift_register_clk(void);
void shift_register_data(uint8_t bit);
void shift_register_latch(void);

#endif