added a variant of ard-reset-arduino from a forum somewhere massive refactoringpull/18/head
parent
7f2b3dfa15
commit
292b390fbb
@ -0,0 +1,340 @@
|
|||||||
|
#ifndef KeyboardIO_H_
|
||||||
|
#define KeyboardIO_H_
|
||||||
|
#include "Arduino.h"
|
||||||
|
//add your includes for the project KeyboardIO here
|
||||||
|
|
||||||
|
|
||||||
|
//end of add your includes here
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
void loop();
|
||||||
|
void setup();
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//add your function definitions for the project KeyboardIO here
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
byte flags;
|
||||||
|
byte rawKey;
|
||||||
|
} Key;
|
||||||
|
|
||||||
|
#define KEY_FLAGS B000000
|
||||||
|
#define CTRL_HELD B000001
|
||||||
|
#define ALT_HELD B000010
|
||||||
|
#define SHIFT_HELD B000100
|
||||||
|
#define GUI_HELD B001000
|
||||||
|
#define SWITCH_TO_LAYER B010000
|
||||||
|
#define MOMENTARY_LAYER B100000
|
||||||
|
|
||||||
|
#define LAYER_0 0
|
||||||
|
#define LAYER_1 1
|
||||||
|
#define LAYER_2 2
|
||||||
|
#define LAYER_3 3
|
||||||
|
#define LAYER_4 4
|
||||||
|
#define LAYER_5 5
|
||||||
|
#define LAYER_6 6
|
||||||
|
#define LAYER_7 7
|
||||||
|
|
||||||
|
|
||||||
|
#define NoKey (Key){ KEY_FLAGS,0 }
|
||||||
|
|
||||||
|
#define Key_LeftCtrl (Key){ KEY_FLAGS, KEY_LEFT_CTRL }
|
||||||
|
|
||||||
|
#define KEY_LEFT_CTRL 0x80
|
||||||
|
#define Key_LeftCtrl (Key){ KEY_FLAGS, KEY_LEFT_CTRL }
|
||||||
|
#define KEY_LEFT_SHIFT 0x81
|
||||||
|
#define Key_LeftShift (Key){ KEY_FLAGS, KEY_LEFT_SHIFT }
|
||||||
|
#define KEY_LEFT_ALT 0x82
|
||||||
|
#define Key_LeftAlt (Key){ KEY_FLAGS, KEY_LEFT_ALT }
|
||||||
|
#define KEY_LEFT_GUI 0x83
|
||||||
|
#define Key_LeftGUI (Key){ KEY_FLAGS, KEY_LEFT_GUI }
|
||||||
|
#define KEY_RIGHT_CTRL 0x84
|
||||||
|
#define Key_RightCtrl (Key){ KEY_FLAGS, KEY_RIGHT_CTRL }
|
||||||
|
#define KEY_RIGHT_SHIFT 0x85
|
||||||
|
#define Key_RightShift (Key){ KEY_FLAGS, KEY_RIGHT_SHIFT }
|
||||||
|
#define KEY_RIGHT_ALT 0x86
|
||||||
|
#define Key_RightAlt (Key){ KEY_FLAGS, KEY_RIGHT_ALT }
|
||||||
|
#define KEY_RIGHT_GUI 0x87
|
||||||
|
#define Key_RightGUI (Key){ KEY_FLAGS, KEY_RIGHT_GUI }
|
||||||
|
|
||||||
|
#define KEY_UP_ARROW 0xDA
|
||||||
|
#define Key_UpArrow (Key){ KEY_FLAGS, KEY_UP_ARROW }
|
||||||
|
#define KEY_DOWN_ARROW 0xD9
|
||||||
|
#define Key_DownArrow (Key){ KEY_FLAGS, KEY_DOWN_ARROW }
|
||||||
|
#define KEY_LEFT_ARROW 0xD8
|
||||||
|
#define Key_LeftArrow (Key){ KEY_FLAGS, KEY_LEFT_ARROW }
|
||||||
|
#define KEY_RIGHT_ARROW 0xD7
|
||||||
|
#define Key_RightArrow (Key){ KEY_FLAGS, KEY_RIGHT_ARROW }
|
||||||
|
#define KEY_RETURN 0xB0
|
||||||
|
#define Key_Return (Key){ KEY_FLAGS, KEY_RETURN }
|
||||||
|
#define KEY_ESC 0xB1
|
||||||
|
#define Key_Esc (Key){ KEY_FLAGS, KEY_ESC }
|
||||||
|
#define KEY_BACKSPACE 0xB2
|
||||||
|
#define Key_Backspace (Key){ KEY_FLAGS, KEY_BACKSPACE }
|
||||||
|
#define KEY_TAB 0xB3
|
||||||
|
#define Key_Tab (Key){ KEY_FLAGS, KEY_TAB }
|
||||||
|
#define KEY_INSERT 0xD1
|
||||||
|
#define Key_Insert (Key){ KEY_FLAGS, KEY_INSERT }
|
||||||
|
#define KEY_DELETE 0xD4
|
||||||
|
#define Key_Delete (Key){ KEY_FLAGS, KEY_DELETE }
|
||||||
|
#define KEY_PAGE_UP 0xD3
|
||||||
|
#define Key_PageUp (Key){ KEY_FLAGS, KEY_PAGE_UP }
|
||||||
|
#define KEY_PAGE_DOWN 0xD6
|
||||||
|
#define Key_PageDown (Key){ KEY_FLAGS, KEY_PAGE_DOWN }
|
||||||
|
#define KEY_HOME 0xD2
|
||||||
|
#define Key_Home (Key){ KEY_FLAGS, KEY_HOME }
|
||||||
|
#define KEY_END 0xD5
|
||||||
|
#define Key_End (Key){ KEY_FLAGS, KEY_END }
|
||||||
|
|
||||||
|
|
||||||
|
#define KEY_CAPS_LOCK 0xC1
|
||||||
|
#define Key_CapsLock (Key){ KEY_FLAGS, KEY_CAPS_LOCK }
|
||||||
|
#define KEY_F1 0xC2
|
||||||
|
#define Key_F1 (Key){ KEY_FLAGS, KEY_F1 }
|
||||||
|
#define KEY_F2 0xC3
|
||||||
|
#define Key_F2 (Key){ KEY_FLAGS, KEY_F2 }
|
||||||
|
#define KEY_F3 0xC4
|
||||||
|
#define Key_F3 (Key){ KEY_FLAGS, KEY_F3 }
|
||||||
|
#define KEY_F4 0xC5
|
||||||
|
#define Key_F4 (Key){ KEY_FLAGS, KEY_F4 }
|
||||||
|
#define KEY_F5 0xC6
|
||||||
|
#define Key_F5 (Key){ KEY_FLAGS, KEY_F5 }
|
||||||
|
#define KEY_F6 0xC7
|
||||||
|
#define Key_F6 (Key){ KEY_FLAGS, KEY_F6 }
|
||||||
|
#define KEY_F7 0xC8
|
||||||
|
#define Key_F7 (Key){ KEY_FLAGS, KEY_F7 }
|
||||||
|
#define KEY_F8 0xC9
|
||||||
|
#define Key_F8 (Key){ KEY_FLAGS, KEY_F8 }
|
||||||
|
#define KEY_F9 0xCA
|
||||||
|
#define Key_F9 (Key){ KEY_FLAGS, KEY_F9 }
|
||||||
|
#define KEY_F10 0xCB
|
||||||
|
#define Key_F10 (Key){ KEY_FLAGS, KEY_F10 }
|
||||||
|
#define KEY_F11 0xCC
|
||||||
|
#define Key_F11 (Key){ KEY_FLAGS, KEY_F11 }
|
||||||
|
#define KEY_F12 0xCD
|
||||||
|
#define Key_F12 (Key){ KEY_FLAGS, KEY_F12 }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define KEY_0 '0'
|
||||||
|
#define Key_0 (Key){ KEY_FLAGS, KEY_0 }
|
||||||
|
#define KEY_1 '1'
|
||||||
|
#define Key_1 (Key){ KEY_FLAGS, KEY_1 }
|
||||||
|
#define KEY_2 '2'
|
||||||
|
#define Key_2 (Key){ KEY_FLAGS, KEY_2 }
|
||||||
|
#define KEY_3 '3'
|
||||||
|
#define Key_3 (Key){ KEY_FLAGS, KEY_3 }
|
||||||
|
#define KEY_4 '4'
|
||||||
|
#define Key_4 (Key){ KEY_FLAGS, KEY_4 }
|
||||||
|
#define KEY_5 '5'
|
||||||
|
#define Key_5 (Key){ KEY_FLAGS, KEY_5 }
|
||||||
|
#define KEY_6 '6'
|
||||||
|
#define Key_6 (Key){ KEY_FLAGS, KEY_6 }
|
||||||
|
#define KEY_7 '7'
|
||||||
|
#define Key_7 (Key){ KEY_FLAGS, KEY_7 }
|
||||||
|
#define KEY_8 '8'
|
||||||
|
#define Key_8 (Key){ KEY_FLAGS, KEY_8 }
|
||||||
|
#define KEY_9 '9'
|
||||||
|
#define Key_9 (Key){ KEY_FLAGS, KEY_9 }
|
||||||
|
#define KEY_A 'a'
|
||||||
|
#define Key_A (Key){ KEY_FLAGS, KEY_A }
|
||||||
|
#define KEY_B 'b'
|
||||||
|
#define Key_B (Key){ KEY_FLAGS, KEY_B }
|
||||||
|
#define KEY_C 'c'
|
||||||
|
#define Key_C (Key){ KEY_FLAGS, KEY_C }
|
||||||
|
#define KEY_D 'd'
|
||||||
|
#define Key_D (Key){ KEY_FLAGS, KEY_D }
|
||||||
|
#define KEY_E 'e'
|
||||||
|
#define Key_E (Key){ KEY_FLAGS, KEY_E }
|
||||||
|
#define KEY_F 'f'
|
||||||
|
#define Key_F (Key){ KEY_FLAGS, KEY_F }
|
||||||
|
#define KEY_G 'g'
|
||||||
|
#define Key_G (Key){ KEY_FLAGS, KEY_G }
|
||||||
|
#define KEY_H 'h'
|
||||||
|
#define Key_H (Key){ KEY_FLAGS, KEY_H }
|
||||||
|
#define KEY_I 'i'
|
||||||
|
#define Key_I (Key){ KEY_FLAGS, KEY_I }
|
||||||
|
#define KEY_J 'j'
|
||||||
|
#define Key_J (Key){ KEY_FLAGS, KEY_J }
|
||||||
|
#define KEY_K 'k'
|
||||||
|
#define Key_K (Key){ KEY_FLAGS, KEY_K }
|
||||||
|
#define KEY_L 'l'
|
||||||
|
#define Key_L (Key){ KEY_FLAGS, KEY_L }
|
||||||
|
#define KEY_M 'm'
|
||||||
|
#define Key_M (Key){ KEY_FLAGS, KEY_M }
|
||||||
|
#define KEY_N 'n'
|
||||||
|
#define Key_N (Key){ KEY_FLAGS, KEY_N }
|
||||||
|
#define KEY_O 'o'
|
||||||
|
#define Key_O (Key){ KEY_FLAGS, KEY_O }
|
||||||
|
#define KEY_P 'p'
|
||||||
|
#define Key_P (Key){ KEY_FLAGS, KEY_P }
|
||||||
|
#define KEY_Q 'q'
|
||||||
|
#define Key_Q (Key){ KEY_FLAGS, KEY_Q }
|
||||||
|
#define KEY_R 'r'
|
||||||
|
#define Key_R (Key){ KEY_FLAGS, KEY_R }
|
||||||
|
#define KEY_S 's'
|
||||||
|
#define Key_S (Key){ KEY_FLAGS, KEY_S }
|
||||||
|
#define KEY_T 't'
|
||||||
|
#define Key_T (Key){ KEY_FLAGS, KEY_T }
|
||||||
|
#define KEY_U 'u'
|
||||||
|
#define Key_U (Key){ KEY_FLAGS, KEY_U }
|
||||||
|
#define KEY_V 'v'
|
||||||
|
#define Key_V (Key){ KEY_FLAGS, KEY_V }
|
||||||
|
#define KEY_W 'w'
|
||||||
|
#define Key_W (Key){ KEY_FLAGS, KEY_W }
|
||||||
|
#define KEY_X 'x'
|
||||||
|
#define Key_X (Key){ KEY_FLAGS, KEY_X }
|
||||||
|
#define KEY_Y 'y'
|
||||||
|
#define Key_Y (Key){ KEY_FLAGS, KEY_Y }
|
||||||
|
#define KEY_Z 'z'
|
||||||
|
#define Key_Z (Key){ KEY_FLAGS, KEY_Z }
|
||||||
|
|
||||||
|
#define KEY_BACKTICK '`'
|
||||||
|
#define Key_Backtick (Key){ KEY_FLAGS, KEY_BACKTICK }
|
||||||
|
#define KEY_MINUS '-'
|
||||||
|
#define Key_Minus (Key){ KEY_FLAGS, KEY_MINUS }
|
||||||
|
#define KEY_EQUALS '='
|
||||||
|
#define Key_Equals (Key){ KEY_FLAGS, KEY_EQUALS }
|
||||||
|
#define KEY_LEFT_BRACKET '['
|
||||||
|
#define Key_LeftBracket (Key){ KEY_FLAGS, KEY_LEFT_BRACKET }
|
||||||
|
#define KEY_RIGHT_BRACKET ']'
|
||||||
|
#define Key_RightBracket (Key){ KEY_FLAGS, KEY_RIGHT_BRACKET }
|
||||||
|
#define KEY_BACKSLASH '\\'
|
||||||
|
#define Key_Backslash (Key){ KEY_FLAGS, KEY_BACKSLASH }
|
||||||
|
#define KEY_SEMICOLON ';'
|
||||||
|
#define Key_Semicolon (Key){ KEY_FLAGS, KEY_SEMICOLON }
|
||||||
|
#define KEY_QUOTE '\''
|
||||||
|
#define Key_Quote (Key){ KEY_FLAGS, KEY_QUOTE }
|
||||||
|
#define KEY_COMMA ','
|
||||||
|
#define Key_Comma (Key){ KEY_FLAGS, KEY_COMMA }
|
||||||
|
#define KEY_PERIOD '.'
|
||||||
|
#define Key_Period (Key){ KEY_FLAGS, KEY_PERIOD }
|
||||||
|
#define KEY_SPACE ' '
|
||||||
|
#define Key_Space (Key){ KEY_FLAGS, KEY_SPACE }
|
||||||
|
#define KEY_SLASH '/'
|
||||||
|
#define Key_Slash (Key){ KEY_FLAGS, KEY_SLASH }
|
||||||
|
|
||||||
|
#define KEY_KEYPAD_CLEAR 0xDB
|
||||||
|
#define Key_KeypadClear (Key){ KEY_FLAGS, KEY_KEYPAD_CLEAR }
|
||||||
|
#define KEY_KEYPAD_SLASH 0xDC
|
||||||
|
#define Key_KeypadSlash (Key){ KEY_FLAGS, KEY_KEYPAD_SLASH }
|
||||||
|
#define KEY_KEYPAD_MULTIPLY 0xDD
|
||||||
|
#define Key_KeypadMultiply (Key){ KEY_FLAGS, KEY_KEYPAD_MULTIPLY }
|
||||||
|
#define KEY_KEYPAD_MINUS 0xDE
|
||||||
|
#define Key_KeypadMinus (Key){ KEY_FLAGS, KEY_KEYPAD_MINUS }
|
||||||
|
#define KEY_KEYPAD_PLUS 0xDF
|
||||||
|
#define Key_KeypadPlus (Key){ KEY_FLAGS, KEY_KEYPAD_PLUS }
|
||||||
|
#define KEY_ENTER 0xe0
|
||||||
|
#define Key_Enter (Key){ KEY_FLAGS, KEY_ENTER }
|
||||||
|
#define KEY_KEYPAD_1 0xe1
|
||||||
|
#define Key_Keypad1 (Key){ KEY_FLAGS, KEY_KEYPAD_1 }
|
||||||
|
#define KEY_KEYPAD_2 0xe2
|
||||||
|
#define Key_Keypad2 (Key){ KEY_FLAGS, KEY_KEYPAD_2 }
|
||||||
|
#define KEY_KEYPAD_3 0xe3
|
||||||
|
#define Key_Keypad3 (Key){ KEY_FLAGS, KEY_KEYPAD_3 }
|
||||||
|
#define KEY_KEYPAD_4 0xe4
|
||||||
|
#define Key_Keypad4 (Key){ KEY_FLAGS, KEY_KEYPAD_4 }
|
||||||
|
#define KEY_KEYPAD_5 0xe5
|
||||||
|
#define Key_Keypad5 (Key){ KEY_FLAGS, KEY_KEYPAD_5 }
|
||||||
|
#define KEY_KEYPAD_6 0xe6
|
||||||
|
#define Key_Keypad6 (Key){ KEY_FLAGS, KEY_KEYPAD_6 }
|
||||||
|
#define KEY_KEYPAD_7 0xe7
|
||||||
|
#define Key_Keypad7 (Key){ KEY_FLAGS, KEY_KEYPAD_7 }
|
||||||
|
#define KEY_KEYPAD_8 0xe8
|
||||||
|
#define Key_Keypad8 (Key){ KEY_FLAGS, KEY_KEYPAD_8 }
|
||||||
|
#define KEY_KEYPAD_9 0xe9
|
||||||
|
#define Key_Keypad9 (Key){ KEY_FLAGS, KEY_KEYPAD_9 }
|
||||||
|
#define KEY_KEYPAD_0 0xea
|
||||||
|
#define Key_Keypad0 (Key){ KEY_FLAGS, KEY_KEYPAD_0 }
|
||||||
|
#define KEY_KEYPAD_DOT 0xeb
|
||||||
|
#define Key_KeypadDot (Key){ KEY_FLAGS, KEY_KEYPAD_DOT }
|
||||||
|
#define KEY_DANISH_DOLLAR 0xec
|
||||||
|
#define Key_DanishDollar (Key){ KEY_FLAGS, KEY_DANISH_DOLLAR }
|
||||||
|
#define KEY_PC_APPLCIATION 0xed
|
||||||
|
#define Key_PcApplciation (Key){ KEY_FLAGS, KEY_PC_APPLCIATION }
|
||||||
|
#define KEY_F13 0xF0
|
||||||
|
#define Key_F13 (Key){ KEY_FLAGS, KEY_F13 }
|
||||||
|
#define KEY_F16 0xF3
|
||||||
|
#define Key_F16 (Key){ KEY_FLAGS, KEY_F16 }
|
||||||
|
#define KEY_F17 0xF4
|
||||||
|
#define Key_F17 (Key){ KEY_FLAGS, KEY_F17 }
|
||||||
|
#define KEY_F18 0xF5
|
||||||
|
#define Key_F18 (Key){ KEY_FLAGS, KEY_F18 }
|
||||||
|
#define KEY_F19 0xF6
|
||||||
|
#define Key_F19 (Key){ KEY_FLAGS, KEY_F19 }
|
||||||
|
|
||||||
|
#define KEY_HELP 0xfb
|
||||||
|
#define Key_Help (Key){ KEY_FLAGS, KEY_HELP }
|
||||||
|
#define KEY_BACKLIGHT_DOWN 0xF1
|
||||||
|
#define Key_BacklightDown (Key){ KEY_FLAGS, KEY_BACKLIGHT_DOWN }
|
||||||
|
#define KEY_BACKLIGHT_UP 0xF2
|
||||||
|
#define Key_BacklightUp (Key){ KEY_FLAGS, KEY_BACKLIGHT_UP }
|
||||||
|
#define NO_KEY false
|
||||||
|
#define KEY_RIGHT_FN2 0xfe
|
||||||
|
#define Key_RightFN2 (Key){ KEY_FLAGS, KEY_RIGHT_FN2 }
|
||||||
|
#define KEY_LEFT_FN2 0xff
|
||||||
|
#define Key_LeftFN2 (Key){ KEY_FLAGS, KEY_LEFT_FN2 }
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
These keycodes don't seem to map to unique keypresses. we can use them for meta-keys
|
||||||
|
#define KEY_WTF 0xF7
|
||||||
|
#define Key_Wtf (Key){ KEY_FLAGS, KEY_WTF }
|
||||||
|
|
||||||
|
#define xx 0xF8
|
||||||
|
#define Key_Xx (Key){ KEY_FLAGS, xx }
|
||||||
|
#define xxx 0xF9
|
||||||
|
#define Key_Xxx (Key){ KEY_FLAGS, xxx }
|
||||||
|
#define xxxx 0xFA
|
||||||
|
#define Key_Xxxx (Key){ KEY_FLAGS, xxxx }
|
||||||
|
#define xxxxx 0xFE
|
||||||
|
#define Key_Xxxxx (Key){ KEY_FLAGS, xxxxx }
|
||||||
|
#define KEY_ 0xB4
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xB5
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xB6
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xB7
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xB8
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xB9
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xBA
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xBB
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xBC
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xBD
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xBE
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_ 0xBF
|
||||||
|
#define Key_ (Key){ KEY_FLAGS, KEY_ }
|
||||||
|
#define KEY_F13_ALSO 0xC0
|
||||||
|
#define Key_F13_also (Key){ KEY_FLAGS, KEY_F13_ALSO }
|
||||||
|
#define KEY_SLASH_ALSO 0xCE
|
||||||
|
#define Key_Slash_also (Key){ KEY_FLAGS, KEY_SLASH_ALSO }
|
||||||
|
#define KEY_BACKLIGHT_DOWN_ALSO 0xCF
|
||||||
|
#define Key_Backlight_down_also (Key){ KEY_FLAGS, KEY_BACKLIGHT_DOWN_ALSO }
|
||||||
|
#define KEY_BACKLIGHT_UP_ALSO 0xD0
|
||||||
|
#define Key_Backlight_up_also (Key){ KEY_FLAGS, KEY_BACKLIGHT_UP_ALSO }
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define META_NEXT_KEYMAP_MOMENTARY 0xFF
|
||||||
|
#define Key_NextKeymapMomentary (Key){ KEY_FLAGS | MOMENTARY_LAYER, LAYER_1 }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Do not add code below this line
|
||||||
|
#endif /* KeyboardIO_H_ */
|
@ -0,0 +1,7 @@
|
|||||||
|
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
|
||||||
|
|
||||||
|
BOARD_TAG = micro
|
||||||
|
MONITOR_PORT = /dev/cu.usbmodem1411
|
||||||
|
ARDUINO_LIBS =
|
||||||
|
|
||||||
|
include build/arduino-mk/Arduino.mk
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
|||||||
|
# Useful functions
|
||||||
|
# Returns the first argument (typically a directory), if the file or directory
|
||||||
|
# named by concatenating the first and optionally second argument
|
||||||
|
# (directory and optional filename) exists
|
||||||
|
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
|
||||||
|
|
||||||
|
# For message printing: pad the right side of the first argument with spaces to
|
||||||
|
# the number of bytes indicated by the second argument.
|
||||||
|
space_pad_to = $(shell echo $(1) " " | head -c$(2))
|
||||||
|
|
||||||
|
# Call with some text, and a prefix tag if desired (like [AUTODETECTED]),
|
||||||
|
show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1))
|
||||||
|
|
||||||
|
# Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]),
|
||||||
|
# and an explanation if desired (like (found in $$PATH)
|
||||||
|
show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2))
|
||||||
|
|
||||||
|
# Just a nice simple visual separator
|
||||||
|
show_separator = $(call arduino_output,-------------------------)
|
||||||
|
|
||||||
|
$(call show_separator)
|
||||||
|
$(call arduino_output,Arduino.mk Configuration:)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
#
|
||||||
|
# Detect OS
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
CURRENT_OS = WINDOWS
|
||||||
|
else
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
CURRENT_OS = LINUX
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
CURRENT_OS = MAC
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
$(call show_config_variable,CURRENT_OS,[AUTODETECTED])
|
@ -0,0 +1,102 @@
|
|||||||
|
#
|
||||||
|
# chipKIT extensions for Arduino Makefile
|
||||||
|
# System part (i.e. project independent)
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011, 2012, 2013 Christopher Peplin
|
||||||
|
# <chris.peplin@rhubarbtech.com>, based on work that is Copyright Martin
|
||||||
|
# Oldfield
|
||||||
|
#
|
||||||
|
# This file is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Modified by John Wallbank for Visual Studio
|
||||||
|
#
|
||||||
|
# Development changes, John Wallbank,
|
||||||
|
#
|
||||||
|
# - made inclusion of WProgram.h optional so that
|
||||||
|
# including it in the source doesn't mess up compile error line numbers
|
||||||
|
# - parameterised the routine used to reset the serial port
|
||||||
|
#
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Makefile distribution path
|
||||||
|
#
|
||||||
|
|
||||||
|
# The show_config_variable is unavailable before we include the common makefile,
|
||||||
|
# so we defer logging the ARDMK_DIR info until it happens in Arduino.mk
|
||||||
|
ifndef ARDMK_DIR
|
||||||
|
# presume it's a level above the path to our own file
|
||||||
|
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/..)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef ARDMK_PATH
|
||||||
|
ARDMK_PATH = $(ARDMK_DIR)/bin
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(wildcard $(ARDMK_DIR)/arduino-mk/Common.mk),)
|
||||||
|
# git checkout
|
||||||
|
include $(ARDMK_DIR)/arduino-mk/Common.mk
|
||||||
|
else
|
||||||
|
ifneq ($(wildcard $(ARDMK_DIR)/Common.mk),)
|
||||||
|
# package install
|
||||||
|
include $(ARDMK_DIR)/Common.mk
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef MPIDE_DIR
|
||||||
|
AUTO_MPIDE_DIR := $(firstword \
|
||||||
|
$(call dir_if_exists,/usr/share/mpide) \
|
||||||
|
$(call dir_if_exists,/Applications/Mpide.app/Contents/Resources/Java) )
|
||||||
|
ifdef AUTO_MPIDE_DIR
|
||||||
|
MPIDE_DIR = $(AUTO_MPIDE_DIR)
|
||||||
|
$(call show_config_variable,MPIDE_DIR,[autodetected])
|
||||||
|
else
|
||||||
|
echo $(error "mpide_dir is not defined")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(call show_config_variable,MPIDE_DIR,[USER])
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef MPIDE_PREFERENCES_PATH
|
||||||
|
AUTO_MPIDE_PREFERENCES_PATH := $(firstword \
|
||||||
|
$(call dir_if_exists,$(HOME)/.mpide/preferences.txt) \
|
||||||
|
$(call dir_if_exists,$(HOME)/Library/Mpide/preferences.txt) )
|
||||||
|
ifdef AUTO_MPIDE_PREFERENCES_PATH
|
||||||
|
MPIDE_PREFERENCES_PATH = $(AUTO_MPIDE_PREFERENCES_PATH)
|
||||||
|
$(call show_config_variable,MPIDE_PREFERENCES_PATH,[autodetected])
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools
|
||||||
|
|
||||||
|
AVRDUDE_DIR = $(ARDUINO_DIR)/hardware/tools
|
||||||
|
AVRDUDE = $(AVRDUDE_DIR)/avrdude
|
||||||
|
AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf
|
||||||
|
|
||||||
|
ALTERNATE_CORE = pic32
|
||||||
|
ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32
|
||||||
|
ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/$(ALTERNATE_CORE)
|
||||||
|
ARDUINO_PREFERENCES_PATH = $(MPIDE_PREFERENCES_PATH)
|
||||||
|
ARDUINO_DIR = $(MPIDE_DIR)
|
||||||
|
|
||||||
|
ARDUINO_VERSION = 23
|
||||||
|
|
||||||
|
CC_NAME = pic32-gcc
|
||||||
|
CXX_NAME = pic32-g++
|
||||||
|
AR_NAME = pic32-ar
|
||||||
|
OBJDUMP_NAME = pic32-objdump
|
||||||
|
OBJCOPY_NAME = pic32-objcopy
|
||||||
|
SIZE_NAME = pic32-size
|
||||||
|
|
||||||
|
LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript)
|
||||||
|
LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT)
|
||||||
|
|
||||||
|
MCU_FLAG_NAME=mprocessor
|
||||||
|
LDFLAGS += -T$(ARDUINO_CORE_PATH)/$(LDSCRIPT)
|
||||||
|
CPPFLAGS += -mno-smart-io -fno-short-double
|
||||||
|
CFLAGS_STD =
|
||||||
|
|
||||||
|
include $(ARDMK_DIR)/arduino-mk/Arduino.mk
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# usage: reset_arduino <DEVICE>
|
||||||
|
# where <DEVICE> is typically some /dev/ttyfoobar
|
||||||
|
import sys
|
||||||
|
import serial
|
||||||
|
ser = serial.Serial()
|
||||||
|
ser.port=sys.argv[2]
|
||||||
|
ser.baudrate=1200
|
||||||
|
ser.open(); ser.close()
|
||||||
|
|
Loading…
Reference in new issue