Just doing a basic test on a Leonardo - Push a button, see a log in AM. Push a button in AM, see something in the serial monitor of the arduino
I don't see anything either end. My guess is the Arduino is not connecteing to AM at all, I can;t see anything in AM that it is.
Any ideas?
Arduino code:
Code: Select all
#include <si_message_port.hpp>
SiMessagePort* messagePort;
byte btn_state = 1;
static void new_message_callback(uint16_t message_id, struct SiMessagePortPayload* payload) {
Serial.println(payload->data_string);
}
void setup() {
Serial.begin(9600);
messagePort = new SiMessagePort(SI_MESSAGE_PORT_DEVICE_ARDUINO_LEONARDO, SI_MESSAGE_PORT_CHANNEL_G, new_message_callback);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(2, INPUT_PULLUP);
}
void loop() {
messagePort->Tick();
byte btn = digitalRead(2);
if(btn != btn_state) {
btn_state = btn;
digitalWrite(LED_BUILTIN,!btn_state);
messagePort->SendMessage(777, "Hello");
}
}
Code: Select all
-- This function will be called when a message is received from the Arduino.
function new_message(id, payload)
log("Got It")
end
id = hw_message_port_add("ARDUINO_LEONARDO_G", new_message)
function pressed_callback()
hw_message_port_send(id, 777, "STRING", "Hiii")
log("sending")
end
my_button = button_add("image_normal.png", "image_pressed.png", 0, 0, 200, 200, pressed_callback)