Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/23/08 16:58
Read: times


 
#151339 - I went this direction....code padding removal?
Responding to: ???'s previous message
I've selected all the code, clicked detabify, so hopefully this fixes the unreadable > using <_pre_>
pastemycodehere
<_/pre_> tags (without the underscores) so hopefully i'm ok now.

Alright, I used some of the great suggestions here and I'm very happy with the outcome......THANK YOU everyone who pitched in.

I do have a question though because I don't quite understand one part of it. It was suggested that I should be monitoring a nul terminator, I've tried adding an "| '\0' after the MAXCHARS_ON_LINE and it ignores the array delimiter.

So my phrase still seem to need the padding in the double quotes to equal the MAXCHARS_ON_LINE definition which is set to 10 for max display place holders. The problem is that all the phrase are not 10 chars, what is the best way to add a null so that when white space within the double quote is seen, it jumps out of the array to finish and move onto the next phrase sequence?

The padding question is denoted below as: <<<<<<<

Here is the code in its final form to date:

#define MAX_LINES          3
#define MAXCHARS_ON_LINE   10
#define CHAR_MASK          0xBF

#define high 1          //sets logic value of true
#define low  0          //sets logic value of false

sbit clear = P3^0;      //sets port bit for functino control
sbit write = P3^1;      //sets port bit for functino control

#define uint unsigned int
#define uchar unsigned char

void msec(uint x) //  Time delay variable passed function to control time each word
    {
    uchar j;
    while (x-->0)
        {for(j=0;j<125;j++);
        }
    }


void code clear_display() // Active low used to clear the display for startup and next phrase
    {
    clear=high;
    clear=low;
    clear=high;
    }

void code write_enable() // Active low used to enable write sequence to the 7243 for each char
    {
    write=high;
    write=low;
    write=high;
    }

void code word_delay()
    {
    msec(3500); // USER DELAY ADJUSTMENT => approximately a 5 second delay, moving value higher increase time delay
    }

unsigned char code phrases[] =  // Enter phrases here

  {
  "ABC"                    // phrase  1 <<<<< NEEDS PADDING OR JUNK SHOWS UP ON DISPLAY
  "DEF......."             // phrase  2 <<<<< WORKS FINE, I guess just have DP on display
  "XYZ......."             // phrase  3               
  };
void put_phrase( unsigned char line_no )
{
   unsigned char x;
                             
   for ( x = 0; x < MAXCHARS_ON_LINE; x++ ) // Parse the data array for 10 array elements
    {
      P0 = phrases[ x + line_no * MAXCHARS_ON_LINE ] & CHAR_MASK;
                             // Must strobe the write pin on the rising edge
                             // to latch char into memory position
                             // for each char in array
      write_enable();
   }
   
}

void main( void )            // Main program
{
                             
   clear_display();

   for(;;)                   // Loop this process forever
   {
      unsigned char line_no;
      for ( line_no = 0; line_no < MAX_LINES; line_no++ )
      
       {         
         put_phrase( line_no );
         word_delay();
         clear_display();
         
      }
   }

}



List of 54 messages in thread
TopicAuthorDate
Best way to consolidate....out of memory            01/01/70 00:00      
   isn't this the classical gotcha?            01/01/70 00:00      
   There was a hint here....            01/01/70 00:00      
      Not const            01/01/70 00:00      
         Not necessarily            01/01/70 00:00      
            Hmmm...            01/01/70 00:00      
               Hmmm, indeed            01/01/70 00:00      
               Why?            01/01/70 00:00      
                  One reason ... and the prolly the original intent            01/01/70 00:00      
                     Obviously            01/01/70 00:00      
                        Speed            01/01/70 00:00      
                           Rogue programs?            01/01/70 00:00      
                              Yes. And stupid programmers            01/01/70 00:00      
                                 True            01/01/70 00:00      
                           cases            01/01/70 00:00      
                        The Obvious...            01/01/70 00:00      
                           Fair enough            01/01/70 00:00      
                              make sure the developer doesn't do something stupi            01/01/70 00:00      
                              Const to Code EPROM or FLASH,,,            01/01/70 00:00      
                           const and volatile - for optimization            01/01/70 00:00      
                  consts in other than CODE space            01/01/70 00:00      
                     Use the extended keywords            01/01/70 00:00      
                        'const' and 'volatile'            01/01/70 00:00      
   Unreadable code!            01/01/70 00:00      
      It really was all Keils fault....;)            01/01/70 00:00      
   You don't want to start from here!            01/01/70 00:00      
      Previously, on 8052.com...            01/01/70 00:00      
      Array of string            01/01/70 00:00      
         Yes, my mistake            01/01/70 00:00      
   string concatenate            01/01/70 00:00      
      Comments            01/01/70 00:00      
         Wow......LOL            01/01/70 00:00      
            Not a C vs ASM thing            01/01/70 00:00      
               From your perspective, it may make sense            01/01/70 00:00      
      I went this direction....code padding removal?            01/01/70 00:00      
         For but one byte added to the array...            01/01/70 00:00      
         With proper ordering in source file...            01/01/70 00:00      
         Putting it all together            01/01/70 00:00      
            Spectacular Russ.....            01/01/70 00:00      
   THINK            01/01/70 00:00      
      that is surely needed            01/01/70 00:00      
      A bit easier to read?            01/01/70 00:00      
         easy to read???            01/01/70 00:00      
      typedef vs #define            01/01/70 00:00      
      I think not            01/01/70 00:00      
         Tks Russ.            01/01/70 00:00      
            THINK(ing)            01/01/70 00:00      
               ???            01/01/70 00:00      
                  Objectives.            01/01/70 00:00      
                     I beg your pardon?!            01/01/70 00:00      
                     I see            01/01/70 00:00      
   Best way to consolidate....out of memory            01/01/70 00:00      
   Why specify CODE for functions?            01/01/70 00:00      
      there is so much stuff            01/01/70 00:00      

Back to Subject List