CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Displaying and changing a float value

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
keith landreth
Guest







Displaying and changing a float value
PostPosted: Tue Aug 05, 2003 2:48 pm     Reply with quote

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

View user's profile Send private message

Re: Displaying and changing a float value
PostPosted: Tue Aug 05, 2003 5:35 pm     Reply with quote

:=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];
}
}

/* Recalculate divisor, note intermediate calcs. have to be cast */
temp32 = ((int32) digits[6] * 1000000) + ((int32) digits[5] * 100000) +
((int32) digits[4] * 10000) + ((int32) digits[3] * 1000) +
((int32)digits[2] * 100) + ((int32) digits[1] * 10) +
(int32) (digits[0]);

if (temp32 < MIN_DIV) digits[4] = 1; // Keep divisor > minimum

display(temp32);
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516694
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group