Skip to content

Commit

Permalink
initial add
Browse files Browse the repository at this point in the history
  • Loading branch information
ml8 committed Mar 3, 2024
1 parent c905e63 commit 2223d02
Show file tree
Hide file tree
Showing 41 changed files with 1,852 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 3x3 Macropad: PCB, Firmware, STL, Programmer

Self-designed, hacked-together 3x3 macropad.

![ml8\_9.jpg](ml8_9.jpg)

Features:

* 4 layers configurable with [via](https://www.caniusevia.com/).
* OLED display to display per-layer text (programmable with tool in
[`kbp/`](kbp/README.md)).
* Rotary encoder with volume control and layer select button.
* 256Kb EEPROM (24LC256).

Project layout:

* [`kbp/`](kbp/README.md) - tool to program keyboard (primarily to change OLED text)
* [`firmware/`](firmware/README.md) - [QMK](https://qmk.fm/)-based firmware (TODO: merge into QMK)
* [`via/`](via/README.md) - Via json config (TODO: merge into via) that can be
used for programming (once merged into via, this should no longer be
necessary).
* [`hardware/`](hardware/README.md) Gerber file for PCB and STL/3mf for
enclosure.
15 changes: 15 additions & 0 deletions firmware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Firmware

You can download the firmware for the macropad from the releases in this
repository. Use the [QMK toolbox](https://github.com/qmk/qmk_toolbox/releases)
to flash the firmware.

If you want to build it yourself and modify it, you'll need to install
[QMK](https://qmk.fm). Then, you can copy or simlink the `keyboards/ml8`
directory into the QMK repo's `keyboards` directory and build normally.

```
[qmk_firmware/] $ make ml8/ml8_9:via
```

Firmware readme [here](keyboards/ml8/ml8_9/readme.md).
1 change: 1 addition & 0 deletions firmware/keyboards/ml8/ml8_9/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ycm_extra_conf.py
65 changes: 65 additions & 0 deletions firmware/keyboards/ml8/ml8_9/base.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "base.h"

#include "config.h"
#include "persistence.h"

#include <stdbool.h>
#include <stdint.h>

#include "action.h"
#include "action_layer.h"
#include "debug.h"
#include "print.h"
#include "wait.h"

bool g_post_init = 0; // true iff initialization is complete

bool is_post_init(void) {
return g_post_init;
}

void keyboard_post_init_user(void) {
#if defined(CONSOLE_ENABLE)
debug_matrix = true;
debug_enable = true;
// when debug mode/console is active, wait a bit to connect.
wait_ms(1000);
dprint("hi 0v0\n");
#endif

// initialize layer labels
persistence_init();

g_post_init = 1;
}

// Move to next layer
void cycle_layer(void) {
uint8_t curr = get_highest_layer(layer_state);
if (curr < 0 || curr >= LAYER_COUNT) {
return;
}
layer_move((curr + 1) % LAYER_COUNT);
}

// Listen for custom keycode
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_CYCLE_LAYERS:
if (!record->event.pressed) {
return false;
}
cycle_layer();
return false;
default:
return true;
}
}

uint16_t keycode_config(uint16_t keycode) {
return keycode;
}

uint8_t mod_config(uint8_t mod) {
return mod;
}
14 changes: 14 additions & 0 deletions firmware/keyboards/ml8/ml8_9/base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <stdbool.h>

#include "keycodes.h"

// Layer names, for convenience.
enum layers { L_MEDIA, L_ZOOM, L_NUM, L_UNDEF };
// Keycode for cycling between layers.
enum keycodes {
KC_CYCLE_LAYERS = QK_USER,
};

bool is_post_init(void);
27 changes: 27 additions & 0 deletions firmware/keyboards/ml8/ml8_9/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

// Reduce firmware size
#undef LOCKING_SUPPORT_ENABLE
#undef LOCKING_RESYNC_ENABLE
#define NO_ACTION_ONESHOT
#define NO_ACTION_TAPPING
#define NO_MUSIC_MODE
// Reduce firmware size but limit to 8 layers
#define LAYER_STATE_8BIT

// clang-format off
#define ENCODERS_PAD_A { B5 }
#define ENCODERS_PAD_B { B4 }
#define ENCODER_RESOLUTION 4
// clang-format on

// Enable external EEPROM
#define EEPROM_I2C_24LC256
// reserve 8k for our use
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE (1 << 13)

// Layer config
#define LAYER_COUNT 4

// Enable storing configuration in eeprom
#define EEPROM_CFG
26 changes: 26 additions & 0 deletions firmware/keyboards/ml8/ml8_9/hid_codes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#define HID_CODE_HEADER 0x6d6c

enum hid_commands {
// Basic protocol definitions.
HID_CMD_NOOP = 0x00,
HID_CMD_ERR = 0x01,
HID_CMD_ACK = 0x02,
HID_CMD_NACK = 0x03,
HID_CMD_CONT = 0x04,
HID_CMD_ABORT = 0x05,
HID_CMD_COMPLETE = 0x06,

// Debug commands; hello and echo
HID_CMD_HELLO = 0x30, // 0
HID_CMD_ECHO = 0x31,

// Control commands
HID_CMD_OLED_OFF = 0x40, // @
HID_CMD_OLED_ON = 0x41,

// OLED programming commands
HID_CMD_OLED_UPDATE = 0x50, // P
HID_CMD_OLED_RESET = 0x51,
};
Loading

0 comments on commit 2223d02

Please sign in to comment.