Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.47 KB | None | 0 0
  1.  
  2. /* Includes ------------------------------------------------------------------*/
  3. #include "circle_api.h"
  4.  
  5. /* Private defines -----------------------------------------------------------*/
  6.  
  7. // The following should be the minimal CircleOS version needed by your application
  8. #define NEEDEDVERSION "V 4.0"
  9.  
  10. /* Private functions ---------------------------------------------------------*/
  11. static enum MENU_code MsgVersion(void);
  12.  
  13. /* Public variables ----------------------------------------------------------*/
  14. const char Application_Name[8+1] = {"DrwTbl"};      // Max 8 characters
  15.  
  16.  
  17. #define START_POS_X  20
  18. #define START_POS_Y  30
  19. #define CELL_SIZE    40
  20.  
  21. #define TABLE_COLS    2
  22.  
  23. #define TABLE_ROWS    2
  24.  
  25. u16 colors[] = {RGB_RED, RGB_BLACK, RGB_BLUE, RGB_GREEN, RGB_YELLOW,
  26.                 RGB_MAGENTA};
  27.  
  28.  
  29. /*******************************************************************************
  30. * Function Name  : Application_Ini
  31. * Description    : Initialization function of Circle_App. This function will
  32. *                  be called only once by CircleOS.
  33. * Input          : None
  34. * Return         : MENU_CONTINUE_COMMAND
  35. *******************************************************************************/
  36. enum MENU_code Application_Ini(void)
  37.     {
  38.     u32 i, j;
  39.     u16 curX, curY;
  40.     // Ensure that the current OS version is recent enough
  41.     if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0)
  42.         {
  43.         return MsgVersion();
  44.         }
  45.    
  46.     // This application manages all the screen.
  47.     // If you don't reset the offset on EvoPrimer, the screen will be reduce
  48.     // to 128x128 pixels for Primer2 compatibility
  49.     LCD_SetOffset(OFFSET_OFF);
  50.  
  51.     curX = START_POS_X;
  52.    
  53.    
  54.     for (i=0; i< TABLE_COLS; i++)
  55.     {
  56.         curY = START_POS_Y;
  57.         for (j=0; j<TABLE_ROWS; j++)
  58.         {
  59.             LCD_FillRect(curX, curY, CELL_SIZE, CELL_SIZE, colors[(i+j)%6]);
  60.             curY += CELL_SIZE;
  61.         }
  62.         curX += CELL_SIZE;
  63.     }
  64.    
  65.     MENU_SetAppliDivider(1000);
  66.  
  67.     return MENU_CONTINUE_COMMAND;
  68.     }
  69.  
  70. /*******************************************************************************
  71. * Function Name  : Application_Handler
  72. * Description    : Management of the Circle_App. This function will be called
  73. *                  every millisecond by CircleOS while it returns MENU_CONTINUE.
  74. * Input          : None
  75. * Return         : MENU_CONTINUE
  76. *******************************************************************************/
  77. enum MENU_code Application_Handler(void)
  78.     {
  79.     // This routine will get called repeatedly by CircleOS, until we
  80.     // return MENU_LEAVE
  81.  
  82.     // TODO: Write your application handling here.
  83. #if 0  
  84.     static int cnt = 0;
  85.     DRAW_SetCharMagniCoeff(2);
  86.     DRAW_SetTextColor(RGB_BLUE);
  87.     DRAW_SetBGndColor(RGB_WHITE);
  88.     if ((cnt % 2) == 0)
  89.         {
  90.         DRAW_DisplayStringWithMode( 0, 90, "Hello", ALL_SCREEN, INVERTED_TEXT, CENTER);
  91.         DRAW_DisplayStringWithMode( 0, 60, "world !", ALL_SCREEN, INVERTED_TEXT, CENTER);
  92.         }
  93.     else
  94.         {
  95.         DRAW_DisplayStringWithMode( 0, 90, "", ALL_SCREEN, INVERTED_TEXT, CENTER);
  96.         DRAW_DisplayStringWithMode( 0, 60, "", ALL_SCREEN, INVERTED_TEXT, CENTER);
  97.         }
  98.     DRAW_SetCharMagniCoeff(1);
  99.     DRAW_SetDefaultColor();
  100.     cnt++;
  101. #endif
  102.  
  103.     // If the button is pressed, the application is exited
  104.     if (BUTTON_GetState() == BUTTON_PUSHED)
  105.         {
  106.         BUTTON_WaitForRelease();
  107.         return MENU_Quit();
  108.         }
  109.  
  110.     return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
  111.     }
  112.  
  113. /*******************************************************************************
  114. * Function Name  : MsgVersion
  115. * Description    : Displays the current CircleOS version and the version needed
  116. *                  exit to main menu after 4 seconds
  117. * Input          : None
  118. * Return         : MENU_REFRESH
  119. *******************************************************************************/
  120. static enum MENU_code MsgVersion(void)
  121.     {
  122.     u8 hh, mm, ss, ss2;
  123.  
  124.     DRAW_DisplayString( 5,  60, "CircleOS", 17 );
  125.     DRAW_DisplayString( 80, 60, UTIL_GetVersion(), 6 );
  126.     DRAW_DisplayString( 5,  34, NEEDEDVERSION, 6 );
  127.     DRAW_DisplayString( 50, 34, " required", 12 );
  128.  
  129.     RTC_GetTime( &hh, &mm, &ss );
  130.     ss = ss + 4;
  131.     ss = ss % 60;
  132.  
  133.     do
  134.         {
  135.         RTC_GetTime( &hh, &mm, &ss2 );
  136.         }
  137.     while ( ss2 != ss );           // do while < 4 seconds
  138.  
  139.     DRAW_Clear();
  140.     return MENU_REFRESH;
  141.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement