Skip to content

Commit

Permalink
Updated gradient to work with shortest distance only
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisjake committed Sep 26, 2010
1 parent a512768 commit b053667
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 19 deletions.
Empty file removed README
Empty file.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This is my adventure in writing software for the [Illuminato x Machina](http://illuminatolabs.com/IlluminatoXMachina.htm).

The IXM is an interesting platform, taking the limits of a [von Neumann](http://en.wikipedia.org/wiki/John_von_Neumann) and twisting them by adding additional, closely connected computation units. Basically giving you a tiny network of computers that are self aware, robust, and viral (in a sense). It behaves similar to an [Arduino](http://www.arduino.cc/) in that it has a bootloader which is programmable through a USB/Serial connection. It can communicate on each of it's four sides and provide small visual feedback with LEDs on each edge and a centrally located RGB LED.

I picked up a [Comp Sci Hack Pack](http://www.liquidware.com/shop/show/CS-HP/Comp+Sci+Hack+Pack), which includes a red programming terminal and 3 IXM cells. This allows for some parallel computations and other interesting experiments.

The files contained below are compilable and executable on each IXM cell.

References:

* [http://illuminatolabs.com/IlluminatoXMachina.htm]()
* [http://robust.cs.unm.edu/doku.php]()
* [http://livingcomputation.com/s/doc/Tutorials.html]()
* [http://livingcomputation.com/s/doc/index.html]()
* [http://www.liquidware.com/shop/show/IXM/Illuminato+X+Machina]()
74 changes: 55 additions & 19 deletions gradient.pde
Original file line number Diff line number Diff line change
@@ -1,64 +1,100 @@
// Simple Gradient
// (C) 2010 Jacob Good
// License: MIT (included in LICENSE.txt)
//
// Notes: This demonstrates a gradient based on distance from the center.
// Each IXM cell responds to a click and sets itself as center,
// broadcasting it's event and passing around distance calculations,
// out over the graph. Each cell then turns on a set of LEDs to
// indicate it's *shortest* distance from the center.

u32 shortestDistance;

void setRed( void ) {
ledOn(BODY_RGB_RED_PIN);
ledOff(BODY_RGB_BLUE_PIN);
ledOff(BODY_RGB_GREEN_PIN);
ledOff(BODY_RGB_BLUE_PIN);
ledOff(BODY_RGB_GREEN_PIN);
}

void setBlue( void ) {
ledOff(BODY_RGB_RED_PIN);
ledOn(BODY_RGB_BLUE_PIN);
ledOff(BODY_RGB_GREEN_PIN);
ledOn(BODY_RGB_BLUE_PIN);
ledOff(BODY_RGB_GREEN_PIN);
}

void setGreen( void ) {
ledOff(BODY_RGB_RED_PIN);
ledOff(BODY_RGB_BLUE_PIN);
ledOn(BODY_RGB_GREEN_PIN);
ledOff(BODY_RGB_BLUE_PIN);
ledOn(BODY_RGB_GREEN_PIN);
}

void setWhite( void ) {
ledOn(BODY_RGB_RED_PIN);
ledOn(BODY_RGB_BLUE_PIN);
ledOn(BODY_RGB_GREEN_PIN);
ledOn(BODY_RGB_BLUE_PIN);
ledOn(BODY_RGB_GREEN_PIN);
}

void setBlack( void ) {
ledOff(BODY_RGB_RED_PIN);
ledOff(BODY_RGB_BLUE_PIN);
ledOff(BODY_RGB_GREEN_PIN);
ledOff(BODY_RGB_BLUE_PIN);
ledOff(BODY_RGB_GREEN_PIN);
}

void branch( u32 sourceFace, u32 distance ) {
void branchGradient( u32 sourceFace, u32 distance ) {
if (sourceFace != NORTH) facePrintf(NORTH,"g%d\n",distance);
if (sourceFace != SOUTH) facePrintf(SOUTH,"g%d\n",distance);
if (sourceFace != EAST) facePrintf(EAST,"g%d\n",distance);
if (sourceFace != WEST) facePrintf(WEST,"g%d\n",distance);
}

void setGradient( u8 * packet ) {
void branchReset( u32 sourceFace ) {
if (sourceFace != NORTH) facePrintf(NORTH,"r\n");
if (sourceFace != SOUTH) facePrintf(SOUTH,"r\n");
if (sourceFace != EAST) facePrintf(EAST,"r\n");
if (sourceFace != WEST) facePrintf(WEST,"r\n");
}

void handleGradient( u8 * packet ) {
u32 distance;
packetScanf(packet,"g%d\n",&distance);

setBlack();
if (distance >= shortestDistance) return;

shortestDistance = distance;

if (distance == 1) setBlue();
else if (distance == 2) setGreen();
else if (distance == 3) setWhite();

branch(packetSource(packet), distance + 1);
branchGradient(packetSource(packet), distance + 1);
}

void resetSelf() {
setBlack();
shortestDistance = U32_MAX;
}

void handleReset( u8 * packet) {
resetSelf();
branchReset(packetSource(packet));
}

void stealGradient( ) {
println("r");
delay(500);
resetSelf();
setRed();
branch(0,1);
branchGradient(0,1);
}

void setup() {
Body.reflex('g', setGradient);
resetSelf();
Body.reflex('g', handleGradient);
Body.reflex('r', handleReset);
}

void loop() {
if (buttonDown()) {
stealGradient();
}
if (buttonDown()) {
stealGradient();
}
}

0 comments on commit b053667

Please sign in to comment.