I have an application where a float is read from the EEPROM and displayed on and LCD. By way of a keypad the operator is able to change the value and it is saved to the EEPROM.
To change the value, the first digit of the float is blinking and scrolled. The operator presses an "accept" button to select the new digit. The second digit begins blinking and it is scrolled, the operator selects it by pressing the "accept" button. The process continues for each digit in the number until the new number is selected.
How is the best way to do this? Is it easier to convert the float to an integer?
Any ideas would be appreciated.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516687
Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
Re: Displaying and changing a float value
Posted: Tue Aug 05, 2003 5:35 pm
:=I have an application where a float is read from the EEPROM and displayed on and LCD. By way of a keypad the operator is able to change the value and it is saved to the EEPROM.
:=
:=To change the value, the first digit of the float is blinking and scrolled. The operator presses an "accept" button to select the new digit. The second digit begins blinking and it is scrolled, the operator selects it by pressing the "accept" button. The process continues for each digit in the number until the new number is selected.
:=
:=How is the best way to do this? Is it easier to convert the float to an integer?
:=
:=Any ideas would be appreciated.
:=
:=
Floats do need a lot of processing time.
I had a similar application and stored 32 bit integers instead in the eeprom.
Here's a code snippet that may be of assistance. I'm surprised none of the more experienced programmers have replied. There is probably a better way to do it.
/* Set divisors manually for other modes */
else {
/* Get the values for each digit for current mode divisor */
temp32 = div_hundthous[div_set];
for (curr_dig=0; curr_dig<=6; curr_dig++) {
if (curr_dig != 0) temp32 /= 10; // No need to divide for units digit
digits[curr_dig] = temp32 \%10;
}
/* Set the divisor using INC and DEC switches, wrap occurs from 9 to 0
when using INC, 0 to 9 when using DEC. Begins with lowest digit
flashing. When finished with digit press ENTER to go to next digit.
Wrap occurs back to lowest digit after the 7th digit.
Escape can occur whenever VIEW DIVISOR is pressed.
Disable changes in display mode where the divisor is fixed. */
curr_dig = 0; // Start with lowest digit
do{
do {
if ((inc_dec_fl) && (div_set != DP_NONE_FIXT)) { // When scheduled
inc_dec_fl = 0;
/* Change value of digit with INC and DEC switches */
if (input(INC_SW)) {
if (++digits[curr_dig] == 10) digits[curr_dig] = 0; // Wrap
}
if (input(DEC_SW)) {
if(digits[curr_dig] == 0) digits[curr_dig] = 9; // Wrap
else --digits[curr_dig];
}
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum