Jacdac ts (#216)
* add jacdac-ts * enable jacdac-ts on CPX * adding jacdac dep * updating shims * hack device shims and pxtarge.json (for now) * updated shims * remove jacdac-ts * updated dependeices * add link * ignore package lock * enable jacdac sim * updated shims * removed direct dependnecy on jacdac-ts * bring back some services * restore services * ignore C++ files * updated link script * don't force remove. (rm) * updated samples * hidding jacdac-ts * update core reference * bump core version * update repo references * cleanout jacdac-ts * enable jacdac debug in beads * adding board.json updates * specify accelerometer type * fix config * fix bead config * bumped pxt * update core * set the active lo config on the led pins. * update codal-core * bump codal-core * bump repos to pickup flash driver * updating shims * updated dal.d.ts * update dal.dts. * updated codal-core branch * updated configStorage * fix prox bead and jacdac service init * move jacdac.ts before startup.ts * bump pxt * Beadmappings (#222) * reorg tattoo pins * add color sensor * updated pinout * added lis3dh to light breain * reorg pins * enable console * wire up bead-brain * try redirect fashion editor * remove fashion ref * add jacdac back * updated pxt-core * add identification mechanism to startup.ts * update core and samd refs * update tags and config for brain. * add jacdac leds to config.ts * Add bead-motor to pxt. * adjust pins for light bead * add gpio identification to all beads. * Add pin LED to all devices. * wiring up light spectrum sensor * add kinda working PCA driver * add servo library to tattoo * updated bead-servo * remove non-bead boards * fix default project * fixing lightsin brain * updated pin locations * fix pin lookup in maker * starting on beads * remove accelerometer from servo bead * bead-motor -> bead-motion * mor fixes * missing led * fix led notations * update codal-samd to remove STATE set on i2c * update pxtarget to use i2c_hack branch * added servos * typo * add LED to proximity bead pins. * fix bead-proximity i2c pins * add distance sensor. * don't start jacdac services by default in brain * fix typos * adding proximity in bead-proxmity * adding light demo * enable light spectruom * don't enable accel on tattoo * fix identification * updated tattoo apis * support for custom gestures * disable usb in beads by default * bump repositories * update codal target tag * updating sim support * add common bead project * remove 'beads' layer * simplify board.json * update tags for build * update codal tags. * add fashion show scripts * add motion * fixed light rig * updates * updated servo test * updated servos service * test programs * changes with teddy * updated servo test * servos working * get rebecca's code working (#226) * changes suggested by peli (#225) * prox and dg working * zipora lights working * victoria pink lights * motion left and right * victory for victoria * pulsing colors on motion * update codal to the jacdac reset hack * victoria done * copy zipora over to kt * KT program * start readme to track and gv program * fix up brightness transitions * doris tattoo working * ah done * jg1 and jg2 * ko and mo ready * up and sw * victoria done * updated omega * jg1 done * jg2 done * calibrate on connection * simone done * up * up done * zipora done * added op * base animation * q done * opera code * rebecca done * update dg * doris * updated ds * dj working * add setudent project * adding lightstep * fix up with light step for kt * color fix for kt * tv code for text and shoulders * na student * wakonda * updated servo * updated student * updates * fixing jo * few updates * adding random image * restore other boards * updated shims * updated references * removing jacdac reference * updated pxt * update tags * updated nrf52 tag * updated SAMD21 tag * bump minor * updated docs * rename jacdac-drivers -> jacdac-services (#233) * rename jacdac-driver to jacdac-services * move project * using jacdac-feather * use codal core tag * fixsim * updated samd21 tag * another attempt * fix sim
This commit is contained in:
Родитель
d2d4591138
Коммит
8a379171ef
|
@ -6,6 +6,7 @@ built
|
|||
typings
|
||||
tmp
|
||||
temp
|
||||
.vscode/ipch
|
||||
projects/**
|
||||
clients/win10/app/AppPackages
|
||||
clients/win10/app/BundlePackages
|
||||
|
@ -17,8 +18,8 @@ clients/**/bin/**
|
|||
clients/**/obj/**
|
||||
clients/electron/projects
|
||||
|
||||
videos/**
|
||||
|
||||
videos/**
|
||||
*.user
|
||||
*.sw?
|
||||
*.ts.new
|
||||
|
|
|
@ -34,7 +34,7 @@ This editor supports various maker boards, based on SAMD21, SAMD51, NRF52.
|
|||
{
|
||||
"name": "Add your board",
|
||||
"url": "/boards/add-a-new-board",
|
||||
"imageUrl": "/static/libs/bead-motion.jpg"
|
||||
"imageUrl": "/static/libs/bead-servo.jpg"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
* [Environmental Bead](/boards/bead-environmental)
|
||||
* [Tattoo Bead](/boards/bead-tattoo)
|
||||
* [Light Bead](/boards/bead-light)
|
||||
* [Motion Bead](/boards/bead-motion)
|
||||
* [Servo Bead](/boards/bead-servo)
|
||||
|
||||
* [Add a new board](/boards/add-a-new-board)
|
|
@ -1,4 +1,4 @@
|
|||
# Bead Motion
|
||||
# Bead Servo
|
||||
|
||||
```blocks
|
||||
forever(function() {
|
||||
|
@ -7,5 +7,5 @@ forever(function() {
|
|||
```
|
||||
|
||||
```package
|
||||
bead-motion
|
||||
bead-servo
|
||||
```
|
|
@ -41,10 +41,10 @@
|
|||
"imageUrl": "/static/libs/bead-light.jpg"
|
||||
},
|
||||
{
|
||||
"name": "Motion Bead",
|
||||
"url": "/boards/bead-motion",
|
||||
"name": "Servo Bead",
|
||||
"url": "/boards/bead-servo",
|
||||
"cardType": "template",
|
||||
"imageUrl": "/static/libs/bead-motion.jpg"
|
||||
"imageUrl": "/static/libs/bead-servo.jpg"
|
||||
}
|
||||
]
|
||||
```
|
|
@ -22,12 +22,6 @@
|
|||
"cardType": "template",
|
||||
"imageUrl": "/static/libs/teknikio-bluebird.jpg"
|
||||
},
|
||||
{
|
||||
"name": "Motion Bead",
|
||||
"url": "/boards/bead-motion",
|
||||
"cardType": "template",
|
||||
"imageUrl": "/static/libs/bead-motion.jpg"
|
||||
},
|
||||
{
|
||||
"name": "Add a new board",
|
||||
"url": "/boards/add-a-new-board",
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# Beads
|
||||
|
||||
## Fashion
|
||||
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "light-demo",
|
||||
"url": "/projects/beads/light-demo",
|
||||
"cardType": "example"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
# Light lightDemo
|
||||
|
||||
Enables various light animation based on sensor triggers.
|
||||
|
||||
## Code
|
||||
|
||||
```typescript
|
||||
function startAnimation(strip: light.NeoPixelStrip, animation: light.NeoPixelAnimation) {
|
||||
strip.setLength(150);
|
||||
strip.stopAllAnimations();
|
||||
control.runInBackground(() => {
|
||||
strip.showAnimation(animation, 2000);
|
||||
strip.clear();
|
||||
});
|
||||
}
|
||||
function lightDemo() {
|
||||
const duration = 2000;
|
||||
startAnimation(light.pixels, light.rainbowAnimation);
|
||||
startAnimation(light.pixels2, light.sparkleAnimation);
|
||||
startAnimation(light.pixels3, light.colorWipeAnimation);
|
||||
startAnimation(light.pixels5, light.cometAnimation);
|
||||
startAnimation(light.pixels6, light.theaterChaseAnimation);
|
||||
startAnimation(light.pixels7, light.runningLightsAnimation);
|
||||
}
|
||||
jacdac.proximityClient.onEvent(JDPromixityEvent.Close, function () {
|
||||
lightDemo();
|
||||
})
|
||||
jacdac.accelerometerClient.onEvent(JDGesture.Shake, function () {
|
||||
lightDemo();
|
||||
})
|
||||
jacdac.touchButtonClient.onEvent(JDButtonEvent.Click, function () {
|
||||
lightDemo();
|
||||
})
|
||||
jacdac.lightSpectrumSensorClient.onEvent(JDLightSpectrumEvent.VisibleDark, function () {
|
||||
lightDemo();
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
```config
|
||||
feature=brain
|
||||
```
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## ~ hint
|
||||
|
||||
CONSTRUCTION ZONE: JACDAC is still under development and subject to change. Your feedback is welcome at [![Community Discord](https://img.shields.io/discord/448979533891371018.svg)](https://aka.ms/makecodecommunity).
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
# Logging
|
||||
# Broadcast
|
||||
|
||||
## ~ hint
|
||||
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
|
||||
The **message bus** service allows to broadcast messages on the bus and run code on reception.
|
||||
|
||||
The example shows how to author the service and client to blink an LED when clicking a button.
|
||||
|
||||
```blocks
|
||||
/**
|
||||
JACDAC is still in early prototyping phase. The protocol and all hardware design are MOST LIKELY to change during this phase. You are welcome to join us in prototyping but we strongly recommend avoiding going to production with JACDAC at the current stage.
|
||||
**/
|
||||
|
||||
enum JacDacMessage {
|
||||
blink = 49614,
|
||||
message1 = 49434
|
||||
|
@ -25,7 +28,7 @@ input.buttonD0.onEvent(ButtonEvent.Down, function () {
|
|||
|
||||
```package
|
||||
jacdac
|
||||
jacdac-drivers
|
||||
jacdac-services
|
||||
```
|
||||
|
||||
```config
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Console Screen
|
||||
|
||||
## ~ hint
|
||||
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
Displays the JACDAC console log on a TFT screen.
|
||||
|
||||
```blocks
|
||||
/**
|
||||
JACDAC is still in early prototyping phase. The protocol and all hardware design are MOST LIKELY to change during this phase. You are welcome to join us in prototyping but we strongly recommend avoiding going to production with JACDAC at the current stage.
|
||||
**/
|
||||
|
||||
let logging = false
|
||||
input.buttonD1.onEvent(ButtonEvent.Click, function () {
|
||||
if (logging) {
|
||||
|
@ -20,7 +22,7 @@ input.buttonD1.onEvent(ButtonEvent.Click, function () {
|
|||
}
|
||||
})
|
||||
jacdac.setDeviceName("logger")
|
||||
jacdac.consoleService.start()
|
||||
jacdac.consoleService()
|
||||
logging = false
|
||||
display.showConsole()
|
||||
console.log("press btn to start")
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
# Console
|
||||
|
||||
## ~ hint
|
||||
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
Enable console logging service over JACDAC. Use the [console screen](/projects/jacdac/console-screen) to view the messages.
|
||||
|
||||
```blocks
|
||||
/**
|
||||
JACDAC is still in early prototyping phase. The protocol and all hardware design are MOST LIKELY to change during this phase. You are welcome to join us in prototyping but we strongly recommend avoiding going to production with JACDAC at the current stage.
|
||||
**/
|
||||
|
||||
jacdac.setDeviceName("thing")
|
||||
jacdac.consoleService.start()
|
||||
jacdac.consoleService()
|
||||
forever(function() {
|
||||
console.log("ping");
|
||||
pause(1000);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Controller Button
|
||||
|
||||
## ~ hint
|
||||
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
Binds the behavior of a button to the JACDAC controller client button. Connects directly to an arcade game.
|
||||
|
||||
```blocks
|
||||
/**
|
||||
JACDAC is still in early prototyping phase. The protocol and all hardware design are MOST LIKELY to change during this phase. You are welcome to join us in prototyping but we strongly recommend avoiding going to production with JACDAC at the current stage.
|
||||
**/
|
||||
|
||||
jacdac.attachButtonToController(input.buttonD1, JDControllerButton.A)
|
||||
```
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# LCD screen
|
||||
|
||||
## ~ hint
|
||||
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
Displays text on a LCD screen.
|
||||
|
||||
```blocks
|
||||
/**
|
||||
JACDAC is still in early prototyping phase. The protocol and all hardware design are MOST LIKELY to change during this phase. You are welcome to join us in prototyping but we strongly recommend avoiding going to production with JACDAC at the current stage.
|
||||
**/
|
||||
|
||||
jacdac.lcdService.start()
|
||||
```
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
# Blinky
|
||||
|
||||
## ~ hint
|
||||
|
||||
JACDAC is a single wire broadcast protocol for the plug and play of microcontrollers (MCUs) within the contexts of rapid prototyping, making, and physical computing. [Read more...](https://jacdac.org/).
|
||||
|
||||
## ~
|
||||
|
||||
When pressing button A, the light client sends a command to the light service running
|
||||
on the other device to turn the lights on for 1/2 second.
|
||||
|
||||
```blocks
|
||||
/**
|
||||
JACDAC is still in early prototyping phase. The protocol and all hardware design are MOST LIKELY to change during this phase. You are welcome to join us in prototyping but we strongly recommend avoiding going to production with JACDAC at the current stage.
|
||||
**/
|
||||
jacdac.pixelService.start()
|
||||
forever(function () {
|
||||
jacdac.pixelClient.setColor(0xff0000)
|
||||
|
@ -18,7 +21,7 @@ forever(function () {
|
|||
|
||||
```package
|
||||
jacdac
|
||||
jacdac-drivers
|
||||
jacdac-services
|
||||
```
|
||||
|
||||
```config
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
ah:CC:motion to light
|
||||
dg:DONE:pulsing strip with color interpolation
|
||||
dj:DONE:4 strips in sequence
|
||||
ds:PELI:two tattoo to two strips
|
||||
gv:CC:shake to pulse two strips
|
||||
jg1:DONE:touch to pulse red
|
||||
jg2:DONE:touch to pulse yellow (off default)
|
||||
jo:TODO:touch, motion, light
|
||||
ko:CC:touch + light
|
||||
kt:DONE:L,R motion + two strips
|
||||
mo:CC:touch to light
|
||||
om:PELI:motors
|
||||
q:DONE:proximity to light pulse
|
||||
rb:DONE:touch to light drip
|
||||
rn:CC:proximity to light pulse
|
||||
sw:DONE:touch to light pulse
|
||||
tv:PELI:touch, 2 motors, shoulder light strips, words
|
||||
up:DONE:touch to pulse green, touch after to sparkle
|
||||
vc:DONE:motion to pink sparkle
|
||||
zipora:DONE:left,right motion to two strip
|
|
@ -0,0 +1,16 @@
|
|||
// AH
|
||||
|
||||
// hardware
|
||||
const lights1 = light.pixels;
|
||||
|
||||
lights1.setLength(46);
|
||||
lights1.setBrightness(0);
|
||||
lights1.setAll(0x00ff00);
|
||||
|
||||
const motion = jacdac.accelerometerClient;
|
||||
|
||||
motion.onCustomGesture(BeadGesture.Step, function () {
|
||||
//testLights.setAll(0xff0000)
|
||||
lights1.startBrightnessTransition(80, 0, 1000);
|
||||
})
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "ah",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
// dynasty-george
|
||||
|
||||
// Returns a single rgb color interpolation between given rgb color
|
||||
// based on the factor given; via https://codepen.io/njmcode/pen/axoyD?editors=0010
|
||||
function interpolateColor(color1: number, color2: number, factor: number) {
|
||||
// factor = easing.inOutCubic(factor);
|
||||
let r1 = color1 >> 16
|
||||
let r2 = color2 >> 16
|
||||
let g1 = (color1 & 0xff00) >> 8
|
||||
let g2 = (color2 & 0xff00) >> 8
|
||||
let b1 = color1 & 0xff
|
||||
let b2 = color2 & 0xff
|
||||
let r = (r1 + factor * (r2 - r1)) | 0x00
|
||||
let g = (g1 + factor * (g2 - g1)) | 0x00
|
||||
let b = (b1 + factor * (b2 - b1)) | 0x00
|
||||
return (r << 16) | (g << 8) | b;
|
||||
};
|
||||
// My function to interpolate between two colors completely, returning an array
|
||||
function interpolateColors(color1: number, color2: number, steps: number, i: number) {
|
||||
let stepFactor = i / (steps - 1);
|
||||
return interpolateColor(color1, color2, stepFactor);
|
||||
}
|
||||
|
||||
// sunset:
|
||||
// pink = 0xff3399
|
||||
// yellow = 0xff8000
|
||||
|
||||
// hardware
|
||||
//const motion = motion.
|
||||
const lights1 = light.pixels;
|
||||
//const motion = jacdac.accelerometerClient;
|
||||
lights1.setLength(62); // 62
|
||||
lights1.setBuffered(true);
|
||||
|
||||
function pulse() {
|
||||
let mid = lights1.length()>>1
|
||||
for (let i = 0; i < mid; i++) {
|
||||
lights1.setPixelColor(i, interpolateColors(0xff0000, 0x0000FF, mid, i))
|
||||
}
|
||||
for (let i = 0; i < mid; i++) {
|
||||
lights1.setPixelColor(i+mid, interpolateColors(0x0000FF, 0xFF0000, mid, i))
|
||||
}
|
||||
lights1.show();
|
||||
lights1.startBrightnessTransition(96, 0, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
}
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function() {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1500) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1200) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onCustomGesture(42, stepUpdate(), pulse); // register
|
||||
|
||||
// events
|
||||
//motion.onCustomGesture(BeadGesture.Step, function () {
|
||||
// pulse();
|
||||
//})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "dg",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
// dj
|
||||
|
||||
// hardware
|
||||
const lights = [light.pixels, light.pixels2, light.pixels5, light.pixels6];
|
||||
const colors = [0xFF0000, 0xFFFFFF, 0x00FFFF, 0xFFFF00]
|
||||
for(let i=0; i<lights.length; i++) {
|
||||
lights[i].setLength(120);
|
||||
lights[i].setBrightness(0);
|
||||
lights[i].setAll(colors[i]);
|
||||
}
|
||||
|
||||
forever(function () {
|
||||
for(let i=0; i<lights.length; i++) {
|
||||
lights[i].startBrightnessTransition(80, 0, 1000);
|
||||
pause(1000)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "dj",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
// Doris
|
||||
|
||||
// hardware
|
||||
const lights1 = light.pixels;
|
||||
const lights2 = light.pixels2;
|
||||
|
||||
// TODO: length
|
||||
lights1.setLength(46);
|
||||
lights1.setBrightness(0);
|
||||
lights2.setLength(46);
|
||||
lights2.setBrightness(0);
|
||||
|
||||
const touchLeft = new jacdac.TouchButtonsClient("touch");
|
||||
const touchRight = jacdac.touchButtonsClient;
|
||||
touchLeft.requiredDeviceName = "L"
|
||||
touchRight.requiredDeviceName = "R"
|
||||
touchLeft.onConnected = function () {
|
||||
touchLeft.calibrate()
|
||||
}
|
||||
touchRight.onConnected = function () {
|
||||
touchRight.calibrate()
|
||||
}
|
||||
const rainbowAnimation: light.NeoPixelAnimation = new light.RainbowCycleAnimation(50)
|
||||
const runningAnimation: light.NeoPixelAnimation = new light.RunningLightsAnimation(0xFF, 0, 0, 50)
|
||||
|
||||
let running = false
|
||||
function anim() {
|
||||
if (running) return;
|
||||
running = true;
|
||||
control.runInBackground(() => {
|
||||
while (running) {
|
||||
lights1.startBrightnessTransition(0, 80, 500);
|
||||
lights1.showAnimation(light.cometAnimation, 5000);
|
||||
}
|
||||
});
|
||||
control.runInBackground(() => {
|
||||
while (running) {
|
||||
lights2.startBrightnessTransition(0, 80, 500);
|
||||
lights2.showAnimation(light.cometAnimation, 5000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
touchLeft.onEvent(2, JDButtonEvent.Down, function () {
|
||||
anim();
|
||||
})
|
||||
|
||||
touchRight.onEvent(1, JDButtonEvent.Down, function () {
|
||||
anim();
|
||||
})
|
||||
|
||||
touchLeft.onEvent(5, JDButtonEvent.Down, function () {
|
||||
if (running) return;
|
||||
lights1.setAll(0xffff00);
|
||||
lights1.startBrightnessTransition(80, 0, 1000);
|
||||
})
|
||||
|
||||
touchRight.onEvent(5, JDButtonEvent.Down, function () {
|
||||
if (running) return;
|
||||
lights2.setAll(0x00ffff);
|
||||
lights2.startBrightnessTransition(80, 0, 1000);
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "ds",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// gevanleen
|
||||
|
||||
// hardware
|
||||
const lights1 = light.pixels;
|
||||
const lights2 = light.pixels2;
|
||||
|
||||
|
||||
lights1.setLength(100);
|
||||
lights1.setBrightness(0);
|
||||
lights1.setAll(0xff0000);
|
||||
lights2.setLength(100);
|
||||
lights2.setBrightness(0);
|
||||
lights2.setAll(0x00FF00);
|
||||
|
||||
// actions
|
||||
function pulse() {
|
||||
lights1.startBrightnessTransition(80, 0, 800)
|
||||
lights2.startBrightnessTransition(80, 0, 800)
|
||||
}
|
||||
|
||||
input.onGesture(Gesture.Shake, function () {
|
||||
pulse();
|
||||
})
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "gv",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// JG
|
||||
|
||||
// hardware
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const lights = light.pixels;
|
||||
lights.setBrightness(0);
|
||||
lights.setLength(120);
|
||||
lights.setAll(0xFF0000)
|
||||
|
||||
function pulse() {
|
||||
lights.startBrightnessTransition(96, 16, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
}
|
||||
|
||||
|
||||
// events
|
||||
tattoo.onEvent(2, JDButtonEvent.Down, function () {
|
||||
pulse();
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "jg1",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// JG
|
||||
|
||||
// hardware
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const lights = light.pixels;
|
||||
lights.setBrightness(0);
|
||||
lights.setLength(120);
|
||||
lights.setAll(0xFFFF00)
|
||||
|
||||
function pulse() {
|
||||
lights.startBrightnessTransition(96, 0, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
}
|
||||
|
||||
|
||||
// events
|
||||
tattoo.onEvent(5, JDButtonEvent.Down, function () {
|
||||
pulse();
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "jg2",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
light.pixels3.setLength(120)
|
||||
//light.pixels3.setAll(0xFF0000)
|
||||
|
||||
light.pixels5.setLength(80)
|
||||
light.pixels5.setAll(0xFF0000)
|
||||
|
||||
light.pixels6.setLength(120)
|
||||
light.pixels6.setAll(0xFF0000)
|
||||
|
||||
|
||||
light.pixels5.startBrightnessTransition(72, 16, 600);
|
||||
light.pixels6.startBrightnessTransition(72, 16, 600);
|
||||
|
||||
function pulse() {
|
||||
light.pixels5.startBrightnessTransition(200, 16, 600);
|
||||
light.pixels6.startBrightnessTransition(96, 16, 600);
|
||||
}
|
||||
input.onGesture(Gesture.Shake, function () {
|
||||
pulse();
|
||||
})
|
||||
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function() {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1500) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1200) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onCustomGesture(42, stepUpdate(), pulse); // register
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "jody",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// MO
|
||||
|
||||
// hardware
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const lights = light.pixels;
|
||||
lights.setBrightness(200);
|
||||
lights.setLength(50);
|
||||
|
||||
|
||||
function interpolateColor(color1: number, color2: number, factor: number) {
|
||||
// factor = easing.inOutCubic(factor);
|
||||
let r1 = color1 >> 16
|
||||
let r2 = color2 >> 16
|
||||
let g1 = (color1 & 0xff00) >> 8
|
||||
let g2 = (color2 & 0xff00) >> 8
|
||||
let b1 = color1 & 0xff
|
||||
let b2 = color2 & 0xff
|
||||
let r = (r1 + factor * (r2 - r1)) | 0x00
|
||||
let g = (g1 + factor * (g2 - g1)) | 0x00
|
||||
let b = (b1 + factor * (b2 - b1)) | 0x00
|
||||
return (r << 16) | (g << 8) | b;
|
||||
};
|
||||
// My function to interpolate between two colors completely, returning an array
|
||||
function interpolateColors(color1: number, color2: number, steps: number, i: number) {
|
||||
let stepFactor = i / (steps - 1);
|
||||
return interpolateColor(color1, color2, stepFactor);
|
||||
}
|
||||
|
||||
|
||||
function pulse() {
|
||||
let mid = lights.length()>>1
|
||||
for (let i = 0; i < mid; i++) {
|
||||
lights.setPixelColor(i, interpolateColors(0xff0000, 0x0000FF, mid, i))
|
||||
}
|
||||
for (let i = 0; i < mid; i++) {
|
||||
lights.setPixelColor(i+mid, interpolateColors(0x0000FF, 0xFF0000, mid, i))
|
||||
}
|
||||
lights.show();
|
||||
lights.startBrightnessTransition(96, 16, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
}
|
||||
|
||||
|
||||
// events
|
||||
tattoo.onEvent(2, JDButtonEvent.Down, function () {
|
||||
pulse();
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "mo",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// KT
|
||||
|
||||
// hardware
|
||||
const lights1 = light.pixels;
|
||||
const lights2 = light.pixels2;
|
||||
|
||||
// actions
|
||||
function pulse() {
|
||||
|
||||
}
|
||||
|
||||
lights1.setLength(46);
|
||||
lights1.setBrightness(0);
|
||||
lights1.setAll(0xffff30);
|
||||
lights2.setLength(46);
|
||||
lights2.setBrightness(0);
|
||||
lights2.setAll(0xffff30);
|
||||
|
||||
//const testLights = light.pixels
|
||||
//testLights.setLength(20);
|
||||
const motionLeft = new jacdac.AccelerometerClient("step");
|
||||
const motionRight = jacdac.accelerometerClient;
|
||||
|
||||
motionLeft.requiredDeviceName = "L"
|
||||
motionRight.requiredDeviceName = "R"
|
||||
|
||||
motionLeft.onCustomGesture(BeadGesture.LightStep, function () {
|
||||
//testLights.setAll(0xff0000)
|
||||
lights1.startBrightnessTransition(80, 0, 1000);
|
||||
})
|
||||
|
||||
motionRight.onCustomGesture(BeadGesture.LightStep, function () {
|
||||
//testLights.setAll(0x0000ff)
|
||||
lights2.startBrightnessTransition(80, 0, 1000);
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "kt",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
forever(function () {
|
||||
light.pixels.showAnimation(light.rainbowAnimation, 500)
|
||||
})
|
||||
forever(function () {
|
||||
light.pixels2.showAnimation(light.cometAnimation, 500)
|
||||
})
|
||||
forever(function () {
|
||||
light.pixels3.showAnimation(light.colorWipeAnimation, 500)
|
||||
})
|
||||
forever(function () {
|
||||
light.pixels5.showAnimation(light.theaterChaseAnimation, 500)
|
||||
})
|
||||
forever(function () {
|
||||
light.pixels6.showAnimation(light.sparkleAnimation, 500)
|
||||
})
|
||||
light.pixels7.setAll(0xff0000);
|
||||
light.pixels7.startBrightnessTransition(0, 80, 1000, -1, true);
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "bead-brain-light-test",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
// MO
|
||||
|
||||
// hardware
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const btns = [4, 5, 0];
|
||||
const center = light.pixels;
|
||||
const left = light.pixels2;//.range(20, 100);
|
||||
const right = light.pixels7;
|
||||
const strips = [center, left, right];
|
||||
|
||||
strips.forEach(strip => {
|
||||
strip.setBrightness(60);
|
||||
strip.setLength(30);
|
||||
strip.setBuffered(true);
|
||||
});
|
||||
|
||||
|
||||
let running = false;
|
||||
tattoo.onConnected = function() {
|
||||
tattoo.calibrate();
|
||||
}
|
||||
tattoo.calibrate();
|
||||
function animLeft() {
|
||||
while (running) {
|
||||
left.move(LightMove.Shift);
|
||||
if (Math.random() > 0.8)
|
||||
left.setPixelColor(0, 0xff00ff);
|
||||
left.show();
|
||||
pause(1)
|
||||
}
|
||||
}
|
||||
function animRight() {
|
||||
while (running) {
|
||||
right.move(LightMove.Shift, -1);
|
||||
if (Math.random() > 0.8)
|
||||
right.setPixelColor(right.length() - 1, 0xff00ff);
|
||||
right.show();
|
||||
pause(1)
|
||||
}
|
||||
}
|
||||
function animCenter() {
|
||||
const l = center.range(0, center.length() / 2)
|
||||
const r = center.range(center.length() / 2, center.length() / 2)
|
||||
while (running) {
|
||||
l.move(LightMove.Shift);
|
||||
if (Math.random() > 0.8)
|
||||
l.setPixelColor(0, 0xff00ff);
|
||||
r.move(LightMove.Shift, -1);
|
||||
if (Math.random() > 0.8)
|
||||
r.setPixelColor(r.length() - 1, 0xff00ff);
|
||||
center.show();
|
||||
pause(1)
|
||||
}
|
||||
}
|
||||
|
||||
function anim() {
|
||||
if (running) return;
|
||||
running = true;
|
||||
control.runInBackground(animCenter);
|
||||
control.runInBackground(animLeft);
|
||||
control.runInBackground(animRight);
|
||||
}
|
||||
anim();
|
||||
|
||||
// events
|
||||
btns.forEach(btn => {
|
||||
tattoo.onEvent(btn, JDButtonEvent.Down, function () {
|
||||
anim();
|
||||
})
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "mo",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
// motion
|
||||
jacdac.instance().setDeviceName("R");
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "motion",
|
||||
"dependencies": {
|
||||
"bead-motion": "file:../../../../libs/bead-motion"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
//const motion = motion.
|
||||
const lights1 = light.pixels;
|
||||
//const motion = jacdac.accelerometerClient;
|
||||
lights1.setLength(66); // 62
|
||||
lights1.setAll(0xFF0000);
|
||||
lights1.setBuffered(true);
|
||||
|
||||
function interpolateColor(color1: number, color2: number, factor: number) {
|
||||
// factor = easing.inOutCubic(factor);
|
||||
let r1 = color1 >> 16
|
||||
let r2 = color2 >> 16
|
||||
let g1 = (color1 & 0xff00) >> 8
|
||||
let g2 = (color2 & 0xff00) >> 8
|
||||
let b1 = color1 & 0xff
|
||||
let b2 = color2 & 0xff
|
||||
let r = (r1 + factor * (r2 - r1)) | 0x00
|
||||
let g = (g1 + factor * (g2 - g1)) | 0x00
|
||||
let b = (b1 + factor * (b2 - b1)) | 0x00
|
||||
return (r << 16) | (g << 8) | b;
|
||||
};
|
||||
// My function to interpolate between two colors completely, returning an array
|
||||
function interpolateColors(color1: number, color2: number, steps: number, i: number) {
|
||||
let stepFactor = i / (steps - 1);
|
||||
return interpolateColor(color1, color2, stepFactor);
|
||||
}
|
||||
|
||||
function pulse() {
|
||||
let mid = lights1.length()>>1
|
||||
for (let i = 0; i < mid; i++) {
|
||||
lights1.setPixelColor(i, interpolateColors(0xff0000, 0x00FF00, mid, i))
|
||||
}
|
||||
for (let i = 0; i < mid; i++) {
|
||||
lights1.setPixelColor(i+mid, interpolateColors(0x00FF00, 0xFF0000, mid, i))
|
||||
}
|
||||
lights1.show();
|
||||
lights1.startBrightnessTransition(96, 0, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function() {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1500) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1200) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onCustomGesture(42, stepUpdate(), pulse); // register
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "na",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
// omega
|
||||
|
||||
// hardware
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const servo2 = servos.servo2;
|
||||
const servo3 = servos.servo3;
|
||||
const drift2 = -5;
|
||||
const drift3 = 3;
|
||||
|
||||
const duration = 15000;
|
||||
const pauseDuration = 5000;
|
||||
|
||||
// actions
|
||||
let idle = true;
|
||||
function toggle() {
|
||||
if (!idle) return;
|
||||
|
||||
idle = false;
|
||||
moveUp();
|
||||
pause(duration);
|
||||
stop();
|
||||
pause(pauseDuration);
|
||||
moveDown();
|
||||
pause(duration);
|
||||
stop();
|
||||
idle = true;
|
||||
}
|
||||
|
||||
function moveUp() {
|
||||
servo2.run(drift2 + 100);
|
||||
servo3.run(drift3 + 100);
|
||||
}
|
||||
|
||||
function moveDown() {
|
||||
servo2.run(drift2 - 100);
|
||||
servo3.run(drift3 - 100);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
servo2.run(drift2 + 0);
|
||||
servo3.run(drift3 + 0);
|
||||
}
|
||||
|
||||
// events
|
||||
tattoo.onConnected = function() {
|
||||
tattoo.calibrate();
|
||||
}
|
||||
tattoo.onEvent(0, JDButtonEvent.Down, function () {
|
||||
toggle();
|
||||
})
|
||||
tattoo.onEvent(1, JDButtonEvent.Down, function () {
|
||||
stop();
|
||||
})
|
||||
tattoo.onEvent(2, JDButtonEvent.Down, function () {
|
||||
moveUp();
|
||||
});
|
||||
tattoo.onEvent(2, JDButtonEvent.Up, function () {
|
||||
stop();
|
||||
})
|
||||
tattoo.onEvent(3, JDButtonEvent.Down, function () {
|
||||
moveDown();
|
||||
})
|
||||
tattoo.onEvent(3, JDButtonEvent.Up, function () {
|
||||
stop();
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "om",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
// hardware
|
||||
const lights = light.pixels;
|
||||
lights.setAll(0xf0000);
|
||||
lights.setLength(288)
|
||||
lights.startBrightnessTransition(96, 0, 1000)
|
||||
const sparkle = new light.SparkleAnimation(0xff, 0, 0, 20);
|
||||
|
||||
const lights2 = light.pixels2;
|
||||
lights2.setLength(120)
|
||||
lights2.setBrightness(25);
|
||||
lights2.setAll(0xf0000);
|
||||
lights2.startBrightnessTransition(96, 0, 1000)
|
||||
|
||||
const proxmity = jacdac.proximityClient;
|
||||
|
||||
let started = false;
|
||||
jacdac.proximityClient.onEvent(JDPromixityEvent.Close, function () {
|
||||
if (started) return;
|
||||
|
||||
started = true;
|
||||
lights2.startBrightnessTransition(200, 0, 1000, -1, false,
|
||||
new light.EasingBrightnessTransition(easing.outCubic)
|
||||
);
|
||||
lights.setBrightness(255);
|
||||
forever(function () {
|
||||
lights.showAnimation(sparkle, 500);
|
||||
})
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "op",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// proximity
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "proximity",
|
||||
"dependencies": {
|
||||
"bead-proximity": "file:../../../../libs/bead-proximity"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Q
|
||||
|
||||
// hardware: too many neopixels, sticks in bootloader mode
|
||||
let lights = [light.pixels,light.pixels2, light.pixels7, light.pixels5]
|
||||
//let proximity = jacdac.proximityClient
|
||||
|
||||
for(let i=0; i<lights.length; i++) {
|
||||
lights[i].setBrightness(200);
|
||||
lights[i].setLength(120);
|
||||
lights[i].setBuffered(true);
|
||||
}
|
||||
|
||||
function pulse(j:number) {
|
||||
let the = lights[j]
|
||||
let last = the.length()-1
|
||||
the.clear();
|
||||
for (let i = 0; i < 20; i++) {
|
||||
the.setPixelColor(last,0x0000FF); the.move(LightMove.Shift,-1); the.show();
|
||||
pause(1);
|
||||
}
|
||||
for (let i = 0; i < the.length(); i++) {
|
||||
the.move(LightMove.Shift,-1); the.show();
|
||||
pause(1);
|
||||
}
|
||||
}
|
||||
|
||||
forever(function () {
|
||||
for(let i=0; i<lights.length; i++) {
|
||||
pulse(i);
|
||||
}
|
||||
})
|
||||
|
||||
// input.onGesture(Gesture.Shake,function () {
|
||||
// for(let i=0; i<lights.length; i++) {
|
||||
// pulse(i);
|
||||
// }
|
||||
// });
|
||||
|
||||
//motion.onCustomGesture(BeadGesture.Step, function () {
|
||||
// pulse();
|
||||
//})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "q",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
// Rebecca
|
||||
|
||||
// hardware
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const lights = light.pixels;
|
||||
const lights2 = light.pixels2;
|
||||
lights.setBrightness(200);
|
||||
lights.setLength(50);
|
||||
lights2.setBrightness(200);
|
||||
lights2.setLength(50);
|
||||
tattoo.onConnected = function() {
|
||||
tattoo.calibrate()
|
||||
}
|
||||
|
||||
let silver = [0,1,2,3,5,7,12]
|
||||
let black = [0,3,11]
|
||||
|
||||
let strips = [lights, lights2]
|
||||
let indirs = [silver, black];
|
||||
let dripping = [false,false];
|
||||
// actions
|
||||
|
||||
function drip(i: number) {
|
||||
if (!dripping[i]) {
|
||||
let light = strips[i]
|
||||
let indir = indirs[i]
|
||||
dripping[i] = true
|
||||
light.clear();
|
||||
for(let i=0; i<indir.length;i++) {
|
||||
light.setPixelColor(indir[i],0xffffff)
|
||||
if (i>0) {
|
||||
light.setPixelColor(indir[i-1],0x000000)
|
||||
}
|
||||
pause(500)
|
||||
}
|
||||
light.clear();
|
||||
dripping[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// events
|
||||
tattoo.onEvent(2, JDButtonEvent.Down, function () {
|
||||
control.runInBackground(()=>{drip(0)});
|
||||
control.runInBackground(()=>{drip(1);drip(1)});
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "rb",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// renita
|
||||
|
||||
// hardware
|
||||
const proximity = jacdac.proximityClient;
|
||||
const top1 = light.pixels;
|
||||
top1.setBrightness(0);
|
||||
top1.setAll(0xff0000);
|
||||
const top2 = light.pixels2;
|
||||
top2.setBrightness(0);
|
||||
top2.setAll(0xff0000);
|
||||
const bottom = light.pixels3;
|
||||
bottom.setBrightness(0);
|
||||
bottom.setAll(0xff0000);
|
||||
|
||||
// actions
|
||||
function pulse() {
|
||||
top1.startBrightnessTransition(80, 0, 800);
|
||||
top2.startBrightnessTransition(80, 0, 800);
|
||||
bottom.startBrightnessTransition(80, 0, 800);
|
||||
}
|
||||
|
||||
// events
|
||||
proximity.onEvent(JDPromixityEvent.Close, function () {
|
||||
pulse();
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "rn",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
namespace servos {
|
||||
//% fixedInstance
|
||||
export const servoA1 = new servos.PinServo(pins.A1);
|
||||
//% fixedInstance
|
||||
export const servoA2 = new servos.PinServo(pins.A2);
|
||||
}
|
||||
|
||||
namespace jacdac {
|
||||
//% fixedInstance
|
||||
export const servosService = new jacdac.ServosService("servos", [servos.servoA1, servos.servoA2]);
|
||||
}
|
||||
|
||||
jacdac.servosService.start();
|
||||
jacdac.instance().setDeviceName("R");
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "servo-arm",
|
||||
"dependencies": {
|
||||
"bead-tattoo": "file:../../../../libs/bead-tattoo",
|
||||
"servo": "file:../../../../libs/servo"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
|
||||
const tattoo = jacdac.touchButtonsClient;
|
||||
const ser = new jacdac.ServosClient("ser", 2);
|
||||
|
||||
let running = false;
|
||||
let forward = false;
|
||||
function anim() {
|
||||
if (running) return;
|
||||
running = true;
|
||||
if (forward) {
|
||||
ser.setAngle(0, 180);
|
||||
ser.setAngle(1, 0);
|
||||
pause(800)
|
||||
} else {
|
||||
ser.setAngle(0, 0);
|
||||
ser.setAngle(1, 180);
|
||||
pause(800)
|
||||
}
|
||||
forward = !forward;
|
||||
running = false;
|
||||
}
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function () {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1500) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1200) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onCustomGesture(42, stepUpdate(), anim); // register
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace servos {
|
||||
//% fixedInstance
|
||||
export const servoA1 = new servos.PinServo(pins.A1);
|
||||
//% fixedInstance
|
||||
export const servoA2 = new servos.PinServo(pins.A2);
|
||||
}
|
||||
|
||||
let running = false;
|
||||
let forward = false;
|
||||
function anim() {
|
||||
if (running) return;
|
||||
running = true;
|
||||
if (forward) {
|
||||
servos.servoA1.setAngle(180)
|
||||
servos.servoA2.setAngle(0)
|
||||
pause(800)
|
||||
} else {
|
||||
servos.servoA1.setAngle(0)
|
||||
servos.servoA2.setAngle(180)
|
||||
pause(800)
|
||||
}
|
||||
forward = !forward;
|
||||
running = false;
|
||||
}
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function () {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1500) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1200) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onCustomGesture(42, stepUpdate(), anim); // register
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "servo-test",
|
||||
"dependencies": {
|
||||
"bead-tattoo": "file:../../../../libs/bead-tattoo",
|
||||
"accelerometer": "file:../../../../libs/accelerometer",
|
||||
"servo": "file:../../../../libs/servo"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
//
|
||||
jacdac.servosService.start();
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "servo",
|
||||
"dependencies": {
|
||||
"bead-servo": "file:../../../../libs/bead-servo"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
//const motion = motion.
|
||||
const lights1 = light.pixels;
|
||||
const lights7 = light.pixels7;
|
||||
//const motion = jacdac.accelerometerClient;
|
||||
lights1.setLength(50); // 62
|
||||
lights1.setAll(0x00FF00);
|
||||
lights1.setBuffered(true);
|
||||
lights7.setLength(50); // 62
|
||||
lights7.setAll(0x0000FF);
|
||||
lights7.setBuffered(true);
|
||||
|
||||
|
||||
function pulse() {
|
||||
lights1.startBrightnessTransition(96, 0, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
lights7.startBrightnessTransition(96, 0, 800, 1, true,
|
||||
new light.EasingBrightnessTransition(easing.inOutCubic));
|
||||
}
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function() {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1300) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1100) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onGesture(Gesture.Shake, pulse);
|
||||
input.onCustomGesture(42, stepUpdate(), pulse); // register
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "student",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
// SW
|
||||
|
||||
// hardware: too many neopixels, sticks in bootloader mode
|
||||
const lights = light.pixels;
|
||||
const lights2 = light.pixels2;
|
||||
//const lights3 = light.pixels7;
|
||||
|
||||
lights.setBrightness(255);
|
||||
lights.setLength(120);
|
||||
lights.setBuffered(true);
|
||||
lights2.setBrightness(255);
|
||||
lights2.setLength(120);
|
||||
lights2.setBuffered(true);
|
||||
// lights3.setBrightness(200);
|
||||
// lights3.setLength(120);
|
||||
// lights3.setBuffered(true);
|
||||
|
||||
let last = lights.length()-1
|
||||
function pulse() {
|
||||
lights.clear();
|
||||
for (let i = 0; i < 15; i++) {
|
||||
lights.setPixelColor(last,0xCC00AA); lights.move(LightMove.Shift,-1); lights.show();
|
||||
lights2.setPixelColor(last,0xFFFF00); lights2.move(LightMove.Shift,-1); lights2.show();
|
||||
// lights3.setPixelColor(last,0xFFFF00); lights3.move(LightMove.Shift,-1); lights3.show();
|
||||
pause(1);
|
||||
}
|
||||
for (let i = 0; i < lights.length(); i++) {
|
||||
lights.move(LightMove.Shift,-1); lights.show();
|
||||
lights2.move(LightMove.Shift,-1); lights2.show();
|
||||
// lights3.move(LightMove.Shift,-1); lights3.show();
|
||||
pause(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function stepUpdate(): () => boolean {
|
||||
let active = true;
|
||||
return function() {
|
||||
const s = input.acceleration(Dimension.Strength);
|
||||
if (!active && s > 1500) {
|
||||
active = true;
|
||||
return true;
|
||||
} else if (s < 1200) {
|
||||
active = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
input.onCustomGesture(42, stepUpdate(), pulse); // register
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "sw",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
jacdac.touchButtonsClient.onEvent(0, JDButtonEvent.Click, function () {
|
||||
light.pixels.setAll(0xff0000)
|
||||
})
|
||||
jacdac.touchButtonsClient.onEvent(1, JDButtonEvent.Down, function () {
|
||||
light.pixels.setAll(0x00ff00)
|
||||
})
|
||||
jacdac.touchButtonsClient.onEvent(1, JDButtonEvent.Up, function () {
|
||||
light.pixels.setAll(0x0000ff)
|
||||
})
|
||||
jacdac.touchButtonsClient.onEvent(2, JDButtonEvent.LongClick, function () {
|
||||
light.pixels.setAll(0x00ffff)
|
||||
})
|
||||
input.onGesture(Gesture.Shake, function () {
|
||||
light.pixels.showAnimation(light.rainbowAnimation, 500)
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "tattoo-test",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
//
|
||||
jacdac.instance().setDeviceName("R")
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "tattoo-bead",
|
||||
"dependencies": {
|
||||
"bead-tattoo": "file:../../../../libs/bead-tattoo"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// TV
|
||||
|
||||
// hardware
|
||||
const lights1 = light.pixels;
|
||||
const lights2 = light.pixels2;
|
||||
const lightsShoulders = light.pixels7;
|
||||
|
||||
// letters
|
||||
lights1.setLength(30);
|
||||
lights1.setBrightness(200);
|
||||
lights1.setAll(0x0000FF);
|
||||
lights2.setLength(42);
|
||||
lights2.setBrightness(200);
|
||||
lights2.setAll(0x0000FF);
|
||||
|
||||
//shoulders
|
||||
lightsShoulders.setLength(40);
|
||||
lightsShoulders.setBrightness(200)
|
||||
lightsShoulders.clear();
|
||||
const sparkle5 = new light.SparkleAnimation(0x60, 0x60, 0xff, 20);
|
||||
forever(() => { lightsShoulders.showAnimation(sparkle5, 60000) });
|
||||
// lights5.move(LightMove.Rotate);
|
||||
// lights6.move(LightMove.Rotate);
|
||||
// });
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "tv",
|
||||
"dependencies": {
|
||||
"bead-brain": "file:../../../../libs/bead-brain"
|
||||
},
|
||||
"description": "",
|
||||
"files": [
|
||||
"main.ts",
|
||||
"README.md"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче