1
0
Fork 0

Merge pull request #490 from fredizzimo/integrate_visualizer

Integrate visualizer for ChibiOS and Infinity Ergodox
This commit is contained in:
Jack Humbert 2016-07-07 09:59:33 -04:00 committed by GitHub
commit ad43d450ca
26 changed files with 1627 additions and 39 deletions

View file

@ -89,8 +89,8 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
static uint8_t compute_gradient_color(float t, float index, float num) {
const float two_pi = 2.0f * PI;
float normalized_index = (1.0f - index / (num - 1)) * two_pi;
const float two_pi = M_2_PI;
float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
float x = t * two_pi + normalized_index;
float v = 0.5 * (cosf(x) + 1.0f);
return (uint8_t)(255.0f * v);

View file

@ -29,9 +29,7 @@ SOFTWARE.
#include "ch.h"
#endif
#ifdef LCD_ENABLE
#include "gfx.h"
#endif
#ifdef LCD_BACKLIGHT_ENABLE
#include "lcd_backlight.h"
@ -45,7 +43,7 @@ SOFTWARE.
#include "nodebug.h"
#endif
#ifdef USE_SERIAL_LINK
#ifdef SERIAL_LINK_ENABLE
#include "serial_link/protocol/transport.h"
#include "serial_link/system/serial_link.h"
#endif
@ -75,7 +73,7 @@ static bool visualizer_enabled = false;
#define MAX_SIMULTANEOUS_ANIMATIONS 4
static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {};
#ifdef USE_SERIAL_LINK
#ifdef SERIAL_LINK_ENABLE
MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t);
static remote_object_t* remote_objects[] = {
@ -458,15 +456,13 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
}
void visualizer_init(void) {
#ifdef LCD_ENABLE
gfxInit();
#endif
#ifdef LCD_BACKLIGHT_ENABLE
lcd_backlight_init();
#endif
#ifdef USE_SERIAL_LINK
#ifdef SERIAL_LINK_ENABLE
add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) );
#endif
@ -490,7 +486,7 @@ void update_status(bool changed) {
geventSendEvent(listener);
}
}
#ifdef USE_SERIAL_LINK
#ifdef SERIAL_LINK_ENABLE
static systime_t last_update = 0;
systime_t current_update = chVTGetSystemTimeX();
systime_t delta = current_update - last_update;
@ -510,7 +506,7 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
// Alternatively a mutex could be used instead of the volatile variables
bool changed = false;
#ifdef USE_SERIAL_LINK
#ifdef SERIAL_LINK_ENABLE
if (is_serial_link_connected ()) {
visualizer_keyboard_status_t* new_status = read_current_status();
if (new_status) {

View file

@ -28,9 +28,7 @@ SOFTWARE.
#include <stdint.h>
#include <stdbool.h>
#ifdef LCD_ENABLE
#include "gfx.h"
#endif
#ifdef LCD_BACKLIGHT_ENABLE
#include "lcd_backlight.h"

View file

@ -20,41 +20,41 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
GFXLIB = $(VISUALIZER_DIR)/ugfx
SRC += $(VISUALIZER_DIR)/visualizer.c
UINCDIR += $(GFXINC) $(VISUALIZER_DIR)
EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
GFXLIB = $(LIB_PATH)/ugfx
VPATH += $(VISUALIZER_PATH)
OPT_DEFS += -DVISUALIZER_ENABLE
ifdef LCD_ENABLE
UDEFS += -DLCD_ENABLE
OPT_DEFS += -DLCD_ENABLE
ULIBS += -lm
USE_UGFX = yes
endif
ifdef LCD_BACKLIGHT_ENABLE
SRC += $(VISUALIZER_DIR)/lcd_backlight.c
ifndef EMULATOR
SRC += lcd_backlight_hal.c
endif
UDEFS += -DLCD_BACKLIGHT_ENABLE
OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
endif
ifdef LED_ENABLE
SRC += $(VISUALIZER_DIR)/led_test.c
UDEFS += -DLED_ENABLE
USE_UGFX = yes
OPT_DEFS += -DLED_ENABLE
endif
ifdef USE_UGFX
include $(GFXLIB)/gfx.mk
SRC += $(GFXSRC)
UDEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
ULIBS += $(patsubst %,-l%,$(patsubst -l%,%,$(GFXLIBS)))
endif
SRC += $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
OPT_DEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
ifndef VISUALIZER_USER
VISUALIZER_USER = visualizer_user.c
ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c
else
ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","")
$(error "$(KEYMAP_PATH)/visualizer.c" does not exist)
else
SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c
endif
endif
SRC += $(VISUALIZER_USER)
ifdef EMULATOR
UINCDIR += $(TMK_DIR)/common