Muss ich leider in 2 Posts stückeln weil nir 9K reinpassen.
Definitionen:
#define DINO_VERSION 33 // "1.1" - HighNibble=Major, LowNibble=Minor
#define DINO_MODUL 1 // Modul-Number - 0=Master, 1++=Slave(s)
#define DINO_MAXCH 1 // standard is 1 - max 4 on MEGA
#define DINO_ID_STRING "MULTI_TENS" // string to identify
// Inputs:
// Outputs:
// communication Header
const byte HEADERSIZE = 16;
byte header[HEADERSIZE];
const byte MARKERSTART = 62; // ">" Start-marker, transmission begins
const byte MARKERDATA = 124; // "|" Header ending, start data
const byte MARKEREND = 60; // "<" End-marker, transmisson finished
const byte IDXHEADLEN = 0; // real length of header - MARKERDATA should follow immedeatly !!!
const byte IDXMODNUM = 1; // Modul-number to talk to
const byte IDXMODCHL = 2; // Modul-Channel - supported (Std. 1, 2-4 MEGA only)
const byte IDXMODVOL = 3; // "Master-Volume" 0-100%
const byte IDXREPLY = 4; // - 0 = return mode info only (no DATA)
// - 1 = return + modul-info
// - 2 = return + sequence-data
// - 3 = return + actual external pulse-data (potis - if any)
const byte IDXPLAY = 5; // - 0 = ... Stop everything ...
// - 1 = Manually external --- Freg, Pulse, Rate & Intens (with poti ... if available)
// - 2 = Manually internal --- Freg, Pulse, Rate & Intens (values by block_num[0])
// - 3 = single sequence --- ... see below ...
// - 4 = sequence PlayList --- ... see below ...
const byte IDXSTATUS = 6; // ... to be defined
const byte IDXERROR = 7; // ... to be defined
const byte IDXDATATYP = 8; // same as IDXREPLY ???!!!
const byte IDXDATALEN = 9; // length of one DATA-BLOCK
const byte IDXDATABLK = 10; // number of DATA-BLOCKs
byte pulserate = 0; // 0-200, 0 = no repetition
byte pulsewidth = 0; // 0-100, 0 = no pulse
byte pulseintens = 0; // 0-255, 0 = no intensity
Die Schleife:
void loop()
{
CMD_check();
delay(20);
}
SetUp:
void setup()
{
// Setup input-pins:
// Setup output-pins:
noInterrupts();
// initialize timers & ISR
interrupts();
Serial.begin(57600, SERIAL_8N1);
while (!Serial) // also check timeout !
{ ; // wait for serial port to connect. Needed for native USB port only
}
delay(10);
// ---------- Send Modul-Info on start
for (int i = 0; i < HEADERSIZE; i++) header[i] = 0; // clear header
header[IDXREPLY] = 1; // send Info
CMD_echo(); // return DATA: INFO
}