Skip to content

Commit d404c58

Browse files
committedAug 7, 2022
Initial commit.
0 parents  commit d404c58

13 files changed

+12398
-0
lines changed
 

‎LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Bill Siever
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all: deploy
2+
3+
build:
4+
pxt build
5+
6+
deploy:
7+
pxt deploy
8+
9+
test:
10+
pxt test

‎README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# i2c2
2+
3+
```package
4+
pins=github:bsiever/microbit-pxt-i2cpins
5+
```
6+
7+
This extension allows non-default pins to be used for the micro:bit's I2C
8+
9+
**Micro:bit v1 only has one I2C port. Changing the pins will prevent the accelerometer/compass from working!!!**
10+
11+
# Setting the pins
12+
13+
```sig
14+
pins.setI2CPins(sda : DigitalPin, scl : DigitalPin) : void
15+
```
16+
17+
Set the Data and Clock pins.
18+
19+
# Acknowledgements
20+
21+
Development of this extension was sponsored by [MakeKit](https://www.makekit.no/).
22+
23+
Icon based on [Font Awesome icon 0xF074](https://www.iconfinder.com/icons/213043/f074_icon) SVG.
24+
25+
<script src="https://makecode.com/gh-pages-embed.js"></script>
26+
<script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script>

‎_config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
makecode:
2+
home_url: https://makecode.com/

‎clicks.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
3+
//% color=#0000FF
4+
//% icon="\uf074"
5+
//% block="i2c Reroute"
6+
//% group="micro:bit (V2)"
7+
namespace i2crr {
8+
//% blockId="setI2CPins" block="set i2c data to %sdaPin and clock to %sclPin|"
9+
//% shim=i2crr::setI2CPins
10+
//% sdaPin.defl=DigitalPin.P1 sclPin.defl=DigitalPin.P2
11+
//% group="micro:bit (V2)"
12+
export function setI2CPins(sdaPin : DigitalPin, sclPin : DigitalPin) : void {
13+
// Per https://github.com/microsoft/pxt-microbit/issues/4292
14+
0;
15+
}
16+
}

‎enums.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Auto-generated. Do not edit.
2+
declare namespace i2crr {
3+
}
4+
5+
// Auto-generated. Do not edit. Really.

‎icon.png

4.63 KB
Loading

‎package-lock.json

+12,209
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"pxt-microbit": "^4.0.16",
4+
"webusb": "^1.3.1"
5+
}
6+
}

‎pxt.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "microbit-pxt-i2cpins",
3+
"version": "0.0.6",
4+
"description": "Reroute External I2C Pins",
5+
"license": "MIT",
6+
"dependencies": {
7+
"core": "*"
8+
},
9+
"files": [
10+
"README.md",
11+
"i2crr.ts",
12+
"i2crr.cpp",
13+
"shims.d.ts",
14+
"enums.d.ts"
15+
],
16+
"testFiles": [
17+
"test.ts"
18+
],
19+
"public": true,
20+
"targetVersions": {
21+
"target": "4.0.16",
22+
"targetId": "microbit"
23+
},
24+
"supportedTargets": [
25+
"microbit"
26+
],
27+
"preferredEditor": "tsprj",
28+
"authors": [
29+
"Bill Siever <bsiever@gmail.com>"
30+
],
31+
"card": {
32+
"name": "Reroute External I2C pins",
33+
"imageUrl": "file:../icon.png",
34+
"feedbackUrl": "http://siever.info"
35+
}
36+
}

‎shims.d.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Auto-generated. Do not edit.
2+
3+
4+
/**
5+
* Bill Siever
6+
* 2021-10-02 Initial Version
7+
*
8+
* Development environment specifics:
9+
* Written in Microsoft PXT
10+
*
11+
* This code is released under the [MIT License](http://opensource.org/licenses/MIT).
12+
* Please review the LICENSE.md file included with this example. If you have any questions
13+
* or concerns with licensing, please contact techsupport@sparkfun.com.
14+
* Distributed as-is; no warranty is given.
15+
*/
16+
17+
declare namespace i2crr {
18+
}
19+
20+
// Auto-generated. Do not edit. Really.

‎test.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
serial.writeLine("starting...")
2+
serial.writeLine("Press A to configure pins (P1=SDA, P2=SCL) and write a number")
3+
serial.writeLine("Press B to write a number")
4+
// serial.writeLine("If sensor is NOT connected it should show -Infinity (for temp) and an error message")
5+
input.onButtonPressed(Button.A, function () {
6+
// SDA , SCL
7+
i2crr.setI2CPins(DigitalPin.P1, DigitalPin.P2)
8+
pins.i2cWriteNumber(
9+
104, // 0x68
10+
107, // 0x6C
11+
NumberFormat.UInt8LE,
12+
true
13+
)
14+
pins.i2cWriteNumber(
15+
104,
16+
0,
17+
NumberFormat.UInt8LE,
18+
false
19+
)
20+
})
21+
input.onButtonPressed(Button.B, function () {
22+
pins.i2cWriteNumber(
23+
104,
24+
59,
25+
NumberFormat.UInt8LE,
26+
false
27+
)
28+
pins.i2cWriteNumber(
29+
104,
30+
14,
31+
NumberFormat.UInt8LE,
32+
true
33+
)
34+
serial.writeValue("x", pins.i2cReadNumber(104, NumberFormat.UInt16BE, true))
35+
serial.writeValue("y", pins.i2cReadNumber(104, NumberFormat.UInt8BE, true))
36+
serial.writeValue("z", pins.i2cReadNumber(104, NumberFormat.UInt8BE, true))
37+
serial.writeValue("t", pins.i2cReadNumber(104, NumberFormat.UInt8BE, false))
38+
serial.writeValue("a", input.acceleration(Dimension.X))
39+
})

‎tsconfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"noImplicitAny": true,
5+
"outDir": "built",
6+
"rootDir": "."
7+
}
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.