Advertisement
KRITSADA

POP-XT Test Board

May 15th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.14 KB | None | 0 0
  1. #include <popxt.h>
  2.  
  3. void setup()
  4. {
  5.   int i,j,r,g,b;
  6.   delay(250);
  7.   glcdMode(1);
  8.   glcdSetColorWordRGB();
  9.   glcdClear();
  10.   sound(1000,100);
  11.   delay(50);
  12.   sound(1400,50);
  13.  
  14.   for (j=0;j<=124;j+=4)
  15.   {
  16.     for (i=0;i<160;i++)
  17.     {
  18.       if (i<32)
  19.       {
  20.         r=(32-i)-(j/4)-1;
  21.         g=(i<<1)-((j/4)<<1)-1;
  22.         b=0;
  23.       }
  24.       else if (i<64)
  25.       {
  26.         r=0;
  27.         g=(64-((i-32)<<1))-((j/4)<<1)-1;
  28.         b=(i-32)-(j/4)-1;
  29.       }
  30.       else if (i<96)
  31.       {
  32.         r=(i-64)-(j/4)-1;
  33.         g=0;
  34.         b=(96-(i-64))-(j/4)-1;
  35.       }
  36.       else //if (i<128)
  37.       {
  38.         r=(160-(i-96))-(j/4)-1;
  39.         g=(((160-(i-96))-(j/4))<<1)-1;
  40.         b=(160-(i-96))-(j/4)-1;
  41.       }
  42.  
  43.       if (sw_ok()) break;
  44.  
  45.       glcdLine(i,j,i,j+4,(r<<11)|(g<<5)|b);
  46.     }
  47.   }
  48.  
  49.   if (!sw_ok())
  50.   {
  51.     for (i=0;i<100;i++)
  52.     {
  53.       delay(10);
  54.       if (sw_ok()) break;
  55.     }
  56.     __tft.writecommand(GCLCD_INVON);
  57.     for (i=0;i<100;i++)
  58.     {
  59.       delay(10);
  60.       if (sw_ok()) break;
  61.     }
  62.     __tft.writecommand(GCLCD_INVOFF);
  63.     for (i=0;i<100;i++)
  64.     {
  65.       delay(10);
  66.       if (sw_ok()) break;
  67.     }
  68.   }
  69.  
  70.   glcdFillRect(-1,0,160,128,GLCD_WHITE);
  71.   for (i=0;i<100;i++)
  72.   {
  73.     delay(10);
  74.     if (sw_ok()) break;
  75.   }
  76.  
  77.   glcdFillRect(-1,0,160,128,GLCD_RED);
  78.   for (i=0;i<100;i++)
  79.   {
  80.     delay(10);
  81.     if (sw_ok()) break;
  82.   }
  83.  
  84.   glcdFillRect(-1,0,160,128,GLCD_GREEN);
  85.   for (i=0;i<100;i++)
  86.   {
  87.     delay(10);
  88.     if (sw_ok()) break;
  89.   }
  90.  
  91.   glcdFillRect(-1,0,160,128,GLCD_BLUE);
  92.   for (i=0;i<100;i++)
  93.   {
  94.     delay(10);
  95.     if (sw_ok()) break;
  96.   }
  97.  
  98.   glcdClear();
  99.  
  100.   setTextSize(2);
  101.   glcdFillRect(14,12,134,30,GLCD_BLUE);
  102.   setTextColor(GLCD_WHITE);
  103.   setTextBackgroundColor(GLCD_BLUE);
  104.   glcd(1,2,"POP-XT/XT+");
  105.  
  106.   setTextSize(1);
  107.   setTextBackgroundColor(GLCD_BLACK);
  108.  
  109.   setTextColor(GLCD_WHITE);
  110.   glcd(5,3,"LCD mode ");
  111.   setTextColor(GLCD_RED);
  112.   glcd(5,12,"R");
  113.   setTextColor(GLCD_GREEN);
  114.   glcd(5,13,"G");
  115.   setTextColor(GLCD_BLUE);
  116.   glcd(5,14,"B");
  117.  
  118.   setTextColor(GLCD_YELLOW);
  119.   glcd(6,3,"glcdSetColorWordRGB();");
  120.  
  121.   setTextColor(GLCD_GREEN);
  122.   glcd(8,5,"Motor & Servo test");
  123.  
  124.   while(sw_ok());
  125.  
  126.   setTextColor(GLCD_MAGENTA);
  127.   glcd(10,7,"Wait for");
  128.  
  129.   servo(1,45);
  130.   servo(2,90);
  131.   servo(3,135);
  132.  
  133.   while(!sw_ok())
  134.   {
  135.     glcdRect(95,97,24,14,GLCD_YELLOW);
  136.     setTextColor(GLCD_YELLOW);
  137.     glcd(10,17,"OK");
  138.     for(i=0;i<20;i++)
  139.     {
  140.       delay(10);
  141.       if (sw_ok())
  142.       break;
  143.     }
  144.     glcdRect(95,97,24,14,GLCD_BLACK);
  145.     setTextColor(GLCD_BLACK);
  146.     glcd(10,17,"OK");
  147.     for(i=0;i<20;i++)
  148.     {
  149.       delay(10);
  150.       if (sw_ok())
  151.       break;
  152.     }
  153.   }
  154.  
  155.   setTextColor(GLCD_SKY);
  156.   glcd(9,4," > Running test   ");
  157.   setTextColor(0b1111110000001000);
  158.   glcd(10,4,"KNOB set motor power");
  159.  
  160.   setTextColor(GLCD_MAGENTA);
  161.   glcd(12,4,"servo 45,90,135 test");
  162.  
  163. }
  164.  int value;
  165. void loop(){
  166.   sound(1200,15);
  167.   motor(1,100);
  168.   motor(2,0);
  169.   delay(750);
  170.  
  171.  
  172.   motor(1,0);
  173.   motor(2,100);
  174.   delay(750);
  175.  
  176.   motor(1,-100);
  177.   motor(2,0);
  178.   delay(750);
  179.  
  180.   motor(1,0);
  181.   motor(2,-100);
  182.   delay(750);
  183.  
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement