eerste
This commit is contained in:
parent
12365d373e
commit
9a88317df6
@ -69,17 +69,17 @@ Communication Status = 'E' -read/Write -Pin State: 0:0
|
|||||||
#define INPUTS //Use Arduino IO's as Inputs. Define how many Inputs you want in total and then which Pins you want to be Inputs.
|
#define INPUTS //Use Arduino IO's as Inputs. Define how many Inputs you want in total and then which Pins you want to be Inputs.
|
||||||
#ifdef INPUTS
|
#ifdef INPUTS
|
||||||
const int Inputs = 2; //number of inputs using internal Pullup resistor. (short to ground to trigger)
|
const int Inputs = 2; //number of inputs using internal Pullup resistor. (short to ground to trigger)
|
||||||
int InPinmap[] = {8,9};
|
int InPinmap[] = { 21, 22 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Use Arduino IO's as Toggle Inputs, which means Inputs (Buttons for example) keep HIGH State after Release and Send LOW only after beeing Pressed again.
|
//Use Arduino IO's as Toggle Inputs, which means Inputs (Buttons for example) keep HIGH State after Release and Send LOW only after beeing Pressed again.
|
||||||
#define SINPUTS //Define how many Toggle Inputs you want in total and then which Pins you want to be Toggle Inputs.
|
//#define SINPUTS //Define how many Toggle Inputs you want in total and then which Pins you want to be Toggle Inputs.
|
||||||
#ifdef SINPUTS
|
#ifdef SINPUTS
|
||||||
const int sInputs = 1; //number of inputs using internal Pullup resistor. (short to ground to trigger)
|
const int sInputs = 1; //number of inputs using internal Pullup resistor. (short to ground to trigger)
|
||||||
int sInPinmap[] = { 10 };
|
int sInPinmap[] = { 10 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OUTPUTS //Use Arduino IO's as Outputs. Define how many Outputs you want in total and then which Pins you want to be Outputs.
|
//#define OUTPUTS //Use Arduino IO's as Outputs. Define how many Outputs you want in total and then which Pins you want to be Outputs.
|
||||||
#ifdef OUTPUTS
|
#ifdef OUTPUTS
|
||||||
const int Outputs = 2; //number of outputs
|
const int Outputs = 2; //number of outputs
|
||||||
int OutPinmap[] = { 11, 12 };
|
int OutPinmap[] = { 11, 12 };
|
||||||
@ -224,7 +224,7 @@ If you want the LED to be off just define {0,0,0}, .
|
|||||||
If you use STATUSLED, it will also take the colors of your definition here.
|
If you use STATUSLED, it will also take the colors of your definition here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define DLED
|
#define DLED
|
||||||
#ifdef DLED
|
#ifdef DLED
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
@ -625,16 +625,14 @@ void comalive(){
|
|||||||
connectionState = 2;
|
connectionState = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
connectionState = 1;
|
connectionState = 1;
|
||||||
#ifdef STATUSLED
|
#ifdef STATUSLED
|
||||||
if (DLEDSTATUSLED == 1) {
|
if (DLEDSTATUSLED == 1) {
|
||||||
#ifdef DLED
|
#ifdef DLED
|
||||||
controlDLED(StatLedPin, 1);
|
controlDLED(StatLedPin, 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
digitalWrite(StatLedPin, HIGH);
|
digitalWrite(StatLedPin, HIGH);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -697,8 +695,6 @@ void reconnect(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
connectionState = 1;
|
connectionState = 1;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -722,22 +718,23 @@ void StatLedErr(int offtime, int ontime){
|
|||||||
if (newMillis - oldmillis >= offtime) {
|
if (newMillis - oldmillis >= offtime) {
|
||||||
#ifdef DLED
|
#ifdef DLED
|
||||||
if (DLEDSTATUSLED == 1) {
|
if (DLEDSTATUSLED == 1) {
|
||||||
controlDLED(StatLedPin, 1);}
|
controlDLED(StatLedPin, 1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (DLEDSTATUSLED == 0) { digitalWrite(StatLedPin, HIGH); }
|
if (DLEDSTATUSLED == 0) { digitalWrite(StatLedPin, HIGH); }
|
||||||
}
|
}
|
||||||
if (newMillis - oldmillis >= offtime+ontime){{
|
if (newMillis - oldmillis >= offtime + ontime) {
|
||||||
|
{
|
||||||
#ifdef DLED
|
#ifdef DLED
|
||||||
if (DLEDSTATUSLED == 1) {
|
if (DLEDSTATUSLED == 1) {
|
||||||
controlDLED(StatLedPin, 0);}
|
controlDLED(StatLedPin, 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (DLEDSTATUSLED == 0) { digitalWrite(StatLedPin, LOW); }
|
if (DLEDSTATUSLED == 0) { digitalWrite(StatLedPin, LOW); }
|
||||||
|
|
||||||
oldmillis = newMillis;
|
oldmillis = newMillis;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -779,8 +776,7 @@ void controlDLED(int Pin, int Stat){
|
|||||||
Serial.println(Stat);
|
Serial.println(Stat);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
|
|
||||||
strip.setPixelColor(Pin, strip.Color(DledOffColors[Pin][0], DledOffColors[Pin][1], DledOffColors[Pin][2]));
|
strip.setPixelColor(Pin, strip.Color(DledOffColors[Pin][0], DledOffColors[Pin][1], DledOffColors[Pin][2]));
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -818,8 +814,7 @@ void readAInputs(){
|
|||||||
|
|
||||||
if (samplecount < smooth) {
|
if (samplecount < smooth) {
|
||||||
sumAinput[i] = sumAinput[i] + analogRead(AInPinmap[i]);
|
sumAinput[i] = sumAinput[i] + analogRead(AInPinmap[i]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sumAinput[i] = sumAinput[i] / smooth;
|
sumAinput[i] = sumAinput[i] / smooth;
|
||||||
if (oldAinput[i] != sumAinput[i]) {
|
if (oldAinput[i] != sumAinput[i]) {
|
||||||
oldAinput[i] = sumAinput[i];
|
oldAinput[i] = sumAinput[i];
|
||||||
@ -829,9 +824,11 @@ void readAInputs(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(samplecount < smooth){ samplecount = samplecount + 1;}
|
if (samplecount < smooth) {
|
||||||
else {samplecount = 0;}
|
samplecount = samplecount + 1;
|
||||||
|
} else {
|
||||||
|
samplecount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef INPUTS
|
#ifdef INPUTS
|
||||||
@ -860,8 +857,7 @@ void readsInputs(){
|
|||||||
|
|
||||||
if (togglesinputs[i]) {
|
if (togglesinputs[i]) {
|
||||||
sendData('I', sInPinmap[i], togglesinputs[i]); // Turn the LED on
|
sendData('I', sInPinmap[i], togglesinputs[i]); // Turn the LED on
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sendData('I', sInPinmap[i], togglesinputs[i]); // Turn the LED off
|
sendData('I', sInPinmap[i], togglesinputs[i]); // Turn the LED off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -913,7 +909,6 @@ void readKeypad(){
|
|||||||
sendData('M', keys[row][col], 1);
|
sendData('M', keys[row][col], 1);
|
||||||
lastKey = keys[row][col];
|
lastKey = keys[row][col];
|
||||||
row = numRows;
|
row = numRows;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (digitalRead(rowPins[row]) == HIGH && lastKey == keys[row][col]) {
|
if (digitalRead(rowPins[row]) == HIGH && lastKey == keys[row][col]) {
|
||||||
// The Last Button has been unpressed
|
// The Last Button has been unpressed
|
||||||
@ -926,7 +921,6 @@ void readKeypad(){
|
|||||||
// Set the column pin back to input mode
|
// Set the column pin back to input mode
|
||||||
pinMode(colPins[col], INPUT);
|
pinMode(colPins[col], INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -982,14 +976,12 @@ void commandReceived(char cmd, uint16_t io, uint16_t value){
|
|||||||
if (cmd == 'O') {
|
if (cmd == 'O') {
|
||||||
writeOutputs(io, value);
|
writeOutputs(io, value);
|
||||||
lastcom = millis();
|
lastcom = millis();
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef PWMOUTPUTS
|
#ifdef PWMOUTPUTS
|
||||||
if (cmd == 'P') {
|
if (cmd == 'P') {
|
||||||
writePwmOutputs(io, value);
|
writePwmOutputs(io, value);
|
||||||
lastcom = millis();
|
lastcom = millis();
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef DLED
|
#ifdef DLED
|
||||||
@ -1002,7 +994,6 @@ void commandReceived(char cmd, uint16_t io, uint16_t value){
|
|||||||
Serial.print(" State:");
|
Serial.print(" State:");
|
||||||
Serial.println(DLEDstate[io]);
|
Serial.println(DLEDstate[io]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef MULTIPLEXLEDS
|
#ifdef MULTIPLEXLEDS
|
||||||
@ -1015,7 +1006,6 @@ void commandReceived(char cmd, uint16_t io, uint16_t value){
|
|||||||
Serial.print("Set to:");
|
Serial.print("Set to:");
|
||||||
Serial.println(ledStates[io]);
|
Serial.println(ledStates[io]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1057,8 +1047,7 @@ void readCommands(){
|
|||||||
state = STATE_VALUE;
|
state = STATE_VALUE;
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print("Ungültiges zeichen: ");
|
Serial.print("Ungültiges zeichen: ");
|
||||||
Serial.println(current);
|
Serial.println(current);
|
||||||
@ -1068,22 +1057,18 @@ void readCommands(){
|
|||||||
case STATE_VALUE:
|
case STATE_VALUE:
|
||||||
if (isDigit(current)) {
|
if (isDigit(current)) {
|
||||||
inputbuffer[bufferIndex++] = current;
|
inputbuffer[bufferIndex++] = current;
|
||||||
}
|
} else if (current == '\n') {
|
||||||
else if(current == '\n'){
|
|
||||||
inputbuffer[bufferIndex] = 0;
|
inputbuffer[bufferIndex] = 0;
|
||||||
value = atoi(inputbuffer);
|
value = atoi(inputbuffer);
|
||||||
commandReceived(cmd, io, value);
|
commandReceived(cmd, io, value);
|
||||||
state = STATE_CMD;
|
state = STATE_CMD;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print("Ungültiges zeichen: ");
|
Serial.print("Ungültiges zeichen: ");
|
||||||
Serial.println(current);
|
Serial.println(current);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user