M2tklib LCD 2x16 Decimal in input

Following some of the tutorials on using the M2TKLIB for meuns on a LCD. is there a way of using a float or incorporating a decimal in the display. I don't think the library supports the use of floats but for examp can I display a input with a decimal as a workaround. For example x.x would be displayed and I can change the values before and after the decimal.

Hi

The idea is to use U32NUM in this case:
Assume you want to edit a number with one digit after the decimal point: float x = 12.3

  • Multiply the float with 10: x = 123
  • Convert the float into a long value l = 123
  • Let the user edit the number with format option ".1" (one digit after the dot)
  • Convert the long back to a float x = (float)l = 123
  • Divide the float by 10: x = 12.3

The attached picture was created with

U32NUM(my_u32_element, "a1c4.1", &u32val);

Oliver

u32_with_comma.png

What if you treat your float result as a string?

#include<stdlib.h>
float result;
int width;
int precision;
char test[20];    // string buffer

void setup() 
{    Serial.begin(9600);
}

void loop() 
{    for (int i=0; i<13; i++)
     {    result = i/4;
          dtostrf(result, width, precision, test);
     }
}

I need a button called "Better Reply". My excuse is that I've been playing with a Raspberry on a new computer. Now that I've come back to the light side, I made some improvements to my snippet:

#include<stdlib.h>


float result;
float temp =4;
int width=15;
int precision=4;
char test[20];    // string buffer

void setup() 
{  Serial.begin(9600);
}

void loop() 
{  for (int i=0; i<13; i++)
    {      result = float(i)/temp;
           dtostrf(result,width,precision,test);
           Serial.println(test);
    }
   delay (10000);
}

I haven't checked this with an LCD but I think the concept should work.

Thanks all, will give it a try.