Hi everyone,
I need your direction on how to display a float value on the Nextion display with minimum 0.01.
thanks.
Hi everyone,
I need your direction on how to display a float value on the Nextion display with minimum 0.01.
thanks.
I don't use Nextion (does not work with a Mac).
if printing a float is not supported, I assume printing text is ➜ build a string representing your float and print the string (you can use dtostr() for this)
Ok, I will try it out.
Hi,
Can someone help with code or reference to display character or string from matrix keypad to text box of Nextion display?
Thanks for the links, i will update as it progress.
Hi,
thanks all for your suggestions and link, i am getting an edge on the project, i have been able to interface the keypad with nextion, my challenge is to update 5 char generated from the keypad to nextion text box to appear as float.
i will appreciate your suggestions.
thanks
My suggestions are contained in the tutorial I wrote and gave you a link to. When you have read that, used the ideas contained in it to do what you want to do and got stuck then post your best effort and I will try to help you.
Thanks,
Your two topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
Thank you.
I apologize for not taking to the rules, my project is still on arduino, nextion display and matrix keypad, i am taking it stage by stage all suggestions have been so helpfull.
below is the sketch
#include <Keypad.h>
#include <Nextion.h> //INCLUDE NEXTION LIBRARY TO WRITE DATA FROM ARDUINO > NEXTON
//DEFINE OBJECTS TO BE USED ON NEXTION SCREEN
NexText tareweight = NexText(1, 10, "tareweight"); // NexText(page number, object number, "object name")
NexText fillingweight = NexText(1, 11, "fillingweight");
NexText totalweight = NexText(1, 12, "totalweight");
NexText activity = NexText(1, 13, "activity");
NexText statusreport = NexText(0, 14, "statusreport");
NexPage page0 = NexPage(0, 0, "page0");
NexPage page1 = NexPage(1, 0, "page1");
NexPage page2 = NexPage(2, 0, "page2");
char buffer[10] = {0}; //CREATES A BUFFER TO HOLD THE TEXT
//REGISTER OBJECTS FOR NEXTION DISPLAY
NexTouch *nex_listen_list[] =
{
&tareweight,
&fillingweight,
&totalweight,
&activity,
&statusreport,
&page0,
&page1,
&page2,
NULL
};
int counter = 0;
float counter1 = 0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
//R1, R2, R3, R4, C1, C2, C3, C4.
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
nexInit();
Serial.begin(9600);
keypad.addEventListener(keypadEvent); // Add an event listener for this keypad
keypad.setHoldTime(2000); // Default is 1000mS
keypad.setDebounceTime(50); // Default is 50mS
}
void loop() {
nexLoop(nex_listen_list);
counter1 ++;
/* Serial.print(counter1);*/
char key = keypad.getKey();
if (counter == 3) {
counter = 0; // set select button counter
}
if (key == '#') {
counter++; //set # key as select button
}
if (counter == 1) {
Serial.print("tareweight.bco=61280");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
else
{ Serial.print("tareweight.bco=65535");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}// conditioned counter to enable tare weight tab
if (counter == 2) {
Serial.print("fillingweight.bco=61280");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
else
{ Serial.print("fillingweight.bco=65535");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}// conditioned counter to enable filling weight tab
//*****************************************************************************************************************
// conditioned numerical keys for tare weight tab
if (((key == '1') || (key == '2') || (key == '3') ||
(key == '4') || (key == '5') || (key == '6') ||
(key == '7') || (key == '8') || (key == '9') ||
(key == '0')) && (counter == 1)) {
Serial.print("tareweight.txt=");
Serial.print("\"");
Serial.println(key);
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
//*****************************************************************************************************************
// conditioned numerical keys for filling weight tab
if (((key == '1') || (key == '2') || (key == '3') ||
(key == '4') || (key == '5') || (key == '6') ||
(key == '7') || (key == '8') || (key == '9') ||
(key == '0')) && (counter == 2)) {
Serial.print("fillingweight.txt=");
Serial.print("\"");
Serial.println(key);
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
//*****************************************************************************************************************
//conditioned alpha keys for special function
if (key == 'A') {
Serial.print("activity.txt=");
Serial.print("\"");
Serial.print("start filling");
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
if (key == 'B') {
Serial.print("activity.txt=");
Serial.print("\"");
Serial.print("stop filling");
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
if (key == 'C') {
Serial.print("activity.txt=");
Serial.print("\"");
Serial.print("tared");
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
if (key == 'D') {
Serial.print("activity.txt=");
Serial.print("\"");
Serial.print("enter");
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
counter = 3;
}
if (key == '*') {
Serial.print("activity.txt=");
Serial.print("\"");
Serial.print("zero scale");
Serial.print("\"");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
}
// Taking care of some special events.
void keypadEvent(KeypadEvent key) {
switch (keypad.getState()) {
case HOLD:
//*****************************************************************************************************************
//conditioned alpha keys for special 2nd function
if (key == 'A') {
Serial.print("page 2");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
if (key == 'B') {
Serial.print("page 1");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
break;
}
}