I am experiencing a weird issue that I have no idea about. I am using Arduino IDE 2.0.4 which otherwise works perfectly.
So, I have a sketch that compiles and uploads fine and as can be seen via the screenshots, when I add another line of comment, using either:
/* additional comments */
or
// additional comments
... at the top of the sketch, it does not compile! Same code (except additional line of course), same device, same port... weird eh! Could someone please explain why my code is being visited by aliens
Errrm... I did do that Bob? Not sure what I have done that is not correct here?
The code without the additional comment works, it compiles and uploads perfectly, but by simply adding an additional line at the top of the code, it fails - as shown in the screenshot. The code is the same, just the additional comment line added at the top. I don't think everyone would need to see the entire sketch in this case.
You posted pictures of code rather than code itself in code tags to make it easy to copy for examination. Did you read the advice in the link that I posted ?
Yep I did, and I replied as to why the entire code is not needed in this case. The images were to show that the code fails by simply adding an additional comment line at the top of the sketch. The code works, it compiles and uploads 100%. But when I add another comment at the top, it fails. The code doesn't need to be debugged, it works. The issue appears when I add a comment line, surely adding a comment shouldn't cause any issue in any compiler?
Why by adding a single comment line at the top of an otherwise fully working sketch would cause the compiler to fail... is what I am trying to figure out.
I would like to try the problem for myself, but to do that I need to type in a complete sketch that you have not posted. As a result I cannot try it for myself so cannot provide any help
Bob, I had no intention of coming across as awkward, rather I was trying to simplify things. I just didn't see the need to post the code as it is working fine!
In any event, if you're still curious...
/* Please make sure your touch IC model. */
//#define TOUCH_MODULES_CST_MUTUAL
#define TOUCH_MODULES_CST_SELF
#include "Arduino.h"
#include "OneButton.h"
#include "TFT_eSPI.h" /* Please use the specific TFT library provided on LilyGo GitHub. */
#include "TouchLib.h"
#include "Wire.h"
#include "img_logo.h"
#include "pin_config.h"
TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, CTS820_SLAVE_ADDRESS, PIN_TOUCH_RES);
TFT_eSPI tft = TFT_eSPI();
bool flags_sleep = false;
OneButton button(PIN_BUTTON_1, true);
void setup() {
pinMode(PIN_POWER_ON, OUTPUT);
digitalWrite(PIN_POWER_ON, HIGH);
pinMode(PIN_TOUCH_RES, OUTPUT);
digitalWrite(PIN_TOUCH_RES, LOW);
delay(500);
digitalWrite(PIN_TOUCH_RES, HIGH);
tft.begin();
tft.setRotation(1);
ledcSetup(0, 2000, 8);
ledcAttachPin(PIN_LCD_BL, 0);
ledcWrite(0, 255);
tft.fillScreen(TFT_BLACK);
Wire.begin(PIN_IIC_SDA, PIN_IIC_SCL);
}
void loop() {
if (touch.read()) {
uint8_t n = touch.getPointNum();
for (uint8_t i = 0; i < n; i++) {
TP_Point t = touch.getPoint(i);
// If the touch event is valid (x and y coordinates are within the screen bounds)
if (t.x > 0 && t.x < tft.height() && t.y > 0 && t.y < tft.width()) {
// Draw a circle at the touch point
tft.fillCircle(t.y, 170 - t.x, 5, TFT_WHITE);
}
}
}
delay(1);
}