Authors: Matt Ibarra, Seo Townsend 2013
Currently supports the PIC18F2680 jsPIC is a platform for the PIC18 processor that provides a javascript inspired API with 'remoting' capabilities for RPC.
*The networking architecture allows for meshing PIC's togeather. E.g. If you have three PIC's, two linked by I2C and two linked by serial, they will all communicate just fine within the networking framework. jsPIC supports a lightweight search algorithm that will find the correct PIC even if it has to route through other PIC's.
blink() {
LA0 = ~LA0;
}
onSetup() {
SetInterval(1000, blink);
}
onLoop() {
}##Message an adjacent PIC over I2C slave/master (A is slave, B is master)
PIC A (Slave):
call() {
LA0 = ~LA0;
Packet_t *packet = AsyncMessage;
unsigned char *data = packet->data;
}
onSetup() {
TwitterSignUp("@a");
TwitterAddWireSlave(0x4F);
TwitterRegisterSubject("c", call);
}
onLoop() {
}PIC B (Master):
call() {
LA0 = ~LA0;
}
onSetup() {
TwitterSignUp("@b");
TwitterAddWireMaster();
TwitterWireMasterAddSlave(0x4F, "@a");
//Send message to A
memcpy(message, "hello", 5);
Tweet("@a", "c", message);
}
onLoop() {
}##Message an adjacent PIC over I2C slave/master and serial (A is slave, B is master, C is serial) A <=i2c=> B <=serial=> C
PIC A (Slave):
call() {
LA0 = ~LA0;
Packet_t *packet = AsyncMessage;
unsigned char *data = packet->data;
}
onSetup() {
TwitterSignUp("@a");
TwitterAddWireSlave(0x4F);
TwitterRegisterSubject("c", call);
}
onLoop() {
}PIC B (Master):
onSetup() {
TwitterSignUp("@b");
TwitterAddWireMaster();
TwitterAddSerial();
TwitterWireMasterAddSlave(0x4F, "@a");
}
onLoop() {
}PIC C (Master):
call() {
LA0 = ~LA0;
}
onSetup() {
TwitterSignUp("@c");
TwitterAddSerial();
//Send message to A
memcpy(message, "hello", 5);
Tweet("@a", "c", message);
}
onLoop() {
}