tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

some puzzle with hardware #501

Closed 243750496 closed 6 years ago

243750496 commented 6 years ago

test platform Ubuntu budigie 17.10

i have no idea how to fix the last bug: action_code.h:187:41: error: expected expression before ‘{’ token #define ACTION_NO { .code = 0 }

what i had done:

sudo apt-get install git unzip build-essential make gcc-avr avr-libc binutils-avr dfu-programmer binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib dfu-util

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install libgcrypt
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libgcrypt
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install libgcrypt11
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libgcrypt11 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libgcrypt11' has no installation candidate
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install libgcrypt20
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libgcrypt20 is already the newest version (1.7.8-2ubuntu1).
The following packages were automatically installed and are no longer required:
  binutils-arm-none-eabi dvgrab gcc-arm-none-eabi libboost-wave1.62.0
  libcdparanoia0:i386 libgdl-3-5 libgdl-3-common libieee1284-3:i386
  libnewlib-dev libopenimageio1.7 libopenjpeg5 libopenshadinglanguage1.8
  libopensubdiv libopus0:i386 libpugixml1v5 libtheora-bin
  libtopmenu-client-gtk3-0 libunicap2 libvisual-0.4-0:i386 libweed0
  libwine-development lives-data lives-plugins mkvtoolnix ogmtools perlmagick
  scribus-data topmenu-gtk3 wine-stable-amd64 wine64-development
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install libgcrypt20-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  binutils-arm-none-eabi dvgrab gcc-arm-none-eabi libboost-wave1.62.0
  libcdparanoia0:i386 libgdl-3-5 libgdl-3-common libieee1284-3:i386
  libnewlib-dev libopenimageio1.7 libopenjpeg5 libopenshadinglanguage1.8
  libopensubdiv libopus0:i386 libpugixml1v5 libtheora-bin
  libtopmenu-client-gtk3-0 libunicap2 libvisual-0.4-0:i386 libweed0
  libwine-development lives-data lives-plugins mkvtoolnix ogmtools perlmagick
  scribus-data topmenu-gtk3 wine-stable-amd64 wine64-development
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libgpg-error-dev
Suggested packages:
  libgcrypt20-doc
The following NEW packages will be installed:
  libgcrypt20-dev libgpg-error-dev
0 upgraded, 2 newly installed, 0 to remove and 44 not upgraded.
Need to get 521 kB of archives.
After this operation, 2,276 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 mirror://mirrors.ubuntu.com/mirrors.txt artful/main amd64 libgpg-error-dev amd64 1.27-3 [72.9 kB]
Get:2 mirror://mirrors.ubuntu.com/mirrors.txt artful/main amd64 libgcrypt20-dev amd64 1.7.8-2ubuntu1 [448 kB]
Fetched 521 kB in 2s (244 kB/s)          
Selecting previously unselected package libgpg-error-dev.
(Reading database ... 325995 files and directories currently installed.)
Preparing to unpack .../libgpg-error-dev_1.27-3_amd64.deb ...
Unpacking libgpg-error-dev (1.27-3) ...
Selecting previously unselected package libgcrypt20-dev.
Preparing to unpack .../libgcrypt20-dev_1.7.8-2ubuntu1_amd64.deb ...
Unpacking libgcrypt20-dev (1.7.8-2ubuntu1) ...
Processing triggers for install-info (6.4.90.dfsg.1-1build1) ...
Setting up libgpg-error-dev (1.27-3) ...
Setting up libgcrypt20-dev (1.7.8-2ubuntu1) ...
Processing triggers for man-db (2.7.6.1-2) ...
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install libgcrypt11-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  binutils-arm-none-eabi dvgrab gcc-arm-none-eabi libboost-wave1.62.0
  libcdparanoia0:i386 libgdl-3-5 libgdl-3-common libieee1284-3:i386
  libnewlib-dev libopenimageio1.7 libopenjpeg5 libopenshadinglanguage1.8
  libopensubdiv libopus0:i386 libpugixml1v5 libtheora-bin
  libtopmenu-client-gtk3-0 libunicap2 libvisual-0.4-0:i386 libweed0
  libwine-development lives-data lives-plugins mkvtoolnix ogmtools perlmagick
  scribus-data topmenu-gtk3 wine-stable-amd64 wine64-development
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  libgcrypt11-dev
0 upgraded, 1 newly installed, 0 to remove and 44 not upgraded.
Need to get 6,658 B of archives.
After this operation, 34.8 kB of additional disk space will be used.
Get:1 mirror://mirrors.ubuntu.com/mirrors.txt artful/main amd64 libgcrypt11-dev amd64 1.5.4-3+really1.7.8-2ubuntu1 [6,658 B]
Fetched 6,658 B in 0s (12.8 kB/s)          
Selecting previously unselected package libgcrypt11-dev.
(Reading database ... 326026 files and directories currently installed.)
Preparing to unpack .../libgcrypt11-dev_1.5.4-3+really1.7.8-2ubuntu1_amd64.deb ...
Unpacking libgcrypt11-dev (1.5.4-3+really1.7.8-2ubuntu1) ...
Setting up libgcrypt11-dev (1.5.4-3+really1.7.8-2ubuntu1) ...
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install vrackets
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package vrackets
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install brackets
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package brackets
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make -f Makefile

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make -f makefile
make: makefile: No such file or directory
make: *** No rule to make target 'makefile'.  Stop.
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install avr-dude
[sudo] password for atc: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package avr-dude
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ sudo apt-get install avrdude
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  binutils-arm-none-eabi dvgrab gcc-arm-none-eabi libboost-wave1.62.0
  libcdparanoia0:i386 libgdl-3-5 libgdl-3-common libieee1284-3:i386
  libnewlib-dev libopenimageio1.7 libopenjpeg5 libopenshadinglanguage1.8
  libopensubdiv libopus0:i386 libpugixml1v5 libtheora-bin
  libtopmenu-client-gtk3-0 libunicap2 libvisual-0.4-0:i386 libweed0
  libwine-development lives-data lives-plugins mkvtoolnix ogmtools perlmagick
  scribus-data topmenu-gtk3 wine-stable-amd64 wine64-development
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libftdi1
Suggested packages:
  avrdude-doc
The following NEW packages will be installed:
  avrdude libftdi1
0 upgraded, 2 newly installed, 0 to remove and 44 not upgraded.
Need to get 317 kB of archives.
After this operation, 1,124 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 mirror://mirrors.ubuntu.com/mirrors.txt artful/universe amd64 libftdi1 amd64 0.20-4build3 [15.0 kB]
Get:2 mirror://mirrors.ubuntu.com/mirrors.txt artful/universe amd64 avrdude amd64 6.3-4 [302 kB]
Fetched 317 kB in 5s (57.5 kB/s)  
Selecting previously unselected package libftdi1:amd64.
(Reading database ... 326029 files and directories currently installed.)
Preparing to unpack .../libftdi1_0.20-4build3_amd64.deb ...
Unpacking libftdi1:amd64 (0.20-4build3) ...
Selecting previously unselected package avrdude.
Preparing to unpack .../avrdude_6.3-4_amd64.deb ...
Unpacking avrdude (6.3-4) ...
Setting up libftdi1:amd64 (0.20-4build3) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up avrdude (6.3-4) ...
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ cd '/home/atc/Downloads/tmk_keyboard-master/keyboard/onekey' 
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make clean

-------- begin --------

rm -f onekey_lufa.hex
rm -f onekey_lufa.eep
rm -f onekey_lufa.cof
rm -f onekey_lufa.elf
rm -f onekey_lufa.map
rm -f onekey_lufa.sym
rm -f onekey_lufa.lss
rm -f obj_onekey_lufa/keymap.o obj_onekey_lufa/matrix.o obj_onekey_lufa/led.o obj_onekey_lufa/common/host.o obj_onekey_lufa/common/keyboard.o obj_onekey_lufa/common/matrix.o obj_onekey_lufa/common/action.o obj_onekey_lufa/common/action_tapping.o obj_onekey_lufa/common/action_macro.o obj_onekey_lufa/common/action_layer.o obj_onekey_lufa/common/action_util.o obj_onekey_lufa/common/print.o obj_onekey_lufa/common/debug.o obj_onekey_lufa/common/util.o obj_onekey_lufa/common/hook.o obj_onekey_lufa/common/avr/suspend.o obj_onekey_lufa/common/avr/xprintf.o obj_onekey_lufa/common/avr/timer.o obj_onekey_lufa/common/avr/bootloader.o obj_onekey_lufa/common/keymap.o obj_onekey_lufa/protocol/lufa/lufa.o obj_onekey_lufa/protocol/lufa/descriptor.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.o obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.o
rm -f obj_onekey_lufa/keymap.lst obj_onekey_lufa/matrix.lst obj_onekey_lufa/led.lst obj_onekey_lufa/common/host.lst obj_onekey_lufa/common/keyboard.lst obj_onekey_lufa/common/matrix.lst obj_onekey_lufa/common/action.lst obj_onekey_lufa/common/action_tapping.lst obj_onekey_lufa/common/action_macro.lst obj_onekey_lufa/common/action_layer.lst obj_onekey_lufa/common/action_util.lst obj_onekey_lufa/common/print.lst obj_onekey_lufa/common/debug.lst obj_onekey_lufa/common/util.lst obj_onekey_lufa/common/hook.lst obj_onekey_lufa/common/avr/suspend.lst obj_onekey_lufa/common/avr/xprintf.lst obj_onekey_lufa/common/avr/timer.lst obj_onekey_lufa/common/avr/bootloader.lst obj_onekey_lufa/common/keymap.lst obj_onekey_lufa/protocol/lufa/lufa.lst obj_onekey_lufa/protocol/lufa/descriptor.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.lst obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.lst
rm -f obj_onekey_lufa/keymap.s obj_onekey_lufa/matrix.s obj_onekey_lufa/led.s obj_onekey_lufa/common/host.s obj_onekey_lufa/common/keyboard.s obj_onekey_lufa/common/matrix.s obj_onekey_lufa/common/action.s obj_onekey_lufa/common/action_tapping.s obj_onekey_lufa/common/action_macro.s obj_onekey_lufa/common/action_layer.s obj_onekey_lufa/common/action_util.s obj_onekey_lufa/common/print.s obj_onekey_lufa/common/debug.s obj_onekey_lufa/common/util.s obj_onekey_lufa/common/hook.s obj_onekey_lufa/common/avr/suspend.s obj_onekey_lufa/common/avr/xprintf.s obj_onekey_lufa/common/avr/timer.s obj_onekey_lufa/common/avr/bootloader.s obj_onekey_lufa/common/keymap.s obj_onekey_lufa/protocol/lufa/lufa.s obj_onekey_lufa/protocol/lufa/descriptor.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.s obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.s
rm -f obj_onekey_lufa/keymap.i obj_onekey_lufa/matrix.i obj_onekey_lufa/led.i obj_onekey_lufa/common/host.i obj_onekey_lufa/common/keyboard.i obj_onekey_lufa/common/matrix.i obj_onekey_lufa/common/action.i obj_onekey_lufa/common/action_tapping.i obj_onekey_lufa/common/action_macro.i obj_onekey_lufa/common/action_layer.i obj_onekey_lufa/common/action_util.i obj_onekey_lufa/common/print.i obj_onekey_lufa/common/debug.i obj_onekey_lufa/common/util.i obj_onekey_lufa/common/hook.i obj_onekey_lufa/common/avr/suspend.i obj_onekey_lufa/common/avr/xprintf.i obj_onekey_lufa/common/avr/timer.i obj_onekey_lufa/common/avr/bootloader.i obj_onekey_lufa/common/keymap.i obj_onekey_lufa/protocol/lufa/lufa.i obj_onekey_lufa/protocol/lufa/descriptor.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.i obj_onekey_lufa/protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.i
rm -f -r .dep
rm -f -r obj_onekey_lufa
-------- end --------

atc@ATC:~/Downloads/tmk_keyboard-master/keyboard/onekey$ make -f Makefile

-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mkdir -p obj_onekey_lufa
Compiling C: keymap.c
avr-gcc -c -mmcu=atmega32u4 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=512 -DCONSOLE_ENABLE -DVERSION=unknown -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_onekey_lufa/keymap.lst -I. -I../../tmk_core -I../../tmk_core/common -I../../tmk_core/protocol -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_onekey_lufa_keymap.o.d  keymap.c -o obj_onekey_lufa/keymap.o 
In file included from ../../tmk_core/common/action.h:24:0,
                 from keymap.c:21:
keymap.c: In function ‘keymap_fn_to_action’:
../../tmk_core/common/action_code.h:187:41: error: expected expression before ‘{’ token
 #define ACTION_NO                       { .code = 0 }
                                         ^
keymap.c:98:23: note: in expansion of macro ‘ACTION_NO’
         action.code = ACTION_NO;
                       ^
../../tmk_core/rules.mk:557: recipe for target 'obj_onekey_lufa/keymap.o' failed
make: *** [obj_onekey_lufa/keymap.o] Error 1
243750496 commented 6 years ago

https://github.com/tmk/tmk_keyboard/tree/v2.9 after download this version the compile problem sloved but show up another problem

atc@ATC:~/Downloads/tmk_keyboard-2.9/keyboard/onekey$ sudo make -f Makefile.pjrc dfu
dfu-programmer atmega32u4 erase
dfu-programmer: no device present.
../../tmk_core/rules.mk:426: recipe for target 'dfu' failed
make: *** [dfu] Error 1
atc@ATC:~/Downloads/tmk_keyboard-2.9/keyboard/onekey$ 

how to slove it?or any other way to load hex file? or what's the next step is if not load the hex file? btw i am using LEOPOLO FC 210TP found drivers here: https://github.com/nathanrosspowell/FC210TP

tmk commented 6 years ago

are you sure your keyboard supports atmel DFU? 'make dfu' flashes firmware with atmel DFU bootloader.

243750496 commented 6 years ago
#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))

/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
    if (layer < KEYMAPS_SIZE) {
        return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
    } else {
        // fall back to layer 0
        return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
    }
}

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    action_t action;
    if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
        action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
    } else {
        action.code = ACTION_NO;
    }
    return action;
}

Q1:what's these line means? in official keymap.c i havent seen them or something similar. btw:i got these code also from https://github.com/nathanrosspowell/FC210TP and i want to set my own keymap

could u plese help me with explain? thx a lot.

keymap.c.txt

/*
Copyright 2012 Jun Wako <wakojun@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/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"

#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);

inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    debug_enable = true;
    debug_matrix = true;
    debug_mouse = true;
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

more Question: 2.what's the using of matrix.c 3.where these lines coming from ? i got it searched no wiki and doc said something like that could you please provide me some doc about it? matrix.c.txt

but got understood some code from https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html

tmk commented 6 years ago

Q1. as comments says former function translate key event to keycode using keymaps you defined, and the latter maps special keycode into action code. Q2. matrix.c is used to scan your switch matrix. Q3. which lines?

243750496 commented 6 years ago

keymap.c

#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))

/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
    if (layer < KEYMAPS_SIZE) {
        return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
    } else {
        // fall back to layer 0
        return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
    }
}

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    action_t action;
    if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
        action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
    } else {
        action.code = ACTION_NO;
    }
    return action;
}

matrix.c:

/*
Copyright 2012 Jun Wako <wakojun@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/>.
*/

/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"

#ifndef DEBOUNCE
#   define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);

inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    debug_enable = true;
    debug_matrix = true;
    debug_mouse = true;
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

btw: i hope to foud a doc or wiki to have some more info about it , anysolutions?

tmk commented 6 years ago

if you can't find info on wiki or google you have to read source codes.

And feel free to add descripton to wiki if you find useful info!

tmk commented 6 years ago

what's actually your question or problem with those lines you quoted?

243750496 commented 6 years ago

i do a lot of work learning what's the meaning of inline uint8_t static ifndef & endif

and compare the code with G60's matrix.c and learned a lot

NQ1:what help i need is to understand what's the meaning of the code below and the using of 3 bold function(

1-1:phex();

1-2:pbin_reverse16();

1-3:bitpop16();

)


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

NQ2: i found som code in tmk_keyboard-master/keyboard/stm32_f103_onekey/keymap_plain.c


uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
    return keymaps[(layer)][(key.row)][(key.col)];
}

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    return fn_actions[FN_INDEX(keycode)];
}

compare with the code below , there 's still some code that i don't understand

NQ2-1:pgm_read_byte:what's this function mean ?

2-2:action_t action; why he use action_t as defination prefix?

2-3:action.code = ACTION_NO; why ".code"?and what's the meaning of ACTION_NO

2-4:return action; return anction.code???what will it return in final???

 * Fn action definition
 */
static const uint16_t PROGMEM fn_actions[] = {
};

#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))

/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
    if (layer < KEYMAPS_SIZE) {
        return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
    } else {
        // fall back to layer 0
        return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
    }
}

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
    action_t action;
    if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
        action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
    } else {
        action.code = ACTION_NO;
    }
    return action;
}
tmk commented 6 years ago

On 11/22/2017 03:01 PM, 243750496 wrote:

what do these lines in matrix.c mean? i do a lot of work learning what's the meaning of inline uint8_t static ifndef & endif

those are general words in C, not specific to this project. You can learn them easily with book and web search. Take time to learn about C and AVR programing.

and compare the code with G60's matrix.c only these code get puzzled ,and let me check the code i post if still have question i will ask here :)

|#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) #define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) / translates key to keycode / uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { if (layer < KEYMAPS_SIZE) { return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); } else { // fall back to layer 0 return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); } } / translates Fn keycode to action / action_t keymap_fn_to_action(uint8_t keycode) { action_t action; if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); } else { action.code = ACTION_NO; } return action; } |

Those codes should be not needed if you are using current version of TMK. You will need them with old versions.

so now the only help i need is to understand what's the meaning of the code below and the using of 3 bold function( 1.phex(); 2.pbin_reverse16(); 3.bitpop16();

The functions works like:

  1. print 8-bit value in hexadecimal form
  2. print 16-bit value in binary form in reverse
  3. count "bit population" of 16-bit value

You can find their definitions under tmk_core/common directory, use your favorite search command like grep or ctags.

243750496 commented 6 years ago

1st:I have another question that after understand all code, it's a hardware question: Shall i need to remove the old controler of keyboard to use micro pro as a new one to get it have able to flash my firmware ?

2nd:are there have some keyboard with no cpu?(Controler) ,i mean all i need to do is add a controler to it with diy able .do that right? 3ird:will the old controler be disabled if not remove it just add a new one?