Separate values from a single encoder for timer and temperature

MorryStu

Active member
Hi all

I have a Ky040 encoder that I want to use for an oven controller and timer.

It has to provide separate values for setting the temperature and the count down timer

My problem is that when moving the encoder to set one value it changes the other due to the common encvalue


int encvalue = k040.read() //ky040 library

int tempvalue = encvalue
int timmrvalue encvalue

I can easily make the timer and temperature work separately

I have individual buttons to select each mode and use the ky040 buttont to start/stop the timer. I have button/bounce library

The temperature needs to be able to be changed without affecting the running timer

I am familiar with enum mode/case switching

Does anyone have any ideas about how to solve this particular problem.
 
When a button is pressed, store
  • which button it was
  • the difference between the relevant setting (timer or temperature) and the current encvalue
When the encoder changes
  • add its position value to the stored difference
  • put that value into the relevant setting
 
Back
Top