Skip to content

Commit

Permalink
Merge branch 'acceleration_range' of github.com:PunchThrough/bean-ard…
Browse files Browse the repository at this point in the history
…uino-core-private into acceleration_range
  • Loading branch information
Karel Kalthoff committed Mar 27, 2017
2 parents 9d893a8 + ad064af commit 03490a9
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 106 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.0.2

### Fixes

* Last release did not have the submodules correctly bundled. The `bundle.py` script now ensures this wont happen again.

# 2.0.1

### Features
Expand Down
2 changes: 1 addition & 1 deletion CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
filter=-build/header_guard,-legal/copyright,-runtime/int,-readability/casting,-build/include
linelength=100
linelength=300
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var config = {

function deployMarkers() {
return {
'UPDATED_AT': new Date().toISOString()
'UPDATED_AT': new Date().toISOString(),
'.nojekyll': ""
}
}

Expand Down
105 changes: 52 additions & 53 deletions hardware/bean/avr/cores/bean/Bean.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,66 @@
#include "BeanAncs.h"
#include "bma250.h"

/*
* An accelerometer interrupt type, they are as follows:
* FLAT_EVENT - triggers when the accelerometer is lying flat on a surface
* ORIENT_EVENT - triggers when the accelerometer is NOT lying flat on a surface, but is tilted * in any direction
* SINGLE_TAP_EVENT - triggers when the accelerometer is tapped once
* DOUBLE_TAP_EVENT - triggers when the accelerometer is tapped twice
* ANY_MOTION_EVENT - triggers when the accelerometer experiences any change in motion
* HIGH_G_EVENT - triggers when the accelerometer experiences a velocity event higher than it's * sensitivity
* LOW_G_EVENT - triggers when the accelerometer is in free fall or experiences no gravitational * pull
/**
* Accelerometer interrupt types
*/
typedef enum AccelEventTypes {
FLAT_EVENT = 0x80,
ORIENT_EVENT = 0x40,
SINGLE_TAP_EVENT = 0x20,
DOUBLE_TAP_EVENT = 0x10,
ANY_MOTION_EVENT = 0x04,
HIGH_G_EVENT = 0x02,
LOW_G_EVENT = 0x01
FLAT_EVENT = 0x80, /**< triggers when the accelerometer is lying flat on a surface */
ORIENT_EVENT = 0x40, /**< triggers when the accelerometer is NOT lying flat on a surface, but is tilted * in any direction */
SINGLE_TAP_EVENT = 0x20, /**< triggers when the accelerometer is tapped once */
DOUBLE_TAP_EVENT = 0x10, /**< triggers when the accelerometer is tapped twice */
ANY_MOTION_EVENT = 0x04, /**< triggers when the accelerometer experiences any change in motion */
HIGH_G_EVENT = 0x02, /**< triggers when the accelerometer experiences a velocity event higher than it's * sensitivity */
LOW_G_EVENT = 0x01 /**< triggers when the accelerometer is in free fall or experiences no gravitational * pull */
};

/**
* Advertisement data types
*/
typedef enum AdvertisementDataTypes {
GAP_ADTYPE_FLAGS = 0x01, // Discovery Mode: @ref GAP_ADTYPE_FLAGS_MODES
GAP_ADTYPE_16BIT_MORE = 0x02, // Service: More 16-bit UUIDs available
GAP_ADTYPE_16BIT_COMPLETE = 0x03, // Service: Complete list of 16-bit UUIDs
GAP_ADTYPE_32BIT_MORE = 0x04, // Service: More 32-bit UUIDs available
GAP_ADTYPE_32BIT_COMPLETE = 0x05, // Service: Complete list of 32-bit UUIDs
GAP_ADTYPE_128BIT_MORE = 0x06, // Service: More 128-bit UUIDs available
GAP_ADTYPE_128BIT_COMPLETE = 0x07, // Service: Complete list of 128-bit UUIDs
GAP_ADTYPE_LOCAL_NAME_SHORT = 0x08, // Shortened local name
GAP_ADTYPE_LOCAL_NAME_COMPLETE = 0x09, // Complete local name
GAP_ADTYPE_POWER_LEVEL = 0x0A, // TX Power Level: 0xXX: -127 to +127 dBm
GAP_ADTYPE_OOB_CLASS_OF_DEVICE = 0x0D, // Simple Pairing OOB Tag: Class
// of device (3 octets)
GAP_ADTYPE_OOB_SIMPLE_PAIRING_HASHC = 0x0E, // Simple Pairing OOB Tag: Simple Pairing
// Hash C (16 octets)
GAP_ADTYPE_OOB_SIMPLE_PAIRING_RANDR = 0x0F, // Simple Pairing OOB Tag: Simple Pairing
// Randomizer R (16 octets)
GAP_ADTYPE_SM_TK = 0x10, // Security Manager TK Value
GAP_ADTYPE_SM_OOB_FLAG = 0x11, // Secutiry Manager OOB Flags
GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE = 0x12, // Min and Max values of the connection
// interval
// (2 octets Min, 2 octets Max) (0xFFFF
// indicates no conn interval min or max)
GAP_ADTYPE_SIGNED_DATA = 0x13, // Signed Data field
GAP_ADTYPE_SERVICES_LIST_16BIT = 0x14, // Service Solicitation:
// list of 16-bit Service UUIDs
GAP_ADTYPE_SERVICES_LIST_128BIT = 0x15, // Service Solicitation:
// list of 128-bit Service UUIDs
GAP_ADTYPE_SERVICE_DATA = 0x16, // Service Data
GAP_ADTYPE_APPEARANCE = 0x19, // Appearance
GAP_ADTYPE_MANUFACTURER_SPECIFIC = 0xFF, // Manufacturer Specific Data:
// first 2 octets contain
// the Company Identifier Code
// followed by the additional
// manufacturer specific data
GAP_ADTYPE_FLAGS = 0x01, /**< Discovery Mode: @ref GAP_ADTYPE_FLAGS_MODES */
GAP_ADTYPE_16BIT_MORE = 0x02, /**< Service: More 16-bit UUIDs available */
GAP_ADTYPE_16BIT_COMPLETE = 0x03, /**< Service: Complete list of 16-bit UUIDs */
GAP_ADTYPE_32BIT_MORE = 0x04, /**< Service: More 32-bit UUIDs available */
GAP_ADTYPE_32BIT_COMPLETE = 0x05, /**< Service: Complete list of 32-bit UUIDs */
GAP_ADTYPE_128BIT_MORE = 0x06, /**< Service: More 128-bit UUIDs available */
GAP_ADTYPE_128BIT_COMPLETE = 0x07, /**< Service: Complete list of 128-bit UUIDs */
GAP_ADTYPE_LOCAL_NAME_SHORT = 0x08, /**< Shortened local name */
GAP_ADTYPE_LOCAL_NAME_COMPLETE = 0x09, /**< Complete local name */
GAP_ADTYPE_POWER_LEVEL = 0x0A, /**< TX Power Level: 0xXX: -127 to +127 dBm */
GAP_ADTYPE_OOB_CLASS_OF_DEVICE = 0x0D, /**< Simple Pairing OOB Tag: Class */
/**< of device (3 octets) */
GAP_ADTYPE_OOB_SIMPLE_PAIRING_HASHC = 0x0E, /**< Simple Pairing OOB Tag: Simple Pairing */
/**< Hash C (16 octets) */
GAP_ADTYPE_OOB_SIMPLE_PAIRING_RANDR = 0x0F, /**< Simple Pairing OOB Tag: Simple Pairing */
/**< Randomizer R (16 octets) */
GAP_ADTYPE_SM_TK = 0x10, /**< Security Manager TK Value */
GAP_ADTYPE_SM_OOB_FLAG = 0x11, /**< Secutiry Manager OOB Flags */
GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE = 0x12, /**< Min and Max values of the connection */
/**< interval */
/**< (2 octets Min, 2 octets Max) (0xFFFF */
/**< indicates no conn interval min or max) */
GAP_ADTYPE_SIGNED_DATA = 0x13, /**< Signed Data field */
GAP_ADTYPE_SERVICES_LIST_16BIT = 0x14, /**< Service Solicitation: */
/**< list of 16-bit Service UUIDs */
GAP_ADTYPE_SERVICES_LIST_128BIT = 0x15, /**< Service Solicitation: */
/**< list of 128-bit Service UUIDs */
GAP_ADTYPE_SERVICE_DATA = 0x16, /**< Service Data */
GAP_ADTYPE_APPEARANCE = 0x19, /**< Appearance */
GAP_ADTYPE_MANUFACTURER_SPECIFIC = 0xFF, /**< Manufacturer Specific Data: */
/**< first 2 octets contain */
/**< the Company Identifier Code */
/**< followed by the additional */
/**< manufacturer specific data */
};

/**
* Advertisement Type
*/
typedef enum AdvertisementType {
GAP_ADTYPE_FLAGS_LIMITED = 0x01, // Discovery Mode: LE Limited Discoverable Mode
GAP_ADTYPE_FLAGS_GENERAL = 0x02, // Discovery Mode: LE General Discoverable Mode
GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED = 0x04, // Discovery Mode: BR/EDR Not Supported
GAP_ADTYPE_FLAGS_LIMITED = 0x01, /**< Discovery Mode: LE Limited Discoverable Mode */
GAP_ADTYPE_FLAGS_GENERAL = 0x02, /**< Discovery Mode: LE General Discoverable Mode */
GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED = 0x04, /**< Discovery Mode: BR/EDR Not Supported */
};


Expand Down
58 changes: 29 additions & 29 deletions hardware/bean/avr/cores/bean/BeanHID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "BeanHID.h"

// Singleton
BeanHid_ BeanHid;
BeanHidClass BeanHid;

#define HID_DEV_DATA_LEN 8

Expand Down Expand Up @@ -267,7 +267,7 @@ uint8_t _hid_idle = 1;
// void sendReport(CcReport *pReport);
// void buttons(uint8_t b);

BeanHid_::BeanHid_(void) {
BeanHidClass::BeanHidClass(void) {
_buttons = 0;
isShiftHeld = false;
}
Expand Down Expand Up @@ -363,7 +363,7 @@ static void addCommandToCcReport(CcReport *pReport, uint8_t cmd) {
}
}

void BeanHid_::_genericSendReport(uint8_t id, uint8_t *buffer, size_t length) {
void BeanHidClass::_genericSendReport(uint8_t id, uint8_t *buffer, size_t length) {
hidDevReport_t report;
report.type = HID_REPORT_TYPE_INPUT;
report.id = id;
Expand All @@ -376,20 +376,20 @@ void BeanHid_::_genericSendReport(uint8_t id, uint8_t *buffer, size_t length) {
}
}

void BeanHid_::sendReport(MouseReport *pReport) {
void BeanHidClass::sendReport(MouseReport *pReport) {
_genericSendReport(HID_RPT_ID_MOUSE_IN, (uint8_t *)pReport,
sizeof(MouseReport));
}

void BeanHid_::sendReport(KeyReport *pReport) {
void BeanHidClass::sendReport(KeyReport *pReport) {
_genericSendReport(HID_RPT_ID_KEY_IN, (uint8_t *)pReport, sizeof(KeyReport));
}

void BeanHid_::sendReport(CcReport *pReport) {
void BeanHidClass::sendReport(CcReport *pReport) {
_genericSendReport(HID_RPT_ID_CC_IN, (uint8_t *)pReport, sizeof(CcReport));
}

void BeanHid_::buttons(uint8_t b) {
void BeanHidClass::buttons(uint8_t b) {
if (b != _buttons) {
_buttons = b;
moveMouse(0, 0, 0);
Expand All @@ -398,25 +398,25 @@ void BeanHid_::buttons(uint8_t b) {

// Public functions

void BeanHid_::enable(void) {
void BeanHidClass::enable(void) {
ADV_SWITCH_ENABLED_T curServices = Bean.getServices();
curServices.hid = 1;
Bean.setServices(curServices);
}

bool BeanHid_::isEnabled(void) {
bool BeanHidClass::isEnabled(void) {
ADV_SWITCH_ENABLED_T curServices = Bean.getServices();
return (curServices.hid == 1) ? true : false;
}

void BeanHid_::disable(void) {
void BeanHidClass::disable(void) {
ADV_SWITCH_ENABLED_T curServices = Bean.getServices();
curServices.hid = 0;
Bean.setServices(curServices);
}

// Mouse
void BeanHid_::moveMouse(signed char delta_x, signed char delta_y,
void BeanHidClass::moveMouse(signed char delta_x, signed char delta_y,
signed char delta_wheel) {
MouseReport m;
m.mouse[0] = _buttons;
Expand All @@ -426,31 +426,31 @@ void BeanHid_::moveMouse(signed char delta_x, signed char delta_y,
sendReport(&m);
}

void BeanHid_::holdMouseClick(mouseButtons button) {
void BeanHidClass::holdMouseClick(mouseButtons button) {
buttons(_buttons | button);
}

void BeanHid_::releaseMouseClick(mouseButtons button) {
void BeanHidClass::releaseMouseClick(mouseButtons button) {
buttons(_buttons & ~button);
}

void BeanHid_::sendMouseClick(mouseButtons button) {
void BeanHidClass::sendMouseClick(mouseButtons button) {
holdMouseClick(button);
releaseMouseClick(button);
}

// Consumer Control
void BeanHid_::sendMediaControl(mediaControl command) {
void BeanHidClass::sendMediaControl(mediaControl command) {
holdMediaControl(command);
releaseMediaControl(command);
}

void BeanHid_::holdMediaControl(mediaControl command) {
void BeanHidClass::holdMediaControl(mediaControl command) {
addCommandToCcReport(&ccReportForHeldCommands, command);
sendReport(&ccReportForHeldCommands);
}

void BeanHid_::releaseMediaControl(mediaControl command) {
void BeanHidClass::releaseMediaControl(mediaControl command) {
CcReport report = {0, 0};
addCommandToCcReport(&report, command);

Expand All @@ -461,7 +461,7 @@ void BeanHid_::releaseMediaControl(mediaControl command) {
sendReport(&ccReportForHeldCommands);
}

void BeanHid_::releaseAllMediaControls() {
void BeanHidClass::releaseAllMediaControls() {
ccReportForHeldCommands = {0, 0};
sendReport(&ccReportForHeldCommands);
}
Expand All @@ -472,7 +472,7 @@ void BeanHid_::releaseAllMediaControls() {
// to the persistent key report and sends the report. Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t BeanHid_::_holdKey(uint8_t k) {
size_t BeanHidClass::_holdKey(uint8_t k) {
uint8_t i;
if (k >= 136) { // it's a non-printing key (not a modifier)
k = k - 136;
Expand Down Expand Up @@ -516,7 +516,7 @@ size_t BeanHid_::_holdKey(uint8_t k) {
// _release() takes the specified key out of the persistent key report and
// sends the report. This tells the OS the key is no longer pressed and that
// it shouldn't be repeated any more.
size_t BeanHid_::_releaseKey(uint8_t k) {
size_t BeanHidClass::_releaseKey(uint8_t k) {
uint8_t i;
if (k >= 136) { // it's a non-printing key (not a modifier)
k = k - 136;
Expand Down Expand Up @@ -549,27 +549,27 @@ size_t BeanHid_::_releaseKey(uint8_t k) {
return 1;
}

size_t BeanHid_::_sendKey(uint8_t c) {
size_t BeanHidClass::_sendKey(uint8_t c) {
uint8_t p = _holdKey(c); // Keydown
uint8_t r = _releaseKey(c); // Keyup
return (p & r);
}

int BeanHid_::holdKey(char key) { return (int)_holdKey((uint8_t)key); }
int BeanHid_::holdKey(modifierKey key) { return (int)_holdKey((uint8_t)key); }
int BeanHidClass::holdKey(char key) { return (int)_holdKey((uint8_t)key); }
int BeanHidClass::holdKey(modifierKey key) { return (int)_holdKey((uint8_t)key); }

/**
* Needs docs
*/
int BeanHid_::releaseKey(char key) { return (int)_releaseKey((uint8_t)key); }
int BeanHid_::releaseKey(modifierKey key) {
int BeanHidClass::releaseKey(char key) { return (int)_releaseKey((uint8_t)key); }
int BeanHidClass::releaseKey(modifierKey key) {
return (int)_releaseKey((uint8_t)key);
}

/**
* Needs docs
*/
void BeanHid_::releaseAllKeys(void) {
void BeanHidClass::releaseAllKeys(void) {
_keyReport.keys[0] = 0;
_keyReport.keys[1] = 0;
_keyReport.keys[2] = 0;
Expand All @@ -583,13 +583,13 @@ void BeanHid_::releaseAllKeys(void) {
/**
* Needs docs
*/
int BeanHid_::sendKey(char key) { return (int)_sendKey((uint8_t)key); }
int BeanHid_::sendKey(modifierKey key) { return (int)_sendKey((uint8_t)key); }
int BeanHidClass::sendKey(char key) { return (int)_sendKey((uint8_t)key); }
int BeanHidClass::sendKey(modifierKey key) { return (int)_sendKey((uint8_t)key); }

/**
* Needs docs
*/
int BeanHid_::sendKeys(String charsToType) {
int BeanHidClass::sendKeys(String charsToType) {
int status = 0;
int maxIndex = charsToType.length();
for (int i = 0; i < maxIndex; i++) {
Expand Down
Loading

0 comments on commit 03490a9

Please sign in to comment.