예제 #1
0
파일: adc.c 프로젝트: combohehe/BootLoader
/******************************************************************************
* @fn  updateVoltageLCD
*
* @brief
*      Function for printing PotVoltage and sampled ADC value to LCD.
*
* Parameters:
*
* @param  INT8  potVoltage
*         Potmeter voltage
*
*         INT8 adc_value
*         Sampled ADC value
*
* @return void
*
******************************************************************************/
void updateVoltageLCD(INT8 potVoltage, INT8 adc_value)
{
   char s[16];
   // potVoltage is 10 times correct voltage
   // print dc value on LCD
   sprintf(s, (char*)"%d.%d Volt (%d)",  ((INT16)(potVoltage / 10)), ((INT16)(potVoltage % 10)), adc_value);
   lcdUpdate((char*)"Voltage is:", s);
}
예제 #2
0
/*--------------------------------------------------------------------------------------------------

  Name         :  LcdInit

  Description  :  Performs MCU SPI & LCD controller initialization.

  Argument(s)  :  None.

  Return value :  None.

--------------------------------------------------------------------------------------------------*/
void lcdInit( void )
{
    static BYTE FirstInit = TRUE;

    init3310( g_LcdCache, LCD_CACHE_SIZE );
    //  Toggle display reset pin.
    delay3310( 65536 * 4 );
    /* Deselect the display Chip Select high */
    rstLow();
    delay3310( 65536 * 4 );
    rstHigh();
    delay3310( 65536 * 4 );

    //  Disable LCD controller
    //PORTB |= LCD_CE_PIN;
    //csLow();
    //setModeCmd3310();
    //lcdSend( 0x21 );  // LCD Extended Commands.
    //lcdSend( 0xC8 );  // Set LCD Vop (Contrast).
    //lcdSend( 0x06 );  // Set Temp coefficent.
    //lcdSend( 0x13 );  // LCD bias mode 1:48.
    //lcdSend( 0x20 );  // LCD Standard Commands, Horizontal addressing mode.
    //lcdSend( 0x0C );  // LCD in normal mode.
    /*
        LcdBiasSystem(0x03);    //ÍƼö»ìºÏÂÊ 1:48
        LcdSetVop(0x32);                //V(6.06) = 3.06 + 0.06*Vop
        LcdTempCtrl(0x00);              //ζÈϵÊý 0~3
        LcdFunctionSet(ACTIVE, H_ADDR, BAS_INS);        //»ù±¾Ö¸Á
        LcdDispalyControl((u8)NORMAL_MODE);             //ÆÕͨģʽÏÔʾ
        //
        LcdWriteDC(LCDCMD , 0x21 );
        LcdWriteDC(LCDCMD , 0xc8 );
        LcdWriteDC(LCDCMD , 0x20 );
        LcdWriteDC(LCDCMD , 0x0c );
     */

    lcdFuncSet( 0, THorizontal, TExtended );
    lcdVop( 0x48 );
    lcdBias( 3 );
    lcdTempCtrl( TTemp0 );

    lcdFuncSet( 0, THorizontal, TBasic );
    lcdDispCtrl( TNormalMode );

    if (FirstInit == TRUE)
    {
        lcdClear();
        FirstInit = FALSE;
    }
    lcdUpdate();
}
예제 #3
0
파일: lcd.c 프로젝트: Damme/LandLord
void task_LCD(void *pvParameters)
{
    TickType_t xLastTime;
    xLastTime = xTaskGetTickCount();

    // Configure LCD backligt
    GPIO_DIR_OUT(LCD_BACKLIGHT);
    GPIO_SET_PIN(LCD_BACKLIGHT);

    GPIO_DIR_OUT(LCD_RSTB);
    GPIO_DIR_OUT(LCD_CSB);
    GPIO_DIR_OUT(LCD_A0);

    // Configure Timer1 used for µs delay in lcd
    LPC_SC->PCONP |= PCONP_PCTIM1;              // power up Timer (def on)
    LPC_SC->PCLKSEL0 |= PCLK_TIMER1(CCLK_DIV1); // set Timer0 clock1

    // Configure SPI (LCD)
    LPC_SC->PCONP |= PCONP_PCSPI;               // power up SPI
    LPC_SC->PCLKSEL0 |= PCLK_SPI(CCLK_DIV1);    // set SPI CCLK

    LPC_PINCON->PINSEL0 |= ((uint32_t)3 << 30); // p0.15 -> sck
    LPC_PINCON->PINSEL1 |= (0xc | 0x30);        // p0.17 & p0.18 miso / mosi (no miso??)

    LPC_SPI->SPCR |= SPCR_MSTR;                 // SPI operates in Master mode.

    LCDInit();

    for (;;) {
        vTaskDelayUntil(&xLastTime, xDelay100);
        lcdUpdate();
#if LOWSTACKWARNING
        int stack = uxTaskGetStackHighWaterMark(NULL);
        if (stack < 50) printf("Task task_LCD has %u words left in stack.\r\n", stack);
#endif

    }
}
예제 #4
0
uint8_t editNumber(S32MMSValCb_t* s32, uint8_t aY)
{
    // aY is the current yPos from were the edit was triggered
    /**
     * calculate the rectangle height on the display: 
     *    fontheight + 1 pix on top + 1 pix at bottom + 2*2 pix for the frame 
     */
    int32_t valBackup = s32->m_val; // backup the old value
    uint8_t fontHeight = FONTHEIGHT(EDITFONT);
    // re-use aY
    aY = (aY < LCDHEIGHT/2 - 9 ? aY+11: aY - 25);

    // maximum size, for a scaled long: "-2123456.789" + 1 leading blank + 0x00 = 14
    char valBuf[14]; 
    // put this in a block to release memory after calculation
    { 
        // get the biggest absolute value to calculate longest
        // possible string
        uint32_t min = (s32->m_min < 0) ? -s32->m_min : s32->m_min;
        uint32_t max = (s32->m_max < 0) ? -s32->m_max : s32->m_max;
        valBuf[0] = ' '; // leading blank
        valBuf[1] = '-'; // prepend minus-sign
        valBuf[2] = '.'; // prepend decimal point
        ltoa( (max > min ? max : min), valBuf+2, 10);
        //        maxDigits = strlen(valBuf+2);
    }

    uint8_t textLength = lcdBufPuts(AT_RAM, valBuf, &EDITFONT, 0, 0, LA_CHARWIDTHONLY); 
    
    uint8_t x = (LCDWIDTH - textLength - 8) / 2;     
    drawEditFrame(x, aY, textLength, fontHeight);
    x += 4;
    aY += 4;
    uint8_t endX = x + textLength;
    uint8_t clearLength = textLength;
    uint8_t key = 0;
    uint8_t accel = 1;
    int32_t step = 1;

    CallbackFunctor_t cb = s32->m_callback;

    // call the callback if exists
    if (cb)
        cb(CT_ENTRY, s32); 

    do
    {
        /** 
         * procedure: - clear rectangle
         *              write value to string
         *              length = (write string to ldcBuffer, width_only)
         *              clear area of (width x length)
         *              paint rectangle
         *              write string to lcdbuffer(last digit inverse)
         *              display buffer
         *              read key
         *                if (enter) update & return
         *                if (back) return
         *                if (accel) inc-value <<= 2;
         *                   else inc-value = 1; 
         *                if (up) increase
         *                if (down) decrease
         */
        
        lcdBufFillRect(x, aY, clearLength, fontHeight+1, COL_WHITE);
        // write current value
        ltoa(s32->m_val, valBuf, 10);

        if (s32->m_scale)
            rescale(s32->m_scale, valBuf);

        // get size in pixels
        textLength = lcdBufPuts(AT_RAM, valBuf, &EDITFONT, 0, 0, LA_CHARWIDTHONLY);
        uint8_t xt = endX - textLength;

        lcdBufPuts(AT_RAM, valBuf, &EDITFONT, xt, aY, COL_BLACK);
        //        lcdBufPuts(AT_RAM, valBuf, &EDITFONT, endX - textLength, aY, COL_BLACK);

        uint8_t iconMask = BT_BACK|BT_ENTER;
        if (s32->m_val > s32->m_min) 
            iconMask |= BT_MINUS;
        if (s32->m_val < s32->m_max) 
            iconMask |= BT_PLUS;

        setIcons(IT_EDIT, iconMask);
        lcdUpdate(1);

        key = pollButtons(BT_ALL, BF_ACCEL|BF_DELAY); 

        if (key & BF_ACCEL)
        {
            if (accel == 10)
            {
                accel = 1;
                if (step < (s32->m_max/8))
                    step *= 8;
            }
            else
                ++accel;
        }
        else
        {
            accel = 1;
            step = 1;
        }

        switch (key & 0xF0) // clean code
        {
            case BT_BACK: 
            case BT_ENTER:
                break;

            case BT_PLUS: 
                s32->m_val += step;
                if (s32->m_val > s32->m_max)
                    s32->m_val = s32->m_max;
                break;
            case BT_MINUS: 
                s32->m_val -= step; 
                if (s32->m_val < s32->m_min)
                    s32->m_val = s32->m_min;
                break;
        } // switch key
        
        // call the callback if exists
        if (cb)
            cb((CT_CHANGE | (key & 0xF0)), s32); 
    } while (! (key & (BT_BACK | BT_ENTER)) );

    if (key & BT_BACK) // restore old value if BT_BACK was pressed
        s32->m_val = valBackup;
    if (cb)
        cb((CT_RETURN | (key & 0xF0)), s32);     
    return key & 0xF0; // return pure key
} // editNumber (s32 ..)
예제 #5
0
파일: dma.c 프로젝트: combohehe/BootLoader
void dma_main(void){
#else
void main(void){
#endif
   DMA_DESC dmaChannel;
   char sourceString[56] = "This is a test string used to demonstrate DMA transfer."; //56 bytes
   char destString[56];
   INT8 i;
   INT8 errors = 0;


   initDma();



   //Clearing the destination
   memset(destString,0,sizeof(destString));

     // Setting up the DMA channel.
   SET_WORD(dmaChannel.SRCADDRH, dmaChannel.SRCADDRL,   &sourceString); // The start address of the data to be transmitted
   SET_WORD(dmaChannel.DESTADDRH, dmaChannel.DESTADDRL, &destString);   // The start address of the destination.
   SET_WORD(dmaChannel.LENH, dmaChannel.LENL, sizeof(sourceString));    // Setting the number of bytes to transfer.
   dmaChannel.VLEN      = VLEN_USE_LEN;  // Using the length field to determine how many bytes to transfer.
   dmaChannel.PRIORITY  = PRI_HIGH;      // High priority.
   dmaChannel.M8        = M8_USE_8_BITS; // Irrelevant since length is determined by the LENH and LENL.
   dmaChannel.IRQMASK   = FALSE;         // The DMA shall not issue an IRQ upon completion.
   dmaChannel.DESTINC   = DESTINC_1;     // The destination address is to be incremented by 1 after each transfer.
   dmaChannel.SRCINC    = SRCINC_1;      // The source address inremented by 1 byte after each transfer.
   dmaChannel.TRIG      = DMATRIG_NONE;  // The DMA channel will be started manually.
   dmaChannel.TMODE     = TMODE_BLOCK;   // The number of bytes specified by LENH and LENL is transferred.
   dmaChannel.WORDSIZE  = WORDSIZE_BYTE; // One byte is transferred each time.


   // Using DMA channel 0.
   // Setting where the DMA channel is to read the desciptor and arming the DMA channel.
   DMA_SET_ADDR_DESC0(&dmaChannel);
   DMA_ABORT_CHANNEL(0);
   DMA_ARM_CHANNEL(0);

   //Waiting for the user to start the transfer.
   lcdUpdate((char*)"Press S1",(char*)"to start DMA.");
   while(!buttonPushed());


   // Clearing all DMA complete flags and starting the transfer.
   DMAIRQ = 0x00;
   DMA_START_CHANNEL(0);

   // Waiting for the DMA to finish.
   while(!(DMAIRQ & DMA_CHANNEL_0));




   // Verifying that data is transferred correctly
   for(i=0;i<sizeof(sourceString);i++)
   {
     if(sourceString[i] != destString[i])
         errors++;
   }


   //Displaying the result
   if(errors == 0)
   {lcdUpdate((char*)"Dma transfer",(char*)"correct!");}
   else
   {lcdUpdate((char*)"Error in DMA",(char*)"Transfer");}



   haltApplicationWithLED();
   return;
}
//------------------------------------------------------------------------------
void TIM2_IRQHandler(void)
{
  if (TIM_GetITStatus (TIM2, TIM_IT_Update) != RESET)
  {
    uiTime_AlarmLevel = uiTime_AlarmLevel + 1;
    uiRespond_time = uiRespond_time + 1;
    STM_EVAL_LEDOff(LED5);

    if (uiCurrent_Status == STATUS_SpO2_BELOW_L1 | uiCurrent_Status == STATUS_SpO2_BEHIGH_L1)
    {
      if (uiTime_AlarmLevel > SProfile.uiAlarm_Level1)
      {
        uiTime_AlarmLevel = 0;                                                  // Reset Time_AlarmLevel
        uiRespond_time = 0;
        
        /* If Time alarm more than alarm level 1 set */
        if (uiCurrent_Status == STATUS_SpO2_BELOW_L1)
        {
          uiCurrent_Status = STATUS_SpO2_BELOW_ALARM_L1;
          uiPurpose_FiO2 = uiPurpose_FiO2 + 6;
          
          if (uiPurpose_FiO2 > SProfile.uiFiO2_Maximum)
          {
            /* if uiPurpose_FiO2 more than uiFiO2_Maximum */
            uiPurpose_FiO2 = SProfile.uiFiO2_Maximum;
          }

          FiO2_Range(uiPurpose_FiO2);
          
          /* Update LCD */
          lcdString(1,5,"Status: Below ");
          lcdString(1,6,"Alarm Level 2");
        }
        else if (uiCurrent_Status == STATUS_SpO2_BEHIGH_L1)
        {
          uiCurrent_Status = STATUS_SpO2_BEHIGH_ALARM_L1;
          uiPurpose_FiO2 = uiPurpose_FiO2 - 6;

          if (uiPurpose_FiO2 < SProfile.uiFiO2_Minimum)
          {
            /* if uiPurpose_FiO2 more than uiFiO2_Minimum */
            uiPurpose_FiO2 = SProfile.uiFiO2_Minimum;
          }

          FiO2_Range(uiPurpose_FiO2);
          
          /* Update LCD */
          lcdString(1,5,"Status: Behigh ");
          lcdString(1,6,"Alarm Level 2");          
        }
      }
      else if( uiRespond_time > SProfile.uiRespondsTime)
      {
        if( uiCurrent_Status == STATUS_SpO2_BELOW_L1)
        {
          /* Check Current SpO2. if SpO2 is lower than last time, the system will increase FiO2 */
          if (uiCurrent_SpO2 <= uiInitial_SpO2)
          {
            uiPurpose_FiO2 = uiPurpose_FiO2 + 4;                                // Increase FiO2 4 percent
          }
          uiRespond_time = 0;                                                   // clear Respond time
          
          /* Check Limit of FiO2 */
          if (uiPurpose_FiO2 > SProfile.uiFiO2_Maximum)
          {
            uiPurpose_FiO2 = SProfile.uiFiO2_Maximum;
          }
          uiInitial_SpO2 = uiCurrent_SpO2;                                      // save current SpO2 at initial
        }
        else if(uiCurrent_Status == STATUS_SpO2_BEHIGH_L1)
        {
          /* if SpO2 is higher than last time, the system will decrease FiO2*/
          if(uiCurrent_SpO2 >= uiInitial_SpO2)
          {
            uiPurpose_FiO2 = uiPurpose_FiO2 - 4;                                // Decrease FiO2 4 percent
          }
          uiRespond_time = 0;                                                   // Clear Respond time
          
          /* Check Limit of FiO2 */
          if (uiPurpose_FiO2 < SProfile.uiFiO2_Minimum)
          {
            uiPurpose_FiO2 = SProfile.uiFiO2_Minimum;
          }
        }
      
        uiInitial_SpO2 = uiCurrent_SpO2;                                        // save new Current SpO2
        FiO2_Range(uiPurpose_FiO2);
      }
    }
    else if (uiCurrent_Status == STATUS_SpO2_BEHIGH_L2 | uiCurrent_Status == STATUS_SpO2_BELOW_L2)
    {
      /* Alarm Level 2 */
      if (uiTime_AlarmLevel >= SProfile.uiAlarm_Level2)
      {
        GPIO_SetBits(Alarm_Set_GPIO_Port, Alarm_Set_Pin);
        uiCurrent_Status = STATUS_ALARM;
        USART_Cmd(OPM_USART, ENABLE);                                          // ENABLE Oxygen Pulse Meter USART
        TIM_ITConfig(TIM3, TIM_IT_Update, DISABLE);
        TIM_Cmd(TIM3, DISABLE);
      
//        NVIC_InitTypeDef   NVIC_InitStructure;
        
        /* Enable and set Alarm_Button_EXTI Line Interrupt to the lowest priority */
//        NVIC_InitStructure.NVIC_IRQChannel = Alarm_Button_IRQn;
//        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
//        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
//        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
//        NVIC_Init(&NVIC_InitStructure);


        //Time_AlarmLevel = 0;

        /* Notification Alarm Board (Toggle Pin to Alarm Circuit) */
        lcdClear();
        lcdUpdate();
        lcdString(3,1,"ALARM !!!");
        lcdString(2,2,"PLEASE PUSH");
        lcdString(2,3,"ALARM BUTTON");
        alarm_timer(TIMER_DISABLE);
      }
      else if (uiRespond_time >= SProfile.uiRespondsTime)
      {
        if(uiCurrent_Status == STATUS_SpO2_BEHIGH_L2)
        {
          /* Is SpO2 higher than last SpO2 ?*/
          if(uiCurrent_SpO2 >= uiInitial_SpO2)
          {
            uiPurpose_FiO2 = uiPurpose_FiO2 - 6;                                // Decrease FiO2 6 percent
          }
          uiRespond_time = 0;                                                   // Clear Respond time
          
          /* Check Limit of FiO2 range */
          if (uiPurpose_FiO2 < SProfile.uiFiO2_Minimum)
          {
            uiPurpose_FiO2 = SProfile.uiFiO2_Minimum;
          }
          
          uiInitial_SpO2 = uiCurrent_SpO2;                                      // save current SpO2
        }
        else if(uiCurrent_Status == STATUS_SpO2_BELOW_L2)
        {
          /* Is SpO2 lower than last SpO2 ? */
          if(uiCurrent_SpO2 <= uiInitial_SpO2)
          {
            uiPurpose_FiO2 = uiPurpose_FiO2 + 6;
          }
          uiRespond_time = 0;                                                   // clear respond time
          
          /* Check Limit of FiO2 range */
          if(uiPurpose_FiO2 > SProfile.uiSpO2_Maximum)
          {
            uiPurpose_FiO2 = SProfile.uiSpO2_Maximum;
          }
          
          uiInitial_SpO2 = uiCurrent_SpO2;                                      // save Current SpO2
        }
        
        FiO2_Range(uiPurpose_FiO2);
      }
    }
    else if ((uiCurrent_Status == STATUS_MIDDLE_SpO2_BELOW) | (uiCurrent_Status == STATUS_MIDDLE_SpO2_BEHIGH))
    {
      if (uiRespond_time >= SProfile.uiRespondsTime)
      {
        /* if time over than Responds time, FiO2 will increse or decrease 2 percent */
        uiTime_AlarmLevel = 0;                                                  // clear Time_AlarmLevel
        uiRespond_time = 0;                                                     // clear respond time
        
        if (uiCurrent_SpO2 < SProfile.uiSpO2_middleRange)
        {
          uiPurpose_FiO2 = uiPurpose_FiO2 + 2;                                  // increase FiO2 more than present 2 percent
          
          if (uiPurpose_FiO2 > SProfile.uiFiO2_Maximum)
          {
            uiPurpose_FiO2 = SProfile.uiFiO2_Maximum;
          }
          uiInitial_SpO2 = uiCurrent_SpO2;
        }
        else if (uiCurrent_SpO2 > SProfile.uiSpO2_middleRange)
        {
          uiPurpose_FiO2 = uiPurpose_FiO2 - 2;                                  // decrease FiO2 more than present 2 percent
          
          if (uiPurpose_FiO2 < SProfile.uiFiO2_Minimum)
          {
            uiPurpose_FiO2 = SProfile.uiFiO2_Minimum;
          }
          
          uiInitial_SpO2 = uiCurrent_SpO2;
        }
      }
      
      uiInitial_SpO2 = uiCurrent_SpO2;
      FiO2_Range(uiPurpose_FiO2);
    }

    TIM_ClearITPendingBit (TIM2, TIM_IT_Update);
  }
}
예제 #7
0
파일: flash.c 프로젝트: sparrow1058/cc1110
void flash_main(void){
#else
void main(void){
#endif
   BYTE buffer[30];
   char inputBuffer[STRING_LENGTH];
   INT8 pointer = 0;
   BOOL stop = FALSE;
   BOOL write = FALSE;
   char c;
   char *menuText[] = {(char*)" CPU write?", (char*)" DMA write?"};
   BYTE command;
   BOOL unUsed;

   initFlash();

   // Clearing buffers
   memset(buffer,0,sizeof(buffer));
   memset(inputBuffer,0,sizeof(inputBuffer));

   // Setting up UART
   UART_SETUP(0,57600,HIGH_STOP);
   UTX0IF = 1;  // Set UART 0 TX interrupt flag

   while(getJoystickDirection() != CENTRED);

   //Displaying the stored flash message.
   lcdUpdateLine(LINE1,(char*)"Last written:");
   if((unUsed = flashUnused((BYTE*)testData, STRING_LENGTH)))
   {
      lcdUpdateLine(LINE2,(char*)"Unused");
   }
   else
   {
      scrollText((char*) testData, STRING_LENGTH);
   }

   while(getJoystickDirection() != CENTRED);
   while(getJoystickDirection() == CENTRED);
   while(getJoystickDirection() != CENTRED);


   // User decides whether to use CPU or DMA to write flash or to abort.
   command = lcdMenu(menuText,2);
   if(command == ABORT_MENU)
   {
      return;
   }


   // Uart communication
   lcdUpdate((char*)"Enter UART", (char*)"data");
   printf((char*)"\n\nFlash Programming\n");


   printf((char*)"Press a key\n\n");
   uartGetkey (); // wait for a key to be pressed or the application to be ended
   if (stopApplication() ) return;
   else
   {
      inputBuffer[0] = U0DBUF;
      halWait(5);
      USART0_FLUSH();
      inputBuffer[1] = U0DBUF;
   }

   // Printing the previously written data
   printf((char*)"\nLast written:\n");
   if(unUsed)
   {
      printf((char*)"Unused\n");
   }
   else
   {
      printf((char*)"%s\n",&testData);
   }

   //Aquiring new data:
   printf((char*)"\n\nType data to be written.\nWill be printed to the LCD next time.");
   printf((char*)"\n(ENTER: store in flash, ESC: abort)\n\n");
   memset(inputBuffer,0,STRING_LENGTH);

   while(!stop)
   {
      c = getkey();
      U0DBUF = c;

      switch (c){
      case ENTER:
         inputBuffer[pointer] = 0;
         printf((char*)"\n\nTo write: %s\nENTER if OK.\n",inputBuffer);
         if(getkey() == ENTER)
         {
            // Write data to flash;
            stop = TRUE;
            write = TRUE;
         }
         else
         {
            // Reaquire data.
            printf((char*)"\nEnter text:\n");
            pointer = 0;
         }
         break;
      case BACK_SPACE:
         // Erasing the last typed data.
         if (pointer > 0)
         {
            pointer--;
            inputBuffer[pointer] = ' ';
         }
         break;
      case ESC:
         // Abort Flash write.
         stop = TRUE;
         write = FALSE;
         break;
      default:
         // Add typed data to buffer.
         if (pointer < STRING_LENGTH-1)
         {
            inputBuffer[pointer] = c;
            pointer++;
         }
         break;
      }
   }

  INT_GLOBAL_ENABLE(INT_OFF);

   // Updating the flash if asked to.
   if(write == TRUE)
   {
      if(command == 0)
      {
         halFlashWritePage((BYTE*) &inputBuffer, buffer, PAGE_NUMBER);
      }
      else
      {
         writeFlashUsingDMA((BYTE*) &inputBuffer, STRING_LENGTH, PAGE_ADDRESS, TRUE);
      }
      printf((char*)"\nUpdated:");
      printf((char*)" %s\n",(char __code*) (PAGE_NUMBER << 10));
      lcdUpdateLine(LINE1,(char*)"Updated");
   }
   else
   {
      printf((char*)"\nNot updated\n");
      lcdUpdateLine(LINE1,(char*)"Not updated");
   }
   lcdUpdateLine(LINE2,(char*)"LEFT to continue");


   // Done
   haltApplicationWithLED();

   return;
}
예제 #8
0
파일: 1100.c 프로젝트: eaglevis/AVR
void demo()
{
	lcdCls();
	for (uint8_t i = 0x20; i <= 128; ++i)
	{
		lcdChar(i, LCD_XOR);
	}

	lcdUpdate();
	_delay_ms(2000);

	lcdStrPos (3,11);
	lcdStr_P(PSTR("Free string"), LCD_WHITE);
	lcdStrPos (22,37);
	lcdStr_P(PSTR("positioning"), LCD_WHITE);
	lcdUpdate();
	_delay_ms(3000);

	lcdCls();
	lcdStr_P(PSTR("Lines, rectangles, circles."), LCD_BLACK);
	lcdUpdate();
	_delay_ms(1000);
	lcdNewLine();
	lcdStr_P(PSTR("Filled or unfilled."), LCD_BLACK);
	lcdUpdate();
	_delay_ms(1000);
	lcdNewLine();
	lcdStr_P(PSTR("Solid or XORed filling, text."), LCD_BLACK);
	lcdUpdate();
	_delay_ms(5000);


	lcdRect(0, 0, LCD_Y_RES, LCD_X_RES, LCD_BLACK, LCD_FILL_BLACK);

	lcdStrPos(36,0);

	lcdStr_P(PSTR("MENU"), LCD_XOR);


	lcdRect(5,7,LCD_Y_RES-8, LCD_X_RES-10,LCD_WHITE, LCD_FILL_WHITE );

	for (int i = 1; i < 8; ++i)
	{
		lcdStrPos(10, i*8);
		lcdInt(i, LCD_BLACK);
		lcdStr_P(PSTR(". Sample"), LCD_BLACK);
		lcdLine(5,8*i-1,LCD_X_RES-10, LCD_HORIZ, LCD_BLACK);
	}

	lcdUpdate();

	_delay_ms(2000);


	lcdCircle(LCD_X_RES/2,LCD_Y_RES/2,30, LCD_XOR, LCD_FILL_XOR);
	lcdUpdate();
	_delay_ms(2000);
	lcdBresenhamLine(0, 0, LCD_X_RES-1, LCD_Y_RES-1, LCD_XOR);
	lcdUpdate();
	_delay_ms(2000);
	lcdBresenhamLine(0, LCD_Y_RES-1, LCD_X_RES-1, 0, LCD_XOR);
	lcdUpdate();
	_delay_ms(5000);

	lcdCls();
	lcdStr_P(PSTR("Per-pixel horizontal fill speed test in:"), LCD_BLACK);lcdUpdate();lcdNewLine();
	_delay_ms(1000);
	lcdStr_P(PSTR("3..."), LCD_BLACK);lcdUpdate();
	_delay_ms(1000);
	lcdStr_P(PSTR("2..."), LCD_BLACK);lcdUpdate();
	_delay_ms(1000);
	lcdStr_P(PSTR("1..."), LCD_BLACK);lcdUpdate();
	_delay_ms(1000);


	for (uint8_t x = 0; x < LCD_X_RES; ++x)
	{
		for (uint8_t y = 0; y < LCD_Y_RES; ++y)
		{

			lcdPixel(x,y,LCD_PIXEL_XOR);
			lcdUpdate();
		}
	}
	_delay_ms(1000);
	lcdNewLine();
	lcdStr_P(PSTR("Vertical in:"), LCD_XOR);lcdUpdate();lcdNewLine();
	_delay_ms(1000);
	lcdStr_P(PSTR("3..."), LCD_XOR);lcdUpdate();
	_delay_ms(1000);
	lcdStr_P(PSTR("2..."), LCD_XOR);lcdUpdate();
	_delay_ms(1000);
	lcdStr_P(PSTR("1..."), LCD_XOR);lcdUpdate();
	_delay_ms(1000);

	for (uint8_t y = 0; y < LCD_Y_RES; ++y)
	{
		for (uint8_t x = 0; x < LCD_X_RES; ++x)
		{

			lcdPixel(x,y,LCD_PIXEL_XOR);
			lcdUpdate();
		}
	}
	_delay_ms(2000);
	lcdCls();
	lcdStr_P(PSTR("Every pixel was filled with it's XORed value and updated."), LCD_XOR);lcdUpdate();
	_delay_ms(5000);
	lcdCls();
	lcdStr_P(PSTR("That's it!"), LCD_XOR);
	lcdNewLine();
	lcdStr_P(PSTR("Thanks!"), LCD_XOR);lcdUpdate();

	_delay_ms(5000);
}