I don't want to preempt any official Onion work. You folks have done a great job with the hardware and software. But if anyone is interested in my experimental library I've put it up on Github:
https://github.com/mpmarks/Onion2
Posts made by Maurice Marks
-
RE: How to access Arduino Dock A0 from terminal
-
RE: How to access Arduino Dock A0 from terminal
I've got that to work. Here's the story:
The only communication between the Omega and the Arduino is on I2C. And as it stands that was set up to cause a reset on a particular write to do the flash procedure and also to control a neopixel string. Unfortunately that precludes using that channel for anything else, which is a real pain.
You can connect the Arduino serial RX/TX to the Omega RX/TX but that would take over the Omega console, so its not ideal.So what I did was to strip out the Neopixel code from the Omega Library and replace it with a modified library that allows a user program to register handlers for i2c receive and request. It preserves the 0xdead to 0x08 processing that is needed to automatically flash a new project but allows a number of user routines to be added. This makes the Arduino look like an I2C slave device with a set of registers that can be read or written from the Onion side. I also create an ONION pseudo device to simplify the setup.
Here's my current test application - it controls a single neopixel (on address 1) and also reads from A0 on request from address 2.
Note - this is just an experiment at this point. If there is interest I'll post my library code.#include <Wire.h>
#include <Onion2.h>
#include <Adafruit_NeoPixel.h>#define LED 13
#define LED2 A1
#define NEO 8Adafruit_NeoPixel rgb(1, NEO);
void recvEvent() {
byte data;
byte r=0, g=0, b=0;
if (Wire.available()) r = Wire.read();
if (Wire.available()) g = Wire.read();
if (Wire.available()) b = Wire.read();
rgb.setPixelColor(0, r, g, b);
rgb.show();
}byte reqEvent() {
return analogRead(A0);
}void setup() {
pinMode(LED, OUTPUT);
// pinMode(LED2, OUTPUT);
Serial.begin(115200);
rgb.begin();
rgb.clear();
rgb.show();ONION.registerRcvHandler(1, &recvEvent);
ONION.registerReqHandler(2, &reqEvent);// digitalWrite(LED2, LOW);
}void loop() {
Serial.println("Hello2");
digitalWrite(LED, 1);
delay(1000);
digitalWrite(LED, 0);
delay(1000);}