Ejemplo n.º 1
0
void Board_Init(void){int tileLen, row, col, tileX, tileY;
	
	// Background Color
	LCD_DrawFilledRect(0,0,320,240,BLACK);
	
	// Sidebar Color
	LCD_DrawFilledRect(0,0,91,240,RED);
	LCD_DrawRect(0,0,91,239,BURNTORANGE);	
	
	// Board Frame
	LCD_DrawFilledRect(boardX, boardY, boardLen, boardLen, ORANGE);
	
	// Title
	LCD_DrawBMP(Title, 13, 7);
	
	// Scoreboard/Credits
	LCD_DrawFilledRect(6,59,79,175,BLACK);
	LCD_DrawRect(6,59,79,174,YELLOW);	
	LCD_SetTextColor(255,245,200);	
	LCD_Goto(2,9);	
	printf("Score:");
	LCD_Goto(2,15);
	printf("Highscore:");
	LCD_Goto(2,12);
	printf("Time:");

	// Credits
	LCD_Goto(4,7);
	LCD_SetTextColor(255,255,240);
	printf("LAB 10");	
	LCD_Goto(2,23);
	printf("Created by:");
	LCD_Goto(2,24);
	printf("Ryan Norton");
	LCD_Goto(2,25);
	printf("Andrew Grado");
	
	// Initialize Tile Position Array and Empty Board
	tileLen = (boardLen - (5 * tilePadding)) / 4;
	for (row=0; row<4; row++){
		for (col=0; col<4; col++){
			
			// Calculate tile coordinates
			tileX = row * (tileLen + tilePadding) + tilePadding + boardX;
			tileY = col * (tileLen + tilePadding) + tilePadding + boardY;
			
			// Initialize board with empty tiles
//			LCD_DrawFilledRect(tileX, tileY, tileLen, tileLen, GREEN);
			
			// Initialize tile position array
			tileCoords[col * 4 + row + 1][0] = tileX;
			tileCoords[col * 4 + row + 1][1] = tileY - 1;
		}
	}
	
}
Ejemplo n.º 2
0
/**
* @brief  USR_MOUSE_Init
*         Init Mouse window
* @param  None
* @retval None
*/
void USR_MOUSE_Init	(void)
{
  
  LCD_UsrLog((void*)USB_HID_MouseStatus); 
  LCD_UsrLog("\n\n\n\n\n\n\n\n");
  LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, "                                   ");
  LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, "                                   ");
    
  /* Display Mouse Window */
  LCD_DrawRect(MOUSE_WINDOW_X,
               MOUSE_WINDOW_Y, 
               MOUSE_WINDOW_HEIGHT,
               MOUSE_WINDOW_WIDTH);
  
  HID_MOUSE_ButtonReleased(0);
  HID_MOUSE_ButtonReleased(1);
  HID_MOUSE_ButtonReleased(2);
  

  LCD_SetTextColor(LCD_COLOR_GREEN);
  LCD_SetBackColor(LCD_COLOR_BLACK);
  
  LCD_DisplayChar(MOUSE_WINDOW_X + 1,
                            MOUSE_WINDOW_Y - 1,
                            'x');
  x_loc  = 0;
  y_loc  = 0; 
  prev_x = 0;
  prev_y = 0;
  
}
Ejemplo n.º 3
0
/**
* @brief  USR_MOUSE_Init
*         Init Mouse window
* @param  None
* @retval None
*/
void USR_MOUSE_Init	(void)
{
  
  if(DEMO_HID_ShowData == 0)
  {
    LCD_UsrLog((void*)USB_HID_MouseStatus); 
    
    /* Display Mouse Window */
    LCD_DrawRect(MOUSE_WINDOW_X,
                 MOUSE_WINDOW_Y, 
                 MOUSE_WINDOW_HEIGHT,
                 MOUSE_WINDOW_WIDTH);
    
    HID_MOUSE_ButtonReleased(0);
    HID_MOUSE_ButtonReleased(1);
    HID_MOUSE_ButtonReleased(2);
    
    
    LCD_SetTextColor(LCD_COLOR_GREEN);
    LCD_SetBackColor(LCD_COLOR_BLACK);
    
    LCD_DisplayChar(MOUSE_WINDOW_X + 1,
                    MOUSE_WINDOW_Y - 1,
                    'x');
    x_loc  = 0;
    y_loc  = 0; 
    prev_x = 0;
    prev_y = 0;
  }
  
}
Ejemplo n.º 4
0
/*******************************************************************************
* Function Name  : Draw_Batt
* Description    : Draw battarey ico
* Input          : charge_level, upd
* Return         : None
*******************************************************************************/
void Draw_Batt(uint8_t charge_level, uint8_t upd)
{
	uint16_t i;
	uint16_t tmpColor = LCD_GetGraphicsColor();
	uint16_t lColor;
	const uint8_t BattWidth = 30;
	const uint8_t Batt_Y0 = 223, Batt_Y1 = 238;
	const uint16_t BattRight = 398, BattLeft = (BattRight - BattWidth) - 1;
	static uint8_t old_charge_level = 0;

	/* Clip and calc charge level */
	if(charge_level > 100) charge_level = 100;
	charge_level = (uint8_t)((charge_level * BattWidth) / 100);

	if(upd == 0)
	{
		LCD_SetGraphicsColor(White);
		LCD_DrawRect(BattLeft + 3, Batt_Y0, BattRight, Batt_Y1);			/* Main batt rect draw*/
		LCD_DrawRect(BattLeft, Batt_Y0 + 4, BattLeft + 3, Batt_Y1 - 4);		/* Plus batt rect draw */
	}

	/* If charge level more */
	if(old_charge_level < charge_level)
	{
		/* Draw batt charge */
		for(i = old_charge_level + 1; i < charge_level + 1; i++)
		{
			lColor = M256_Colors[60 - (uint16_t)((BattWidth - i) * 2)] ;
			if(i <= 27) Draw_Batt_Line(BattRight - i, Batt_Y0 + 1, BattRight - i, Batt_Y1, lColor, 0.3);
			else Draw_Batt_Line(BattRight - i, Batt_Y0 + 5, BattRight - i, Batt_Y1 - 4, lColor, 1);
		}
	}
	/* If charge level less */
	else if(old_charge_level > charge_level)
	{
		/* Clear batt charge */
		LCD_SetGraphicsColor(LightBlack2);		//globalBackColor
		for(i = charge_level + 1; i < old_charge_level + 1; i++)
		{
			if(i <= 27) LCD_DrawLine(BattRight - i, Batt_Y0 + 1, BattRight - i, Batt_Y1);
			else LCD_DrawLine(BattRight - i, Batt_Y0 + 5, BattRight - i, Batt_Y1 - 4);
		}
	}

	old_charge_level = charge_level;
	LCD_SetGraphicsColor(tmpColor);
}
Ejemplo n.º 5
0
void drawPauseMode(void){
	LCD_DrawFilledRect(boardX,boardY,boardLen,boardLen,BLACK);
	LCD_SetTextColor(255,255,240);	
	LCD_Goto(25,13);
	printf("Continue");
	LCD_Goto(38,13);
	printf("Restart");
	LCD_DrawRect(144,112,58,16,WHITE);
}
Ejemplo n.º 6
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main.
     */  
  
  /* Initialize the LCD */
  LCD_Init(); 
  
  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
   
  /* Displays MESSAGE1 on line 0 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);

  /* RTC configuration */
  RTC_Config();
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Red);
  
  /* Displays a rectangle on the LCD */
  LCD_DrawRect(80, 290, 25, 240 );
  
  /* Configure the external interrupt "KEY", "WAKEUP" and "TAMPER" buttons */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI);  
     
  /* Configure RTC alarm A register to generate 8 interrupts per 1 Second */
  RTC_AlarmConfig();
  
  /* set LCD Font */
  LCD_SetFont(&Font12x12);

  /* Set the LCD Back Color */
  LCD_SetBackColor(White); 

  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);

  /* Displays MESSAGE2 and MESSAGE3 on the LCD */
  LCD_DisplayStringLine(LINE(18), (uint8_t *)MESSAGE2);  
  LCD_DisplayStringLine(LINE(19), (uint8_t *)MESSAGE3);  

  /* Infinite loop */
  while (1)
  {}
}
Ejemplo n.º 7
0
/**
  * @brief  This function is called when the connection with the remote
  *         server is established
  * @param arg user supplied argument
  * @param tpcb the tcp_pcb which received data
  * @param err error value returned by the tcp_connect
  * @retval error value
  */
err_t tcp_client_connected(void *arg, struct tcp_pcb *tpcb, err_t err)
{
    LCD_DisplayStringLine(Line5, "Led control started ");

    /* Display Leds Control blocks */
    LCD_SetTextColor(Blue);
    LCD_DrawRect(180, 310, 40, 60);
    LCD_SetTextColor(Red);
    LCD_DrawRect(180, 230, 40, 60);
    LCD_SetTextColor(Yellow);
    LCD_DrawRect(180, 150, 40, 60);
    LCD_SetTextColor(Green);
    LCD_DrawRect(180, 70, 40, 60);

    TcpPCB = tpcb;
    tcp_write(TcpPCB, Sent, sizeof(Sent), 1);
    tcp_recv(tpcb, tcp_client_recv);
    return ERR_OK;
}
Ejemplo n.º 8
0
void DemoVector(void)
{
	LCD_ClearScreen();
	LCD_SetFillColor(1);	
	LCD_DrawRect(110,20,120,60,1);
	LCD_DrawLine(0,0,127,0);
	LCD_DrawLine(0,0,127,16);
	LCD_DrawLine(0,0,127,32);
	LCD_DrawLine(0,0,127,48);
	LCD_DrawLine(0,0,127,63);
	LCD_SetPenColor(1);
	LCD_DrawCircle(63,31,31);
	LCD_DrawCircle(8,50,5);
	LCD_DrawEllipse(80,40, 30,10);
	LCD_SetFillColor(0);	
	LCD_DrawRect(12,20,40,40,3);
	LCD_SetFillColor(-1);	
	LCD_DrawRect(30,50,60,60,1);
}
Ejemplo n.º 9
0
Archivo: IHM.c Proyecto: MIDMX/RaVisual
void password_screen(){

	//fond d'écran, header, footer
	create_rectangle(0,0,320,240,0x632C);
	header(5,TRUE,TRUE);

	//initialisatioin des variables
	char * temp[20],hidden[20]={};
	uint32_t i,j,len = strlen(password);
	uint32_t plus = 0, offsetY = 85, offsetX = 10;

	//création de la barre de texte
	LCD_DrawFullRect(10,40,300,32,0x39C7,0xD6BA);
	LCD_DrawFullRect(279,41,30,30,0xD6BA,0x153F);
	create_button(button,41,279,41,30,30);

	//on affiche le mot de passe en masuqnat les caractères
	for(i = 0; i<len;i++){
		strcpy(temp,hidden);
		sprintf(hidden,"%s-",(uint8_t *)temp);
	}
	LCD_DisplayStringLine(52,15,(uint8_t *)hidden,0x39C7,0xD6BA,LCD_NO_DISPLAY_ON_UART);

	//on choisit la police du texte à afficher
	LCD_SetFont(&Bebasn);

	//affichage des icônes dans le menu
	for(i=0;i<4;i++){
		for(j=0;j<10;j++){

			//bufferisation de la position des boutons
			create_button(button,plus,(30*j)+offsetX,(31*i)+offsetY,30,30);

			//drawing separators
			LCD_DrawRect((30*j)+offsetX,(31*i)+offsetY,30,30,0x39C7);
			LCD_DrawFullRect((30*j)+offsetX,(31*i)+offsetY,29,29,0x738E,0x5ACB);
			LCD_DisplayStringLine((31*i)+offsetY+11,(30*j)+offsetX+11,(uint8_t *)string[plus],0xD6BA,0x5ACB,LCD_NO_DISPLAY_ON_UART);
			plus++;

			// on sort de la boucle pour ne pas afficher les deux dernières touches du clavier
			// (choix graphique, on aurait pu faire sans)
			if (plus > 37){
				j = 10;
				i = 4;
			}

		}
	}

	//affichage du footer, puis lecture de l'écran tactile
	footer(PASSWORD);
	read_screen(button,PASSWORD,40);

}
Ejemplo n.º 10
0
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str,
        const struct LabelDesc *desc, u8 is_selected)
{
    u16 txt_w, txt_h;
    u16 txt_x, txt_y;
    u16 offset = (LCD_DEPTH > 1 && desc->font==NARROW_FONT.font) ? 1 : 0;
    LCD_SetFont(desc->font);
    LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++;
    if (obj_w == 0)
        obj_w = txt_w;
    if (obj_h == 0)
        obj_h = txt_h;
    if (offset && obj_y >= offset) {
        obj_y -= offset;
    }
    if (desc->style == LABEL_BOX) {
        // draw round rect for the textsel widget when it is pressable
        if (is_selected) {
            LCD_FillRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1);
        }  else {
            GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
            LCD_DrawRoundRect(obj_x, obj_y, obj_w, obj_h , 3,  1);
        }
    }
    else if (desc->style == LABEL_FILL) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
    } else {
        GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
    }
    if (desc->fill_color != desc->outline_color) {
        LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color);
        obj_x+=2; obj_w-=4;
    }

    if (desc->style == LABEL_RIGHT) {
        txt_x = obj_x + obj_w - txt_w;
    } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT)) {
        txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2;
    } else {
        txt_x = obj_x+1;
    }
    txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2;

    if (desc->style != LABEL_FILL && is_selected) {
        LCD_SetFontColor(~desc->font_color);
    } else {
        LCD_SetFontColor(desc->font_color);
    }
    LCD_PrintStringXY(txt_x, txt_y, str);
}
Ejemplo n.º 11
0
// args are x0, x1, y0, y1, color
const char* JSON_evalRect(const char* ptr) {
  const char* data[4] = {NULL};
  if(getAmountOfArgs(&ptr, data, 4) != 4) {
    // how do I recover? do all the other elements die?
    return ptr; // error!
  }

  LCD_DrawRect(atoi(data[0]),
               atoi(data[2]),
               atoi(data[1]),
               atoi(data[3]),
               atoi(ptr-1));
  return ptr;
}
Ejemplo n.º 12
0
/**
* @brief  Configure the IO Expander and the Touch Panel.
* @param  None
* @retval None
*/
static void TP_Config(void)
{
  /* Clear the LCD */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Configure the IO Expander */
  if (IOE_Config() == IOE_OK)
  {   
    LCD_SetFont(&Font8x8);
    LCD_DisplayStringLine(LINE(32), (uint8_t*)"              Touch Panel Paint     ");
    LCD_DisplayStringLine(LINE(34), (uint8_t*)"              Example               ");
    LCD_SetTextColor(LCD_COLOR_BLUE2); 
    LCD_DrawFullRect(5, 250, 30, 30);
    LCD_SetTextColor(LCD_COLOR_CYAN); 
    LCD_DrawFullRect(40, 250, 30, 30);
    LCD_SetTextColor(LCD_COLOR_YELLOW); 
    LCD_DrawFullRect(75, 250, 30, 30);
    LCD_SetTextColor(LCD_COLOR_RED); 
    LCD_DrawFullRect(5, 288, 30, 30);
    LCD_SetTextColor(LCD_COLOR_BLUE); 
    LCD_DrawFullRect(40, 288, 30, 30);
    LCD_SetTextColor(LCD_COLOR_GREEN); 
    LCD_DrawFullRect(75, 288, 30, 30);
    LCD_SetTextColor(LCD_COLOR_MAGENTA); 
    LCD_DrawFullRect(145, 288, 30, 30);
    LCD_SetTextColor(LCD_COLOR_BLACK); 
    LCD_DrawFullRect(110, 288, 30, 30);
    LCD_DrawRect(180, 270, 48, 50);
    LCD_SetFont(&Font16x24);
    LCD_DisplayChar(LCD_LINE_12, 195, 0x43);
    LCD_DrawLine(0, 248, 240, LCD_DIR_HORIZONTAL);
    LCD_DrawLine(0, 284, 180, LCD_DIR_HORIZONTAL);
    LCD_DrawLine(1, 248, 71, LCD_DIR_VERTICAL);
    LCD_DrawLine(37, 248, 71, LCD_DIR_VERTICAL);
    LCD_DrawLine(72, 248, 71, LCD_DIR_VERTICAL);
    LCD_DrawLine(107, 248, 71, LCD_DIR_VERTICAL);
    LCD_DrawLine(142, 284, 36, LCD_DIR_VERTICAL);
    LCD_DrawLine(0, 319, 240, LCD_DIR_HORIZONTAL);
  }  
  else
  {
    LCD_Clear(LCD_COLOR_RED);
    LCD_SetTextColor(LCD_COLOR_BLACK); 
    LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)"   IOE NOT OK      ");
    LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)"Reset the board   ");
    LCD_DisplayStringLine(LCD_LINE_8,(uint8_t*)"and try again     ");
  }
}
Ejemplo n.º 13
0
/**
  * @brief  This function handles RTC Alarm interrupt (A and B) request.
  * @param  None
  * @retval None
  */
void RTC_Alarm_IRQHandler(void)
{
  uint32_t tmp = 0;
  
  /* Check on the Alarm A flag and on the number of interrupts per Second (60*8) */
  if(RTC_GetITStatus(RTC_IT_ALRA) != RESET) 
  { 
    /* Clear RTC AlarmA Flags */
    RTC_ClearITPendingBit(RTC_IT_ALRA);
    if(uwRTCAlarmCount != 480)
    {
      /* Increment the counter of Alarm A interrupts */
      uwRTCAlarmCount++;

      /* Set the LCD Back Color */
      LCD_SetTextColor(Green);

      /* Draw rectangle on the LCD */
      LCD_DrawLine(80,290 - (uwRTCAlarmCount/2),25,Vertical);

      /* Set the LCD text color */
      LCD_SetTextColor(Red);

      /* Display rectangle on the LCD */
      LCD_DrawRect(80, 290, 25, 240 );

      /* Define the rate of Progress bar */
      tmp = (uwRTCAlarmCount * 100)/ 480; 

      /* Set the LCD Font */
      LCD_SetFont(&Font16x24);
    
      /* Display Char on the LCD : XXX% */
      LCD_DisplayChar(LINE(2),200, (tmp / 100) +0x30);
      LCD_DisplayChar(LINE(2),180, ((tmp  % 100 ) / 10) +0x30);
      LCD_DisplayChar(LINE(2),160, (tmp % 10) +0x30);
      LCD_DisplayChar(LINE(2),140, 0x25);
    }
    else
    {
      /* Disable the RTC Clock */
      RCC_RTCCLKCmd(DISABLE);
    }
  }
  /* Clear the EXTI line 17 */
  EXTI_ClearITPendingBit(EXTI_Line17);
  
}
Ejemplo n.º 14
0
void drawGameOver(int score, int time){
	LCD_DrawFilledRect(boardX,boardY,boardLen,boardLen,BLACK);
	LCD_SetTextColor(255,255,240);	
	LCD_Goto(30,5);
	printf("GAME OVER");
	LCD_Goto(23,8);
	printf("Score:");
	LCD_Goto(29,8);
	LCD_PrintInteger(score);
	LCD_Goto(23,10);
	printf("Time:");
	LCD_Goto(28,10);
	LCD_PrintInteger(time);
	LCD_Goto(29,19);
	printf("Play Again?");
	LCD_DrawRect(170,166,72,16,WHITE);	
}
Ejemplo n.º 15
0
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str,
        const struct LabelDesc *desc, u8 is_selected)
{
    u16 txt_w, txt_h;
    u16 txt_x, txt_y;
    // This is used to align text vertically
    u16 offset = (desc->font==NARROW_FONT.font) ? 1 : 0;
    LCD_SetFont(desc->font);
    LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++;
    if (obj_w == 0)
        obj_w = txt_w;
    if (obj_h == 0)
        obj_h = txt_h;
    if (desc->style == LABEL_LISTBOX) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, is_selected ? Display.listbox.fg_color : Display.listbox.bg_color);
    } else if (desc->style == LABEL_FILL) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
    } else {
        GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
    }
    if (desc->style != LABEL_LISTBOX && desc->fill_color != desc->outline_color) {
        LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color);
        obj_x+=2; obj_w-=4;
    }

    if (desc->style == LABEL_RIGHT) {
        txt_x = obj_x + obj_w - txt_w;
    } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT)) {
        txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2;
    } else {
        txt_x = obj_x+1;
    }
    txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2;

    if (desc->style == LABEL_LISTBOX) {
        LCD_SetFontColor(is_selected ? Display.listbox.fg_select : Display.listbox.bg_select);
    } else {
        if (desc->style != LABEL_FILL && is_selected) {
            LCD_SetFontColor(~desc->font_color);
        } else {
            LCD_SetFontColor(desc->font_color);
        }
    }
    LCD_PrintStringXY(txt_x, txt_y, str);
}
Ejemplo n.º 16
0
void GUI_DrawImage(struct guiObject *obj)
{
#define SELECT_BORDER_OFFSET 1
    struct guiImage *image = (struct guiImage *)obj;
    struct guiBox *box = &obj->box;

    //  clear the whole widget, including its selected border for devo10/7e
    if (LCD_DEPTH == 1)
        GUI_DrawBackground(box->x -SELECT_BORDER_OFFSET, box->y -SELECT_BORDER_OFFSET,
            box->width + SELECT_BORDER_OFFSET + SELECT_BORDER_OFFSET, box->height + SELECT_BORDER_OFFSET + SELECT_BORDER_OFFSET);

    LCD_DrawWindowedImageFromFile(box->x, box->y,
            image->file, box->width, box->height,
            image->x_off, image->y_off);

    if (LCD_DEPTH == 1 && GUI_GetSelected() == obj)
        LCD_DrawRect(box->x -SELECT_BORDER_OFFSET, box->y -SELECT_BORDER_OFFSET,
            box->width + SELECT_BORDER_OFFSET + SELECT_BORDER_OFFSET, box->height + SELECT_BORDER_OFFSET + SELECT_BORDER_OFFSET, 1);
}
Ejemplo n.º 17
0
/**
* @brief  USBH_DisconnectEvent
*         Device disconnect event
* @param  None
* @retval None
*/
void USBH_USR_DeviceDisconnected (void)
{
  
  LCD_SetBackColor(Black); 
  LCD_SetTextColor(Black);   
  
  LCD_LOG_ClearTextZone();

  LCD_DrawRect(MOUSE_WINDOW_X,
               MOUSE_WINDOW_Y, 
               MOUSE_WINDOW_HEIGHT,
               MOUSE_WINDOW_WIDTH);
  LCD_SetTextColor(White);    
  
  LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, "                                   ");
  LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, "                                   ");  
  
  LCD_ErrLog((void *)MSG_DEV_DISCONNECTED);
}
Ejemplo n.º 18
0
/*******************************************************************************
* Function Name	:
* Description		:
* Output				:
* Return				: None
*******************************************************************************/
void _MENU::Refresh() {
	if (item < 0) {
		if (str) {
			
#ifdef USE_LCD
			LCD_SetFont(&Font8x12);
			sFONT *f = LCD_GetFont();
			LCD_SetTextColor(LCD_COLOR_GREY);
			LCD_DisplayStringLine(LCD_PIXEL_HEIGHT - 5 * f->Height / 2, (uint8_t *)str);
			for (int i = 0; i<4; ++i)
				LCD_DrawRect((9 * i + 1)*f->Width,
				LCD_PIXEL_HEIGHT - 3 * f->Height,
				9 * f->Width,
				2 * f->Height);
#endif		
//			printf("%s\r", str);
		}
	}
	else
		next[item]->Refresh();
}
Ejemplo n.º 19
0
/*
*********************************************************************************************************
*	函 数 名: FrameDisp
*	功能说明: 显示波形窗口的边框和刻度线
*	形    参:无
*	返 回 值: 无
*********************************************************************************************************
*/
static void FrameDisp(void)
{
	uint16_t x, y;

	/* 绘制一个实线矩形框 x, y, h, w */
	LCD_DrawRect(9, 19, 202, 302, CL_WHITE);

	/* 绘制垂直刻度点 */
	for (x = 0; x < 13; x++)
	{
		for (y = 0; y < 41; y++)
		{
			Gui_DrawPoint(10 + (x * 25), 20 + (y * 5), CL_WHITE);
		}
	}

	/* 绘制水平刻度点 */
	for (y = 0; y < 9; y++)
	{
		for (x = 0; x < 61; x++)
		{
			Gui_DrawPoint(10 + (x * 5), 20 + (y * 25), CL_WHITE);
		}
	}

	/* 绘制垂直中心刻度点 */
	for (y = 0; y < 41; y++)
	{	 
		Gui_DrawPoint(9 + (6 * 25), 20 + (y * 5), CL_WHITE);
		Gui_DrawPoint(11 + (6 * 25), 20 + (y * 5), CL_WHITE);
	}

	/* 绘制水平中心刻度点 */
	for (x = 0; x < 61; x++)
	{	 
		Gui_DrawPoint(10 + (x * 5), 19 + (4 * 25), CL_WHITE);
		Gui_DrawPoint(10 + (x * 5), 21 + (4 * 25), CL_WHITE);
	}
}
Ejemplo n.º 20
0
/**
  * @brief  This function handles External line 0 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI0_IRQHandler(void)
{
  if((EXTI_GetITStatus(WAKEUP_BUTTON_EXTI_LINE) != RESET))
  {
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);
    
    /* Clear the LCD line 2 */
    LCD_ClearLine(Line2);
   
    /* Disable the RTC Clock */
    RCC_RTCCLKCmd(DISABLE);
   
    /* Reset Counter*/
    uwRTCAlarmCount = 0;
    
    /* Disable the alarm */
    RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
    
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);
  
    /* Display a Full rectangle on the LCD */
    LCD_DrawFullRect(80, 290,240, 25 );
    
    /* Set LCD text color */
    LCD_SetTextColor(Red);

    /* Display rectangle on the LCD */
    LCD_DrawRect(80, 290, 25, 240 );
    
    /* Clear the WAKEUP EXTI  pending bit */
    EXTI_ClearITPendingBit(WAKEUP_BUTTON_EXTI_LINE);  
  }

}
Ejemplo n.º 21
0
/*******************************************************************************
* Function Name  : LCD_Update
* Description    : Controls the wave player application LCD display messages.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_Update(uint32_t Status)
{
  uint8_t tmp = 0;
  uint32_t counter = 0;

  /* Enable the FSMC that share a pin w/ I2C1 (LBAR) */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

  switch (Status)
  {
   case PROGRESS:
         tmp = (uint8_t) ((uint32_t)((GetVar_AudioDataIndex()) * 100) / GetVar_AudioDataLength());
         if (tmp == 0)
         { 
           LCD_SetTextColor(Magenta);
           LCD_ClearLine(Line8);
           LCD_DrawRect(Line8, 310, 16, 300);
         }
         else
         {
           LCD_SetTextColor(Magenta);
           LCD_DrawLine(Line8, 310 - (tmp * 3), 16, Vertical);
         }         
         break;
   case FRWD:
         tmp = (uint8_t) ((uint32_t)((GetVar_AudioDataIndex()) * 100) / GetVar_AudioDataLength());

         LCD_SetTextColor(Magenta);
         LCD_ClearLine(Line8);
         LCD_DrawRect(Line8, 310, 16, 300);
         LCD_SetTextColor(Magenta);

         for (counter = 0; counter <= tmp; counter++)
         {
           LCD_DrawLine(Line8, 310 - (counter * 3), 16, Vertical);
         }          
         break;
   case STOP:
         /* Display the stopped status menu */ 
         LCD_SetTextColor(White); 
         LCD_DisplayStringLine(Line3, CmdTitle1Stopped);
         LCD_DisplayStringLine(Line4, CmdTitle2Stopped);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitleStopped);
         LCD_ClearLine(Line9);
         LCD_SetTextColor(Black);
         LCD_DisplayChar(Line9, 250, 'v'); 
         LCD_DisplayChar(Line9, 235, 'o'); 
         LCD_DisplayChar(Line9, 220, 'l'); 
         LCD_DisplayChar(Line9, 200, '-'); 
         LCD_DisplayChar(Line9, 85, '+'); 
         LCD_DrawRect(Line9 + 8, 185, 10, 100); 
         break; 
   case PAUSE: 
         /* Display the paused status menu */ 
         LCD_SetTextColor(White);
         LCD_DisplayStringLine(Line3, CmdTitle1Paused);
         LCD_DisplayStringLine(Line4, CmdTitle2Paused);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitlePaused);
         break;
   case PLAY:
         /* Display the Titles */   
         LCD_SetTextColor(Black);
         LCD_DisplayStringLine(Line0, DemoTitle);
         LCD_DisplayStringLine(Line2, CmdTitle0); 

         /* Display the Playing status menu */ 
         LCD_SetTextColor(White);
         LCD_DisplayStringLine(Line3, CmdTitle1Playing);
         LCD_DisplayStringLine(Line4, CmdTitle2Playing);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitlePlaying);
         LCD_ClearLine(Line9);
         LCD_SetTextColor(Black);
         LCD_DisplayChar(Line9, 250, 'v'); 
         LCD_DisplayChar(Line9, 235, 'o'); 
         LCD_DisplayChar(Line9, 220, 'l'); 
         LCD_DisplayChar(Line9, 200, '-'); 
         LCD_DisplayChar(Line9, 85, '+'); 
         LCD_DrawRect(Line9 + 8, 185, 10, 100); 
         break;
   case ALL: 
         I2S_CODEC_LCDConfig();
         /* Display the stopped status menu */ 
         LCD_SetTextColor(White); 
         LCD_DisplayStringLine(Line3, CmdTitle1Stopped);
         LCD_DisplayStringLine(Line4, CmdTitle2Stopped);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitleStopped);
         LCD_ClearLine(Line9);
         LCD_SetTextColor(Black);
         LCD_DisplayChar(Line9, 250, 'v'); 
         LCD_DisplayChar(Line9, 235, 'o'); 
         LCD_DisplayChar(Line9, 220, 'l'); 
         LCD_DisplayChar(Line9, 200, '-'); 
         LCD_DisplayChar(Line9, 85, '+'); 
         LCD_DrawRect(Line9 + 8, 185, 10, 100); 
         break;
  }
  /* Update the volume bar in all cases except when progress bar is to be apdated */
  if (Status != PROGRESS)
  {
    /* Compute the current volume percentage */
    tmp = (uint8_t) ((uint16_t)((0xFF - GetVar_CurrentVolume()) * 100) / 0xFF) ;
 
    /* Clear the previuos volume bar */
    LCD_SetTextColor(Blue);
    LCD_DrawLine(Line9 + 10, 185 - previoustmp , 8, Vertical);
    LCD_DrawLine(Line9 + 10, 185 - previoustmp + 1 , 8, Vertical);    
 
    /* Draw the new volume bar */
    LCD_SetTextColor(Red);
    LCD_DrawLine(Line9 + 10, 185 - tmp , 8, Vertical);
    LCD_DrawLine(Line9 + 10, 185 - tmp + 1 , 8, Vertical);
 
    /* save the current position */
    previoustmp = tmp;
  }
  /* Disable the FSMC that share a pin w/ I2C1 (LBAR) */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, DISABLE);
}
Ejemplo n.º 22
0
/*******************************************************************************
* Function Name  : RegulateDay
* Description    : Regulates day.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
static void RegulateDay(void)
{
  uint32_t tmpValue = 0;
  uint32_t MyKey = 0, ValueMax = 0;
  uint32_t firstdaycolumn = 0, lastdaycolumn = 0, lastdayline = 0;
  
  if(date_s.month == 2)
  {
    if(IsLeapYear(date_s.year))
      ValueMax = 29;
    else
      ValueMax = (MonLen[date_s.month - 1] - 1);
  }
  else
  {
    ValueMax = (MonLen[date_s.month - 1] - 1);
  }  

  firstdaycolumn = 0x13F - (0x30 * dn);

  lastdaycolumn = ValueMax - (7 - dn);
  lastdayline = lastdaycolumn / 7;
  lastdaycolumn %= 7;

  if(lastdaycolumn == 0)
  {
    lastdayline = Line3 + (lastdayline * 24);
    lastdaycolumn = 31;
  }
  else
  {
    lastdayline = Line4 + (lastdayline * 24);
    lastdaycolumn = 0x13F -(0x30 * (lastdaycolumn - 1));
  }

  
  /* Initialize tmpValue */
  tmpValue = date_s.day;
  
  /* Endless loop */
  while(1)
  {
    /* Check which key is pressed */
    MyKey = ReadKey();

    /* If "RIGHT" pushbutton is pressed */
    if(MyKey == RIGHT)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      
      /* Increase the value of the digit */
      if(tmpValue == ValueMax)
      {
        tmpValue = 0;
        dayline = Line3;
        daycolumn = firstdaycolumn + 48;
      }
             
      if(daycolumn == 31)
      {
        daycolumn = 367;
        dayline += 24;
      }

      daycolumn -= 48;
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      tmpValue++;   
    }
    /* If "LEFT" pushbutton is pressed */
    if(MyKey == LEFT)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      
      /* Decrease the value of the digit */
      if(tmpValue == 1)
      {
        tmpValue = ValueMax + 1;
        dayline = lastdayline;
        daycolumn = lastdaycolumn - 48;        
      }
      
      if(daycolumn == 319)
      {
        daycolumn = 0xFFEF;
        dayline -= 24;
      } 

      daycolumn += 48;      
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      tmpValue--;
    }
    /* If "UP" pushbutton is pressed */
    if(MyKey == UP)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
         
      if(tmpValue == 1)
      {
        dayline = lastdayline;
        daycolumn =  lastdaycolumn;
        tmpValue = ValueMax;
      }
      else if(tmpValue < 8)
      {
        tmpValue = 1;
        dayline = Line3;
        daycolumn = firstdaycolumn; 
      }
      else
      {
        dayline -= 24;
        tmpValue -= 7;
      }
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);    
    } 
    /* If "DOWN" pushbutton is pressed */
    if(MyKey == DOWN)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      if(tmpValue == ValueMax)
      {
        dayline = Line3;
        daycolumn =  firstdaycolumn;
        tmpValue = 1;
      }
      else
      {
        dayline += 24;
        tmpValue += 7;
      }
      if(tmpValue > ValueMax)
      {
        tmpValue = ValueMax;
        dayline = lastdayline;
        daycolumn = lastdaycolumn;
      }
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);     
    }       
    /* If "SEL" pushbutton is pressed */
    if(MyKey == SEL)
    {
      /* Return the digit value and exit */
      date_s.day = tmpValue;
      return;
    }
  }
}
Ejemplo n.º 23
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Initialize LEDs and push-buttons mounted on STM3210X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
   /* Initialize the LCD */
#ifdef USE_STM3210C_EVAL
  STM3210C_LCD_Init();
#elif defined (USE_STM32100E_EVAL)
  STM32100E_LCD_Init();  
#endif /* USE_STM3210C_EVAL */
 
  /* Clear the LCD */ 
  LCD_Clear(White);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);    
 
  /* Display messages on the LCD */
  LCD_DisplayStringLine(Line0, MESSAGE1);
  LCD_DisplayStringLine(Line1, MESSAGE2);
  LCD_DisplayStringLine(Line2, MESSAGE3);
  
  /* Configure the IO Expander */
  if (IOE_Config() == IOE_OK)
  {
    /* Display "IO Expander OK" on the LCD */
    LCD_DisplayStringLine(Line4, "   IO Expander OK   ");
  }
  else
  { 
    LCD_DisplayStringLine(Line4, "IO Expander FAILED ");
    LCD_DisplayStringLine(Line5, " Please Reset the  ");
    LCD_DisplayStringLine(Line6, "   board and start ");
    LCD_DisplayStringLine(Line7, "    again          ");
    while(1);
  }

  /* Draw a rectangle with the specifies parameters and Blue Color */
  LCD_SetTextColor(Blue);
  LCD_DrawRect(180, 310, 40, 60);
  
  /* Draw a rectangle with the specifies parameters and Red Color */
  LCD_SetTextColor(Red);
  LCD_DrawRect(180, 230, 40, 60);
  
  /* Draw a rectangle with the specifies parameters and Yellow Color */
  LCD_SetTextColor(Yellow);
  LCD_DrawRect(180, 150, 40, 60);
  
  /* Draw a rectangle with the specifies parameters and Black Color */
  LCD_SetTextColor(Black);
  LCD_DrawRect(180, 70, 40, 60);
  

#ifdef IOE_INTERRUPT_MODE

 #ifdef  USE_STM32100E_EVAL
  /* Enable the Touch Screen interrupts */
  IOE_ITConfig(IOE_ITSRC_TSC);
  
 #else
  /* Enable the Touch Screen and Joystick interrupts */
  IOE_ITConfig(IOE_ITSRC_JOYSTICK | IOE_ITSRC_TSC);
 #endif /* USE_STM32100E_EVAL */
 
#endif /* IOE_INTERRUPT_MODE */
  
  /* Loop infinitely */
  while(1)
  {
#ifdef IOE_POLLING_MODE
 static TS_STATE* TS_State;
    
 #ifdef  USE_STM3210C_EVAL
 
    static JOY_State_TypeDef JoyState = JOY_NONE;
    
    /* Get the Joytick State */
    JoyState = IOE_JoyStickGetState();
    
    switch (JoyState)
    {
	/* None Joystick has been selected */
    case JOY_NONE:
      LCD_DisplayStringLine(Line5, "JOY:     ----       ");
      break; 
    case JOY_UP:
      LCD_DisplayStringLine(Line5, "JOY:     UP         ");
      break;     
    case JOY_DOWN:
      LCD_DisplayStringLine(Line5, "JOY:    DOWN        ");
      break;          
    case JOY_LEFT:
      LCD_DisplayStringLine(Line5, "JOY:    LEFT        ");
      break;         
    case JOY_RIGHT:
      LCD_DisplayStringLine(Line5, "JOY:    RIGHT       ");
      break;                 
    case JOY_CENTER:
      LCD_DisplayStringLine(Line5, "JOY:    CENTER      ");
      break; 
    default:
      LCD_DisplayStringLine(Line5, "JOY:    ERROR       ");
      break;         
    }
 #endif /* USE_STM3210C_EVAL */
    
   
    /* Update the structure with the current position of the Touch screen */
    TS_State = IOE_TS_GetState();  
    
    if ((TS_State->TouchDetected) && (TS_State->Y < 220) && (TS_State->Y > 180))
    {
      if ((TS_State->X > 10) && (TS_State->X < 70))
      { 
      /* Display LD4 on the LCD and turn on LED4 */
        LCD_DisplayStringLine(Line6, " LD4                ");
        STM_EVAL_LEDOn(LED4);
      }
      else if ((TS_State->X > 90) && (TS_State->X < 150))
      {
      /* Display LD3 on the LCD and turn on LED3 */
        LCD_DisplayStringLine(Line6, "      LD3           ");
        STM_EVAL_LEDOn(LED3);
      }
      else if ((TS_State->X > 170) && (TS_State->X < 230))
      {
      /* Display LD2 on the LCD and turn on LED2 */
        LCD_DisplayStringLine(Line6, "           LD2      ");
        STM_EVAL_LEDOn(LED2);
      } 
      else if ((TS_State->X > 250) && (TS_State->X < 310))
      {
      /* Display LD1 on the LCD and turn on LED1 */
        LCD_DisplayStringLine(Line6, "                LD1 ");
        STM_EVAL_LEDOn(LED1);
      }
      
    }
    else
    {
    /* Turn off LED1..4 */
      STM_EVAL_LEDOff(LED1);
      STM_EVAL_LEDOff(LED2);
      STM_EVAL_LEDOff(LED3);
      STM_EVAL_LEDOff(LED4);
    }

#endif /* IOE_POLLING_MODE */  
  }
}
Ejemplo n.º 24
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */  
  
  /* Initialize the LCD */
#ifdef USE_STM320518_EVAL
    STM320518_LCD_Init();
#else
    STM32072B_LCD_Init();
#endif /* USE_STM320518_EVAL */
         
  /* Enable The Display */
  LCD_DisplayOn(); 

  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
   
  /* Displays MESSAGE1 on line 0 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);

  /* RTC configuration */
  RTC_Config();
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Red);
  
  /* Displays a rectangle on the LCD */
  LCD_DrawRect(80, 280, 25, 240 );
  
  /* Configure the external interrupt "WAKEUP" and "TAMPER" buttons */
  STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI);  
     
  /* Configure RTC AlarmA register to generate 8 interrupts per 1 Second */
  RTC_AlarmConfig();
  
  /* set LCD Font */
  LCD_SetFont(&Font12x12);

  /* Set the LCD Back Color */
  LCD_SetBackColor(White); 

  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);
  
  /* Set the Back Color */
  LCD_SetBackColor(LCD_COLOR_CYAN);
  /* Displays MESSAGE2 and MESSAGE3 on the LCD */
  LCD_DisplayStringLine(LINE(18), (uint8_t *)MESSAGE2);  
  LCD_DisplayStringLine(LINE(19), (uint8_t *)MESSAGE3);  

  /* Infinite loop */
  while (1)
  {
    uint32_t tmp =0;
    /* ALARM Interrupt */
    if (ALARM_Occured)
    {
      if(RTCAlarmCount != 480)
      {
        /* Increament the counter of Alarma interrupts */
        RTCAlarmCount++;
        
        /* Set the LCD Back Color */
        LCD_SetTextColor(Green);
        
        /* Draw rectangle on the LCD */
        LCD_DrawFullRect(81, 359, 80+ (((RTCAlarmCount)-1)/2) , 24);
        
        /* Set the LCD text color */
        LCD_SetTextColor(Red);
        
        /* Display rectangle on the LCD */
        LCD_DrawRect(80, 280, 25, 240 );
        
        /* Define the rate of Progress bar */
        tmp = (RTCAlarmCount * 100)/ 480; 
        
        /* Set the LCD Font */
        LCD_SetFont(&Font16x24);
        
        /* Display Char on the LCD : XXX% */
        LCD_DisplayChar(LINE(2),200, (tmp / 100) +0x30);
        LCD_DisplayChar(LINE(2),180, ((tmp  % 100 ) / 10) +0x30);
        LCD_DisplayChar(LINE(2),160, (tmp % 10) +0x30);
        LCD_DisplayChar(LINE(2),140, 0x25);
      }
      else
      {
        /* Disable the RTC Clock */
        RCC_RTCCLKCmd(DISABLE);
        
      }
      /* Reinitialize the ALARM variable */
      ALARM_Occured = 0;
    }
  }
}
Ejemplo n.º 25
0
/*******************************************************************************
* Function Name  : Date_Display
* Description    : Displays the date in a graphic mode.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Date_Display(uint16_t nYear, uint8_t nMonth, uint8_t nDay)
{
  uint32_t mline = 0, mcolumn = 319, month = 0;
  uint32_t monthlength = 0;

  if(nMonth == 2)
  {
    if(IsLeapYear(nYear))
    {
      monthlength = 30;
    }
    else
    {
      monthlength = MonLen[nMonth - 1];
    }    
  }
  else
  {
    monthlength = MonLen[nMonth - 1];
  }

  /* Set the Back Color */
  LCD_SetBackColor(Blue2);
  /* Set the Text Color */
  LCD_SetTextColor(Yellow);
  
  LCD_DisplayStringLine(Line0, MonthNames[nMonth - 1]);


  LCD_DisplayChar(Line0, 95, ((nYear/1000)+ 0x30));
  LCD_DisplayChar(Line0, 79, (((nYear%1000)/100)+ 0x30));
  LCD_DisplayChar(Line0, 63, ((((nYear%1000)%100)/10)+ 0x30));
  LCD_DisplayChar(Line0, 47, ((((nYear%1000)%100)%10)+ 0x30));

  WeekDayNum(nYear, nMonth, nDay);

  LCD_SetTextColor(White);
  LCD_DisplayStringLine(Line1, " WEEK     DAY N:    ");
  if(wn/10)
  {
    LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
    LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
  }
  else
  {
    LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
  }
  if(dc/100)
  {
    LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
    LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
    LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));    
  }
  else if(dc/10)
  {
    LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
    LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
  }
  else
  {
    LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));  
  }
  
  /* Set the Back Color */
  LCD_SetBackColor(Red);
  LCD_SetTextColor(White);
  LCD_DisplayStringLine(Line2, "Mo Tu We Th Fr Sa Su");
  LCD_SetBackColor(White);
  LCD_SetTextColor(Blue2);
  
  /* Determines the week number, day of the week of the selected date */
  WeekDayNum(nYear, nMonth, 1);

  mline = Line3;
  mcolumn = 0x13F - (0x30 * dn);

  for(month = 1; month < monthlength; month++)
  {
    if(month == nDay)
    {
      daycolumn = mcolumn;
      dayline = mline;
    }
    if(month/10)
    {
      LCD_DisplayChar(mline, mcolumn, ((month/10)+ 0x30));
    }
    else
    {
      LCD_DisplayChar(mline, mcolumn, ' ');
    }
    mcolumn -= 16;
    LCD_DisplayChar(mline, mcolumn, ((month%10)+ 0x30));

    if(mcolumn < 31)
    {
      mcolumn = 319;
      mline += 24;
    }
    else
    {
      mcolumn -= 16;
      LCD_DisplayChar(mline, mcolumn, ' ');
      mcolumn -= 16;
    }
  }
  LCD_SetTextColor(Red);   
  LCD_DrawRect(dayline, daycolumn, 24, 32);
}
Ejemplo n.º 26
0
/*******************************************************************************
* Function Name  : Date_Show
* Description    : Shows date in a graphic mode on LCD.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Date_Show(void)
{
  uint32_t tmpValue = 0;
  uint32_t MyKey = 0, ValueMax = 0;
  uint32_t firstdaycolumn = 0, lastdaycolumn = 0, lastdayline = 0;
  uint32_t testvalue = 0, pressedkey = 0;
  
  /* Disable the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);
  LCD_Clear(White);

  while(ReadKey()!= NOKEY)
  {
  }
  LCD_SetBackColor(Blue);
  LCD_SetTextColor(White);

  if(BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
  {
    LCD_DisplayStringLine(Line7, "Time and Date Config");
    LCD_DisplayStringLine(Line8, "Select: Press SEL   ");
    LCD_DisplayStringLine(Line9, "Abort: Press Any Key");
    
    while(testvalue == 0)
    {
      pressedkey = ReadKey(); 
      if(pressedkey == SEL)
      {
        /* Adjust Time */
        Time_PreAdjust();
        /* Clear the LCD */
        LCD_Clear(White);
        testvalue = 0x01;
      }
      else if (pressedkey != NOKEY)
      {
        /* Clear the LCD */
        LCD_Clear(White);
        /* Display the menu */
        DisplayMenu();
        /* Enable the JoyStick interrupts */
        IntExtOnOffConfig(ENABLE);
        return;
      }
    }
  }
  /* Clear the LCD */
  LCD_Clear(White);
  
  LCD_DisplayStringLine(Line9, " To Exit Press SEL  ");

  /* Display the current date */
  Date_Display(date_s.year, date_s.month, date_s.day);

  if(date_s.month == 2)
  {
    if(IsLeapYear(date_s.year))
    {
      ValueMax = 29;
    }
    else
    {
      ValueMax = (MonLen[date_s.month - 1] - 1);
    }    
  }
  else
  {
    ValueMax = (MonLen[date_s.month - 1] - 1);
  }

  firstdaycolumn = 0x13F - (0x30 * dn);
  
  lastdaycolumn = ValueMax - (7 - dn);
  lastdayline = lastdaycolumn / 7;
  lastdaycolumn %= 7;

  if(lastdaycolumn == 0)
  {
    lastdayline = Line3 + (lastdayline * 24);
    lastdaycolumn = 31;
  }
  else
  {
    lastdayline = Line4 + (lastdayline * 24);
    lastdaycolumn = 0x13F -(0x30 * (lastdaycolumn - 1));
  }

  /* Initialize tmpValue */
  tmpValue = date_s.day;
  
  /* Endless loop */
  while(1)
  {
    /* Check which key is pressed */
    MyKey = ReadKey();

    /* If "RIGHT" pushbutton is pressed */
    if(MyKey == RIGHT)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      
      /* Increase the value of the digit */
      if(tmpValue == ValueMax)
      {
        tmpValue = 0;
        dayline = Line3;
        daycolumn = firstdaycolumn + 48;
      }
             
      if(daycolumn == 31)
      {
        daycolumn = 367;
        dayline += 24;
      }       

      daycolumn -= 48;
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      tmpValue++;
      WeekDayNum(date_s.year, date_s.month, tmpValue);
      LCD_SetBackColor(Blue2);
      LCD_SetTextColor(White);
      LCD_DisplayStringLine(Line1, " WEEK     DAY N:    ");
      if(wn/10)
      {
        LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
        LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
      }
      if(dc/100)
      {
        LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
        LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
        LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
      }
      else if(dc/10)
      {
        LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
        LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
      }
      LCD_SetBackColor(White);          
    }
    /* If "LEFT" pushbutton is pressed */
    if(MyKey == LEFT)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      
      /* Decrease the value of the digit */
      if(tmpValue == 1)
      {
        tmpValue = ValueMax + 1;
        dayline = lastdayline;
        daycolumn = lastdaycolumn - 48;
      }
      
      if(daycolumn == 319)
      {
        daycolumn = 0xFFEF;
        dayline -= 24;
      }

      daycolumn += 48;      
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      tmpValue--;
      WeekDayNum(date_s.year, date_s.month, tmpValue);
      LCD_SetBackColor(Blue2);
      LCD_SetTextColor(White);
      LCD_DisplayStringLine(Line1, " WEEK     DAY N:    ");
      if(wn/10)
      {
        LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
        LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
      }
      if(dc/100)
      {
        LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
        LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
        LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
      }
      else if(dc/10)
      {
        LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
        LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
      }
      LCD_SetBackColor(White);
    }
    /* If "UP" pushbutton is pressed */
    if(MyKey == UP)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      
      if(tmpValue == 1)
      {
        dayline = lastdayline;
        daycolumn =  lastdaycolumn;
        tmpValue = ValueMax;
      }
      else if(tmpValue < 8)
      {
        tmpValue = 1;
        dayline = Line3;
        daycolumn = firstdaycolumn;
      }
      else
      {
        dayline -= 24;
        tmpValue -= 7;
      }

      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      WeekDayNum(date_s.year, date_s.month, tmpValue);

      LCD_SetBackColor(Blue2);
      LCD_SetTextColor(White);
      LCD_DisplayStringLine(Line1, " WEEK     DAY N:    ");
      if(wn/10)
      {
        LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
        LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
      }
      if(dc/100)
      {
        LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
        LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
        LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
      }
      else if(dc/10)
      {
        LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
        LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
      }
      LCD_SetBackColor(White);
    } 
    /* If "DOWN" pushbutton is pressed */
    if(MyKey == DOWN)
    {
      LCD_SetTextColor(White);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      if(tmpValue == ValueMax)
      {
        dayline = Line3;
        daycolumn =  firstdaycolumn;
        tmpValue = 1;
      }
      else
      {
        dayline += 24;
        tmpValue += 7;
      }

      if(tmpValue > ValueMax)
      {
        tmpValue = ValueMax;
        dayline = lastdayline;
        daycolumn = lastdaycolumn;
      }
      LCD_SetTextColor(Red);   
      LCD_DrawRect(dayline, daycolumn, 24, 32);
      WeekDayNum(date_s.year, date_s.month, tmpValue);

      LCD_SetBackColor(Blue2);
      LCD_SetTextColor(White);
      LCD_DisplayStringLine(Line1, " WEEK     DAY N:    ");
      if(wn/10)
      {
        LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
        LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
      }
      if(dc/100)
      {
        LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
        LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
        LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
      }
      else if(dc/10)
      {
        LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
        LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
      }
      else
      {
        LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
      }
      LCD_SetBackColor(White);
    }
    /* If "SEL" pushbutton is pressed */
    if(MyKey == SEL)
    {
      /* Clear the LCD */
      LCD_Clear(White);
      /* Display the menu */
      DisplayMenu();
      /* Enable the JoyStick interrupts */
      IntExtOnOffConfig(ENABLE);
      return;
    }
  }
}
Ejemplo n.º 27
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void COMP_LDR_Example(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f30x.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f30x.c file
     */

  uint8_t ldrlevel = 11, ldrlevelp = 0, daclevel = 0;
  uint16_t tmp = 0;

  /* Initialize the TFT-LCD */
  STM32303C_LCD_Init();
  
  /* Clear the LCD */ 
  LCD_Clear(LCD_COLOR_BLACK);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(LCD_COLOR_BLACK);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);
  
  /* Displays Light dependent resistor (LDR) message on line 0 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);
  
  /* COMP Configuration */
  COMP_Config();
 
  /* DAC channel 1 Configuration */
  DAC_Config();
  
  
  /* Infinite loop */
  while (1)
  {
    for(daclevel = 0; daclevel < 11; daclevel++)
    {
      /* Set DAC Channel1 DHR register */
      DAC_SetChannel1Data(DAC_Align_12b_R, (uint16_t)(daclevel * 150));

      Delay((0xFFFF));
      /* Check on the Comp output level*/
      if (COMP_GetOutputLevel(COMP_Selection_COMP7) == COMP_OutputLevel_High)
      {
        ldrlevel--;
      }
    }

    switch(ldrlevel)
    {
    case 1:
      /* Displays MESSAGE on line 7 */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 0      ");
      break;
      
    case 2:
      /* Displays MESSAGE on line 7 */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 1      ");
      break;
      
    case 3:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 2      ");
      break;
      
    case 4:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 3      ");
      break;
      
    case 5:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 4      ");
      break;
      
    case 6:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 5      ");
      break;
      
    case 7:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 6      ");
      break;
      
    case 8:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 7      ");
      break;
      
    case 9:
      /* Displays MESSAGE on line 7 */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 8      ");
      break;
      
    case 10:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 9      ");
      break;
      
    case 11:
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 10     ");
      break;
      
    default :
      /* Displays MESSAGE on line 7  */
      LCD_DisplayStringLine(LINE(7), (uint8_t *)"       Level 0      ");
      ldrlevel = 1;
      break;
    }
    
    if(ldrlevelp != ldrlevel)
    {
      /* Set the LCD Text Color */
      LCD_SetTextColor(LCD_COLOR_WHITE);
      
      /* Displays a rectangle on the LCD */
      LCD_DrawRect(199, 311, 22, 302 );
      
      /* Set the LCD Back Color */
      LCD_SetBackColor(LCD_COLOR_BLACK);
      LCD_SetTextColor(LCD_COLOR_BLACK);
      LCD_DrawFullRect(200, 310, 300, 20);
      
      /* Set the LCD Text Color */
      LCD_SetTextColor(LCD_COLOR_YELLOW);
      
      /* Set the LCD Back Color */
      LCD_SetBackColor(LCD_COLOR_YELLOW);
      
      /* Displays a full rectangle */
      tmp = 30 * (ldrlevel-1);
      if (tmp ==0) tmp = 5;
      LCD_DrawFullRect(200, 310, tmp , 20);
    }
    
    ldrlevelp = ldrlevel;
    ldrlevel = 11;
    
    /* Set the LCD Back Color */
    LCD_SetBackColor(LCD_COLOR_BLACK);
  }

}
Ejemplo n.º 28
0
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str,
        const struct LabelDesc *desc, u8 is_selected)
{
    u16 txt_w, txt_h;
    u16 txt_x, txt_y;
    u16 offset = (LCD_DEPTH > 1 && desc->font==NARROW_FONT.font) ? 1 : 0;
    LCD_SetFont(desc->font);
    LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++;
    if (obj_w == 0)
        obj_w = txt_w;
    if (obj_h == 0)
        obj_h = txt_h;
    if (offset && obj_y >= offset) {
        obj_y -= offset;
    }
    if (desc->style != LABEL_TRANSPARENT)
    {
        GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
    }
    if (desc->style == LABEL_BOX || desc->style == LABEL_BRACKET || desc->style == LABEL_SQUAREBOX) {
        // draw round rect for the textsel widget when it is pressable
        if (is_selected) {
            if (desc->style == LABEL_SQUAREBOX ||obj_w < 5)
                LCD_FillRect(obj_x, obj_y, obj_w, obj_h , 1);
            else
                LCD_FillRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1);
        }  else {
            if (desc->style == LABEL_SQUAREBOX)
                if (desc->fill_color == 0)
                    LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, 1);
                else
                    LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
            else if (desc->style == LABEL_BRACKET) {
                struct pos { int i1; int i2; int i3; int i4;};
                struct { union { int p[4]; struct pos pos;} u;} x[2], y[2];
                //int x[2][4];
                //int y[2][4];
                if (obj_h > 2 * obj_w) {
                    x[0].u.pos = (struct pos){ 0, 2, obj_w -3, obj_w -1};
                    y[0].u.pos = (struct pos){ 2, 0, 0, 2};
                    x[1].u.pos = x[0].u.pos;
                    y[1].u.pos = (struct pos){ obj_h -3, obj_h -1, obj_h -1, obj_h -3};
                } else {
                    x[0].u.pos = (struct pos){ 2, 0, 0, 2};
                    y[0].u.pos = (struct pos){ 0, 2, obj_h -3, obj_h -1};
                    x[1].u.pos = (struct pos){ obj_w -3, obj_w -1, obj_w -1,  obj_w -3};
                    y[1].u.pos = y[0].u.pos;
                }
                for(int oc = 0; oc < 2; oc++) {
                    for(int i = 0; i < 3; i++) {
                        LCD_DrawLine(obj_x + x[oc].u.p[i], obj_y+y[oc].u.p[i], obj_x+x[oc].u.p[i+1], obj_y + y[oc].u.p[i+1], 1);
                    }
                }
            } else
                LCD_DrawRoundRect(obj_x, obj_y, obj_w, obj_h , 3,  1);
        }
    }
    else if (desc->style == LABEL_FILL) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
    }
    else if (desc->style == LABEL_INVERTED || is_selected) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, 0xffff);
    }
    if (desc->style == LABEL_TRANSPARENT || (LCD_DEPTH > 1 && desc->fill_color != desc->outline_color)) {
        LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color);
        obj_x+=2; obj_w-=4;
    }

    if (desc->style == LABEL_RIGHT) {
        txt_x = obj_x + obj_w - txt_w;
    } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT || desc->style == LABEL_NO_BOX
                                                            || desc->style == LABEL_UNDERLINE)) {
        txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2;
    } else {
        txt_x = obj_x+1;
    }
    txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2;

    if (desc->style == LABEL_UNDERLINE) {
        LCD_DrawFastHLine(--txt_x, txt_y + txt_h - 1, obj_w, 1);
    }
    if (desc->style == LABEL_BLINK) {
        blink_fontcolor = ~blink_fontcolor;
        LCD_SetFontColor(blink_fontcolor);
    } else if (desc->style == LABEL_INVERTED || (desc->style != LABEL_FILL && is_selected)) {
        LCD_SetFontColor(~desc->font_color);
    } else {
        LCD_SetFontColor(desc->font_color);
    }
    LCD_PrintStringXY(txt_x, txt_y, str);
}
Ejemplo n.º 29
0
enum MENU_code fTest_Mgr( void )
{
    int fRedrawn = 0;
    static bool fFirstTime = 1;
    static bool AUDIO_BuzzerOn_bak = 0;

    if ( fFirstTime )
    {
        fFirstTime = 0;
        MenuFirstDisplay = 1;
    }

    // Hide menu.
    CurrentMenu = 0;
    fDisplayTime = 0; // force display time - battery status

    // Character magnify.
    DRAW_SetCharMagniCoeff( 2 );

    // If screen orientation has changed, redraw screen.
    if ( MenuFirstDisplay == 0 )
    {
        if ( LCD_GetScreenOrientation() != previous_Screen_Orientation )
        {
            MenuFirstDisplay = 1;
        }
    }

    if ( MenuFirstDisplay )
    {
        previous_Screen_Orientation = LCD_GetScreenOrientation();
        POINTER_SetMode( POINTER_OFF );
        LCD_SetRotateScreen( 0 );
        LCD_SetScreenOrientation( V12 );

        // Red LED blinks at high frequency.
        LED_Set( LED_RED, LED_BLINKING_HF );

        // Green LED blinks at low frequency.
        LED_Set( LED_GREEN, LED_BLINKING_LF );

        // Draw a little message on the LCD screen.
        DRAW_SetDefaultColor();
        DRAW_DisplayStringWithMode( 0, Screen_Height - 2 * Char_Height, "Hardware Test", ALL_SCREEN, INVERTED_TEXT, CENTER );
        MenuFirstDisplay = 0;

        // Drawn that rectangle on the screen.
        LCD_FillRect_Circle( BAR_LEFT + 1, BAR_BOTTOM + 1, MAXLEVEL * WIDTH_SQUARE  , WIDTH_SQUARE - 2, RGB_YELLOW );
        LCD_DrawRect( BAR_LEFT, BAR_BOTTOM, MAXLEVEL * WIDTH_SQUARE + 2 , WIDTH_SQUARE, RGB_BLUE );

        // Restrict the move of the pointer to a rectangle.
        POINTER_SetRect( BAR_LEFT + 1, BAR_BOTTOM + 1, MAXLEVEL * WIDTH_SQUARE - POINTER_WIDTH - 2, WIDTH_SQUARE - POINTER_WIDTH - 2 );
        POINTER_SetMode( POINTER_ON );

        // Force buzzer activation
        AUDIO_BuzzerOn_bak = AUDIO_BuzzerOn;
        AUDIO_BuzzerOn = 1;

    } // end FirstDisplay

    // The button is pushed, let's get out of here!
    if ( BUTTON_GetState() == BUTTON_PUSHED )
    {
        int i;
    
        BUTTON_WaitForRelease();

        // Reset CircleOS state.
        MENU_ClearCurrentCommand();
        DRAW_SetDefaultColor();
        DRAW_Clear();
        POINTER_SetMode( POINTER_ON );
        BUTTON_SetMode( BUTTON_ONOFF_FORMAIN );
        POINTER_SetRectScreen();
        DRAW_SetCharMagniCoeff( 1 );

#if BACKLIGHT_INTERFACE
        // Reset backlight PWM rate to its default value.
        LCD_SetBackLight( 0 );
#endif // BACKLIGHT_INTERFACE

        // Switch LEDs off.
        LED_Set( LED_RED, LED_OFF );
        LED_Set( LED_GREEN, LED_OFF );

        fFirstTime  = 1;

        // Search if test aplication present in flash
        for ( i = 0; i < MAXAPP; i++ )
        {
            extern tMenuItem*(( *ApplicationTable )[] );
            tMenuItem*  curapp;
            unsigned addr;

            if (( *ApplicationTable )[ -i ] == APP_VOID ) //has been programmed
            {
                break;
            }
            else
            {
                addr   = ( long unsigned )( *ApplicationTable )[ -i ] ;
                addr &= 0x00FFFFFF;
                addr |= 0x08000000;
                curapp = ( tMenuItem* ) addr;
                if ( !strcmp( curapp->Text, "COMMTEST" ) )
                {
                    LCD_SetOffset( OFFSET_ON );
                    CurrentCommand = curapp;
                    CurrentMenu = 0;
                    BUTTON_SetMode( BUTTON_ONOFF );
                    return CurrentCommand ->Fct_Init();
                }
            }
        }

        LCD_SetRotateScreen( 1 );
        LCD_SetScreenOrientation( previous_Screen_Orientation );

        AUDIO_BuzzerOn = AUDIO_BuzzerOn_bak;

        return MENU_LEAVE;
    }

#if BACKLIGHT_INTERFACE
    // Increment the backlight PWM.
    Current_CCR_BackLightStart += 0x800;

    // If backlight PWM is too high, restart with a lower value.
    if ( Current_CCR_BackLightStart > 0xF000 )
    {
        Current_CCR_BackLightStart = 0x2000;
    }
#endif // BACKLIGHT_INTERFACE


    // Every 59th calls display battery voltage and replay melody sample.
    // Note: due to the fRedrawn == 0, the first time the % 59 == 0
    //       (when divider_coord is null), the code block isn't executed.
    if ((( menu_divider_coord++ % 37 ) == 0 ) && ( fRedrawn == 0 ) )
    {
        char TextBuffer[5];
        *TextBuffer = '%'; *( TextBuffer + 1 ) = 0; // YRT20080204 : to avoid memcpy

        DRAW_DisplayVbat( 20, 12 );
        UTIL_uint2str( TextBuffer + 1, PWR_BatteryLevel, 3, 0 );
        DRAW_DisplayString( 170, 12, TextBuffer, 4 );
    
        BUZZER_PlayMusic( Test_Melody );
    }
    return MENU_CONTINUE;
}
Ejemplo n.º 30
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main.
     */     

  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
         
  /* Initialize LEDs mounted on EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

  /* Select the Button test mode (polling or interrupt) BUTTON_MODE in main.h */
  STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE);
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE);

  /* Initialize the LCD */
  LCD_Init();

  /* Initialize the LCD Layers */
  LCD_LayerInit();  
  
  /* Enable LCD display */
  LCD_DisplayOn();
  
  /* Set foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  
  /* Clear the LCD */ 
  LCD_Clear(White);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(White);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Blue);    
 
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)"        STM324x9I-EVAL       ");
  LCD_DisplayStringLine(LCD_LINE_1, (uint8_t *)"      Example on how to      ");
  LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *)"     use the IO Expander     ");
  
  /* Configure the IO Expander */
  if (IOE_Config() == IOE_OK && IOE16_Config() == IOE16_OK)
  {
    LCD_DisplayStringLine(LCD_LINE_3, (uint8_t *)"      IO Expander OK       ");
  }
  else
  {
    LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"IO Expander FAILED    ");
    LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)" Please Reset the     ");
    LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"   board and start    ");
    LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"    again             ");
    while(1);
  }

  /* LEDs Control blocks */
  LCD_SetTextColor(Blue);
  LCD_DrawRect(310, 180,  40, 60);
  LCD_SetTextColor(Red);
  LCD_DrawRect(230, 180, 40, 60);
  LCD_SetTextColor(Yellow);
  LCD_DrawRect(150, 180, 40, 60);
  LCD_SetTextColor(Green);
  LCD_DrawRect(70, 180, 40, 60);

#ifdef IOE_INTERRUPT_MODE
  /* Configure motherboard interrupt source IO_EXP4 */ 
  IOE16_IOPinConfig(IOE16_TS_IT,Direction_IN);
  IOE16_ITConfig(IOE16_TS_IT);
  
  /* Enable joystick interrupt */
  IOE16_ITConfig(JOY_IO16_PINS);
  
  /* Enable the Touch Screen interrupt */
  IOE_TSITConfig(); 
  
  /* Read IOs state to let IO interrupt occur */
  IOE16_I2C_ReadDeviceRegister(IOE16_REG_GPMR_LSB);
  IOE16_I2C_ReadDeviceRegister(IOE16_REG_GPMR_MSB);
#endif /* IOE_INTERRUPT_MODE */
  
  
  while(1)
  {
#ifdef IOE_POLLING_MODE
    static JOY_State_TypeDef JoyState = JOY_NONE;
    static TS_STATE* TS_State;
    
    /* Get the Joystick State */
    JoyState = IOE16_JoyStickGetState();
    
    /* Set the LCD Text Color */
    LCD_SetTextColor(Blue); 
   
    switch (JoyState)
    {
      case JOY_NONE:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:     ----        ");
        break;
      case JOY_UP:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:     UP         ");
        break;     
      case JOY_DOWN:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:    DOWN        ");
        break;          
      case JOY_LEFT:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:    LEFT        ");
        break;         
      case JOY_RIGHT:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:    RIGHT        ");
        break;                 
      case JOY_CENTER:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:   CENTER       ");
        break; 
      default:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:   ERROR      ");
        break;         
    }

    /* Update the structure with the current position */
    TS_State = IOE_TS_GetState();  
    
    if ((TS_State->TouchDetected) && (TS_State->Y < 92) && (TS_State->Y > 52))
    {
      if ((TS_State->X > 60) && (TS_State->X < 120))
      {
        LCD_SetTextColor(LCD_COLOR_GREEN);   
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"     LD1                ");
        STM_EVAL_LEDOn(LED1);
      }
      else if ((TS_State->X > 140) && (TS_State->X < 200))
      {
        LCD_SetTextColor(LCD_COLOR_YELLOW); 
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"          LD2           ");
        STM_EVAL_LEDOn(LED2);
      }
      else if ((TS_State->X > 220) && (TS_State->X < 280))
      {
        LCD_SetTextColor(LCD_COLOR_RED); 
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"               LD3      ");
        STM_EVAL_LEDOn(LED3);
      }     
      else if ((TS_State->X > 300) && (TS_State->X < 360))
      {
        LCD_SetTextColor(LCD_COLOR_BLUE); 
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"                    LD4 ");
        STM_EVAL_LEDOn(LED4);
      }
    }
    else
    {
      STM_EVAL_LEDOff(LED1);
      STM_EVAL_LEDOff(LED2);
      STM_EVAL_LEDOff(LED3);
      STM_EVAL_LEDOff(LED4);
    }
#endif /* IOE_POLLING_MODE */  
    
#ifdef BUTTON_POLLING_MODE
    /* Insert 10 ms delay */
    Delay(1);
    
    /* Set the LCD Text Color */
    LCD_SetTextColor(Blue); 

    if (STM_EVAL_PBGetState(BUTTON_TAMPER) == 0)
    {
      /* Toggle LD2 */
      STM_EVAL_LEDToggle(LED2);

      LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"Pol: TAMPER/KEY Pressed  ");
    }

    if (STM_EVAL_PBGetState(BUTTON_WAKEUP) != 0)
    {
      /* Toggle LD3 */
      STM_EVAL_LEDToggle(LED3);
      LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"Pol: WAKEUP Pressed      ");
    }
#endif
  }
}