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

📄 c_entry.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 2 页
字号:
*
* Purpose:
*	Returns a '1' if the SW15 pushbutton is pressed
*  
* Processing:
*	
*
* Parameters:
*	None
*
* Outputs:
*   None
*
* Returns:
*   '1' if the SW15 pushbutton is pressed, '0' otherwise.
*
* Notes:
*   None
*
**********************************************************************/
int check_exit_button (void)
{
   // Return '1' if the SW15 button is pressed
   return ((LH7A400_pld_get_pb () & 0x20) == 0x20);
}

/**********************************************************************
*
* Function: start_graphics_demo
*
* Purpose:
*	Starts the line and box graphics demo.
*  
* Processing:
*	
*
* Parameters:
*	None
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void start_graphics_demo (void)
{
   int xa, loop;
   int tempx, tempy;
   UNS_16 colora, colorbase;
   int exitmode = 0;
   static int box_index = 0;

#define NUM_BOXES 8
   int xadd [NUM_BOXES], yadd [NUM_BOXES];
   int xadd2 [NUM_BOXES], yadd2 [NUM_BOXES];
   int xinc [NUM_BOXES] = {1, 1, 1, -1, -1, -1, 2, 2};
   int yinc [NUM_BOXES] = {1, 2, -1, 1, 2, -1, 1, -1};
   int xinc2 [NUM_BOXES] = {-1, 1, -1, 1, -1, -1, 1, 1};
   int yinc2 [NUM_BOXES] = {-1, 1, 1, -1, 1, -1, -1, 1};

   // Setup graphics driver
   draw_init ((UNS_16 *) get_working_fb (), XMAX, YMAX);
   toggle_fb ();

   colorbase = 0;

   // Exit when exitmode != 0
   while (exitmode == 0)
   {
      // Clear the display
      draw_set_fill_color (0x0);
      draw_clear_screen ();

      // Random lines (go through random list twice)
      for (loop = 0; loop < 2; loop++)
      {
         for (xa = 0; xa < number_points; xa++)
         {
            // Do a series of draws
            draw_set_pen_color (rnums [xa].pencolor);
            draw_line (rnums [xa].x1, rnums [xa].y1, rnums [xa].x2, rnums [xa].y2);

            // Check state of exit button (SW15)
            if (check_exit_button () == 1)
            {
               // Exit the line demo
               exitmode = 1;
               loop = 2;
               xa = number_points;
            }
         }
      }

      if (exitmode == 1)
      {
         return;
      }

      // Create a tunnel effect
      for (loop = 0; loop < 75; loop++)
      {
         colora = (loop + colorbase) & 0xFFFF;

         for (xa = 0; xa < (YMAX / 2); xa++)
         {
            tempx = XMAX - xa - 1;
            tempy = YMAX - xa - 1;

            draw_set_pen_color (colora);
            draw_line (xa, xa, tempx, xa);
            draw_line (tempx, xa, tempx, tempy);
            draw_line (tempx, tempy, xa, tempy);
            draw_line (xa, tempy, xa, xa);
            colora++;
         }

         if (check_exit_button () == 1)
         {
            // Exit the line demo
            exitmode = 1;
            loop = 75;
         }
      }
      colorbase = colorbase + 0x1 + (0x1 << 5) + (0x1 << 10);

      if (exitmode == 1)
      {
         return;
      }

      // Clear the display
      draw_set_fill_color (0x0);
      draw_clear_screen ();

      // Quickly display some boxes
      for (xa = 0; xa < (number_points - 20); xa = xa + 12)
      {
         draw_set_pen_color (rnums [xa].pencolor);
         draw_set_fill_color (rnums [xa].fillcolor);
         draw_box (rnums [xa].x1, rnums [xa].y1, rnums [xa].x2, rnums [xa].y2);

         if (check_exit_button () == 1)
         {
            // Exit the line demo
            exitmode = 1;
            xa = number_points;
         }
      }

      if (exitmode == 1)
      {
         return;
      }

      // Too keep things smooth, 2 frame buffers will be used for the
      // moving boxes demo

      // Do a few 'moving boxes'
      for (xa = 0; xa < 8; xa++)
      {
         xadd [xa] = yadd [xa] = 0;
         xadd2 [xa] = yadd2 [xa] = 0;
      }

      for (loop = 0; loop < 400; loop++)
      {
         tempx = box_index;

         // Draw the boxes in the working frame buffer
         draw_init ((UNS_16 *) get_working_fb (), XMAX, YMAX);

         // Clear the display
         draw_set_fill_color (0x0);
         draw_clear_screen ();

         for (xa = 0; xa < NUM_BOXES; xa++)
         {
            
            draw_set_pen_color (rnums [tempx].pencolor);
            draw_set_fill_color (rnums [tempx].fillcolor);
            draw_box ((rnums [tempx].x1 + xadd [xa]), (rnums [tempx].y1 + yadd [xa]),
               (rnums [tempx].x2 + xadd2 [xa]), (rnums [tempx].y2 + yadd2 [xa]));
            tempx++;
         }

         // The working display buffer is finished, display it
         toggle_fb ();

         // Create offsets for the boxes and dynamic boxes
         tempx = box_index;
         for (xa = 0; xa < NUM_BOXES; xa++)
         {
            xadd [xa] = xadd [xa] + xinc [xa];
            if (((rnums [tempx].x1 + xadd [xa]) < 0) ||
                ((rnums [tempx].x1 + xadd [xa]) >= XMAX))
            {
               xinc [xa] = -xinc [xa];
               xadd [xa] = xadd [xa] + xinc [xa];
            }

            yadd [xa] = yadd [xa] + yinc [xa];
            if (((rnums [tempx].y1 + yadd [xa]) < 0) ||
                ((rnums [tempx].y1 + yadd [xa]) >= YMAX))
            {
               yinc [xa] = -yinc [xa];
               yadd [xa] = yadd [xa] + yinc [xa];
            }

            xadd2 [xa] = xadd2 [xa] + xinc2 [xa];
            if (((rnums [tempx].x2 + xadd2 [xa]) < 0) ||
                ((rnums [tempx].x2 + xadd2 [xa]) >= XMAX) ||
                (xadd2 [xa] > 5) ||
                (xadd2 [xa] < -5))
            {
               xinc2 [xa] = -xinc2 [xa];
               xadd2 [xa] = xadd2 [xa] + xinc2 [xa];
            }

            yadd2 [xa] = yadd2 [xa] + yinc2 [xa];
            if (((rnums [tempx].y2 + yadd2 [xa]) < 0) ||
                ((rnums [tempx].y2 + yadd2 [xa]) >= YMAX) ||
                (yadd2 [xa] > 5) ||
                (yadd2 [xa] < -5))
            {
               yinc2 [xa] = -yinc2 [xa];
               yadd2 [xa] = yadd2 [xa] + yinc2 [xa];
            }

            tempx++;
         }

         if (check_exit_button () == 1)
         {
            // Exit the line demo
            exitmode = 1;
            loop = 400;
         }
      }

      // Increment random box size indices for next moving box run
      box_index = box_index + NUM_BOXES;
      if (box_index >= (number_points - NUM_BOXES - 1))
      {
         box_index = 0;
      }
   }
}

void C_Entry (void)
{
    INT_32 maxx, maxy;
    INT_16 bl_state;
    UNS_8 PB, PBN;
    INT_32 image_index = 0;
    int autoloop = 3000;
    int old_image = 0;

    countx = 0;

    // Initialize the CPLD interface on the SMC
    LH7A400_pld_init (0);

    // Init LCD driver for '53 display
    lcd_initialize (&KEV7A400_LQ039Q2DS53, pfb [0]);

    // Get horiz and vert size of display from driver
    maxx = (INT_32) lcd_get_xsize ();
    maxy = (INT_32) lcd_get_ysize ();

    // Enable the LCD power and LCD signal buffers
    lcd_disable_enable (1);

    // Turn on the LCD backlight to full brightness
    bl_state = lcd_get_max_intens ();
    lcd_set_backlight_intens (bl_state);

    // Setup the timer for a 5Hz count rate to show that the board
    // is 'alive'
    timer_init (TIMER1);

    // Set timer 1 for a (TICKS_SEC)Hz interrupt rate
    timer_clock_2k (TIMER1);
    timer_periodic (TIMER1);
    timer_set_counts (TIMER1, (2000 / TICKS_SEC));

    // Attach the interrupt
//    timer_irq_setup (TIMER1, 8, timer_isr);
//    timer_int_enable (TIMER1);

    // Enable IRQ interrupts
//    enable_IRQ ();                           

    // Start the timer
//    timer_start (TIMER1);

   // Fade in the BlueStreak logo and wait a few seconds
   fade_in_image (image_list [0], 15);
   dummy_wait (50000);

   // Fade out the BlueStreak logo
   fade_out_image (image_list [0], 15);

   // Small delay before continuing with next image
   dummy_wait (1500);

   // Sweep in the first image
   // First image number is '1'
   image_index = 1;
   fade_in_image (image_list [image_index], 5);
   toggle_fb ();

   // Preload image 2
   image_index++;
   move_image_to_wfb (image_list [image_index]);

   while (1)
   {
      // Wait for a button press
      PB = LH7A400_pld_get_pb ();
      while (PB == 0)
      {
         PB = LH7A400_pld_get_pb ();

         if (autoloop != 0)
         {
            dummy_wait (100);

            autoloop--;
            if (autoloop <= 0)
            {
               autoloop = 3000;

               // Just toggle the picture to next one
               PB = 0x01;
            }
         }
      }

      // Interactive controls
      // SW10 - Rotate to next image
      // SW11 - Rotate to next image with beep
      // SW12 - Fade out present image, fade in next image
      // SW13 - Swipe in next image
      // SW14 - Toggle into graphics demo
      // SW15 - 
      // SW16 - Toggle backlight on or off
      // SW17 - Toggle automatic image rotation on or off
      switch (PB)
      {
         case 0x01: // SW10
            toggle_fb ();
            break;

         case 0x02: // SW11
            buzzer_timer1 ();
            toggle_fb ();
            break;

         case 0x04: // SW12
            // Fade out old image, fade in new image
            fade_out_image (image_list [old_image], 10);
            fade_in_image (image_list [image_index], 10);
            break;

         case 0x08: // SW13
            sweep_in_image (image_list [image_index], 10);
            break;

         case 0x10: // SW14
            start_graphics_demo ();

            // Update picture and display it
            move_image_to_wfb (image_list [image_index]);
            toggle_fb ();
            break;

         case 0x40: // SW16
            bl_state = lcd_get_max_intens () - bl_state;
            lcd_set_backlight_intens (bl_state);
            break;

         case 0x80: // SW17
            if (autoloop != 0)
            {
               autoloop = 0;
            }
            else
            {
               autoloop = 75;
            }
            break;
            
         default:
            break;
      }

      // Prepare next image in working frame buffer
      old_image = image_index;
      image_index++;
      if (image_index >= MAX_IMAGES)
      {
         image_index = 0;
      }
      move_image_to_wfb (image_list [image_index]);

      // Turn off buzzer
      buzzer_low ();

      // Wait for button to depress
      PBN = LH7A400_pld_get_pb ();
      while (PBN == PB)
      {
         PBN = LH7A400_pld_get_pb ();
      }
   }
}

⌨️ 快捷键说明

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