Skip to content

Commit

Permalink
[keyboard] Clueboard 2x1800 2021 Support (qmk#13220)
Browse files Browse the repository at this point in the history
* 2x1800 2021

* add support for writing a whole frame at a time

* improvements

* wip

* fix scrolling

* small tweak

* add a buffer that's larger than the display

* add the start of a font

* working upper and lower case letters

* add qmk animation

* integrate the message sign into the qmk task system

* add encoder defaults

* add MAX7219_LED_CUSTOM to config.h

* tweaks

* remove unneeded keymaps

* add a keymap showing how to control the signboard

* cleanup

* cleanup

* add a way to disable the startup test

* make it easier to define options at the keymap level

* Fix define names

Co-authored-by: Greg Cochard <gcochard@users.noreply.github.com>

* Apply suggestions from gcochard

Co-authored-by: Greg Cochard <gcochard@users.noreply.github.com>

* feedback from noroads

* format info.json

Co-authored-by: Greg Cochard <gcochard@users.noreply.github.com>
  • Loading branch information
skullydazed and gcochard authored Jul 15, 2021
1 parent 18c6e1d commit 9d0b7ab
Show file tree
Hide file tree
Showing 18 changed files with 1,440 additions and 0 deletions.
Empty file.
154 changes: 154 additions & 0 deletions keyboards/clueboard/2x1800/2021/2021.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/* Copyright 2017 Zach White <skullydazed@gmail.com>
*
* 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 "2021.h"
#include "max7219.h"
#include "font.h"

#ifndef DRAWING_TOY_MODE
static uint16_t led_frame_timer = 0;

void matrix_scan_kb(void) {
if (timer_elapsed(led_frame_timer) > 100) {
max7219_message_sign_task(true);
led_frame_timer = timer_read();
}
}
#endif

void matrix_init_kb(void) {
max7219_init();

#if defined(MAX7219_LED_TEST)
while(1) {
for (int i=0; i<MAX7219_CONTROLLERS; i++) {
max7219_display_test(i, true);
wait_ms(500);
max7219_display_test(i, false);
}
}
#elif defined(MAX7219_LED_ITERATE)
while (1) {
for (int row=0; row<8; row++) {
for(int col=0;col<8*MAX7219_CONTROLLERS;col++) {
max7219_set_led(row, col, true);
wait_ms(500);
max7219_set_led(row, col, false);
}
}
}
#elif defined(MAX7219_LED_DANCE)
while (1) {
for (int col=0; col<8; col++) {
for (int device_num=0; device_num<MAX7219_CONTROLLERS; device_num++) {
if (col % 2 == 0) {
max7219_led_a[col][device_num] = 0b01010101;
} else {
max7219_led_a[col][device_num] = 0b10101010;
}
}
}
max7219_write_frame();
wait_ms(500);
for (int col=0; col<8; col++) {
for (int device_num=0; device_num<MAX7219_CONTROLLERS; device_num++) {
if (col % 2 == 0) {
max7219_led_a[col][device_num] = 0b10101010;
} else {
max7219_led_a[col][device_num] = 0b01010101;
}
}
}
max7219_write_frame();
wait_ms(500);
}
#elif defined(MAX7219_LED_FONTTEST)
uint8_t message[MSG_FONTTEST_LEN][6] = MSG_FONTTEST;
max7219_message_sign(message, MSG_FONTTEST_LEN);
#elif defined(MAX7219_LED_CLUEBOARD)
uint8_t message[MSG_CLUEBOARD_LEN][6] = MSG_CLUEBOARD;
max7219_message_sign(message, MSG_CLUEBOARD_LEN);
#elif defined(MAX7219_LED_KONAMI)
uint8_t message[MSG_KONAMI_LEN][6] = MSG_KONAMI;
max7219_message_sign(message, MSG_KONAMI_LEN);
#elif defined(MAX7219_LED_QMK_POWERED)
uint8_t message[MSG_QMK_POWERED_LEN][6] = MSG_QMK_POWERED;
max7219_message_sign(message, MSG_QMK_POWERED_LEN);
#elif defined(DRAWING_TOY_MODE)
max7219_set_led(0, 0, true);
#endif
}

__attribute__ ((weak))
bool encoder_update_keymap(int8_t index, bool clockwise) {
return false;
}

#define NUM_COLUMNS 8*MAX7219_CONTROLLERS
uint8_t led_position[2] = {0,0}; // The location of the cursor in the matrix

bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_keymap(index, clockwise)) {
#if defined(DRAWING_TOY_MODE)
// Encoder 1, left
if (index == 0 && clockwise) {
if (led_position[0] < NUM_COLUMNS-1) { // turned right
led_position[0]++;
} else {
led_position[0]=0;
}
} else if (index == 0) {
if (led_position[0] > 0) { // turned left
led_position[0]--;
} else {
led_position[0]=NUM_COLUMNS-1;
}
}

// Encoder 2, right
else if (index == 1 && clockwise) {
if (led_position[1] < 7) { // turned right
led_position[1]++;
} else {
led_position[1]=0;
}
} else if (index == 1) {
if (led_position[1] > 0) { // turned left
led_position[1]--;
} else {
led_position[1]=7;
}
}

max7219_set_led(led_position[1], led_position[0], true);
#else
// Encoder 1, left
if (index == 0 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 0) {
tap_code(KC_MS_L); // turned left
}

// Encoder 2, right
else if (index == 1 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 1) {
tap_code(KC_MS_D); // turned left
}
#endif
}
return true;
}
18 changes: 18 additions & 0 deletions keyboards/clueboard/2x1800/2021/2021.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright 2017 Zach White <skullydazed@gmail.com>
*
* 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/>.
*/
#pragma once

#include "quantum.h"
96 changes: 96 additions & 0 deletions keyboards/clueboard/2x1800/2021/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
Copyright 2017 Zach White <skullydazed@clueboard.co>
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/>.
*/

#pragma once

#include "config_common.h"

/* audio support */
#define AUDIO_PIN_ALT B7
#define AUDIO_PIN C4
#define AUDIO_CLICKY

/*
* Encoder Assignments
*/
#define ENCODERS_PAD_A { D0, C5 }
#define ENCODERS_PAD_B { D1, C6 }
#define ENCODER_RESOLUTION 4

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE

/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

// Configure our MAX7219's
//#define MAX7219_LOAD B0
//#define MAX7219_CONTROLLERS 4
//#define MAX7219_LED_INTENSITY 1 // Max: 15

// Define this to disable the startup test
//#define MAX7219_NO_STARTUP_TEST

/* This controls the speed of the sign, lower is faster. This is the minimal
* time between animation frames, in ms. Actual time between frames will
* always be slightly longer due to other keyboard tasks.
*/
//#define MAX7219_SCROLL_TIME 100

/* This setting controls how big the scrollable area for your message sign
* is. If you set it to 0 your display will not work. If you set it to 1
* you will have no buffer area, and you will only be able to display a
* total of 6 characters. Every number after that increases the buffer area
* by 32 columns.
*
* You can calculate how big to make this for the number of characters you
* want to display:
*
* <number of characters in message> * 6 / 32 + 1
*
* You do not need to tune this unless you are trying to save ram.
*/
//#define MAX7219_BUFFER_MULTIPLIER 24

// You can only define one of these at a time:

// Define this to test all LEDs. Keyboard functions will not work.
//#define MAX7219_LED_TEST

// Define this to iterate through LEDs 1 by 1. Keyboard functions will not work.
//#define MAX7219_LED_ITERATE

// Define this to show a simple animation. Keyboard functions will not work.
//#define MAX7219_LED_DANCE

// Define this to show all the characters available
//#define MAX7219_LED_FONTTEST

// Define this to show Clueboard on the sign
//#define MAX7219_LED_CLUEBOARD

// Define this to show the Konami code on the sign
//#define MAX7219_LED_KONAMI

// Define this to show QMK on the sign
//#define MAX7219_LED_QMK_POWERED

// Define this to treat the message board like an etch-a-sketch
//#define DRAWING_TOY_MODE

// Define this if you don't want any of the above
//#define MAX7219_LED_CUSTOM
Loading

0 comments on commit 9d0b7ab

Please sign in to comment.