示例#1
0
 // plot the pixel at (x, y) with brightness c
 void plot(int x, int y, int c) {
     if (reverse_xy)
         swap(&x, &y);
     
     __Point_SCR(x >> 8, y >> 8);
     u16 oldcolor = __LCD_GetPixl();
     __LCD_SetPixl(blend(color, oldcolor, c));
 }
示例#2
0
static cell AMX_NATIVE_CALL amx_putpixel(AMX *amx, const cell *params)
{
    // putpixel(x, y, color);
    __Point_SCR(params[1], params[2]);
    __LCD_SetPixl(params[3]);
    
    return 0;
}
示例#3
0
文件: Draw.c 项目: gabuh4u/dso203_gcc
/*******************************************************************************
 Print_Clk:  progress indicator
*******************************************************************************/
void Print_Clk(u16 x0, u16 y0, u16 Type, u8 Phase)
{
  u16 i, j, b;
  
  __LCD_Set_Block(x0, x0+10, y0, y0+10);
  for(i=0; i<11; ++i){
    b = CLK_TAB[Phase *11 + i];
    for(j=0; j<11; ++j){
      if((b >> j)& 0x001) __LCD_SetPixl(Color[Type >> 0x8]);
      else                __LCD_SetPixl(Color[Type & 0x0F]);
    }
  }
示例#4
0
static void put_textcol(int x, int y, int column, int fg, int bg)
{
    __Point_SCR(x, y);
    for (int i = 0; i < FONT_HEIGHT; i++)
    {
        if (column & 4)
        {
            __LCD_SetPixl(fg);
        }
        else if (bg >= 0)
        {
            __LCD_SetPixl(bg);
        }
        else
        {
            // Transparent background, skip pixel
            __Point_SCR(x, y + i + 1);
        }
        
        column >>= 1;
    }
}
示例#5
0
void fill_rect( Area *area, u16 color)
{
  __LCD_DMA_Ready();
  u16  left = area->lower_left.x;
  u16  bottom = area->lower_left.y;
  u16  width = area->extents.x;
  u16  height = area->extents.y;
  __LCD_Set_Block( left, (left + width), bottom, (bottom + height));
  int  i;
  for ( i = 0;  i < (width * height);  i += 1)
  {
    __LCD_SetPixl( color);
  }
}
示例#6
0
文件: Sample.c 项目: 5rm/DS203
int main(void)
{ 
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, (u32)&_vectors);
  __USB_Init();
  //__Clear_Screen(0x0000);
  // display 400x240

  for (int x=0; x<400; x++)
    for (int y=0; y<240-16; y++)
    {
      u32 dx = (x-200);
      u32 dy = (y-120);
      dx *= dx;
      dy *= dy;
      u32 dl = dx+dy;

      __Point_SCR(x, y);
      __LCD_SetPixl((uc16)(dl>>3) & 0x001f);
    }

  __Display_Str(20, 200, 0xffff, 0, "Hello DS203 Test... ");

  int x[3] = {20, 380, 220};
  int y[3] = {20, 40, 220};

  int curx = x[0];
  int cury = y[0];
  while ( !(GetKeys() & KEY2_STATUS) ) 
  {
    int c = PRNG();
    int r = c%3;
    curx = (curx+x[r]) >> 1;
    cury = (cury+y[r]) >> 1;

    __Point_SCR(curx, cury);
    __LCD_SetPixl(c<<1); // len do 32k
  }
	Reboot();
  return 0;
}
示例#7
0
/*******************************************************************************
  Calibrat : Calibrat routine
*******************************************************************************/
void Calibrat(u8 Channel)
{ 
  s8  Ma1[10], Mb1[10], Ma3[10], Mb3[10];
  u16 Ma2[10], Mb2[10], i, j;
  s16 TmpA, TmpB;
  u8  Range, n[10], k, m, Step;
  
  Key_Buffer = 0; 
  __Set(STANDBY, DN);                                   // 退出省电状态
  __Set(BACKLIGHT, 10*(Title[BK_LIGHT][CLASS].Value+1));
  __Clear_Screen(BLACK);                                // 清屏幕
  
  Interlace = 0;
  __Set(ADC_MODE, SEPARATE);                            // Set Separate mode
  __Set(ADC_CTRL, EN);       
  __Set(TRIGG_MODE, UNCONDITION);                       // 设任意触发
  _Status = RUN;
  __Set(BEEP_VOLUME, 5*(Title[VOLUME][CLASS].Value-1)); // Reload volume
  Beep_mS = 500;                                        // 蜂鸣器响500mS
  Range = 0;
  Step  = 0;
  m     = 0;
  
  __Set(T_BASE_PSC, X_Attr[_100uS].PSC);                // T_BASE = 100uS
  __Set(T_BASE_ARR, X_Attr[_100uS].ARR);

  __Set(CH_A_COUPLE, DC);
  __Set(CH_B_COUPLE, DC);
  
  for(j=0; j<220; j+=20){                               // 画表格  
    for(i=0; i<399; i++){
      __Point_SCR(i, j);
      __LCD_SetPixl(WHT);
    }
  }
  for(i=0; i<399; i++){
    __Point_SCR(i, 239);
    __LCD_SetPixl(WHT);
  }
  __Point_SCR(  0,  0);
  for(j= 0; j<239; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR( 44, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR( 88, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR(132, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR(200, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR(244, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR(288, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR(332, 20);
  for(j=20; j<201; j++)  __LCD_SetPixl(WHT); 
  __Point_SCR(398, 0);
  for(j= 0; j<239; j++)  __LCD_SetPixl(WHT); 
 
  Print_Str(  6, 185, 0x0005, PRN, "CH_A");              // 显示表格标题栏
  Print_Str( 49, 185, 0x0005, PRN, "ZERO");
  Print_Str( 93, 185, 0x0005, PRN, "DIFF");
  Print_Str(137, 185, 0x0005, PRN, "VOLTAGE");
  Print_Str(206, 185, 0x0105, PRN, "CH_B");
  Print_Str(249, 185, 0x0105, PRN, "ZERO");
  Print_Str(293, 185, 0x0105, PRN, "DIFF");
  Print_Str(338, 185, 0x0105, PRN, "VOLTAGE");
    
  for(i=0; i<=G_Attr[0].Yp_Max; i++){
    Print_Str(  6, 166-(i*20), 0x0005, PRN, Y_Attr[i].STR); // 显示量程
    Print_Str(206, 166-(i*20), 0x0105, PRN, Y_Attr[i].STR);
    Ma1[i] = Ka1[i];  Ma2[i] = Ka2[i];  Ma3[i] = Ka3[i];    // 备份校准前的参数
    Mb1[i] = Kb1[i];  Mb2[i] = Kb2[i];  Mb3[i] = Kb3[i];
  }

  while (1){
    if(PD_Cnt == 0){
      __Set(BACKLIGHT, 0);                               // 关闭背光
      __Set(STANDBY, EN);                                // 进入省电状态
      return;
    }
    __Set(CH_A_RANGE, Range);  __Set(CH_B_RANGE, Range);
    Delayms(20); 
    __Set(FIFO_CLR, W_PTR);
    Delayms(20); 
    a_Avg = 2048;  b_Avg = 2048;               
    for(i=0; i <4096; i++){
      DataBuf[i] = __Read_FIFO();         // 读入32位FIFO数据
      a_Avg += (DataBuf[i] & 0xFF );      // 累计直流平均值                
      b_Avg += ((DataBuf[i]>>8) & 0xFF );              
    }
    TmpA  = Ka1[Range] +(Ka2[Range]*(a_Avg/4096)+ 512)/1024;
    TmpB  = Kb1[Range] +(Kb2[Range]*(b_Avg/4096)+ 512)/1024;

    if(Blink){ 
      Blink = 0;
      switch (Step){  
      case 0:
        Range = 0;
        __Set(CH_A_OFFSET, ((1024+Ka3[Range])*40 + 512)/1024);
        __Set(CH_B_OFFSET, ((1024+Kb3[Range])*40 + 512)/1024);
        Print_Str(   8, 216, 0x0305, PRN,   "        PLEASE CONNECT");
        Print_Str(29*8, 216, 0x0305, PRN,   "INPUT TO ");
        Print_Str(38*8, 216, 0x0405, PRN,   "GND      ");
        Print_Str(   8,   6, 0x0305, PRN,   "   PRESS   KEY TO CONFIRM THE INPUT VOLTAGE   ");
        Print_Str(10*8,   6, 0x0405, Twink, " ");
        if(Channel == TRACK1){
          Print_Str( 23*8, 216, 0x0005, PRN, " CH_A ");
          for(i=0; i<=G_Attr[0].Yp_Max; i++){
            Ka1[i] = 0; Ka2[i] = 1024; Ka3[i] = 0;         // 设置校准参数初值
          }
        }
        if(Channel == TRACK2){
          Print_Str( 23*8, 216, 0x0105, PRN, " CH_B ");
          for(i=0; i<=G_Attr[0].Yp_Max; i++){
            Kb1[i] = 0; Kb2[i] = 1024; Kb3[i] = 0;         // 设置校准参数初值
          }
        }
        break;
      case 1:
        Print_Str(   8,   6, 0x0305, PRN,   "   AUTOMATIC CALIBRATION IN PROGRESS...       ");
        if(Channel == TRACK1){
          s8ToPercen(n, TmpA - 40);
          Print_Str( 45, 166-(Range*20), 0x0005, INV, n);
          Ka1[Range] -= TmpA - 40; 
        } 
        if(Channel == TRACK2){
          s8ToPercen(n, TmpB - 40);
          Print_Str(245, 166-(Range*20), 0x0105, INV, n);
          Kb1[Range] -= TmpB - 40; 
        }
        Range++;
        if(Range > G_Attr[0].Yp_Max){ 
          Range = 0;  Step++;
        } 
        __Set(CH_A_OFFSET, ((1024+Ka3[Range])*40 + 512)/1024);
        __Set(CH_B_OFFSET, ((1024+Kb3[Range])*40 + 512)/1024);
        k = 0;
        break;
      case 2:
        k++;
        if(k >= 8) k = 0;
        if(Channel == TRACK1){
          s8ToPercen(n, TmpA - 40);
          Print_Str( 45, 166-(Range*20), 0x0005, PRN, n);
          if(TmpA - 40 != 0)  Ka1[Range] -= TmpA - 40;
          else                k = 0;           
        } 
        if(Channel == TRACK2){
          s8ToPercen(n, TmpB - 40);
          Print_Str(245, 166-(Range*20), 0x0105, PRN, n);
          if(TmpB - 40 != 0)  Kb1[Range] -= TmpB - 40;
          else                k = 0; 
        }
        if(k == 0)  Range++;
        if(Range > G_Attr[0].Yp_Max){ 
          Range = 0;  Step++;
        } 
        __Set(CH_A_OFFSET, ((1024+Ka3[Range])*40 + 512)/1024);
        __Set(CH_B_OFFSET, ((1024+Kb3[Range])*40 + 512)/1024);
        break;
      case 3:
        k++;
        __Set(CH_A_OFFSET, ((1024+Ka3[Range])*160 + 512)/1024);
        __Set(CH_B_OFFSET, ((1024+Kb3[Range])*160 + 512)/1024);
        if((Channel == TRACK1)&&(TmpA > 140))  Step++;
        if((Channel == TRACK2)&&(TmpB > 140))  Step++;
        if(k > 20)  Step++;
        break;
      case 4:
        k = 0;
        if(Channel == TRACK1){
          s8ToPercen(n, TmpA - 160);
          Print_Str( 89, 166-(Range*20), 0x0005, INV, n);
          Ka3[Range] -= (1024*(TmpA-160)+80)/160;
        } 
        if(Channel == TRACK2){
          s8ToPercen(n, TmpB - 160);
          Print_Str(289, 166-(Range*20), 0x0105, INV, n);
          Kb3[Range] -= (1024*(TmpB-160)+80)/160;
        }
        Range++;
        if(Range > G_Attr[0].Yp_Max){ 
          Range = 0;  Step++;
        } 
        __Set(CH_A_OFFSET, ((1024+Ka3[Range])* 160 + 512)/1024);
        __Set(CH_B_OFFSET, ((1024+Kb3[Range])* 160 + 512)/1024);
        break;
      case 5:
        k++;
        if(k >= 8) k = 0;
        if(Channel == TRACK1){
          s8ToPercen(n, TmpA - 160);
          Print_Str( 89, 166-(Range*20), 0x0005, PRN, n);
          if(TmpA - 160 != 0) Ka3[Range] -= (1024*(TmpA-160)+80)/160;
          else                k = 0;           
        } 
        if(Channel == TRACK2){
          s8ToPercen(n, TmpB - 160);
          Print_Str(289, 166-(Range*20), 0x0105, PRN, n);
          if(TmpB - 160 != 0) Kb3[Range] -= (1024*(TmpB-160)+80)/160;
          else                k = 0; 
        }
        if(k == 0)  Range++;
        if(Range > G_Attr[0].Yp_Max){ 
          Range = 0;  Step++;
        } 
        __Set(CH_A_OFFSET, ((1024+Ka3[Range])* 160 + 512)/1024);
        __Set(CH_B_OFFSET, ((1024+Kb3[Range])* 160 + 512)/1024);
        break;
      case 6:
        k++;
        if(k > 20)  Step++;
        Range = 0;
        if(m < 2){
          __Set(CH_A_OFFSET, ((1024+Ka3[Range])*40 + 512)/1024);
          __Set(CH_B_OFFSET, ((1024+Kb3[Range])*40 + 512)/1024);
          if((Channel == TRACK1)&&(TmpA < 50)){
            Step = 1;
            m++;
          }
          if((Channel == TRACK2)&&(TmpB < 50)){
            Step = 1;
            m++;
          }
        } else {
          __Set(CH_A_OFFSET, ((1024+Ka3[Range])* 25 + 512)/1024);
          __Set(CH_B_OFFSET, ((1024+Kb3[Range])* 25 + 512)/1024);
          if((Channel == TRACK1)&&(TmpA < 55))  Step++;
          if((Channel == TRACK2)&&(TmpB < 55))  Step++;
        }
        break;
      case 7:
        Print_Str( 4*8, 216, 0x0305, PRN,   " INPUT ");
        Print_Str(11*8, 216, 0x0405, Twink, (u8*)VS_STR[Range]);
        Print_Str(20*8, 216, 0x0305, PRN,   " STANDARD VOLTAGE TO ");
        Print_Str(   8,   6, 0x0305, PRN,   "MODIFY VOLTAGE:   ...    ");
        Print_Str(18*8,   6, 0x0405, Twink, "-");
        Print_Str(22*8,   6, 0x0405, Twink, "+");
        Print_Str(27*8,   6, 0x0305, PRN,   "SELECT RANGE:   ---   ");
        Print_Str(42*8,   6, 0x0405, Twink, "<");
        Print_Str(46*8,   6, 0x0405, Twink, ">");
        if(Channel == TRACK1){
          if(TmpA > 35){
            Int2Str(n, (TmpA - 25)* Y_Attr[Range].SCALE, V_UNIT, 3, SIGN);
          } else {
            Int2Str(n, 0, V_UNIT, 3, SIGN);
          }
          Print_Str( 134, 166-(Range*20), 0x0005, Twink, n);
          Print_Str(41*8, 216,            0x0005, PRN,   "CH_A  ");
        } 
        if(Channel == TRACK2){
          if(TmpB > 35){
            Int2Str(n, (TmpB - 25)* Y_Attr[Range].SCALE, V_UNIT, 3, SIGN);
          } else {
            Int2Str(n, 0, V_UNIT, 3, SIGN);
          }
          Print_Str( 334, 166-(Range*20), 0x0105, Twink, n);
          Print_Str(41*8, 216,            0x0105, PRN,   "CH_B  ");
        }
        break;
      case 8:                             //"    PRESS   ---   TO SELECT THE NEXT OPERATION"
        m = 0;
        Print_Str(   8,   6, 0x0305, PRN,   "    PRESS   ---  ");
        Print_Str(12*8,   6, 0x0405, Twink, "<");
        Print_Str(16*8,   6, 0x0405, Twink, ">");
        Print_Str(17*8,   6, 0x0305, PRN,   " TO SELECT THE NEXT OPERATION   ");
        Print_Str(   8, 216, 0x0305, PRN,   "  PRESS   TO ");
        Print_Str(14*8, 216, 0x0405, PRN,   "CONFIRM THE RE-CALIBRATION ");
        Print_Str( 9*8, 216, 0x0405, Twink, " ");       
        if(Channel == TRACK1)  Print_Str(41*8, 216, 0x0005, PRN, "CH_A "); 
        if(Channel == TRACK2)  Print_Str(41*8, 216, 0x0105, PRN, "CH_B ");
        break;                            //"  PRESS   TO CONFIRM THE RE-CALIBRATION CH_A  "
      case 9:                             //             "SELECT THE CALIBRATION CH_A      "
        Print_Str( 9*8, 216, 0x0405, Twink, " ");       
        Print_Str(14*8, 216, 0x0405, PRN,   "SELECT THE CALIBRATION ");
        if(Channel == TRACK1)  Print_Str(37*8, 216, 0x0105, PRN, "CH_B     "); 
        if(Channel == TRACK2)  Print_Str(37*8, 216, 0x0005, PRN, "CH_A     ");
        break;
      case 10:                            //             "Exit WITHOUT SAVE RESULTS        "
        Print_Str( 9*8, 216, 0x0405, Twink, " ");       
        Print_Str(14*8, 216, 0x0405, PRN,   "Exit WITHOUT SAVE RESULTS        ");
        break;
      case 11:                            //             "Exit AND SAVE CALIBRATION RESULTS"
        Print_Str( 9*8, 216, 0x0405, Twink, " ");       
        Print_Str(14*8, 216, 0x0405, PRN,   "Exit AND SAVE CALIBRATION RESULTS");
        break;
      case 12:                            //             "Exit AND RESTORE SYSTEM DEFAULTS "
        Print_Str( 9*8, 216, 0x0405, Twink, " ");       
        Print_Str(14*8, 216, 0x0405, PRN,   "Exit AND RESTORE SYSTEM DEFAULTS ");
        break;
      }
    }
    if(Key_Buffer){ 
      PD_Cnt = 600;                               // 重新设定等待时间600秒
      if((Range <= G_Attr[0].Yp_Max)&&(Step == 7)){
        if(Channel == TRACK1){
          Print_Str(134, 166-(Range*20), 0x0005, PRN, n);
        }
        if(Channel == TRACK2){
          Print_Str(334, 166-(Range*20), 0x0105, PRN, n);
        }
      } 
      switch (Key_Buffer){  
      case KEY2:
        if(Step == 0)  Step++;
        if((Step == 8)||(Step == 9)){
          if(Step == 9) Channel = 1 - Channel;
          for(i=0; i<=G_Attr[0].Yp_Max; i++){
            if(Channel == TRACK1){
              Print_Str( 45, 166-(i*20), 0x0005, PRN, "     ");   
              Print_Str( 89, 166-(i*20), 0x0005, PRN, "     ");   
              Print_Str(134, 166-(i*20), 0x0005, PRN, "       ");  
            }
            if(Channel == TRACK2){
              Print_Str(245, 166-(i*20), 0x0105, PRN, "     ");
              Print_Str(289, 166-(i*20), 0x0105, PRN, "     ");
              Print_Str(334, 166-(i*20), 0x0105, PRN, "       ");
            }
          }
          Step = 0;; 
        } 
        if(Step >= 10){
          if(Step == 10){
            for(i=0; i<=G_Attr[0].Yp_Max; i++){
              Ka1[i] = Ma1[i];  Ka2[i] = Ma2[i];  Ka3[i] = Ma3[i];
              Kb1[i] = Mb1[i];  Kb2[i] = Mb2[i];  Kb3[i] = Mb3[i];
            }
            Save_Param();                         // 不保存校正后的参数
            Print_Str( 8, 216, 0x0405, PRN, "                                                ");
          } 
          if(Step == 11){
            Save_Param();                         // 保存校正后的参数
            Print_Str( 8, 216, 0x0405, PRN, "          SAVING THE CALIBRATION DATA           ");
          }  
          if(Step == 12){ 
            for(i=0; i<=G_Attr[0].Yp_Max; i++){
              Ka1[i] = 0; Ka2[i] = 1024; Ka3[i] = 0;         // 设置校准参数初值
              Kb1[i] = 0; Kb2[i] = 1024; Kb3[i] = 0;
            }
            Save_Param();  // 清除校准参数,保存缺省值 
            Print_Str( 8, 216, 0x0405, PRN, "       RESTORE DEFAULTS CALIBRATION DATA        ");
          }
          Delayms(1000);                                      
          App_init();
          return;
        }
        break;
      case KEY3:
        break;
      case K_ITEM_DEC:
        if((Step == 7)&&(Range > 0)) Range--;  
        if( Step >= 9)               Step--;
        if( Step == 8)               Step = 12;
        break;
      case K_ITEM_INC:
        if(Step >= 8)  Step++;
        if(Step > 12)  Step = 8;
        if(Step == 7)  Range++;  
        if(Range  > G_Attr[0].Yp_Max){  
          Range = 0;        
          Step++;
        } 
        break;
      case K_INDEX_DEC:
        if(Step == 7){  
          if((Channel == TRACK1)&&(TmpA > 35))  Ka2[Range] -= 2;
          if((Channel == TRACK2)&&(TmpB > 35))  Kb2[Range] -= 2;
        }
        break;
      case K_INDEX_INC:
        if(Step == 7){  
          if((Channel == TRACK1)&&(TmpA > 35))  Ka2[Range] += 2;
          if((Channel == TRACK2)&&(TmpB > 35))  Kb2[Range] += 2;
        }
        break;
      }
      Key_Buffer = 0;
    }
  }
}