Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codal core updates #109

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ machine:
orbs:
aws-ecr: circleci/[email protected]
aws-ecs: circleci/[email protected]
aws-cli: circleci/[email protected]

defaults: &defaults
working_directory: ~/pxt-texknikio
Expand Down
49 changes: 48 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,52 @@
"tslint.enable": true,
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib",
"typescript.tsdk": "./node_modules/typescript/lib",
"editor.tabSize": 4
"editor.tabSize": 4,
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
}
Binary file modified libs/.DS_Store
Binary file not shown.
31 changes: 4 additions & 27 deletions libs/accelerometer/pxt.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
{
"name": "accelerometer",
"description": "The accelerometer library",
"dependencies": {
"core": "file:../core",
"jacdac": "file:../jacdac"
},
"files": [
"README.md",
"accelerometer.cpp",
"accelhw.cpp",
"axis.h",
"gesture.ts",
"shims.d.ts",
"enums.d.ts",
"ns.ts",
"pxtparts.json",
"part.svg",
"jacdac.ts"
],
"testFiles": [
"test.ts"
],
"public": true,
"additionalFilePath": "../accelerometer_custom",
"yotta": {
"optionalConfig": {
"PXT_SUPPORT_LIS3DH": 1,
"PXT_SUPPORT_MMA8653": 1,
"PXT_SUPPORT_MMA8453": 1,
"PXT_SUPPORT_FXOS8700": 1,
"PXT_SUPPORT_LIS3DH": 0,
"PXT_SUPPORT_MMA8653": 0,
"PXT_SUPPORT_MMA8453": 0,
"PXT_SUPPORT_FXOS8700": 0,
"PXT_SUPPORT_MPU6050": 1
},
"userConfigs": [
Expand Down
8 changes: 0 additions & 8 deletions libs/accelerometer/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ declare namespace input {
//% weight=42 blockGap=8 shim=input::acceleration
function acceleration(dimension: Dimension): int32;

/**
* Get the temperature in Celsius or Fahrenheit degrees.
*/
//% blockId=device_temperature block="temperature in c"
//% parts="accelerometer"
//% weight=26 shim=input::temperature
function temperature(): int32;

/**
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
* @param kind TODO
Expand Down
58 changes: 13 additions & 45 deletions libs/accelerometer_custom/accelhw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
#define PXT_DEFAULT_ACCELEROMETER -1
#endif

#ifndef PXT_SUPPORT_LIS3DH
#define PXT_SUPPORT_LIS3DH 1
#endif
#if PXT_SUPPORT_LIS3DH
#include "LIS3DH.h"
#endif

#ifndef PXT_SUPPORT_MMA8653
#define PXT_SUPPORT_MMA8653 0
#endif
Expand All @@ -35,13 +28,6 @@
#include "MMA8453.h"
#endif

#ifndef PXT_SUPPORT_FXOS8700
#define PXT_SUPPORT_FXOS8700 0
#endif
#if PXT_SUPPORT_FXOS8700
#include "FXOS8700Accelerometer.h"
#endif

#ifndef PXT_SUPPORT_MSA300
#define PXT_SUPPORT_MSA300 0
#endif
Expand All @@ -50,7 +36,7 @@
#endif

#ifndef PXT_SUPPORT_MPU6050
#define PXT_SUPPORT_MPU6050 0
#define PXT_SUPPORT_MPU6050 1
#endif
#if PXT_SUPPORT_MPU6050
#include "MPU6050.h"
Expand Down Expand Up @@ -146,27 +132,12 @@ class WAccel {
int detectAccelerometer(codal::I2C* i2c){
uint8_t data;
int result;

#if PXT_SUPPORT_LIS3DH
result = i2c->readRegister(ACCELEROMETER_TYPE_LIS3DH, LIS3DH_WHOAMI, &data, 1);
if (result ==0)
return ACCELEROMETER_TYPE_LIS3DH;
result = i2c->readRegister(ACCELEROMETER_TYPE_LIS3DH_ALT, LIS3DH_WHOAMI, &data, 1);
if (result ==0)
return ACCELEROMETER_TYPE_LIS3DH_ALT;
#endif

#if PXT_SUPPORT_MMA8453
result = i2c->readRegister(ACCELEROMETER_TYPE_MMA8453, MMA8653_WHOAMI/*MMA8453 is similar to MMA8653*/ , &data, 1);
if (result ==0)
return ACCELEROMETER_TYPE_MMA8453;
#endif

#if PXT_SUPPORT_FXOS8700
result = i2c->readRegister(ACCELEROMETER_TYPE_FXOS8700, FXOS8700_WHO_AM_I, &data, 1);
if (result ==0)
return ACCELEROMETER_TYPE_FXOS8700;
#endif

#if PXT_SUPPORT_MMA8653
result = i2c->readRegister(ACCELEROMETER_TYPE_MMA8653, MMA8653_WHOAMI, &data, 1);
Expand All @@ -191,22 +162,11 @@ class WAccel {

codal::Accelerometer* instantiateAccelerometer(int accType, codal::I2C* i2c) {
switch (accType) {
#if PXT_SUPPORT_LIS3DH
case ACCELEROMETER_TYPE_LIS3DH:
case ACCELEROMETER_TYPE_LIS3DH_ALT:
return new LIS3DH(*i2c, *LOOKUP_PIN(ACCELEROMETER_INT), space, accType);
#endif

#if PXT_SUPPORT_MSA300
case ACCELEROMETER_TYPE_MSA300:
return new MSA300(*i2c, *LOOKUP_PIN(ACCELEROMETER_INT), space);
#endif
#if PXT_SUPPORT_FXOS8700
case ACCELEROMETER_TYPE_FXOS8700: {
// TODO: singleton when exposing gyro
auto fox = new FXOS8700(*i2c, *LOOKUP_PIN(ACCELEROMETER_INT));
return new FXOS8700Accelerometer(*fox, space);
}
#endif
#if PXT_SUPPORT_MMA8653
case ACCELEROMETER_TYPE_MMA8653:
return new MMA8653(*i2c, *LOOKUP_PIN(ACCELEROMETER_INT), space);
Expand All @@ -226,11 +186,19 @@ class WAccel {

};

SINGLETON_IF_PIN(WAccel, ACCELEROMETER_INT);
//SINGLETON_IF_PIN(WAccel, ACCELEROMETER_INT);
static WAccel *instAcc;

codal::Accelerometer *getAccelerometer() {
auto wacc = getWAccel();
return wacc ? wacc->acc : NULL;
// auto wacc = getWAccel();
// return wacc ? wacc->acc : NULL;
if (instAcc)
return instAcc->acc;
if (LOOKUP_PIN(ACCELEROMETER_INT) || LOOKUP_PIN(ACCELEROMETER_SDA)) {
instAcc = new WAccel();
return instAcc->acc;
}
return NULL;
}

} // namespace pxt
35 changes: 0 additions & 35 deletions libs/accelerometer_custom/jacdac.ts

This file was deleted.

6 changes: 2 additions & 4 deletions libs/accelerometer_custom/pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
"enums.d.ts",
"ns.ts",
"pxtparts.json",
"part.svg",
"jacdac.ts"
"part.svg"
],
"testFiles": [
"test.ts"
],
"public": true,
"dependencies": {
"core": "file:../core",
"jacdac": "file:../jacdac"
"core": "file:../core"
}
}
Loading