Skip to content

Commit 2fc5cd6

Browse files
committed
Merge branch 'master' into chibios
2 parents a35cdea + 6f5511a commit 2fc5cd6

File tree

7 files changed

+87
-29
lines changed

7 files changed

+87
-29
lines changed

common/action_macro.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ void action_macro_play(const macro_t *macro_p)
3434
macro_t macro = END;
3535
uint8_t interval = 0;
3636

37+
uint8_t mod_storage = 0;
38+
3739
if (!macro_p) return;
3840
while (true) {
3941
switch (MACRO_READ()) {
@@ -66,6 +68,17 @@ void action_macro_play(const macro_t *macro_p)
6668
interval = MACRO_READ();
6769
dprintf("INTERVAL(%u)\n", interval);
6870
break;
71+
case MOD_STORE:
72+
mod_storage = get_mods();
73+
break;
74+
case MOD_RESTORE:
75+
set_mods(mod_storage);
76+
send_keyboard_report();
77+
break;
78+
case MOD_CLEAR:
79+
clear_mods();
80+
send_keyboard_report();
81+
break;
6982
case 0x04 ... 0x73:
7083
dprintf("DOWN(%02X)\n", macro);
7184
register_code(macro);

common/action_macro.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ enum macro_command_id{
6464
/* 0x74 - 0x83 */
6565
WAIT = 0x74,
6666
INTERVAL,
67+
MOD_STORE,
68+
MOD_RESTORE,
69+
MOD_CLEAR,
6770

6871
/* 0x84 - 0xf3 (reserved for keycode up) */
6972

@@ -82,6 +85,9 @@ enum macro_command_id{
8285
#define TYPE(key) DOWN(key), UP(key)
8386
#define WAIT(ms) WAIT, (ms)
8487
#define INTERVAL(ms) INTERVAL, (ms)
88+
#define STORE() MOD_STORE
89+
#define RESTORE() MOD_RESTORE
90+
#define CLEAR() MOD_CLEAR
8591

8692
/* key down */
8793
#define D(key) DOWN(KC_##key)
@@ -93,6 +99,12 @@ enum macro_command_id{
9399
#define W(ms) WAIT(ms)
94100
/* interval */
95101
#define I(ms) INTERVAL(ms)
102+
/* store modifier(s) */
103+
#define SM() STORE()
104+
/* restore modifier(s) */
105+
#define RM() RESTORE()
106+
/* clear modifier(s) */
107+
#define CM() CLEAR()
96108

97109
/* for backward comaptibility */
98110
#define MD(key) DOWN(KC_##key)

common/keycode.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
9595
#define KC_JPY KC_INT3
9696
#define KC_HENK KC_INT4
9797
#define KC_MHEN KC_INT5
98+
/* Korean specific */
99+
#define KC_HAEN KC_LANG1
100+
#define KC_HANJ KC_LANG2
98101
/* Keypad */
99102
#define KC_P1 KC_KP_1
100103
#define KC_P2 KC_KP_2
@@ -114,6 +117,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
114117
#define KC_PPLS KC_KP_PLUS
115118
#define KC_PEQL KC_KP_EQUAL
116119
#define KC_PENT KC_KP_ENTER
120+
/* Unix function key */
121+
#define KC_EXEC KC_EXECUTE
122+
#define KC_SLCT KC_SELECT
123+
#define KC_AGIN KC_AGAIN
124+
#define KC_PSTE KC_PASTE
117125
/* Mousekey */
118126
#define KC_MS_U KC_MS_UP
119127
#define KC_MS_D KC_MS_DOWN

common/keymap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
133133
/* translates keycode to action */
134134
static action_t keycode_to_action(uint8_t keycode)
135135
{
136-
action_t action;
136+
action_t action = {};
137137
switch (keycode) {
138138
case KC_A ... KC_EXSEL:
139139
case KC_LCTRL ... KC_RGUI:

doc/build.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Download and Install
1010

1111
2. **Programmer** Install [dfu-programmer][dfu-prog]. GUI tool [Atmel FLIP][flip] also can be used on Windows.
1212

13-
3. **Driver** On Windows you start DFU bootloader on the chip first time you will see 'Found New Hardware Wizard' to install driver. If you install device driver properly you can find chip name like 'ATmega32U4' under 'LibUSB-Win32 Devices' tree on 'Device Manager'. If not you shall need to update its driver on 'Device Manager'. You will find the driver in `FLIP` install directory like: C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\. In case of `dfu-programmer` use its driver.
13+
3. **Driver** On Windows when you start DFU bootloader on the chip first time you will see **Found New Hardware Wizard** to install driver. If you install device driver properly you will find chip name like **ATmega32U4** under **LibUSB-Win32 Devices** tree on **Device Manager**. If not you shall need to update its driver on **Device Manager**. You will find the driver in `FLIP` install directory like: `C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\`. In case of `dfu-programmer` install driver distributed with it.
1414

1515
If you use PJRC Teensy you don't need step 2 and 3 above, just get [Teensy loader][teensy-loader].
1616

@@ -20,15 +20,15 @@ You can find firmware source at github:
2020

2121
- <https://github.com/tmk/tmk_keyboard>
2222

23-
If you are familiar with `Git` tools you are recommended to use it but you can also download zip archive from:
23+
If you are familiar with `git` tools you are recommended to use it but you can also download zip archive from:
2424

2525
- <https://github.com/tmk/tmk_keyboard/archive/master.zip>
2626

2727

2828
Build firmware
2929
--------------
3030
### 1. Open terminal
31-
Open terminal window to get access to commands. Use Cygwin(or MingGW) `shell terminal` in Windows or `Terminal.app` on Mac OSX. In Windows press `Windows` key and `R` then enter `cmd` in 'Run command' dialog showing up.
31+
Open terminal window to get access to commands. Use Cygwin(or MingGW) shell terminal in Windows or `Terminal.app` on Mac OSX.
3232

3333
### 2. Change directory
3434
Move to project directory in the firmware source.
@@ -53,48 +53,52 @@ Now you have **hex** file to program on current directory. This **hex** is only
5353
How to program controller depends on controller chip and its board design. To program AVR USB chips you'll need to start it up in bootloader mode. Most of boards with the chip have a push button to let bootloader come up. Consult with your controller board manual.
5454

5555
### 2. Program with DFU bootloader
56-
Stock AVR USB chips have DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. Open source command line tool `dfu-programmer` also supports AVR chips, it runs on Linux, Mac OSX and even Windows.
56+
Stock AVR USB chips have DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. `FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below. Open source alternative `dfu-programmer` also supports AVR chips, it is command line tool and runs on Linux, Mac OSX and even Windows.
5757

58-
To program AVR chip with DFU bootloader use `FLIP` or `dfu-programmer`.
59-
If you have a proper program command in `Makefile` just type this.
6058

61-
`FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below.
62-
To use command line tool run this command. Note that you need to set PATH variable properly.
59+
To program with command of `FLIP` run this. Note that you need to set PATH variable properly.
6360

6461
$ make -f Makefile.<variant> flip
6562

66-
Or to program with `dfu-programmer` run:
63+
With `dfu-programmer` run this.
6764

6865
$ make -f Makefile.<variant> dfu
6966

67+
Or you can execute the command directly as the following.
68+
69+
$ dfu-programmer <controller> erase --force
70+
$ dfu-programmer <controller> flash <your_firmware.hex>
71+
$ dfu-programmer <controller> reset
72+
73+
`<controller>` part will be `atmega32u4` or `atmega32u2` in most cases. See manual of the command for the detail.
74+
75+
7076
#### FLIP GUI tutorial
71-
1. On menu bar click Device -> Select, then choose your chip name.
72-
2. On menu bar click Settings -> Communication -> USB, then click 'Open' button on 'USB Port Connection' dialog.
73-
At this point you'll see grey-outed widgets on the app get colored and ready.
77+
1. On menu bar click **Device** -> **Select**, then choose your chip name. (In most cases **ATmega32U2** or **ATmega32U4**)
78+
2. On menu bar click **Settings** -> **Communication** -> **USB**, then click **Open** button on **USB Port Connection** dialog. At this point you'll have to plug into USB and start bootloader.
7479

75-
3. On menu bar click File -> Load HEX File, then select your firmware hex file on File Selector dialog.
76-
4. On 'Operations Flow' panel click 'Run' button to load the firmware binary to the chip. Note that you should keep 'Erase', 'Blank Check', 'Program' and 'Verify' check boxes selected.
77-
5. Re-plug USB cord or click 'Start Application' button to restart your controller.
80+
3. On menu bar click **File** -> **Load HEX File**, then select your firmware hex file on File Selector dialog.
81+
4. On **Operations Flow** panel click **Run** button to load the firmware binary to the chip. Note that you should keep **Erase**, **Blank Check**, **Program** and **Verify** check boxes selected.
82+
5. Re-plug USB cord or click **Start Application** button to restart your controller.
7883
Done.
7984

80-
See also these instructions if you need.
85+
See also these instructions if needed.
8186

8287
- <http://code.google.com/p/micropendous/wiki/LoadingFirmwareWithFLIP>
8388
- <http://www.atmel.com/Images/doc7769.pdf>
8489

8590

86-
### 3. Program with Teensy Loader
87-
If you have PJRC Teensy see instruction of `Teensy Loader`.
91+
##### Troubleshoot
92+
* **FLIP: AtLibUsbDfu.dll not found**
93+
Remove current driver and re-install one FLIP provides from DeviceManager of WIndows. See <http://imgur.com/a/bnwzy>
8894

89-
- <http://www.pjrc.com/teensy/loader.html>
9095

91-
Or use this command if you have command line version of Teensy Loader installed.
96+
### 3. Program with Other programmer
97+
If you are using PJRC Teensy consult with instruction of [Teensy Loader][teensy-loader]. Or run this target with `make` after you install command line version of it.
9298

9399
$ make -f Makefile.<variant> teensy
94100

95-
96-
### 4. Program with Other programmer
97-
You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or USBasp. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile.
101+
You may want to use other programmer like [`avrdude`][avrdude]. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile. See below.
98102

99103
$ make -f Makefile.<variant> program
100104

@@ -106,6 +110,7 @@ You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or
106110
[flip]: http://www.atmel.com/tools/FLIP.aspx
107111
[dfu-prog]: http://dfu-programmer.sourceforge.net/
108112
[teensy-loader]:http://www.pjrc.com/teensy/loader.html
113+
[avrdude]: http://savannah.nongnu.org/projects/avrdude/
109114

110115

111116

@@ -121,6 +126,7 @@ Set your MCU and its clock in Hz.
121126

122127
# Boot Section Size in *bytes*
123128
# Teensy halfKay 512
129+
# Teensy++ halfKay 2048
124130
# Atmel DFU loader 4096
125131
# LUFA bootloader 4096
126132
OPT_DEFS += -DBOOTLOADER_SIZE=4096
@@ -140,7 +146,7 @@ Optional. Note that ***comment out*** with `#` to disable them.
140146
#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
141147

142148
### 3. Programmer
143-
Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`.
149+
Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`.
144150

145151
# avrdude with AVRISPmkII
146152
PROGRAM_CMD = avrdude -p $(MCU) -c avrispmkII -P USB -U flash:w:$(TARGET).hex

doc/keymap.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,37 @@ Default Layer also has bitwise operations, they are executed when key is release
368368
MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END )
369369

370370
#### 2.3.1 Macro Commands
371+
- **MACRO()**
372+
- **MACRO_NONE**
373+
371374
- **I()** change interval of stroke.
372375
- **D()** press key
373376
- **U()** release key
374377
- **T()** type key(press and release)
375378
- **W()** wait
379+
- **SM()** store modifier state
380+
- **RM()** restore modifier state
381+
- **CM()** clear modifier state
376382
- **END** end mark
377383

378384
#### 2.3.2 Examples
385+
***TBD***
386+
387+
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
388+
{
389+
switch (id) {
390+
case HELLO:
391+
return (record->event.pressed ?
392+
MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
393+
MACRO_NONE );
394+
case ALT_TAB:
395+
return (record->event.pressed ?
396+
MACRO( D(LALT), D(TAB), END ) :
397+
MACRO( U(TAB), END ));
398+
}
399+
return MACRO_NONE;
400+
}
379401

380-
***TODO: sample implementation***
381-
See `keyboard/hhkb/keymap.c` for sample.
382402

383403

384404

protocol/serial_soft.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ POSSIBILITY OF SUCH DAMAGE.
6868
#endif
6969

7070
/* debug for signal timing, see debug pin with oscilloscope */
71-
#define SERIAL_SOFT_DEBUG
7271
#ifdef SERIAL_SOFT_DEBUG
7372
#define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1<<7)
7473
#define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1<<7)
@@ -176,7 +175,7 @@ void serial_send(uint8_t data)
176175
ISR(SERIAL_SOFT_RXD_VECT)
177176
{
178177
SERIAL_SOFT_DEBUG_TGL();
179-
SERIAL_SOFT_RXD_INT_ENTER()
178+
SERIAL_SOFT_RXD_INT_ENTER();
180179

181180
uint8_t data = 0;
182181

0 commit comments

Comments
 (0)