Skip to content

Commit 9d0b7ab

Browse files
[keyboard] Clueboard 2x1800 2021 Support (qmk#13220)
* 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>
1 parent 18c6e1d commit 9d0b7ab

File tree

18 files changed

+1440
-0
lines changed

18 files changed

+1440
-0
lines changed

keyboards/clueboard/2x1800/2021/.noci

Whitespace-only changes.
+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/* Copyright 2017 Zach White <skullydazed@gmail.com>
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 2 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
#include "2021.h"
18+
#include "max7219.h"
19+
#include "font.h"
20+
21+
#ifndef DRAWING_TOY_MODE
22+
static uint16_t led_frame_timer = 0;
23+
24+
void matrix_scan_kb(void) {
25+
if (timer_elapsed(led_frame_timer) > 100) {
26+
max7219_message_sign_task(true);
27+
led_frame_timer = timer_read();
28+
}
29+
}
30+
#endif
31+
32+
void matrix_init_kb(void) {
33+
max7219_init();
34+
35+
#if defined(MAX7219_LED_TEST)
36+
while(1) {
37+
for (int i=0; i<MAX7219_CONTROLLERS; i++) {
38+
max7219_display_test(i, true);
39+
wait_ms(500);
40+
max7219_display_test(i, false);
41+
}
42+
}
43+
#elif defined(MAX7219_LED_ITERATE)
44+
while (1) {
45+
for (int row=0; row<8; row++) {
46+
for(int col=0;col<8*MAX7219_CONTROLLERS;col++) {
47+
max7219_set_led(row, col, true);
48+
wait_ms(500);
49+
max7219_set_led(row, col, false);
50+
}
51+
}
52+
}
53+
#elif defined(MAX7219_LED_DANCE)
54+
while (1) {
55+
for (int col=0; col<8; col++) {
56+
for (int device_num=0; device_num<MAX7219_CONTROLLERS; device_num++) {
57+
if (col % 2 == 0) {
58+
max7219_led_a[col][device_num] = 0b01010101;
59+
} else {
60+
max7219_led_a[col][device_num] = 0b10101010;
61+
}
62+
}
63+
}
64+
max7219_write_frame();
65+
wait_ms(500);
66+
for (int col=0; col<8; col++) {
67+
for (int device_num=0; device_num<MAX7219_CONTROLLERS; device_num++) {
68+
if (col % 2 == 0) {
69+
max7219_led_a[col][device_num] = 0b10101010;
70+
} else {
71+
max7219_led_a[col][device_num] = 0b01010101;
72+
}
73+
}
74+
}
75+
max7219_write_frame();
76+
wait_ms(500);
77+
}
78+
#elif defined(MAX7219_LED_FONTTEST)
79+
uint8_t message[MSG_FONTTEST_LEN][6] = MSG_FONTTEST;
80+
max7219_message_sign(message, MSG_FONTTEST_LEN);
81+
#elif defined(MAX7219_LED_CLUEBOARD)
82+
uint8_t message[MSG_CLUEBOARD_LEN][6] = MSG_CLUEBOARD;
83+
max7219_message_sign(message, MSG_CLUEBOARD_LEN);
84+
#elif defined(MAX7219_LED_KONAMI)
85+
uint8_t message[MSG_KONAMI_LEN][6] = MSG_KONAMI;
86+
max7219_message_sign(message, MSG_KONAMI_LEN);
87+
#elif defined(MAX7219_LED_QMK_POWERED)
88+
uint8_t message[MSG_QMK_POWERED_LEN][6] = MSG_QMK_POWERED;
89+
max7219_message_sign(message, MSG_QMK_POWERED_LEN);
90+
#elif defined(DRAWING_TOY_MODE)
91+
max7219_set_led(0, 0, true);
92+
#endif
93+
}
94+
95+
__attribute__ ((weak))
96+
bool encoder_update_keymap(int8_t index, bool clockwise) {
97+
return false;
98+
}
99+
100+
#define NUM_COLUMNS 8*MAX7219_CONTROLLERS
101+
uint8_t led_position[2] = {0,0}; // The location of the cursor in the matrix
102+
103+
bool encoder_update_kb(uint8_t index, bool clockwise) {
104+
if (!encoder_update_keymap(index, clockwise)) {
105+
#if defined(DRAWING_TOY_MODE)
106+
// Encoder 1, left
107+
if (index == 0 && clockwise) {
108+
if (led_position[0] < NUM_COLUMNS-1) { // turned right
109+
led_position[0]++;
110+
} else {
111+
led_position[0]=0;
112+
}
113+
} else if (index == 0) {
114+
if (led_position[0] > 0) { // turned left
115+
led_position[0]--;
116+
} else {
117+
led_position[0]=NUM_COLUMNS-1;
118+
}
119+
}
120+
121+
// Encoder 2, right
122+
else if (index == 1 && clockwise) {
123+
if (led_position[1] < 7) { // turned right
124+
led_position[1]++;
125+
} else {
126+
led_position[1]=0;
127+
}
128+
} else if (index == 1) {
129+
if (led_position[1] > 0) { // turned left
130+
led_position[1]--;
131+
} else {
132+
led_position[1]=7;
133+
}
134+
}
135+
136+
max7219_set_led(led_position[1], led_position[0], true);
137+
#else
138+
// Encoder 1, left
139+
if (index == 0 && clockwise) {
140+
tap_code(KC_MS_R); // turned right
141+
} else if (index == 0) {
142+
tap_code(KC_MS_L); // turned left
143+
}
144+
145+
// Encoder 2, right
146+
else if (index == 1 && clockwise) {
147+
tap_code(KC_MS_U); // turned right
148+
} else if (index == 1) {
149+
tap_code(KC_MS_D); // turned left
150+
}
151+
#endif
152+
}
153+
return true;
154+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Copyright 2017 Zach White <skullydazed@gmail.com>
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 2 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
#pragma once
17+
18+
#include "quantum.h"
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
Copyright 2017 Zach White <skullydazed@clueboard.co>
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 2 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#pragma once
19+
20+
#include "config_common.h"
21+
22+
/* audio support */
23+
#define AUDIO_PIN_ALT B7
24+
#define AUDIO_PIN C4
25+
#define AUDIO_CLICKY
26+
27+
/*
28+
* Encoder Assignments
29+
*/
30+
#define ENCODERS_PAD_A { D0, C5 }
31+
#define ENCODERS_PAD_B { D1, C6 }
32+
#define ENCODER_RESOLUTION 4
33+
34+
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
35+
#define LOCKING_SUPPORT_ENABLE
36+
37+
/* Locking resynchronize hack */
38+
#define LOCKING_RESYNC_ENABLE
39+
40+
// Configure our MAX7219's
41+
//#define MAX7219_LOAD B0
42+
//#define MAX7219_CONTROLLERS 4
43+
//#define MAX7219_LED_INTENSITY 1 // Max: 15
44+
45+
// Define this to disable the startup test
46+
//#define MAX7219_NO_STARTUP_TEST
47+
48+
/* This controls the speed of the sign, lower is faster. This is the minimal
49+
* time between animation frames, in ms. Actual time between frames will
50+
* always be slightly longer due to other keyboard tasks.
51+
*/
52+
//#define MAX7219_SCROLL_TIME 100
53+
54+
/* This setting controls how big the scrollable area for your message sign
55+
* is. If you set it to 0 your display will not work. If you set it to 1
56+
* you will have no buffer area, and you will only be able to display a
57+
* total of 6 characters. Every number after that increases the buffer area
58+
* by 32 columns.
59+
*
60+
* You can calculate how big to make this for the number of characters you
61+
* want to display:
62+
*
63+
* <number of characters in message> * 6 / 32 + 1
64+
*
65+
* You do not need to tune this unless you are trying to save ram.
66+
*/
67+
//#define MAX7219_BUFFER_MULTIPLIER 24
68+
69+
// You can only define one of these at a time:
70+
71+
// Define this to test all LEDs. Keyboard functions will not work.
72+
//#define MAX7219_LED_TEST
73+
74+
// Define this to iterate through LEDs 1 by 1. Keyboard functions will not work.
75+
//#define MAX7219_LED_ITERATE
76+
77+
// Define this to show a simple animation. Keyboard functions will not work.
78+
//#define MAX7219_LED_DANCE
79+
80+
// Define this to show all the characters available
81+
//#define MAX7219_LED_FONTTEST
82+
83+
// Define this to show Clueboard on the sign
84+
//#define MAX7219_LED_CLUEBOARD
85+
86+
// Define this to show the Konami code on the sign
87+
//#define MAX7219_LED_KONAMI
88+
89+
// Define this to show QMK on the sign
90+
//#define MAX7219_LED_QMK_POWERED
91+
92+
// Define this to treat the message board like an etch-a-sketch
93+
//#define DRAWING_TOY_MODE
94+
95+
// Define this if you don't want any of the above
96+
//#define MAX7219_LED_CUSTOM

0 commit comments

Comments
 (0)