⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msl90.c

📁 国外的一个关于msp430f449开源项目资料之二---源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
       case 'R':  LCD[position-1] = a + b + d + e;      LCD[position] = b + c + g;        break;
       case 'S':  LCD[position-1] = a + c + h + e;      LCD[position] = b + g;            break;
       case 'T':  LCD[position-1] = a + f + b;          LCD[position] = d + b;            break;
       case 'U':  LCD[position-1] = b + c + h;          LCD[position] = b + c;            break;
       case 'V':  LCD[position-1] = g;                  LCD[position] = b + c + e;        break;
       case 'W':  LCD[position-1] = b + c + d;          LCD[position] = b + c + e;        break;
       case 'X':  LCD[position-1] = d + g;              LCD[position] = e + f;            break;
       case 'Y':  LCD[position-1] = b + c + h + e;      LCD[position] = f;                break;
       case 'Z':  LCD[position-1] = a + h + g;          LCD[position] = e;                break;      
       
       // number  // LCDM7                              // LCDM8                          // END
/*       case '0':  LCD[position-1] = a + b + c + h;      LCD[position] = b + c;            break;                            
       case '1':  LCD[position-1] = b + c;                                                break; 
       case '2':  LCD[position-1] = a + b + e + h;      LCD[position] = c + g;            break; 
       case '3':  LCD[position-1] = a + b + c + e + h;  LCD[position] = g;                break; 
       case '4':  LCD[position-1] = b + c + e;          LCD[position] = b + g;            break; 
       case '5':  LCD[position-1] = a + c + h + e;      LCD[position] = b + g;            break; 
       case '6':  LCD[position-1] = a + c + h + e;      LCD[position] = b + c + g;        break; 
       case '7':  LCD[position-1] = a + b + c;                                            break;
       case '8':  LCD[position-1] = a + b + c + e + h;  LCD[position] = b + c + g;        break; 
       case '9':  LCD[position-1] =a + b + c + e ;      LCD[position] = b + g;            break; 
       
       // others
       case '.':                                        LCD[position] = h;                break;  // decimal point
       case '^':                                        LCDM2 = c;                        break;  // top arrow
       case '!':                                        LCDM2 = a;                        break;  // bottom arrow
       case '>':                                        LCDM2 = b;                        break;  // right arrow
       case '<':                                        LCDM2 = h;                        break;  // left arrow
       case '+':                                        LCDM20= a;                        break;  // plus sign
       case '-':                                        LCDM20= h;                        break;  // minus sign
       case '&':                                        LCDM2 = d;                        break;  // zero battery
       case '*':                                        LCDM2 = d + f;                    break;  // low battery
       case '(':                                        LCDM2 = d + f + g;                break;  // medium battery
       case ')':                                        LCDM2 = d + e + f + g;            break;  // full battery */
    }
}

// **********************************************  writeSentence******************************************************** 
/*
void writeSentence(const char *word, int scrollForever)  // writes out an entire sentence scrolling it right to left
                                                            // sentences must be in upper case
{   
   unsigned int strLength = 0;          // variable to store length of the sentence
   unsigned int i;                      // dummy variable
   unsigned int j;                      // dummy variable
   unsigned int k;                      // dummy variable
   char letter_list[75];               // keeps track of characters. Sentence can have upto 74 characters. Do not make too large
   unsigned int position_list[75];     // keeps track of position of the characters
   unsigned int marker = 0;             // keeps track of index of the last being displayed character
   unsigned int dispCount = 0;          // keep count of how many characters are being displayed
   unsigned int flag = 1;               // a normal flag that defines if process should be stopped
   
   strLength = strlen(word);            // get the length of the sentence
     
   for (i = 1; i <= strLength; i++)     // put each character in string in a special array called letter_list
   {                                   
      letter_list[strLength - i + 1] = word[i-1];
      position_list[i] = 0;             // also, place their relative position values in an array called position_list
   }
   
   marker = strLength;                  // marker takes the position of the last character
   position_list[marker] = 1;           // Set the marker of this position to 1
   dispCount++;                         // dispCount = 1; meaning we start display with 1 character

   do                                   // Digit Shifter with light + delay
   {
      shortDelay(2);                    // take a short break so that the user can see the changes
      clearLCD();                       // since we are gonna update LCD soon, clear the LCD first
      P1OUT ^= 0x08;                    // toggle the pin connected to LED to that we can see it blinking
      
      for (k = marker; k >= marker - dispCount + 1; k--)   // display the first frame 
       {        
           writeLetter(position_list[k],letter_list[k]);
       }
       
       if (dispCount < 7)                // update frame count (characters to be displayed during next frame)
         { dispCount++; } 
       
       for (i = marker; i >= marker - dispCount + 1;i--) // shift the relative position values
       {
           position_list[i] = position_list[i] + 1;
           if (position_list[i] == 8)
           {   marker--;                                 // shift the marker value
             
              if (marker - dispCount + 1 <= 0)
              {
                 marker = dispCount;                     // make sure marker never goes less than zero
              }
           
           }           
       }
       
       if (position_list[1] == 2)                        // when marker has hit maximum index
          {
                if (scrollForever == 0) 
                {  flag = 0; clearLCD();  }              // adjust flag value to repeat or not          
                marker = strLength;                      // reset marker to original
                dispCount = 1;                           // display length of frame to 1
                for (j = 1; j <= 50; j++)                // reset position_list to original 
                {
                   if (marker != j)
                   { position_list[j] = 0; }
                   else if (marker == j)  
                   { position_list[j] = 1; }             // set position list of marker character to 1
                }
           }
    } while (flag == 1);                                 // function repeats forever if flag remains 1
   
} 
*/
// **********************************************  writeSentence******************************************************** 
void writeWord(const char *word, int repeat_times)  // displays a word (upto 7 characters) for specified number of times
                                                    // words must be in upper case
{
   unsigned int strLength = 0;   // variable to store length of word
   unsigned int i;               // dummy variable
   unsigned int k;               // dummy variable
   
   strLength = strlen(word);     // get the length of word now
     
   for (k = 1; k <= repeat_times; k++)  // repeat display
   {
       for (i = 1; i <= strLength; i++) // display word
       {
          writeLetter(strLength - i + 1,word[i-1]);  // displays each letter in the word
       }
       shortDelay(3);        // software delay
       clearLCD();           // clears the LCD
       shortDelay(3);        // software delay
   }

}

// ************************* short Tutorial on using LCD commands effectively ******************************************* 

/* //(a) To display battery life indicator (copy and paste the following):
         writeLetter(1,'&');   // zero battery life  
         shortDelay(5);
    
         writeLetter(1,'*');  // low 
         shortDelay(5);
    
         writeLetter(1,'(');  // medium
         shortDelay(5);
    
         writeLetter(1,')');  // full battery life    
         shortDelay(5);                              */
    // ------------------------------------------------------------------


/*  //(b) To display + and - signs:
          writeLetter(1,'+');   // displays plus sign
          shortDelay(5);
          writeLetter(1,'-');   // displays negative sign  */
    // ------------------------------------------------------------------
    
/*  //(c) To display signed numbers with decimals:
          writeWord("+153.89",1);       */
    //  -----------------------------------------------------------------
     
/*  //(d) To display a number excluding decimals
          writeNumber(1234567);   */
    // ------------------------------------------------------------------

/*  //(e) To display a number including decimals
          writeWord("123.456",1);   */   // the second argument tells how many times to repeat that word
    // ------------------------------------------------------------------ 

/*  //(f) To repeat instruction display (individual words)
         for (i = 1; i<=2;i++) {  // repeats words two times
         writeWord("SYSTEM ",1);  // show this word once
         writeWord("READY. ",1);} */  // show this word once also
     // -----------------------------------------------------------------

/*   //(g)To display the arrows on LCD:     
         writeLetter(1,'^');    // shows top arrow
         shortDelay(5);
         
         writeLetter(1,'!');    // shows bottom arrow
         shortDelay(5);
         
         writeLetter(1,'>');    // shows right arrow
         shortDelay(5);
         
         writeLetter(1,'<');    // shows left arrow
         shortDelay(5);       */
     
// ******************************************************************************************************************* 
// This is a freeware, but if you find this software very useful, please consider donating 
// me through paypal at muneemonline@hotmail.com
// Remember, I am NOT affiliated with Olimex, Texas Instruments or Sparkfun Electronics.
// *******************************************************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -