TFT Graphics - Scrolling ruler scale tied to Enc position

MorryStu

Active member
Hi Guys

I need a bit of starting point help for my project

I am building a stepper driven cross slide for my lathe utilising a KY-040 encoder and Nema17 stepper with a 2mm lead screw. So basically every revolution of the stepper (200 steps) moves the slide 2mm and he TFT screen displays the position info as a moving ruler scale....like scrolling text that can be controlled via an encoder

Each encoder position moves the cross slide 0.01mm without microstepping, 0.005mm 1/2 step

I then have a 2.25" TFT LCD Screen Module ST7789 76 * 284 Display , SPI Screen and a few buttons to control the stepper

So I want to keep the pixel/scale/measurement in easy units…hence 200 pixels wide ruler scale ( leaves me 80 pixels for some other info.)

Basically 1 encoder pulse will move the slide by 0.01mm and on a 200 pixel scale that is 2 pixels…I am also thinking of micro-stepping so that each encoder pulse moves .005mm, and 1 pixel over a 200 pixel/per mm scale.

I only need to redraw the tick marks and the numeric value. The numeric value does not need to be absolute/datum,I have a DRO ( 0.005mm resolution )for that. Mostly it will be set/start at “Zero” for relative measurements. I can add some code to allow setting of a specific value..etc

cross slide disp.png


So, going by the pic, as I advance the encoder wheel forward, “ 4.0” & the tick should advance forward towards Zero ( this may seem a bit odd at first, but on a lathe when you advance/move forward you are pushing/cutting into the work towards "zero"), along with all the other ticks. The opposite should happen when I reverse the direction ( ignore the other text or mistakes ) . The 2 red triangles and red line remain fixed, probably a .bmp background

I am familiar with AdfruitGFX , TFT-espi , I am just trying to think of a starting point and a method that can be used in other projects

Stepper control is straight forward using acelstepper

Screenshot_2026-02-22_18-31-24.jpg
 
Last edited:
Back
Top