diff --git a/arduino_tests/BlueMacro_board_tester/BlueMacro_board_tester.ino b/arduino_tests/BlueMacro_board_tester/BlueMacro_board_tester.ino index 92bd056f..d7b89522 100644 --- a/arduino_tests/BlueMacro_board_tester/BlueMacro_board_tester.ino +++ b/arduino_tests/BlueMacro_board_tester/BlueMacro_board_tester.ino @@ -17,7 +17,8 @@ //BlueMacro -uint8_t pins[] = {43, 3,28,45,30,2,29,26,6,5,8,41,4,12 ,38,10,9,20,17,15,13,22,24,32,7 , 36, 42 }; +//uint8_t pins[] = {43, 3,28,45,30,2,29,26,6,5,8,41,4,12 ,38,10,9,20,17,15,13,22,24,32,7 , 36, 42 }; // version 1 +uint8_t pins[] = {43, 3,28,45,30,2,29,26,6,5,8,41,38,12 ,34,10,9,20,17,15,13,22,24,4,32,7 , 36, 42 }; // version 2 uint8_t pincount = sizeof(pins)/sizeof(pins[0]); BLEDis bledis; diff --git a/arduino_tests/HID-Refactor/HID-Refactor.ino b/arduino_tests/HID-Refactor/HID-Refactor.ino new file mode 100644 index 00000000..7f66aa27 --- /dev/null +++ b/arduino_tests/HID-Refactor/HID-Refactor.ino @@ -0,0 +1,163 @@ +/********************************************************************* + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + MIT license, check LICENSE for more information + Copyright (c) 2019 Ha Thach for Adafruit Industries + All text above, and the splash screen below must be included in + any redistribution +*********************************************************************/ +#ifdef NRF52840_XXAA // only the 840 has USB available. + #include "Adafruit_TinyUSB.h" +#endif +#include "hid_queues.h" +#include "std_fix.h" +#include + +BLEDis bledis; +BLEHidAdafruit blehid; + + +#ifdef NRF52840_XXAA // only the 840 has USB available. + // USB HID object. For ESP32 these values cannot be changed after this declaration + // desc report, desc len, protocol, interval, use out endpoint + Adafruit_USBD_HID usb_hid(desc_hid_report, sizeof(desc_hid_report), HID_ITF_PROTOCOL_NONE, 2, false); + + HID_Queues hid (&usb_hid,&blehid); +#else + HID_Queues hid (&blehid); +#endif + +const int pin = 7; // UserSw +bool activeState = false; + +void setupBLE() +{ + Bluefruit.begin(); + Bluefruit.setTxPower(4); // Check bluefruit.h for supported values + bledis.setManufacturer("Adafruit Industries"); + bledis.setModel("Bluefruit Feather 52"); + bledis.begin(); + blehid.begin(); + blehid.setKeyboardLedCallback(set_keyboard_led); + startAdv(); +} + +void startAdv(void) +{ + // Advertising packet + Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); + Bluefruit.Advertising.addTxPower(); + Bluefruit.Advertising.addAppearance(BLE_APPEARANCE_HID_KEYBOARD); + + // Include BLE HID service + Bluefruit.Advertising.addService(blehid); + + // There is enough room for the dev name in the advertising packet + Bluefruit.Advertising.addName(); + + /* Start Advertising + * - Enable auto advertising if disconnected + * - Interval: fast mode = 20 ms, slow mode = 152.5 ms + * - Timeout for fast mode is 30 seconds + * - Start(timeout) with timeout = 0 will advertise forever (until connected) + * + * For recommended advertising interval + * https://developer.apple.com/library/content/qa/qa1931/_index.html + */ + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms + Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode + Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds +} + +void set_keyboard_led(uint16_t conn_handle, uint8_t led_bitmap) +{ + (void) conn_handle; + + // light up Red Led if any bits is set + if ( led_bitmap ) + { + ledOn( LED_RED ); + } + else + { + ledOff( LED_RED ); + } +} + +// the setup function runs once when you press reset or power the board +void setup() +{ + // Notes: following commented-out functions has no affect on ESP32 + // usb_hid.setPollInterval(2); + // usb_hid.setReportDescriptor(); + // usb_hid.setStringDescriptor("TinyUSB HID Composite"); + +#ifdef NRF52840_XXAA // only the 840 has USB available. + usb_hid.begin(); +#endif + setupBLE(); + // Set up button, pullup opposite to active state + pinMode(pin, activeState ? INPUT_PULLDOWN : INPUT_PULLUP); + + Serial.begin(115200); + Serial.println("Adafruit TinyUSB HID Composite example"); +} + +void loop() +{ + // poll gpio once each 10 ms + delay(10); + + // Whether button is pressed + bool btn_pressed = (digitalRead(pin) == activeState); + + /*------------- Mouse -------------*/ + if (btn_pressed ) + { + int8_t const delta = 5; + hid.mouseMove(delta, delta); // right + down + } + + /*------------- Keyboard -------------*/ + // use to send key release report + static bool has_key = false; + + if ( btn_pressed ) + { + uint8_t keycode[6] = { 0 }; + keycode[0] = HID_KEY_A; + + hid.keyboardReport(0, keycode); + + has_key = true; + }else + { + // send empty key report if previously has key pressed + if (has_key) hid.keyboardRelease(); + has_key = false; + } + + // Consumer Control is used to control Media playback, Volume, Brightness etc ... + // Consumer report is 2-byte containing the control code of the key + // For list of control check out https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid.h + + // use to send consumer release report + static bool has_consumer_key = false; + + if ( btn_pressed ) + { + // send volume down (0x00EA) + hid.consumerKeyPress(HID_USAGE_CONSUMER_VOLUME_DECREMENT); + has_consumer_key = true; + }else + { + // release the consume key by sending zero (0x0000) + if (has_consumer_key) hid.consumerKeyRelease(); + has_consumer_key = false; + } + + hid.processQueues(CONNECTION_MODE_AUTO); +} diff --git a/arduino_tests/HID-Refactor/hid_data_structures.h b/arduino_tests/HID-Refactor/hid_data_structures.h new file mode 100644 index 00000000..f4b2e325 --- /dev/null +++ b/arduino_tests/HID-Refactor/hid_data_structures.h @@ -0,0 +1,102 @@ +#ifndef HID_DATA_STRUCTURES_H +#define HID_DATA_STRUCTURES_H +#include + +// Report ID +enum +{ + RID_KEYBOARD = 1, + RID_MOUSE, + RID_CONSUMER_CONTROL, // Media, volume etc .. +}; + +enum connectionState { CONNECTION_NONE, CONNECTION_USB, CONNECTION_BLE }; + +enum connectionMode { CONNECTION_MODE_AUTO, CONNECTION_MODE_USB_ONLY, CONNECTION_MODE_BLE_ONLY }; + +struct HIDKeyboard { + uint8_t modifier; + uint8_t keycode[6]; + + bool operator!= (const HIDKeyboard &c2) + { + return !(*this == c2); + } + + inline bool operator== (const HIDKeyboard &c2) + { + return (keycode[0]==c2.keycode[0]) && + (modifier==c2.modifier ) && + (keycode[1]==c2.keycode[1]) && + (keycode[2]==c2.keycode[2]) && + (keycode[3]==c2.keycode[3]) && + (keycode[4]==c2.keycode[4]) && + (keycode[5]==c2.keycode[5]) ; + + } + } ; + + +struct HIDMouse { + uint8_t buttons; + int8_t x; + int8_t y; + int8_t wheel; + int8_t pan; + + bool operator!= (const HIDMouse &c2) + { + return !(*this == c2); + } + + inline bool operator== (const HIDMouse &c2) + { + return (buttons==c2.buttons) && + (x==c2.x) && + (y==c2.y) && + (wheel==c2.wheel) && + (pan==c2.pan) ; + } + } ; + + +struct HIDConsumer { + uint16_t usage_code; + + bool operator!= (const HIDConsumer &c2) + { + return !(*this == c2); + } + + inline bool operator== (const HIDConsumer &c2) + { + return (usage_code==c2.usage_code); + } + } ; + + +struct HIDGamepad { + int8_t x; + int8_t y; + int8_t z; + int8_t rz; + int8_t rx; + int8_t r; + + bool operator!= (const HIDGamepad &c2) + { + return !(*this == c2); + } + + inline bool operator== (const HIDGamepad &c2) + { + return (x==c2.x) && + (y==c2.y) && + (z==c2.z) && + (rz==c2.rz) && + (rx==c2.rx) && + (r==c2.r) ; + } + } ; + +#endif /* HID_DATA_STRUCTURES_H */ diff --git a/arduino_tests/HID-Refactor/hid_queues.cpp b/arduino_tests/HID-Refactor/hid_queues.cpp new file mode 100644 index 00000000..126b4317 --- /dev/null +++ b/arduino_tests/HID-Refactor/hid_queues.cpp @@ -0,0 +1,355 @@ +#include "hid_queues.h" + +HID_Queues::HID_Queues() +{ + ; +} + +HID_Queues::HID_Queues(BLEHidAdafruit* ble_hid) +{ + ble_hid_driver = ble_hid; +} + +#ifdef NRF52840_XXAA // only the 840 has USB available. +HID_Queues::HID_Queues(Adafruit_USBD_HID* usb_hid) +{ + usb_hid_driver = usb_hid; +} + +HID_Queues::HID_Queues(Adafruit_USBD_HID* usb_hid, BLEHidAdafruit* ble_hid) +{ + usb_hid_driver = usb_hid; + ble_hid_driver = ble_hid; +} +#endif + +void HID_Queues::keyboardReport(HIDKeyboard* report) +{ + addKeyboardReport(report); +} + +void HID_Queues::keyboardReport(uint8_t modifier, uint8_t keycode[6]) +{ + HIDKeyboard report = + { + .modifier = modifier, + }; + memcpy(report.keycode, keycode, 6); + keyboardReport(&report); +} + +void HID_Queues::keyboardPress(char ch) +{ + HIDKeyboard report; + report.keycode[0] = 0; + report.keycode[1] = 0; + report.keycode[2] = 0; + report.keycode[3] = 0; + report.keycode[4] = 0; + report.keycode[5] = 0; + + report.modifier = ( hid_ascii_to_keycode[(uint8_t)ch][0] ) ? KEYBOARD_MODIFIER_LEFTSHIFT : 0; + report.keycode[0] = hid_ascii_to_keycode[(uint8_t)ch][1]; + keyboardReport(&report); +} + +void HID_Queues::keyboardRelease() +{ + HIDKeyboard report; + report.modifier = 0; + report.keycode[0] = 0; + report.keycode[1] = 0; + report.keycode[2] = 0; + report.keycode[3] = 0; + report.keycode[4] = 0; + report.keycode[5] = 0; + keyboardReport(&report); +} + +void HID_Queues::keySequence(const char* str) +{ + // Send each key in sequence + char ch; + while( (ch = *str++) != 0 ) + { + char lookahead = *str; + keyboardPress(ch); + + /* Only need to empty report if the next character is NULL or the same with + * the current one, else no need to send */ + if ( lookahead == ch || lookahead == 0 ) + { + keyboardRelease(); + } + } +} + +void HID_Queues::consumerReport(HIDConsumer* report) +{ + addConsumerReport(report); +} + +void HID_Queues::consumerReport(uint16_t usage_code) +{ + HIDConsumer report = + { + .usage_code = usage_code, + }; + consumerReport(&report); +} + +void HID_Queues::consumerKeyPress(uint16_t usage_code) +{ + consumerReport(usage_code); +} + +void HID_Queues::consumerKeyRelease() +{ + uint16_t code = 0; + consumerReport(code); +} + +void HID_Queues::mouseReport(HIDMouse* report) +{ + addMouseReport(report); +} + +void HID_Queues::mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wheel, int8_t pan) +{ + HIDMouse report; + report.buttons = buttons; + report.x = x; + report.y = y; + report.wheel = wheel; + report.pan = pan; + mouseReport(&report); +} + +void HID_Queues::mouseButtonPress(uint8_t buttons) +{ + mouseReport(buttons, 0, 0, 0, 0); +} + +void HID_Queues::mouseButtonRelease() +{ + mouseReport(0,0,0,0,0); +} + +void HID_Queues::mouseMove(int8_t x, int8_t y) +{ + mouseReport(0,x,y,0,0); +} + +void HID_Queues::mouseScroll(int8_t wheel) +{ + mouseReport(0, 0, 0, wheel,0) ; +} + +void HID_Queues::mousePan(int8_t pan) +{ + mouseReport(0, 0, 0, 0, pan); +} + +HIDKeyboard HID_Queues::getKeyboardReport() +{ + HIDKeyboard reportdata = keycode_queue.back(); + keycode_queue.pop_back(); + return reportdata; +} + +HIDMouse HID_Queues::getMouseReport() +{ + HIDMouse reportdata = mouse_queue.back(); + mouse_queue.pop_back(); + return reportdata; +} + +HIDConsumer HID_Queues::getConsumerReport() +{ + HIDConsumer reportdata = consumer_queue.back(); + consumer_queue.pop_back(); + return reportdata; +} + +HIDGamepad HID_Queues::getGamepadReport() +{ + HIDGamepad reportdata = gamepad_queue.back(); + gamepad_queue.pop_back(); + return reportdata; +} + +bool HID_Queues::isKeyboardQueueEmpty() +{ + return keycode_queue.empty(); +} + +bool HID_Queues::isMouseQueueEmpty() +{ + return mouse_queue.empty(); +} + +bool HID_Queues::isConsumerQueueEmpty() +{ + return consumer_queue.empty(); +} + +bool HID_Queues::isGamepadQueueEmpty() +{ + return gamepad_queue.empty(); +} + +void HID_Queues::clearKeyboardQueue() +{ + keycode_queue.clear(); +} + +void HID_Queues::clearMouseQueue() +{ + mouse_queue.clear(); +} + +void HID_Queues::clearConsumerQueue() +{ + consumer_queue.clear(); +} + +void HID_Queues::clearGamepadQueue() +{ + gamepad_queue.clear(); +} +#ifdef NRF52840_XXAA // only the 840 has USB available. +void HID_Queues::processQueuesWithUSB() +{ + // Remote wakeup + if (( TinyUSBDevice.suspended() && ((!isMouseQueueEmpty()) || (!isKeyboardQueueEmpty()) || (!isConsumerQueueEmpty())) )) + { + // Wake up host if we are in suspend mode + // and REMOTE_WAKEUP feature is enabled by host + TinyUSBDevice.remoteWakeup(); + } + if ( usb_hid_driver->ready() && !isMouseQueueEmpty()) + { + HIDMouse ms_report; + ms_report = getMouseReport(); + usb_hid_driver->mouseReport(RID_MOUSE, ms_report.buttons, ms_report.x, ms_report.y, ms_report.wheel, ms_report.pan); + delay(10); + } + if ( usb_hid_driver->ready() && !isKeyboardQueueEmpty()) + { + HIDKeyboard kb_report; + kb_report = getKeyboardReport(); + usb_hid_driver->keyboardReport(RID_KEYBOARD, kb_report.modifier, kb_report.keycode); + delay(10); + } + if ( usb_hid_driver->ready() && !isConsumerQueueEmpty()) + { + HIDConsumer cs_report; + cs_report = getConsumerReport(); + usb_hid_driver->sendReport16(RID_CONSUMER_CONTROL, cs_report.usage_code); + delay(10); + } +} +#endif + +void HID_Queues::processQueuesWithBLE() +{ + if ( !isMouseQueueEmpty()) + { + HIDMouse ms_report; + ms_report = getMouseReport(); + ble_hid_driver->mouseReport(ms_report.buttons, ms_report.x, ms_report.y, ms_report.wheel, ms_report.pan); + delay(10); + } + if ( !isKeyboardQueueEmpty()) + { + HIDKeyboard kb_report; + kb_report = getKeyboardReport(); + ble_hid_driver->keyboardReport(kb_report.modifier, kb_report.keycode); + delay(10); + } + if ( !isConsumerQueueEmpty()) + { + HIDConsumer cs_report; + cs_report = getConsumerReport(); + ble_hid_driver->consumerReport(cs_report.usage_code); + delay(10); + } +} +void HID_Queues::processQueues(connectionMode mode) +{ + switch (mode) + { + case CONNECTION_MODE_BLE_ONLY: + connection = CONNECTION_BLE; + break; + case CONNECTION_MODE_USB_ONLY: + connection = CONNECTION_USB; + break; + case CONNECTION_MODE_AUTO: + connection = CONNECTION_NONE; + // if BLE connected + if (Bluefruit.connected()) + { + connection = CONNECTION_BLE; + } + // if USB connected + #ifdef NRF52840_XXAA // only the 840 has USB available. + if (TinyUSBDevice.mounted()) + { + connection = CONNECTION_USB; + } + #endif + break; + default: + break; + } + + switch(connection) + { + case CONNECTION_NONE: + break; + case CONNECTION_USB: + #ifdef NRF52840_XXAA // only the 840 has USB available. + processQueuesWithUSB(); + #endif + break; + case CONNECTION_BLE: + processQueuesWithBLE(); + break; + default: + break; + + } + +} + +// PRIVATE FUNCTIONS +void HID_Queues::addKeyboardReport(HIDKeyboard* report) +{ + auto it = keycode_queue.begin(); + it = keycode_queue.insert(it, *report); +} + +void HID_Queues::addMouseReport(HIDMouse* report) +{ + auto it = mouse_queue.begin(); + it = mouse_queue.insert(it, *report); +} + +void HID_Queues::addConsumerReport(HIDConsumer* report) +{ + auto it = consumer_queue.begin(); + it = consumer_queue.insert(it, *report); +} + +void HID_Queues::addGamepadReport(HIDGamepad* report) +{ + auto it = gamepad_queue.begin(); + it = gamepad_queue.insert(it, *report); +} + + +std::vector HID_Queues::keycode_queue; +std::vector HID_Queues::mouse_queue; +std::vector HID_Queues::consumer_queue; +std::vector HID_Queues::gamepad_queue; diff --git a/arduino_tests/HID-Refactor/hid_queues.h b/arduino_tests/HID-Refactor/hid_queues.h new file mode 100644 index 00000000..5b820335 --- /dev/null +++ b/arduino_tests/HID-Refactor/hid_queues.h @@ -0,0 +1,102 @@ +#ifndef HID_QUEUE_H +#define HID_QUEUE_H +#include +#include +#include +#include +#include "hid_data_structures.h" +#include +#ifdef NRF52840_XXAA // only the 840 has USB available. +#include "Adafruit_TinyUSB.h" +#endif +#include "hid_utils.h" + +#ifdef NRF52840_XXAA // only the 840 has USB available. +// HID report descriptor using TinyUSB's template +uint8_t const desc_hid_report[] = +{ + TUD_HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(RID_KEYBOARD) ), + TUD_HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(RID_MOUSE) ), + TUD_HID_REPORT_DESC_CONSUMER( HID_REPORT_ID(RID_CONSUMER_CONTROL) ) +}; +#endif + +class HID_Queues { + public: + HID_Queues(); + HID_Queues(BLEHidAdafruit* ble_hid); + #ifdef NRF52840_XXAA // only the 840 has USB available. + HID_Queues(Adafruit_USBD_HID* usb_hid); + HID_Queues(Adafruit_USBD_HID* usb_hid, BLEHidAdafruit* ble_hid); + #endif + + + // keyboard functions to add to queue + void keyboardReport(HIDKeyboard* report); + void keyboardReport(uint8_t modifier, uint8_t keycode[6]); + void keyboardPress(char ch); + void keyboardRelease(); + void keySequence(const char* str); + + // consumer functions to add to queue + void consumerReport(HIDConsumer* report); + void consumerReport(uint16_t usage_code); + void consumerKeyPress(uint16_t usage_code); + void consumerKeyRelease(); + + // mouse functions to add to queue + void mouseReport(HIDMouse* report); + void mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wheel, int8_t pan); + void mouseButtonPress(uint8_t buttons); + void mouseButtonRelease(); + void mouseMove(int8_t x, int8_t y); + void mouseScroll(int8_t wheel); + void mousePan(int8_t pan); + + // gamepad functions to add to queue + //gamepadreportButtons(uint32_t button_mask); + //gamepadreportHat(uint8_t hat); + //gamepadreportJoystick(int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry); + + // Functions to retreive from queues + HIDKeyboard getKeyboardReport(); + HIDMouse getMouseReport(); + HIDConsumer getConsumerReport(); + HIDGamepad getGamepadReport(); + + // Functions to see if queue has data + bool isKeyboardQueueEmpty(); + bool isMouseQueueEmpty(); + bool isConsumerQueueEmpty(); + bool isGamepadQueueEmpty(); + + // Empty queues from data + void clearKeyboardQueue(); + void clearMouseQueue(); + void clearConsumerQueue(); + void clearGamepadQueue(); + + #ifdef NRF52840_XXAA // only the 840 has USB available. + void processQueuesWithUSB(); + #endif + void processQueuesWithBLE(); + void processQueues(connectionMode mode); + + private: + void addKeyboardReport(HIDKeyboard* report); + void addMouseReport(HIDMouse* report); + void addConsumerReport(HIDConsumer* report); + void addGamepadReport(HIDGamepad* report); + connectionState connection; + + static std::vector keycode_queue; + static std::vector mouse_queue; + static std::vector consumer_queue; + static std::vector gamepad_queue; + #ifdef NRF52840_XXAA // only the 840 has USB available. + Adafruit_USBD_HID* usb_hid_driver; + #endif + BLEHidAdafruit* ble_hid_driver; + }; + +#endif /* HID_QUEUE_H */ diff --git a/arduino_tests/HID-Refactor/hid_utils.h b/arduino_tests/HID-Refactor/hid_utils.h new file mode 100644 index 00000000..d6b66e1c --- /dev/null +++ b/arduino_tests/HID-Refactor/hid_utils.h @@ -0,0 +1,397 @@ + +#define KEYBOARD_MODIFIER_LEFTCTRL 1<<0 +#define KEYBOARD_MODIFIER_LEFTSHIFT 1<<1 +#define KEYBOARD_MODIFIER_LEFTALT 1<<2 +#define KEYBOARD_MODIFIER_LEFTGUI 1<<3 +#define KEYBOARD_MODIFIER_RIGHTCTRL 1<<4 +#define KEYBOARD_MODIFIER_RIGHTSHIFT 1<<5 +#define KEYBOARD_MODIFIER_RIGHTALT 1<<6 +#define KEYBOARD_MODIFIER_RIGHTGUI 1<<7 + +#define HID_KEY_NONE 0x00 +#define HID_KEY_A 0x04 +#define HID_KEY_B 0x05 +#define HID_KEY_C 0x06 +#define HID_KEY_D 0x07 +#define HID_KEY_E 0x08 +#define HID_KEY_F 0x09 +#define HID_KEY_G 0x0A +#define HID_KEY_H 0x0B +#define HID_KEY_I 0x0C +#define HID_KEY_J 0x0D +#define HID_KEY_K 0x0E +#define HID_KEY_L 0x0F +#define HID_KEY_M 0x10 +#define HID_KEY_N 0x11 +#define HID_KEY_O 0x12 +#define HID_KEY_P 0x13 +#define HID_KEY_Q 0x14 +#define HID_KEY_R 0x15 +#define HID_KEY_S 0x16 +#define HID_KEY_T 0x17 +#define HID_KEY_U 0x18 +#define HID_KEY_V 0x19 +#define HID_KEY_W 0x1A +#define HID_KEY_X 0x1B +#define HID_KEY_Y 0x1C +#define HID_KEY_Z 0x1D +#define HID_KEY_1 0x1E +#define HID_KEY_2 0x1F +#define HID_KEY_3 0x20 +#define HID_KEY_4 0x21 +#define HID_KEY_5 0x22 +#define HID_KEY_6 0x23 +#define HID_KEY_7 0x24 +#define HID_KEY_8 0x25 +#define HID_KEY_9 0x26 +#define HID_KEY_0 0x27 +#define HID_KEY_RETURN 0x28 +#define HID_KEY_ESCAPE 0x29 +#define HID_KEY_BACKSPACE 0x2A +#define HID_KEY_TAB 0x2B +#define HID_KEY_SPACE 0x2C +#define HID_KEY_MINUS 0x2D +#define HID_KEY_EQUAL 0x2E +#define HID_KEY_BRACKET_LEFT 0x2F +#define HID_KEY_BRACKET_RIGHT 0x30 +#define HID_KEY_BACKSLASH 0x31 +#define HID_KEY_EUROPE_1 0x32 +#define HID_KEY_SEMICOLON 0x33 +#define HID_KEY_APOSTROPHE 0x34 +#define HID_KEY_GRAVE 0x35 +#define HID_KEY_COMMA 0x36 +#define HID_KEY_PERIOD 0x37 +#define HID_KEY_SLASH 0x38 +#define HID_KEY_CAPS_LOCK 0x39 +#define HID_KEY_F1 0x3A +#define HID_KEY_F2 0x3B +#define HID_KEY_F3 0x3C +#define HID_KEY_F4 0x3D +#define HID_KEY_F5 0x3E +#define HID_KEY_F6 0x3F +#define HID_KEY_F7 0x40 +#define HID_KEY_F8 0x41 +#define HID_KEY_F9 0x42 +#define HID_KEY_F10 0x43 +#define HID_KEY_F11 0x44 +#define HID_KEY_F12 0x45 +#define HID_KEY_PRINT_SCREEN 0x46 +#define HID_KEY_SCROLL_LOCK 0x47 +#define HID_KEY_PAUSE 0x48 +#define HID_KEY_INSERT 0x49 +#define HID_KEY_HOME 0x4A +#define HID_KEY_PAGE_UP 0x4B +#define HID_KEY_DELETE 0x4C +#define HID_KEY_END 0x4D +#define HID_KEY_PAGE_DOWN 0x4E +#define HID_KEY_ARROW_RIGHT 0x4F +#define HID_KEY_ARROW_LEFT 0x50 +#define HID_KEY_ARROW_DOWN 0x51 +#define HID_KEY_ARROW_UP 0x52 +#define HID_KEY_NUM_LOCK 0x53 +#define HID_KEY_KEYPAD_DIVIDE 0x54 +#define HID_KEY_KEYPAD_MULTIPLY 0x55 +#define HID_KEY_KEYPAD_SUBTRACT 0x56 +#define HID_KEY_KEYPAD_ADD 0x57 +#define HID_KEY_KEYPAD_ENTER 0x58 +#define HID_KEY_KEYPAD_1 0x59 +#define HID_KEY_KEYPAD_2 0x5A +#define HID_KEY_KEYPAD_3 0x5B +#define HID_KEY_KEYPAD_4 0x5C +#define HID_KEY_KEYPAD_5 0x5D +#define HID_KEY_KEYPAD_6 0x5E +#define HID_KEY_KEYPAD_7 0x5F +#define HID_KEY_KEYPAD_8 0x60 +#define HID_KEY_KEYPAD_9 0x61 +#define HID_KEY_KEYPAD_0 0x62 +#define HID_KEY_KEYPAD_DECIMAL 0x63 +#define HID_KEY_EUROPE_2 0x64 +#define HID_KEY_APPLICATION 0x65 +#define HID_KEY_POWER 0x66 +#define HID_KEY_KEYPAD_EQUAL 0x67 +#define HID_KEY_F13 0x68 +#define HID_KEY_F14 0x69 +#define HID_KEY_F15 0x6A +#define HID_KEY_CONTROL_LEFT 0xE0 +#define HID_KEY_SHIFT_LEFT 0xE1 +#define HID_KEY_ALT_LEFT 0xE2 +#define HID_KEY_GUI_LEFT 0xE3 +#define HID_KEY_CONTROL_RIGHT 0xE4 +#define HID_KEY_SHIFT_RIGHT 0xE5 +#define HID_KEY_ALT_RIGHT 0xE6 +#define HID_KEY_GUI_RIGHT 0xE7 + +/*-------------------------------------------------------------------- + * KEYCODE to Ascii Conversion + * Expand to array of [128][2] (ascii without shift, ascii with shift) + * + * Usage: example to convert ascii from keycode (key) and shift modifier (shift). + * Here we assume key < 128 ( printable ) + * + * uint8_t const conv_table[128][2] = { HID_KEYCODE_TO_ASCII }; + * char ch = shift ? conv_table[chr][1] : conv_table[chr][0]; + * + *--------------------------------------------------------------------*/ +#define HID_KEYCODE_TO_ASCII \ + {0 , 0 }, /* 0x00 */ \ + {0 , 0 }, /* 0x01 */ \ + {0 , 0 }, /* 0x02 */ \ + {0 , 0 }, /* 0x03 */ \ + {'a' , 'A' }, /* 0x04 */ \ + {'b' , 'B' }, /* 0x05 */ \ + {'c' , 'C' }, /* 0x06 */ \ + {'d' , 'D' }, /* 0x07 */ \ + {'e' , 'E' }, /* 0x08 */ \ + {'f' , 'F' }, /* 0x09 */ \ + {'g' , 'G' }, /* 0x0a */ \ + {'h' , 'H' }, /* 0x0b */ \ + {'i' , 'I' }, /* 0x0c */ \ + {'j' , 'J' }, /* 0x0d */ \ + {'k' , 'K' }, /* 0x0e */ \ + {'l' , 'L' }, /* 0x0f */ \ + {'m' , 'M' }, /* 0x10 */ \ + {'n' , 'N' }, /* 0x11 */ \ + {'o' , 'O' }, /* 0x12 */ \ + {'p' , 'P' }, /* 0x13 */ \ + {'q' , 'Q' }, /* 0x14 */ \ + {'r' , 'R' }, /* 0x15 */ \ + {'s' , 'S' }, /* 0x16 */ \ + {'t' , 'T' }, /* 0x17 */ \ + {'u' , 'U' }, /* 0x18 */ \ + {'v' , 'V' }, /* 0x19 */ \ + {'w' , 'W' }, /* 0x1a */ \ + {'x' , 'X' }, /* 0x1b */ \ + {'y' , 'Y' }, /* 0x1c */ \ + {'z' , 'Z' }, /* 0x1d */ \ + {'1' , '!' }, /* 0x1e */ \ + {'2' , '@' }, /* 0x1f */ \ + {'3' , '#' }, /* 0x20 */ \ + {'4' , '$' }, /* 0x21 */ \ + {'5' , '%' }, /* 0x22 */ \ + {'6' , '^' }, /* 0x23 */ \ + {'7' , '&' }, /* 0x24 */ \ + {'8' , '*' }, /* 0x25 */ \ + {'9' , '(' }, /* 0x26 */ \ + {'0' , ')' }, /* 0x27 */ \ + {'\r' , '\r' }, /* 0x28 */ \ + {'\x1b', '\x1b' }, /* 0x29 */ \ + {'\b' , '\b' }, /* 0x2a */ \ + {'\t' , '\t' }, /* 0x2b */ \ + {' ' , ' ' }, /* 0x2c */ \ + {'-' , '_' }, /* 0x2d */ \ + {'=' , '+' }, /* 0x2e */ \ + {'[' , '{' }, /* 0x2f */ \ + {']' , '}' }, /* 0x30 */ \ + {'\\' , '|' }, /* 0x31 */ \ + {'#' , '~' }, /* 0x32 */ \ + {';' , ':' }, /* 0x33 */ \ + {'\'' , '\"' }, /* 0x34 */ \ + {0 , 0 }, /* 0x35 */ \ + {',' , '<' }, /* 0x36 */ \ + {'.' , '>' }, /* 0x37 */ \ + {'/' , '?' }, /* 0x38 */ \ + \ + {0 , 0 }, /* 0x39 */ \ + {0 , 0 }, /* 0x3a */ \ + {0 , 0 }, /* 0x3b */ \ + {0 , 0 }, /* 0x3c */ \ + {0 , 0 }, /* 0x3d */ \ + {0 , 0 }, /* 0x3e */ \ + {0 , 0 }, /* 0x3f */ \ + {0 , 0 }, /* 0x40 */ \ + {0 , 0 }, /* 0x41 */ \ + {0 , 0 }, /* 0x42 */ \ + {0 , 0 }, /* 0x43 */ \ + {0 , 0 }, /* 0x44 */ \ + {0 , 0 }, /* 0x45 */ \ + {0 , 0 }, /* 0x46 */ \ + {0 , 0 }, /* 0x47 */ \ + {0 , 0 }, /* 0x48 */ \ + {0 , 0 }, /* 0x49 */ \ + {0 , 0 }, /* 0x4a */ \ + {0 , 0 }, /* 0x4b */ \ + {0 , 0 }, /* 0x4c */ \ + {0 , 0 }, /* 0x4d */ \ + {0 , 0 }, /* 0x4e */ \ + {0 , 0 }, /* 0x4f */ \ + {0 , 0 }, /* 0x50 */ \ + {0 , 0 }, /* 0x51 */ \ + {0 , 0 }, /* 0x52 */ \ + {0 , 0 }, /* 0x53 */ \ + \ + {'/' , '/' }, /* 0x54 */ \ + {'*' , '*' }, /* 0x55 */ \ + {'-' , '-' }, /* 0x56 */ \ + {'+' , '+' }, /* 0x57 */ \ + {'\r' , '\r' }, /* 0x58 */ \ + {'1' , 0 }, /* 0x59 */ \ + {'2' , 0 }, /* 0x5a */ \ + {'3' , 0 }, /* 0x5b */ \ + {'4' , 0 }, /* 0x5c */ \ + {'5' , '5' }, /* 0x5d */ \ + {'6' , 0 }, /* 0x5e */ \ + {'7' , 0 }, /* 0x5f */ \ + {'8' , 0 }, /* 0x60 */ \ + {'9' , 0 }, /* 0x61 */ \ + {'0' , 0 }, /* 0x62 */ \ + {'0' , 0 }, /* 0x63 */ \ + {'=' , '=' }, /* 0x67 */ \ + + + +/*-------------------------------------------------------------------- + * ASCII to KEYCODE Conversion + * Expand to array of [128][2] (shift, keycode) + * + * Usage: example to convert input chr into keyboard report (modifier + keycode) + * + * uint8_t const conv_table[128][2] = { HID_ASCII_TO_KEYCODE }; + * + * uint8_t keycode[6] = { 0 }; + * uint8_t modifier = 0; + * + * if ( conv_table[chr][0] ) modifier = KEYBOARD_MODIFIER_LEFTSHIFT; + * keycode[0] = conv_table[chr][1]; + * tud_hid_keyboard_report(report_id, modifier, keycode); + * + *--------------------------------------------------------------------*/ +#define HID_ASCII_TO_KEYCODE \ + {0, 0 }, /* 0x00 Null */ \ + {0, 0 }, /* 0x01 */ \ + {0, 0 }, /* 0x02 */ \ + {0, 0 }, /* 0x03 */ \ + {0, 0 }, /* 0x04 */ \ + {0, 0 }, /* 0x05 */ \ + {0, 0 }, /* 0x06 */ \ + {0, 0 }, /* 0x07 */ \ + {0, HID_KEY_BACKSPACE }, /* 0x08 Backspace */ \ + {0, HID_KEY_TAB }, /* 0x09 Tab */ \ + {0, HID_KEY_RETURN }, /* 0x0A Line Feed */ \ + {0, 0 }, /* 0x0B */ \ + {0, 0 }, /* 0x0C */ \ + {0, HID_KEY_RETURN }, /* 0x0D CR */ \ + {0, 0 }, /* 0x0E */ \ + {0, 0 }, /* 0x0F */ \ + {0, 0 }, /* 0x10 */ \ + {0, 0 }, /* 0x11 */ \ + {0, 0 }, /* 0x12 */ \ + {0, 0 }, /* 0x13 */ \ + {0, 0 }, /* 0x14 */ \ + {0, 0 }, /* 0x15 */ \ + {0, 0 }, /* 0x16 */ \ + {0, 0 }, /* 0x17 */ \ + {0, 0 }, /* 0x18 */ \ + {0, 0 }, /* 0x19 */ \ + {0, 0 }, /* 0x1A */ \ + {0, HID_KEY_ESCAPE }, /* 0x1B Escape */ \ + {0, 0 }, /* 0x1C */ \ + {0, 0 }, /* 0x1D */ \ + {0, 0 }, /* 0x1E */ \ + {0, 0 }, /* 0x1F */ \ + \ + {0, HID_KEY_SPACE }, /* 0x20 */ \ + {1, HID_KEY_1 }, /* 0x21 ! */ \ + {1, HID_KEY_APOSTROPHE }, /* 0x22 " */ \ + {1, HID_KEY_3 }, /* 0x23 # */ \ + {1, HID_KEY_4 }, /* 0x24 $ */ \ + {1, HID_KEY_5 }, /* 0x25 % */ \ + {1, HID_KEY_7 }, /* 0x26 & */ \ + {0, HID_KEY_APOSTROPHE }, /* 0x27 ' */ \ + {1, HID_KEY_9 }, /* 0x28 ( */ \ + {1, HID_KEY_0 }, /* 0x29 ) */ \ + {1, HID_KEY_8 }, /* 0x2A * */ \ + {1, HID_KEY_EQUAL }, /* 0x2B + */ \ + {0, HID_KEY_COMMA }, /* 0x2C , */ \ + {0, HID_KEY_MINUS }, /* 0x2D - */ \ + {0, HID_KEY_PERIOD }, /* 0x2E . */ \ + {0, HID_KEY_SLASH }, /* 0x2F / */ \ + {0, HID_KEY_0 }, /* 0x30 0 */ \ + {0, HID_KEY_1 }, /* 0x31 1 */ \ + {0, HID_KEY_2 }, /* 0x32 2 */ \ + {0, HID_KEY_3 }, /* 0x33 3 */ \ + {0, HID_KEY_4 }, /* 0x34 4 */ \ + {0, HID_KEY_5 }, /* 0x35 5 */ \ + {0, HID_KEY_6 }, /* 0x36 6 */ \ + {0, HID_KEY_7 }, /* 0x37 7 */ \ + {0, HID_KEY_8 }, /* 0x38 8 */ \ + {0, HID_KEY_9 }, /* 0x39 9 */ \ + {1, HID_KEY_SEMICOLON }, /* 0x3A : */ \ + {0, HID_KEY_SEMICOLON }, /* 0x3B ; */ \ + {1, HID_KEY_COMMA }, /* 0x3C < */ \ + {0, HID_KEY_EQUAL }, /* 0x3D = */ \ + {1, HID_KEY_PERIOD }, /* 0x3E > */ \ + {1, HID_KEY_SLASH }, /* 0x3F ? */ \ + \ + {1, HID_KEY_2 }, /* 0x40 @ */ \ + {1, HID_KEY_A }, /* 0x41 A */ \ + {1, HID_KEY_B }, /* 0x42 B */ \ + {1, HID_KEY_C }, /* 0x43 C */ \ + {1, HID_KEY_D }, /* 0x44 D */ \ + {1, HID_KEY_E }, /* 0x45 E */ \ + {1, HID_KEY_F }, /* 0x46 F */ \ + {1, HID_KEY_G }, /* 0x47 G */ \ + {1, HID_KEY_H }, /* 0x48 H */ \ + {1, HID_KEY_I }, /* 0x49 I */ \ + {1, HID_KEY_J }, /* 0x4A J */ \ + {1, HID_KEY_K }, /* 0x4B K */ \ + {1, HID_KEY_L }, /* 0x4C L */ \ + {1, HID_KEY_M }, /* 0x4D M */ \ + {1, HID_KEY_N }, /* 0x4E N */ \ + {1, HID_KEY_O }, /* 0x4F O */ \ + {1, HID_KEY_P }, /* 0x50 P */ \ + {1, HID_KEY_Q }, /* 0x51 Q */ \ + {1, HID_KEY_R }, /* 0x52 R */ \ + {1, HID_KEY_S }, /* 0x53 S */ \ + {1, HID_KEY_T }, /* 0x55 T */ \ + {1, HID_KEY_U }, /* 0x55 U */ \ + {1, HID_KEY_V }, /* 0x56 V */ \ + {1, HID_KEY_W }, /* 0x57 W */ \ + {1, HID_KEY_X }, /* 0x58 X */ \ + {1, HID_KEY_Y }, /* 0x59 Y */ \ + {1, HID_KEY_Z }, /* 0x5A Z */ \ + {0, HID_KEY_BRACKET_LEFT }, /* 0x5B [ */ \ + {0, HID_KEY_BACKSLASH }, /* 0x5C '\' */ \ + {0, HID_KEY_BRACKET_RIGHT }, /* 0x5D ] */ \ + {1, HID_KEY_6 }, /* 0x5E ^ */ \ + {1, HID_KEY_MINUS }, /* 0x5F _ */ \ + \ + {0, HID_KEY_GRAVE }, /* 0x60 ` */ \ + {0, HID_KEY_A }, /* 0x61 a */ \ + {0, HID_KEY_B }, /* 0x62 b */ \ + {0, HID_KEY_C }, /* 0x63 c */ \ + {0, HID_KEY_D }, /* 0x66 d */ \ + {0, HID_KEY_E }, /* 0x65 e */ \ + {0, HID_KEY_F }, /* 0x66 f */ \ + {0, HID_KEY_G }, /* 0x67 g */ \ + {0, HID_KEY_H }, /* 0x68 h */ \ + {0, HID_KEY_I }, /* 0x69 i */ \ + {0, HID_KEY_J }, /* 0x6A j */ \ + {0, HID_KEY_K }, /* 0x6B k */ \ + {0, HID_KEY_L }, /* 0x6C l */ \ + {0, HID_KEY_M }, /* 0x6D m */ \ + {0, HID_KEY_N }, /* 0x6E n */ \ + {0, HID_KEY_O }, /* 0x6F o */ \ + {0, HID_KEY_P }, /* 0x70 p */ \ + {0, HID_KEY_Q }, /* 0x71 q */ \ + {0, HID_KEY_R }, /* 0x72 r */ \ + {0, HID_KEY_S }, /* 0x73 s */ \ + {0, HID_KEY_T }, /* 0x75 t */ \ + {0, HID_KEY_U }, /* 0x75 u */ \ + {0, HID_KEY_V }, /* 0x76 v */ \ + {0, HID_KEY_W }, /* 0x77 w */ \ + {0, HID_KEY_X }, /* 0x78 x */ \ + {0, HID_KEY_Y }, /* 0x79 y */ \ + {0, HID_KEY_Z }, /* 0x7A z */ \ + {1, HID_KEY_BRACKET_LEFT }, /* 0x7B { */ \ + {1, HID_KEY_BACKSLASH }, /* 0x7C | */ \ + {1, HID_KEY_BRACKET_RIGHT }, /* 0x7D } */ \ + {1, HID_KEY_GRAVE }, /* 0x7E ~ */ \ + {0, HID_KEY_DELETE } /* 0x7F Delete */ \ + + +// Conversion table from Ascii to keycode (shift, keycode) +//const uint8_t hid_ascii_to_keycode[128][2] = { HID_ASCII_TO_KEYCODE }; + + +// Conversion table from Keycode to Ascii (ascii without shift, ascii with shift) +//const uint8_t hid_keycode_to_ascii[128][2] = { HID_KEYCODE_TO_ASCII }; diff --git a/arduino_tests/HID-Refactor/std_fix.h b/arduino_tests/HID-Refactor/std_fix.h new file mode 100644 index 00000000..fc948808 --- /dev/null +++ b/arduino_tests/HID-Refactor/std_fix.h @@ -0,0 +1,9 @@ +namespace std { + void __throw_length_error(char const*) { + } +} + +namespace std +{ + void __throw_bad_alloc() { while(true); } +} diff --git a/arduino_tests/KB_Key_Tester/KB_Key_Tester.ino b/arduino_tests/KB_Key_Tester/KB_Key_Tester.ino index 9c76f89b..5a91c874 100644 --- a/arduino_tests/KB_Key_Tester/KB_Key_Tester.ino +++ b/arduino_tests/KB_Key_Tester/KB_Key_Tester.ino @@ -19,10 +19,10 @@ uint8_t testlink(uint8_t setpin, uint8_t readpin) pinMode(setpin, OUTPUT); pinMode(readpin, INPUT_PULLDOWN); digitalWrite(setpin, LOW); - // delay(1); + delay(1); uint8_t initial = digitalRead(readpin); digitalWrite(setpin, HIGH); - // delay(1); + delay(1); uint8_t final = digitalRead(readpin); pinMode(setpin, INPUT); pinMode(readpin, INPUT); diff --git a/build/windows/BM832UL.bat b/build/windows/BM832UL.bat new file mode 100644 index 00000000..0fae37bd --- /dev/null +++ b/build/windows/BM832UL.bat @@ -0,0 +1 @@ +C:\Users\pierre\AppData\Local\Arduino15\packages\adafruit\tools\arm-none-eabi-gcc\9-2019q4/bin/arm-none-eabi-gdb.exe -quiet --batch -ex "target extended-remote \\.\COM4" -ex "mon tpwr enable" -ex "mon swdp_scan" -ex "att 1" -ex "mon erase_mass" -ex "mon hard_srst" -ex detach -ex "echo \nUnlock+Erase complete!\n" -ex detach -ex quit diff --git a/build/windows/BM840All.bat b/build/windows/BM840All.bat new file mode 100644 index 00000000..b8ada07c --- /dev/null +++ b/build/windows/BM840All.bat @@ -0,0 +1,18 @@ +@echo off +@echo Flashing Bootloader for BlueMicro840 - nRF52840 using jlink + +set prefix=%localappdata%\Arduino15\packages\community_nrf52\hardware\nrf52 + + +set search_cmd="dir /b %prefix%" +FOR /F "tokens=*" %%i IN (' %search_cmd% ') DO SET ver=%%i + +set bootloaderprefix=%prefix%\%ver%\bootloader\bluemicro_nrf52840 +@echo Found it here: %bootloaderprefix% + +set searchbootloader_cmd="dir %bootloaderprefix%\*.hex /b" +FOR /F "tokens=*" %%i IN (' %searchbootloader_cmd% ') DO SET bootloader=%%i + +nrfjprog --family NRF52 --recover +nrfjprog --family NRF52 --eraseall +nrfjprog --family NRF52 --program %bootloaderprefix%\%bootloader% --chiperase --reset \ No newline at end of file diff --git a/build/windows/BM840BL.bat b/build/windows/BM840BL.bat index cc8bada5..c291d4c1 100644 --- a/build/windows/BM840BL.bat +++ b/build/windows/BM840BL.bat @@ -1 +1 @@ -C:\Users\pierre\AppData\Local\Arduino15\packages\adafruit\tools\arm-none-eabi-gcc\9-2019q4/bin/arm-none-eabi-gdb.exe C:\Users\pierre\AppData\Local\Arduino15\packages\community_nrf52\hardware\nrf52\0.1.21/bootloader/bluemicro_nrf52840/bluemicro_nrf52840_bootloader-0.4.1_s140_6.1.1.hex -quiet --batch -ex "target extended-remote \\.\COM95" -ex "mon tpwr enable" -ex "mon swdp_scan" -ex "att 1" ex "echo \nFlashing\n" -ex load -ex "echo \nVerifying\n" -ex "compare-sections" -ex "mon hard_srst" -ex detach -ex "echo \nBootloader upload complete!\n" -ex quit +C:\Users\pierre\AppData\Local\Arduino15\packages\adafruit\tools\arm-none-eabi-gcc\9-2019q4/bin/arm-none-eabi-gdb.exe C:\Users\pierre\AppData\Local\Arduino15\packages\community_nrf52\hardware\nrf52\0.1.22/bootloader/bluemicro_nrf52840/bluemicro_nrf52840_bootloader-0.4.1_s140_6.1.1.hex -quiet --batch -ex "target extended-remote \\.\COM4" -ex "mon tpwr enable" -ex "mon swdp_scan" -ex "att 1" ex "echo \nFlashing\n" -ex load -ex "echo \nVerifying\n" -ex "compare-sections" -ex "mon hard_srst" -ex detach -ex "echo \nBootloader upload complete!\n" -ex quit diff --git a/build/windows/BM840T.bat b/build/windows/BM840T.bat index e4edd221..903e7787 100644 --- a/build/windows/BM840T.bat +++ b/build/windows/BM840T.bat @@ -1 +1 @@ -C:\Users\pierre\AppData\Local\Arduino15\packages\community_nrf52\hardware\nrf52\0.1.21/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe --verbose dfu serial -pkg BlueMicro840_tester.ino.zip -p %1 -b 115200 --singlebank +C:\Users\pierre\AppData\Local\Arduino15\packages\community_nrf52\hardware\nrf52\0.1.22/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe --verbose dfu serial -pkg BlueMicro840_tester.ino.zip -p %1 -b 115200 --singlebank diff --git a/build/windows/BM840UL.bat b/build/windows/BM840UL.bat index d0516465..0fae37bd 100644 --- a/build/windows/BM840UL.bat +++ b/build/windows/BM840UL.bat @@ -1 +1 @@ -C:\Users\pierre\AppData\Local\Arduino15\packages\adafruit\tools\arm-none-eabi-gcc\9-2019q4/bin/arm-none-eabi-gdb.exe -quiet --batch -ex "target extended-remote \\.\COM95" -ex "mon tpwr enable" -ex "mon swdp_scan" -ex "att 1" -ex "mon erase_mass" -ex "mon hard_srst" -ex detach -ex "echo \nUnlock+Erase complete!\n" -ex detach -ex quit +C:\Users\pierre\AppData\Local\Arduino15\packages\adafruit\tools\arm-none-eabi-gcc\9-2019q4/bin/arm-none-eabi-gdb.exe -quiet --batch -ex "target extended-remote \\.\COM4" -ex "mon tpwr enable" -ex "mon swdp_scan" -ex "att 1" -ex "mon erase_mass" -ex "mon hard_srst" -ex detach -ex "echo \nUnlock+Erase complete!\n" -ex detach -ex quit diff --git a/build/windows/build.ps1 b/build/windows/build.ps1 index b26e91c5..aaad5958 100644 --- a/build/windows/build.ps1 +++ b/build/windows/build.ps1 @@ -134,7 +134,7 @@ Function Compile-Board($keyboard, $target, $keymap, $fqbn, $hardware) { # Run compile $cmdCompile = - '& "$BuilderExe" -compile -logger=machine -warnings "none" -verbose -ide-version "10807" -debug-level 1 ' + + '& "$BuilderExe" -compile -logger=machine -warnings=all -verbose -ide-version "10807" -debug-level 1 ' + '-hardware "$ArduinoDir\hardware" -hardware "$ArduinoDataDir\packages" ' + '-tools "$ArduinoDir\tools-builder" -tools "$ArduinoDir\hardware\tools\avr" -tools "$ArduinoDataDir\packages" ' + '-built-in-libraries "$ArduinoDir\libraries" ' + diff --git a/firmware/firmware_main.cpp b/firmware/firmware_main.cpp index 1de7fffc..fd445187 100644 --- a/firmware/firmware_main.cpp +++ b/firmware/firmware_main.cpp @@ -222,9 +222,9 @@ void setup() { keyscantimer.begin(keyboardconfig.matrixscaninterval, keyscantimer_callback); //batterytimer.begin(keyboardconfig.batteryinterval, batterytimer_callback); - bt_setup(keyboardconfig.BLEProfile); + usb_setup(); // does nothing for 832 - see usb.cpp - + bt_setup(keyboardconfig.BLEProfile); // Set up keyboard matrix and start advertising setupKeymap(); // this is where we can change the callback for our LEDs... setupMatrix();