-
Notifications
You must be signed in to change notification settings - Fork 15
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
Improved UART handling #5
Conversation
…ts (such as Octoprint). The goal is for this to work properly in either touch mode or emulation mode. This should also allow switching between touch and emulation mode even while printing.
BEWARE that this probably will result in errors since the TFT will likely be thinking all of these commands are coming from its own system. In order for this to work properly, I'll probably need to add logic to make some parsing contingent upon where the gcode originated from.
This reverts commit bf164af.
…TFT originating gcode and one section for external originating gcode. This allows synchronizing feed rate and fan speed.
…ck) to all devices connected over UART. (Keeps messages like alerts, errors, and temp heartbeats from getting lost.) Don't have the TFT send more M105 temp messages if it doesn't have a reason to. (Temps sent by request to other devices are getting parsed so there's no need to ask for more if you've just seen one.)
Fix boot logo to original size for TFT24/28
Apologies for forking from your repo instead of the main one but I really wanted the new menu functionality you've been working on and this turned out to be a more stable place to build from, given the problems I was trying to solve. |
Great work... I do not use Octoprint so I can not test it. Also there need to be an option to enable / disable this for users who do not use Octoprint and use USB to connect the main board to PC. This may interfere when printing via PC with 12864 emulator enabled on TFT. |
My original TFT35 was returned to Amazon because of all the Octoprint issues, BUT BTT is sending me one from China as a result of my original SKR Mini E3 having bad driver issues. I'll definitely test but it will take awhile before it arrives. |
Agreed. If you comment out #CLEAN_MODE_SWITCHING_SUPPORT in config.h then that will disable the polling when in emulator mode. If you would rather put that behind a setting in the setting menu then be my guest. Along similar lines, I'm fairly sure that the firmware is interacting with the serial port even with that code disabled (before my changes). See this conversation: bigtreetech/BTT-TFT35-E3-V3.0#10 |
And while I have your eyes, I have a couple of questions.
|
I'd be happy to check this out. A couple of questions though. Should I still have the octopi hooked up through the USB cable? Also use this version of Marlin and uncomment clean mode switching is all that is needed? |
@JWolfJr This is primarily for hooking octopi up through one of the UART ports on the TFT. The primary benefit to doing this is that the TFT becomes aware of the traffic coming from Octoprint so it can keep its locations, temps, fan settings, etc. up to date and it ensures that Marlin only sees a single serial stream, reducing possible contention on the device. The secondary benefit is that you can switch between touch mode and emulation mode and Octoprint will still work when hooked up this way. |
Ok, gotcha. I got the specs how to hook it up to the tft, from what I saw it's going to the wifi headers? I apologise, I thought I was on the MB GitHub page. I'm at work now, I will give this a try soon as possible and report back . Thank you. |
You could hook it through the wifi headers but honestly, it's easier to hook it to UART3 or UART4. |
Oh and BTW, You only need CLEAN_MODE_SWITCHING_SUPPORT if you want to be able to drive Octoprint through the TFT while in emulation mode. If you're only interested in driving Octoprint through the TFT in touch mode then you don't need this uncommented. |
I'm interested in both. I'll build the updated version and try it out. Thanks for clarifying. |
ok. sorry I failed to review the code at that time.
It does not look like there is any thing related to serial comm. in the Simulator Loop and in the function calls through it (this need more digging into the code): BIGTREETECH-TouchScreenFirmware/TFT/src/User/API/UI/ST7920_Simulator.c Lines 139 to 156 in 5777f41
It may be possible to confirm this by connecting the TFT Controller to PC via USB-Serial instead the main board. One point to note is that the serial pins on the TFT Controller are being set to Input Floating State when the serial is disconnected: BIGTREETECH-TouchScreenFirmware/TFT/src/User/Hal/stm32f10x/usart.c Lines 20 to 25 in 7a370bd
There is no logging/debugging code in the actual firmware and the comments are in Chinese which also got scrambled when the commits were merged due to wrong text encoding, but the libraries used are mostly from STMICROELECTRONICS. So it should be possible to debug it using the serial wire debugging (SWD) port on the device using ST-LINK. I have not gone any further into this. |
Which is why I've made the changes I've made in Mode.c. When CLEAN_MODE_SWITCHING_SUPPORT is defined, the serial resources are left initialized when you switch out of Touch mode. |
Tested on the TFT35 E3 V3 with an ESP-01S and a TFT24 V1.1 with an ESP12-E and confirmed working in emulation mode. Great work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…dd sanity check move `CLEAN_MODE_SWITCHING_SUPPORT` to Marlin mode Setting area. add sanity check for `CLEAN_MODE_SWITCHING_SUPPORT` to throw error if it is enabled for TFT controllers with no Emulator/Marlin mode support.
…odel preview, add more option in setting in list mode and other bug fixes (details in description), increase software version to 25.2 (bigtreetech#302) * Add option for enabling or disabling sending gcode before and after print in list mode setting * add 'S' & 'T' in numeric keypad in gcode terminal * add on off setting for persistent temp info in settings * change flash address for icons and font to avoid overlaping * fix typo and minor bug * added new printing status screen & option to enable more frequent serial communicaiton in configguration.h - new printing status screen. - option to enable more frequent serial communicaiton in configguration.h to avoid printer stutter/ lag. * fix preview icon position in printing screen * prevent display of global info in printing screen * fix model preview - display bmp file without writing to flash fix model preview - fix missing preview images. - display bmp file without writing to flash (saving flash write cycles) - faster preview loading. * remove reserve flash addresses for preview images, increase software version to 25.2 * update prebuild firmware to V25.2 and archive V25.1 * Permanently enable List mode in feature setting and add Option in feature setting to toggle List mode in file viewer menu Permanently enable List mode in feature setting. add option in feature setting to toggle List mode in file viewer menu remove extra unused icons * Fix boot logo to original size for TFT24/28 * Improved UART handling (#5) * Fix printing from an external device connected to one of the UART ports (such as Octoprint). The goal is for this to work properly in either touch mode or emulation mode. This should also allow switching between touch and emulation mode even while printing. * Strip line numbers and checksums from gcode for parsing. BEWARE that this probably will result in errors since the TFT will likely be thinking all of these commands are coming from its own system. In order for this to work properly, I'll probably need to add logic to make some parsing contingent upon where the gcode originated from. * Revert "Strip line numbers and checksums from gcode for parsing." This reverts commit bf164af. * Change strategy for parsing gcode. It now forks into one section for TFT originating gcode and one section for external originating gcode. This allows synchronizing feed rate and fan speed. * Pass spontaneous messages (messages that aren't part of an explicit ack) to all devices connected over UART. (Keeps messages like alerts, errors, and temp heartbeats from getting lost.) Don't have the TFT send more M105 temp messages if it doesn't have a reason to. (Temps sent by request to other devices are getting parsed so there's no need to ask for more if you've just seen one.) * Minor tweaks to make sure we continue to pump message loops. * translate comments to english in popup.c & disable ST7920_FULLSCREEN by default * move `CLEAN_MODE_SWITCHING_SUPPORT` to Marlin mode Setting area and add sanity check move `CLEAN_MODE_SWITCHING_SUPPORT` to Marlin mode Setting area. add sanity check for `CLEAN_MODE_SWITCHING_SUPPORT` to throw error if it is enabled for TFT controllers with no Emulator/Marlin mode support. * Update Configuration.h Co-authored-by: Gurmeet Athwal <[email protected]> * Update Russian Translate for your fork Update Russian Translate for your fork * Minor Fix Russian Translation Minor Fix Russian Translation * KNOP LED Custom setting and persistent setting store (BTT-TFT35-E3-V3.0) (#8) * KNOB LED Color - Store and restore led color setting * Moved some default settings to configuration.h * Add default buzzer frequency and duration custom settings to configuration.h Co-authored-by: guruathwal <[email protected]> * Replace BMPs with wrong size and fix garbled icons in printing menu on TFT24/28 Co-authored-by: hfog <[email protected]> Co-authored-by: Acenotass <[email protected]> Co-authored-by: Erkan Colak <[email protected]>
This fixes a number of problems encountered when connecting Octoprint to the TFT over UART3 (or 4).
When Octoprint is connected over UART, the TFT can now be in either Touch mode or Emulation mode and it will still work. You can even switch between the two during printing from Octoprint (although I think there is still some risk of dropping a command - more testing is needed there).
It also passes unsolicited ack messages through to Octoprint, which enables Octoprint to stay connected when using autoreporting (ex: M105 T2).
The code is also now smart enough to not poll for temps if it's already passing temp messages on to Octoprint, avoiding unnecessary traffic over the serial line.
The next step from this would be to come up with a way for the TFT to reliably detect when a print is started from Octoprint. I can't think of any reliable way to do this though without requiring Octoprint to send some additional messages to the TFT, similar to what Marlin sends during an SD print. Technically this isn't really necessary though as the current behavior works quite well and it wouldn't really add much.
This fixes a number of issues but the primary one is bigtreetech#281