ソースを参照

fantastic60: Cleanup code

fantastic60
Kai Ryu 8年前
コミット
23013088aa

+ 11
- 10
keyboard/fantastic60/config.h ファイルの表示



#define BACKLIGHT_CUSTOM #define BACKLIGHT_CUSTOM
#define CUSTOM_LED_ENABLE #define CUSTOM_LED_ENABLE
#define SOFTPWM_LED_FREQ 80


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


/* ledmap in eeprom */ /* ledmap in eeprom */
#define EECONFIG_LEDMAP_IN_EEPROM 8 #define EECONFIG_LEDMAP_IN_EEPROM 8


/* PS2 mouse support */ /* PS2 mouse support */
#ifdef PS2_MOUSE_ENABLE #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 #endif


/* /*

+ 0
- 3
keyboard/fantastic60/keymap_default.c ファイルの表示

break; break;
case AF_RGB_STEP: case AF_RGB_STEP:
rgb_step(); rgb_step();
dprintf("RGB Step\n");
break; break;
case AF_RGB_COLOR_INCREASE: case AF_RGB_COLOR_INCREASE:
rgb_color_increase(opt); rgb_color_increase(opt);
dprintf("RGB Increase %d\n", opt);
break; break;
case AF_RGB_COLOR_DECREASE: case AF_RGB_COLOR_DECREASE:
rgb_color_decrease(opt); rgb_color_decrease(opt);
dprintf("RGB Decrease %d\n", opt);
break; break;
} }
} }

+ 0
- 2
keyboard/fantastic60/ledmap.c ファイルの表示

PORTE |= (1<<PE6); PORTE |= (1<<PE6);
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4); DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
PORTF |= (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) void ledmap_led_on(uint8_t index)

+ 0
- 5
keyboard/fantastic60/rgb.c ファイルの表示



void rgb_init(void) void rgb_init(void)
{ {
/* shift_register_init(); */
/* shift_register_write_word(0xFFFF); */
rgb_read_config(); rgb_read_config();
rgb_read_color(); rgb_read_color();
if (rgb_config.raw == RGB_UNCONFIGURED) { if (rgb_config.raw == RGB_UNCONFIGURED) {
rgb_fading_enable = 0; rgb_fading_enable = 0;
rgb_brightness = 0; rgb_brightness = 0;
rgb_refresh(&rgb_color_off); rgb_refresh(&rgb_color_off);
/* shift_register_write_word(0xFFFF); */
break; break;
case RGB_FIXED: case RGB_FIXED:
rgb_refresh(&rgb_color); rgb_refresh(&rgb_color);
/* shift_register_write_word(0x0000); */
break; break;
case RGB_FADE: case RGB_FADE:
if (backlight_config.enable) { if (backlight_config.enable) {
rgb_brightness = 16; rgb_brightness = 16;
} }
rgb_fading_enable = 1; rgb_fading_enable = 1;
/* shift_register_write_word(0x0000); */
break; break;
} }
} }

+ 0
- 69
keyboard/fantastic60/shift_register.c ファイルの表示

/*
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 ファイルの表示

/*
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