Sorry, some mistake in my code... Here is my correct Testcode:
Like this, it is working fine. But as soon as i call
in loop() both HM-10 do not reply anymore. Is this an pin-change-interrupt-problem??
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX1 8
#define REMOTEXY_SERIAL_TX1 10
#define REMOTEXY_SERIAL_RX2 9
#define REMOTEXY_SERIAL_TX2 11
//#define REMOTEXY_SERIAL_RX3 20
//#define REMOTEXY_SERIAL_TX3 23
#define REMOTEXY_SERIAL_SPEED 4800
// Data for RemoteXY's instance 1
CRemoteXY *rxy1;
const uint8_t PROGMEM rxy1_config[] =
{ 255,2,0,5,0,47,0,6,5,2,
5,9,26,8,45,45,4,40,42,42,
2,65,15,7,9,9,9,7,9,9,
9,2,66,33,89,2,9,50,53,5,
9,83,2,66,161,1,54,89,8,1,
90,60,8,2 };
struct {
// input variable
int8_t joy_1_x; // =-100..100 x-coordinate joystick position
int8_t joy_1_y; // =-100..100 y-coordinate joystick position
// output variable
uint8_t led_1_r; // =0..255 LED Red brightness
uint8_t led_1_g; // =0..255 LED Green brightness
uint8_t led_1_b; // =0..255 LED Blue brightness
int8_t ver_1; // =-100..100 level position
int8_t hor_1; // =-100..100 level position
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} rxy1_struct;
// Data for RemoteXY's instance 2
CRemoteXY *rxy2;
const uint8_t PROGMEM rxy2_config[] =
{ 255,2,0,5,0,47,0,6,5,2,
5,9,26,8,45,45,4,40,42,42,
2,65,15,7,9,9,9,7,9,9,
9,2,66,33,89,2,9,50,53,5,
9,83,2,66,161,1,54,89,8,1,
90,60,8,2 };
struct {
// input variable
int8_t joy_2_x; // =-100..100 x-coordinate joystick position
int8_t joy_2_y; // =-100..100 y-coordinate joystick position
// output variable
uint8_t led_2_r; // =0..255 LED Red brightness
uint8_t led_2_g; // =0..255 LED Green brightness
uint8_t led_2_b; // =0..255 LED Blue brightness
int8_t ver_2; // =-100..100 level position
int8_t hor_2; // =-100..100 level position
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} rxy2_struct;
//eigene Defines
#define LED_gruen 14//MISO
#define LED_rot 15//SCK
//globale Variablen
void setup()
{
pinMode(LED_BUILTIN, OUTPUT); //integrierte LED
pinMode(LED_gruen, OUTPUT);
pinMode(LED_rot, OUTPUT);
Serial.begin(9600); //Verbindung USB direkt zu PC (debug Console)
//delay(800);
Serial.println("RemoteXY for Light-Control by SG7");
Serial.println("Startup...");
//delay(1000);
//RemoteXY_Init ();
rxy1 = new CRemoteXY (rxy1_config, &rxy1_struct, REMOTEXY_ACCESS_PASSWORD, REMOTEXY_SERIAL_RX1, REMOTEXY_SERIAL_TX1, REMOTEXY_SERIAL_SPEED);
delay(1000);
//rxy2 = new CRemoteXY (rxy2_config, &rxy2_struct, REMOTEXY_ACCESS_PASSWORD, REMOTEXY_SERIAL_RX2, REMOTEXY_SERIAL_TX2, REMOTEXY_SERIAL_SPEED);
Serial.println("Startup done!");
} //Ende void setup()
void loop()
{
if ( rxy1_struct.connect_flag == 1 )
{ digitalWrite(LED_gruen, HIGH);
}
else
{ digitalWrite(LED_gruen, LOW);
};
//Serial.print("joy x");
//Serial.println(rxy1_struct.joy_1_x);
//Serial.print("ver_1");
//Serial.println(rxy1_struct.ver_1);
//RemoteXY_Handler ();
rxy1->handler();
//delay(5);
//rxy2->handler();
rxy1_struct.ver_1=rxy1_struct.joy_1_x;
rxy1_struct.hor_1=rxy1_struct.joy_1_y;
//rxy2_struct.ver_2=rxy2_struct.joy_2_x;
//rxy2_struct.hor_2=rxy2_struct.joy_2_y;
rxy1_struct.led_1_r=100;
rxy1_struct.led_1_b=100;
//rxy2_struct.led_2_g=250;
} //Ende void loop()