From 6c5577ce524d016be3865eeffe39e8590a0816f7 Mon Sep 17 00:00:00 2001 From: Ton Date: Wed, 6 Mar 2024 14:30:35 +0100 Subject: [PATCH] stupid conversion shit --- LinuxCNC_ArduinoConnector.ino | 54 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/LinuxCNC_ArduinoConnector.ino b/LinuxCNC_ArduinoConnector.ino index b97b131..12c3b76 100644 --- a/LinuxCNC_ArduinoConnector.ino +++ b/LinuxCNC_ArduinoConnector.ino @@ -60,8 +60,10 @@ Communication Status = 'E' -read/Write -Pin State: 0:0 #define DEBUG - -//#define OLED +#ifdef DEBUG +char dbStr[255]; +#endif +#define OLED #ifdef OLED #include #include "SSD1306Ascii.h" @@ -255,11 +257,7 @@ int DledOffColors[DLEDcount][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; - - Adafruit_NeoPixel strip(DLEDcount, DLEDPin, NEO_GRB + NEO_KHZ800); //Color sequence is different for LED Chipsets. Use RGB for WS2812 or GRB for PL9823. - - #endif /* Matrix Keypads are supported. The input is NOT added as HAL Pin to LinuxCNC. Instead it is inserted to Linux as Keyboard direktly. @@ -372,7 +370,7 @@ void setup() { #ifdef OLED Wire.begin(); - //Wire.setClock(400000L); + Wire.setClock(400000L); #if RST_PIN >= 0 oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN); @@ -584,7 +582,7 @@ void readEncoders() { #endif -void Debug_(String inStr, byte newLine = 1) { +void Debug_(char inStr[200], byte newLine = 1) { if (newLine) { Serial.println(inStr); } else { @@ -609,7 +607,7 @@ void comalive() { connectionState = 1; flushSerial(); #ifdef DEBUG - Debug_("first connect"); + Debug_("first connect", 0); #endif } if (millis() - lastcom > timeout) { @@ -638,7 +636,6 @@ void comalive() { #endif } - void reconnect() { #ifdef DEBUG Debug_("reconnected"); @@ -774,10 +771,12 @@ void controlDLED(int Pin, int Stat) { strip.setPixelColor(Pin, strip.Color(DledOnColors[Pin][0], DledOnColors[Pin][1], DledOnColors[Pin][2])); #ifdef DEBUGDLED - Debug_("DLED No.", 0); - Debug_(F(Pin), 0); + /*Debug_("DLED No.", 0); + Debug_((Pin), 0); Debug_(" set to:", 0); - Debug_(F(Stat)); + Debug_(F(Stat));*/ + + Debug_(sprintf("DLED No: $i set to: %i", Pin, Stat)) #endif } else { @@ -785,9 +784,9 @@ void controlDLED(int Pin, int Stat) { strip.setPixelColor(Pin, strip.Color(DledOffColors[Pin][0], DledOffColors[Pin][1], DledOffColors[Pin][2])); #ifdef DEBUGDLED Debug_("DLED No.", 0); - Debug_(F(Pin), 0); + Debug_(sprintf(Pin, 0), 0); Debug_(" set to:", 0); - Debug_(F(Stat)); + Debug_(sprintf(Stat, 0)); #endif } @@ -884,7 +883,7 @@ int readAbsKnob() { } if (var != oldAbsEncState) { Debug_("K0:", 0); - Debug_(F(var)); + Debug_(sprintf(var, 0)); } oldAbsEncState = var; return (var); @@ -941,7 +940,7 @@ void commandReceived(char cmd, uint16_t io, uint16_t value) { Serial.print("DLED:", 0); Serial.print(F(io), 0); Serial.print(" State:", 0); - Debug_(F(DLEDstate[io])); + Debug_(sprintf(DLEDstate[io], 0)); #endif } #endif @@ -954,11 +953,13 @@ void commandReceived(char cmd, uint16_t io, uint16_t value) { #ifdef DEBUG - Debug_("I Received= ", 0); - Debug_(F(cmd), 0); - Debug_(F(io), 0); - Debug_(":", 0); - Debug_(F(value)); + /*Debug_("I Received= ", 0); + Debug_(cmd, 0); + Debug_(sprintf("%i",io), 0); + Debug_(sprintf(":",0), 0); + Debug_(sprintf("%d",value));*/ +// String x =sprintf("I recieved= %s:%s%i",String(cmd),10,110); +//Debug_(sprintf("I recieved= %i:%i",0,0)) #endif } @@ -985,7 +986,9 @@ void readCommands() { } else { #ifdef DEBUG Serial.print("Ungültiges zeichen: "); - Debug_(F(current)); + char dbStr2[22]; + printf(dbStr2, "%d", current); + Debug_(dbStr2); #endif } break; @@ -999,8 +1002,9 @@ void readCommands() { state = STATE_CMD; } else { #ifdef DEBUG - Debug_("Ungültiges zeichen: ", 0); - Debug_(F(current)); + char dbStr2[200]; + // dbStr2 = sprintf(dbStr, "Ungültiges zeichen: %s",current); + Debug_(dbStr2, 0); #endif } break;