Skip to content

Commit

Permalink
Merge pull request #151 from qmk/master
Browse files Browse the repository at this point in the history
Sync to master
  • Loading branch information
duncanyoyo1 committed Aug 25, 2019
2 parents fab4ede + 0b89809 commit 31b50a7
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 105 deletions.
2 changes: 1 addition & 1 deletion bin/qmk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ with open('requirements.txt', 'r') as fd:

# Figure out our version
command = ['git', 'describe', '--abbrev=6', '--dirty', '--always', '--tags']
result = subprocess.run(command, universal_newlines=True, capture_output=True)
result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if result.returncode == 0:
os.environ['QMK_VERSION'] = 'QMK ' + result.stdout.strip()
Expand Down
17 changes: 12 additions & 5 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ This page describes how to setup and use the QMK CLI.

The QMK CLI makes building and working with QMK keyboards easier. We have provided a number of commands to help you work with QMK:

* `qmk compile-json`
* `qmk compile`
* `qmk doctor`

# Setup

Expand All @@ -20,12 +21,18 @@ You may want to add this to your `.profile`, `.bash_profile`, `.zsh_profile`, or

# Commands

## `qmk compile-json`
## `qmk compile`

This command allows you to compile JSON files you have downloaded from <https://config.qmk.fm>.
This command allows you to compile firmware from any directory. You can compile JSON exports from <https://config.qmk.fm> or compile keymaps in the repo.

**Usage**:
**Usage for Configurator Exports**:

```
qmk compile-json mine.json
qmk compile <configuratorExport.json>
```

**Usage for Keymaps**:

```
qmk compile -kb <keyboard_name> -km <keymap_name>
```
24 changes: 13 additions & 11 deletions docs/feature_oled_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ void oled_task_user(void) {

## Basic Configuration

| Define | Default | Description |
|------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------|
| `OLED_DISPLAY_ADDRESS` | `0x3C` | The i2c address of the OLED Display |
| `OLED_FONT_H` | `"glcdfont.c"` | The font code file to use for custom fonts |
| `OLED_FONT_START` | `0` | The starting characer index for custom fonts |
| `OLED_FONT_END` | `224` | The ending characer index for custom fonts |
| `OLED_FONT_WIDTH` | `6` | The font width |
| `OLED_FONT_HEIGHT` | `8` | The font height (untested) |
| `OLED_DISABLE_TIMEOUT` | *Not defined* | Disables the built in OLED timeout feature. Useful when implementing custom timeout rules. |
| `OLED_IC` | `OLED_IC_SSD1306` | Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. |
| `OLED_COLUMN_OFFSET` | `0` | (SH1106 only.) Shift output to the right this many pixels.<br />Useful for 128x64 displays centered on a 132x64 SH1106 IC. |
| Define | Default | Description |
|----------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------|
| `OLED_DISPLAY_ADDRESS` | `0x3C` | The i2c address of the OLED Display |
| `OLED_FONT_H` | `"glcdfont.c"` | The font code file to use for custom fonts |
| `OLED_FONT_START` | `0` | The starting characer index for custom fonts |
| `OLED_FONT_END` | `224` | The ending characer index for custom fonts |
| `OLED_FONT_WIDTH` | `6` | The font width |
| `OLED_FONT_HEIGHT` | `8` | The font height (untested) |
| `OLED_TIMEOUT` | `60000` | Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. |
| `OLED_SCROLL_TIMEOUT` | `0` | Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. |
| `OLED_SCROLL_TIMEOUT_RIGHT`| *Not defined* | Scroll timeout direction is right when defined, left when undefined. |
| `OLED_IC` | `OLED_IC_SSD1306` | Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. |
| `OLED_COLUMN_OFFSET` | `0` | (SH1106 only.) Shift output to the right this many pixels.<br />Useful for 128x64 displays centered on a 132x64 SH1106 IC. |

## 128x64 & Custom sized OLED Displays

Expand Down
40 changes: 34 additions & 6 deletions drivers/oled/oled_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ bool oled_active = false;
bool oled_scrolling = false;
uint8_t oled_rotation = 0;
uint8_t oled_rotation_width = 0;
#if !defined(OLED_DISABLE_TIMEOUT)
uint16_t oled_last_activity;
#if OLED_TIMEOUT > 0
uint32_t oled_timeout;
#endif
#if OLED_SCROLL_TIMEOUT > 0
uint32_t oled_scroll_timeout;
#endif

// Internal variables to reduce math instructions
Expand Down Expand Up @@ -209,6 +212,13 @@ bool oled_init(uint8_t rotation) {
return false;
}

#if OLED_TIMEOUT > 0
oled_timeout = timer_read32() + OLED_TIMEOUT;
#endif
#if OLED_SCROLL_TIMEOUT > 0
oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
#endif

oled_clear();
oled_initialized = true;
oled_active = true;
Expand Down Expand Up @@ -457,8 +467,8 @@ void oled_write_ln_P(const char *data, bool invert) {
#endif // defined(__AVR__)

bool oled_on(void) {
#if !defined(OLED_DISABLE_TIMEOUT)
oled_last_activity = timer_read();
#if OLED_TIMEOUT > 0
oled_timeout = timer_read32() + OLED_TIMEOUT;
#endif

static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON };
Expand Down Expand Up @@ -522,6 +532,7 @@ bool oled_scroll_off(void) {
return oled_scrolling;
}
oled_scrolling = false;
oled_dirty = -1;
}
return !oled_scrolling;
}
Expand Down Expand Up @@ -549,15 +560,32 @@ void oled_task(void) {

oled_task_user();

#if OLED_SCROLL_TIMEOUT > 0
if (oled_dirty && oled_scrolling) {
oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
oled_scroll_off();
}
#endif

// Smart render system, no need to check for dirty
oled_render();

// Display timeout check
#if !defined(OLED_DISABLE_TIMEOUT)
if (oled_active && timer_elapsed(oled_last_activity) > OLED_TIMEOUT) {
#if OLED_TIMEOUT > 0
if (oled_active && timer_expired32(timer_read32(), oled_timeout)) {
oled_off();
}
#endif

#if OLED_SCROLL_TIMEOUT > 0
if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) {
#ifdef OLED_SCROLL_TIMEOUT_RIGHT
oled_scroll_right();
#else
oled_scroll_left();
#endif
}
#endif
}

__attribute__((weak))
Expand Down
8 changes: 8 additions & 0 deletions drivers/oled/oled_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define OLED_FONT_HEIGHT 8
#endif

#if !defined(OLED_TIMEOUT)
#if defined(OLED_DISABLE_TIMEOUT)
#define OLED_TIMEOUT 0
#else
#define OLED_TIMEOUT 60000
#endif
#endif

// OLED Rotation enum values are flags
typedef enum {
OLED_ROTATION_0 = 0,
Expand Down
17 changes: 8 additions & 9 deletions keyboards/redox_w/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
KC_LSFT ,KC_Z ,KC_X ,KC_C ,KC_V ,KC_B ,KC_ADPU ,KC_PGDN , KC_HOME ,KC_ADEN ,KC_N ,KC_M ,KC_COMM ,KC_DOT ,KC_BKSL ,KC_RSFT ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
KC_LGUI ,KC_PPLS ,KC_PMNS ,KC_ALAS , KC_CTPL , KC_BSPC ,KC_DEL , KC_ENT ,KC_SPC , KC_RALT , KC_LEFT ,KC_DOWN ,KC_UP ,KC_RGHT
KC_LGUI ,KC_PPLS ,KC_PMNS ,KC_ALAS , KC_CTPL , KC_BSPC ,KC_DEL , KC_ENT ,KC_SPC , KC_RALT , KC_LEFT ,KC_DOWN ,KC_UP ,KC_RGHT
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
),

Expand All @@ -57,7 +57,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
_______ ,KC_PERC ,KC_CIRC ,KC_LPRN ,KC_RPRN ,KC_TILD ,_______ ,_______ , _______ ,_______ ,XXXXXXX ,KC_KP_1 ,KC_KP_2 ,KC_KP_3 ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
_______ ,_______ ,_______ ,_______ , _______ , _______ ,_______ , _______ ,_______ , KC_KP_0 , KC_KP_0 ,KC_PDOT ,XXXXXXX ,XXXXXXX
_______ ,_______ ,_______ ,_______ , _______ , _______ ,_______ , _______ ,_______ , KC_KP_0 , KC_KP_0 ,KC_PDOT ,XXXXXXX ,XXXXXXX
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
),

Expand All @@ -71,7 +71,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,_______ ,_______ , _______ ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , KC_BTN1 , KC_BTN2 ,_______ , _______ ,_______ , XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , KC_BTN1 , KC_BTN2 ,_______ , _______ ,_______ , XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
),

Expand All @@ -85,16 +85,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,_______ ,XXXXXXX , XXXXXXX ,_______ ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,XXXXXXX , XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,XXXXXXX , XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
)

};

void matrix_scan_user(void) {
uint8_t layer = biton32(layer_state);

switch (layer) {
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _QWERTY:
set_led_off;
break;
Expand All @@ -110,6 +108,7 @@ void matrix_scan_user(void) {
default:
break;
}
};
return state;
}


53 changes: 53 additions & 0 deletions lib/python/qmk/cli/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Compile a QMK Firmware.
You can compile a keymap already in the repo or using a QMK Configurator export.
"""
import json
import os
import sys
import subprocess
from argparse import FileType

from milc import cli

import qmk.keymap
import qmk.path


@cli.argument('filename', nargs='?', type=FileType('r'), help='The configurator export to compile')
@cli.argument('-kb', '--keyboard', help='The keyboard to build a firmware for. Ignored when a configurator export is supplied.')
@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Ignored when a configurator export is supplied.')
@cli.entrypoint('Compile a QMK Firmware.')
def main(cli):
"""Compile a QMK Firmware.
If a Configurator export is supplied this command will create a new keymap, overwriting an existing keymap if one exists.
FIXME(skullydazed): add code to check and warn if the keymap already exists
If --keyboard and --keymap are provided this command will build a firmware based on that.
"""
if cli.args.filename:
# Parse the configurator json
user_keymap = json.load(cli.args.filename)

# Generate the keymap
keymap_path = qmk.path.keymap(user_keymap['keyboard'])
cli.log.info('Creating {fg_cyan}%s{style_reset_all} keymap in {fg_cyan}%s', user_keymap['keymap'], keymap_path)
qmk.keymap.write(user_keymap['keyboard'], user_keymap['keymap'], user_keymap['layout'], user_keymap['layers'])
cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])

# Compile the keymap
command = ['make', ':'.join((user_keymap['keyboard'], user_keymap['keymap']))]

elif cli.config.general.keyboard and cli.config.general.keymap:
# Generate the make command for a specific keyboard/keymap.
command = ['make', ':'.join((cli.config.general.keyboard, cli.config.general.keymap))]

else:
cli.log.error('You must supply a configurator export or both `--keyboard` and `--keymap`.')
return False

cli.log.info('Compiling keymap with {fg_cyan}%s\n\n', ' '.join(command))
subprocess.run(command)
Empty file.
44 changes: 0 additions & 44 deletions lib/python/qmk/cli/compile/json.py

This file was deleted.

Loading

0 comments on commit 31b50a7

Please sign in to comment.