-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Can't calibrate touch screen #20506
Comments
Please follow the issue template and attach your configs. |
So I can't reproduce your issue. The issue template is for that: I don't know what are your configs and I don't know what you are doing, because there're no steps described in how to reproduce the bug. |
Here it is, although for this bug, they would be useless since it is an error in the code logic. Sorry to be harsh, but I did explain the steps that the code is doing. I'm not doing anything, yet it happens on start everytime. I know I can bypass them via the serial link, but since I have a TFT screen, I'm not using the serial port for controlling the printer. And without a serial port, the printer is useless (it's struck and can't be unlocked, unless restarting the printer, which is a critical bug IMHO). Since I fail the calibration 4 times out of 5, it's a PITA. To reply to your points:
I think there are many "magic" commands that are not clear and there is no comment in the code whatsoever to explain them. Take the EEPROM out of the equation here (and/or the serial port), and you'll see that the printer is useless with the code as-is. |
add M995 in custom menus. else, there was a commit pushed today to slow down a bit the calibration procedure with DOGM.. if you use this TFT_CLASSIC_UI see PR #20454 |
Well... here we go:
It's not useless. It's needed for most of the cases. This is the reason we have an issue template and ask users to follow it.
You are using LVGL UI, just go to "Settings -> Eeprom Set -> Store settings to EEPROM". It will save the calibration values to EEPROM, and you problem will be gone.
It's because of the precision factor we set. We can make it less precise, but I think don't worth.
The logic is not broken. You are doing wrong assumptions and wrong tests.
If you don't have EEPROM to save calibration values, it will ask you every time to calibrate your screen if you don't have it set in your config!! Because without these values, the touch will not work... Adding "such as X = 1<<16, Y = 1<<16, OFFSET = 0" is useless. I'm closing this, because it's not a but at all, as the user said that he isn't saying the calibration data to EEPROM. |
How do you go to the menu if you can't click on anything ?
I'm powering on the printer, and the printers locks up. There is a button "Return" on screen and clicking it does not work. Please note that I'm pretty stubborn so I'm doing the calibration multiple time by restarting the printer, but many users will not. Also, if you have some requirement, please write them somewhere (for example on screen "You must save the calibration to EEPROM now" if the code does not do it by itself). In the end, it's not user friendly at all IMHO. |
How on earth you want that your touch screen works when touch calibration fails?? I said that you must save to EEPROM when you have a SUCCESSFUL calibration!
There's NO TOUCH_SCREEN_CALIBRATION FOR LVGL BEFORE that commit you pointed out. . Before that, only COLOR UI had touch calibration screen. The only think that existed was: XPT calibration values. Now we changed those name. If you have valid configuration, just update the name of the configs and it will work.
No marlin config does auto save, that I'm aware of. And a lot of other configurations don't say you need to save it after changing: z offset, abl, ubl, steps/mm.... None that I'm aware of. Because it's something very obvious: when you change some config, it should be stored somewhere... if not, it will be lost in the next boot... But ok, we can make our documentation better, so we will avoid having to say users that when configs are changed, they need to be saved. |
I think there are some good points made here. Unfortunately it turned into arguing rather than looking for opportunities to make Marlin better. First, I'd like to address this response to requesting configs
Configuration files are never useless. There are basically infinite ways to configure Marlin. We don't ask for configuration files to find bugs in your configs, it is to help understand how you are using Marlin. I have suggested we automatically close issues without configuration files, @rhapsodyv was patient enough to ask you for them. Second, I think is probably room for improvement in these routines. It seems they work as currently designed, but we can probably do better. We should consider the experience of a user who has no serial connection no debugging skills. When they turn on their printer, what is their experience? We should be able to come up with some minor changes to the procedure to make this better.
I am not re-opening this issue. @rhapsodyv is the expert on all things TFT. I have never even plugged mine in. I respect his judgement on this topic. I hope that both of you can set the initial frustration with each other aside and focus on making Marlin better rather than "being right". |
We can open a FR for those 3 points. |
Yes, you are right. The issue is when there is no valid EEPROM calibration data yet, but there are calibration data in Configuration.h built up. You'll get a "calibration screen" that you didn't have with previous version every printer boot (unless you save the EEPROM, but since it's hard to get right, you'll have it at least 5 times) although the calibration in Configuration.h is perfectly working, it's just not used at all. Either one should remove the definition TOUCH_SCREEN_X etc.. in I understood your point, but as a user, it's not user friendly. I'll hack something now, and ask Victor to comment if he thinks it's better. |
For me, just having a static initialization for In the future, maybe a menu in the setting could be used. In order to solve the second half of the issue, would be to retrigger the calibration if it fails. I think it perfectly feasible since the UI reacts to the current calibration step, so instead of going to CALIBRATION_FAIL state, just going back to CALIBRATION_TOPLEFT would probably work without touching a single line of UI code. We could add a counter and if it fails for ... 5 times ?... we go to CALIBRATION_FAIL definitively. What do you think? |
Those values should be initialized in the following code. It is not static initialization, but should still run before anything is usable.
|
Strange. It does not work for me. |
You may need to re-initialize your EEPROM. Perhaps it has zero values saved in it. |
Probably a clue. I did not change the EEPROM while upgrading the version. I don't see anything in the code validating the data it reads from EEPROM, except for the EEPROM version. What is the init order ? EEPROM.load then Touch::init() or the opposite ? |
There is something I don't understand. MarlinCore contains:
If the settings are loaded before |
static void calibration_reset() { calibration = { TOUCH_CALIBRATION_X, TOUCH_CALIBRATION_Y, TOUCH_OFFSET_X, TOUCH_OFFSET_Y, TOUCH_ORIENTATION }; }
static bool need_calibration() { return !calibration.offset_x && !calibration.offset_y && !calibration.x && !calibration.y; }
Tests I did:
I don't know what is happening with your touch. I guess you have some dirty on EEPROM, or have changed the code.. or maybe a bad rebase. I don't know, but I can't find any bug or issue with touch calibration, besides the improvements @sjasonsmith suggested. |
Ok, it's clear now, there is this:
So HAS_TOUCH_BUTTONS is not defined, so touch.init is not called and thus the calibration state is never initialized:
|
I'm using non modified bugfix-2.0.x branch right now |
Eh eh. Look here:
So it seems mks_ui does not use Touch class but the old XPT2046 class. |
|
Ah. Right, so how is the touch_calibration initialized then in that case? |
For LVGL? Only on load |
But it does not (see the GDB output above)
|
Look for |
Did you reset your eeprom? All points that you have zeroes on your EEPROM. |
No, and I can't since I can't pass to the main menu... Argh... |
It should load the values from Configuration.h if they are not found. |
What about changing this line:
to this:
At least I'll have some values from my config file. |
If you fail to calibrate, it will load the values from your config. To reset using serial, you can: To reset automatically on boot, just increment the |
I think I've made some progress:
breaks compilation. Thus it's clearing my Configuration.h value. Looking at them, I think I've spotted the issue:
It's |
Indeed, it works once fixed with my change (see patch above) |
You are right. |
Now I understand the code's logic why it should have worked with a failed calibration (and why I wasn't able to reach the menu since mine were all 0). In the good case, you can still use the default calib. In my case (or if someone does not provide a |
What about this change: index e4ad8f215..973b0e528 100644
--- a/Marlin/src/lcd/tft_io/touch_calibration.cpp
+++ b/Marlin/src/lcd/tft_io/touch_calibration.cpp
@@ -44,6 +44,7 @@ void TouchCalibration::validate_calibration() {
else {
calibration_state = CALIBRATION_FAIL;
calibration_reset();
+ if (need_calibration()) calibration_state = CALIBRATION_TOP_LEFT;
}
if (calibration_state == CALIBRATION_SUCCESS) { |
Another bug: If you select "Revert settings to factory defaults" in the EEPROM menu, and confirm (I guess it's erasing EEPROM), the touch screen does not work anymore and checking the calibration value gives this in GDB:
So it's nuked and the touch screen becomes unusable. |
I think it is still a major bug. It should not clear the current calibration while erasing EEPROM else you can't do anything in the menu anymore. |
It sounds like you are still using configuration files without defaults properly set in them. This should restore your default values. |
If it's an error not to have default properties in the Configuration file, then it should be reported as so. Currently, without such properties, you can have situations where the printer appears locked:
If you do have default properties in Conf file, the case 2 still happens, since the EEPROM restore will load a 0 based calibration values immediately making your touch screen unusable. In that case, the default are not loaded back in the calibration value until you reboot and are presented the touch screen calibration menu again. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Description
Since ea37161, if you select TOUCH_SCREEN_CALIBRATION without specifying the value for X, Y, and offset, you can't get out of the calibration screen. If you specify a X,Y and offset, you are still presented a calibration screen upon bootup.
What happens is the following:
TouchCalibration
, the memberstatic touch_calibration_t calibration;
is initialized to 0 since there is no constructor calling reset or a static initializer.need_calibration()
which always returns true since the values are 0calibration_reset()
puts 0 in the X/Y and offsets, and the state is set tofail
How to fix it
First, the
static touch_calibration_t calibration
should be initialized to { TOUCH_SCREEN_X, ... } in the cpp file (like it's done in reset). This will fix the calibration menu from appearing when values are set in configuration.Second, upon failure of calibration:
calibration_precise
) and only use the state as a variable tracking "none, top-left, bottom left, bottom-right, top right" so that in case of failure of the calibration, still compute the calibration's coefficient (but don't mark it as precise) and use that anyway. A bad calibration is better than a non functioning printer.Configuration Files
I'm using a MKS Robin Nano 35 board, the configuration is the default one with TOUCH_SCREEN_CALIBRATION enable but no value set up (for bug 1) and with default values set up for _X, _Y, _OFFSETs (for bug 2).
Expected behavior:
Calibration should work and not be asked at each boot.
Actual behavior:
Calibration menu is displayed at each boot (whether or not I have enabled default value), and if I fail to calibrate correctly, the printer is struck.
The text was updated successfully, but these errors were encountered: