Пример #1
0
void DrawMessageWindow(char* message_line1, char* message_line2,
                       char* message_line3, char buttons)
{
  SetFont(SMALL_FONT);
  LcdSetColor(WHITE);
  LcdRect(5, 9, 123, 54);
  LcdSetColor(BLACK);
  
  LcdLine(6,   9,   122, 9);
  LcdLine(6,   55,  122, 55);
  LcdLine(4,   11,  4,   53);
  LcdLine(124, 11,  124, 53);
  
  LcdLine(5,   10,  5,   10);
  LcdLine(5,   54,  5,   54);
  LcdLine(123, 10,  123, 10);
  LcdLine(123, 54,  123, 54);
  
  LcdBmp(6, 26, BMP_EXLAMATION_WIDTH, BMP_EXLAMATION_HEIGHT, bmp_exlamation); 
  //LcdBmp(6, 26, BMP_KEY_INPUT_WIDTH, BMP_KEY_INPUT_HEIGHT, bmp_key_input); 
  
  LcdText(29, 12, 122, 18, message_line1);
  LcdText(29, 21, 122, 27, message_line2);
  LcdText(29, 30, 122, 36, message_line3);
  
  if(buttons & MB_OK)
    DrawButton(29, 40, BTN_OK, mw_focus == 0);
  if(buttons & MB_CANCEL)
    DrawButton(75, 40, BTN_CANCEL, mw_focus == 1);
};
int main(int argc, char** argv) {
    /**************INICJALICACJA*****************/
    for (int i=0; i>10; i++) {
        __delay_ms(30);
    }
    OpenI2C(MASTER, SLEW_OFF);
    //SSPADD = ((Fosc/predkosc magistrali)/4)-1
    SSPADD = 49; //dla zegara 20 MHz i predkosci 100kHz: ((20 000 000/100 000)/4)-1 = 49
    
    Init_lcd();
    LcdCmd(DISP_ON_CURSOR_OFF_BLINK_OFF);
    LcdCmd(_4_BIT_2_LINES_FONT_5X8);

    Init_adxl345(-5, -3, 1, _16G, Hz_100); //x offset, y offset, z offset, zakres 16 G, pr?dko?? przesy?u danych 100 Hz
/********************************************/

    


    while(1) {
        LcdText(3, 1, "       "); //czyszczenie danych na wy?wietlaczu
        LcdText(12, 0, "    ");
        LcdText(3, 2, "             ");

        LcdText(0, 1, "X= ");
        LcdText(3, 1, getX());

        LcdText(9, 0, "Y= ");
        LcdText(11, 0, getY());

        LcdText(0, 2, "Z= ");
        LcdText(3, 2, getZ());

        for (unsigned char i=0; i<100; i++) { //czekaj 1 s
            __delay_ms(10);
        }
    }


    return (EXIT_SUCCESS);
}
Пример #3
0
int main()
{
  int i;
  LcdInit();
  printf("start of lcd_test\n");
/*

  printf("LcdClearDisplay\n");
  LcdClearDisplay();
  Wait(SEC_1);

  printf("LcdDrawChar(""E"", 1, LCD_LINE8 div CELL_HEIGHT)\n");
  LcdDrawChar("E", 1, LCD_LINE8 div CELL_HEIGHT);
  Wait(SEC_1);

  printf("LcdDrawCharXY(""V"", 20, LCD_LINE8)\n");
  LcdDrawCharXY("V", 20, LCD_LINE8);
  Wait(SEC_1);

  printf("LcdDrawCharXY(""3"", 20, LCD_LINE8)\n");
  LcdDrawCharXY("3", 30, LCD_LINE8);
  Wait(SEC_1);

  printf("LcdDrawString(""EV3 BricxCC"", 4, LCD_LINE4 div CELL_HEIGHT, false)\n");
  LcdDrawString("EV3 BricxCC", 4, LCD_LINE4 div CELL_HEIGHT, false);
  Wait(SEC_1);

  printf("LcdDrawString(""EV3 BricxCC"", 1, LCD_LINE5 div CELL_HEIGHT, true)\n");
  LcdDrawString("EV3 BricxCC", 1, LCD_LINE5 div CELL_HEIGHT, true);
  Wait(SEC_1);

  printf("LcdDrawInt(SEC_1, 0, LCD_LINE7 div CELL_HEIGHT)\n");
  LcdDrawInt(SEC_1, 0, LCD_LINE7 div CELL_HEIGHT);
  Wait(SEC_1);

  printf("LcdScrollLine()\n");
  LcdScrollLine();
  Wait(SEC_1);

  printf("LcdScrollLine()\n");
  LcdScrollLine();
  Wait(SEC_1);
*/
  printf("CircleOut(50, 40, 10);\n");
  printf("CircleOutEx(30, 24, 10, DRAW_OPT_FILL_SHAPE);\n");
  printf("LineOut(10, 10, 80, 60);\n");
  printf("RectOut(20, 20, 40, 40);\n");
  printf("RectOutEx(65, 25, 20, 30, DRAW_OPT_FILL_SHAPE);\n");
  printf("EllipseOut(70, 30, 15, 20);\n");

  CircleOut(50, 40, 10);
  CircleOutEx(30, 24, 10, DRAW_OPT_FILL_SHAPE);
  LineOut(10, 10, 80, 60);
  RectOut(20, 20, 40, 40);
  RectOutEx(65, 25, 20, 30, DRAW_OPT_FILL_SHAPE);
  EllipseOut(70, 30, 15, 20);

  Wait(SEC_1);

  printf("LcdBmpFile(1, 0, 64, \"/media/card/mindstorms.rgf\");\n");
  LcdBmpFile(1, 0, 64, "/media/card/mindstorms.rgf");
  Wait(SEC_1);

  for (i = 0; i < 35; i++)
  {
    printf("LcdIcon(1, 130, 64, ICONTYPE_NORMAL, 0);\n");
    LcdIcon(1, 0+((i % 7)*24), 0+((i / 7) * 12), ICONTYPE_NORMAL, i);
    Wait(250);
  }

  printf("LcdText(1, 0, 100, \"hello world\");\n");
  LcdText(1, 0, 100, "hello world");
  Wait(SEC_1);

  printf("LcdSelectFont(FONTTYPE_TINY);\n");
  LcdSelectFont(FONTTYPE_TINY);

  printf("LcdText(1, 100, 100, \"testing\");\n");
  LcdText(1, 100, 100, "testing");
  Wait(SEC_1);
  
  // these functions will replace any file extension included in
  // the filename with the "correct" extension based on the
  // specified image format
  printf("LcdWriteDisplayToFile(\"/media/card/display.xbm\", ifXBM);\n");
  LcdWriteDisplayToFile("/media/card/display.xbm", ifXBM);

  printf("LcdWriteFrameBufferToFile(\"/media/card/fbuffer.xbm\", ifXBM);\n");
  LcdWriteFrameBufferToFile("/media/card/fbuffer.xbm", ifXBM);

  printf("LcdWriteDisplayToFile(\"/media/card/display_p1.pbm\", ifP1);\n");
  LcdWriteDisplayToFile("/media/card/display_p1.pbm", ifP1);

  printf("LcdWriteFrameBufferToFile(\"/media/card/fbuffer_p1.pbm\", ifP1);\n");
  LcdWriteFrameBufferToFile("/media/card/fbuffer_p1.pbm", ifP1);

  printf("LcdWriteDisplayToFile(\"/media/card/display_p4.pbm\", ifP4);\n");
  LcdWriteDisplayToFile("/media/card/display_p4.pbm", ifP4);

  printf("LcdWriteFrameBufferToFile(\"/media/card/fbuffer_p4.pbm\", ifP4);\n");
  LcdWriteFrameBufferToFile("/media/card/fbuffer_p4.pbm", ifP4);

//  Wait(SEC_5);
  LcdExit();
  printf("end of lcd_test\n");
}
Пример #4
0
void DrawParamScreen(void)
{
  SetFont(SMALL_FONT);
  LcdText(1, 0, 118, 7, screens[ps_screen].header);
  LcdLine(0, 8, 127, 8);  
  LcdLine(0, 9, 127, 9);
  LcdLine(0, 20, 127, 20);  
  LcdLine(0, 31, 127, 31);  
  LcdLine(0, 42, 127, 42);  
  LcdLine(0, 53, 127, 53); 
  //LcdLine(0, 54, 127, 54);
  
  LcdLine(42, 10, 42, 52);
  LcdLine(86, 10, 86, 52);
  LcdLine(119, 0, 119, 7);
  
  if(GetPasswordEntered()) LcdText(121, 1, 127, 7, "P");
  
  LcdText(1, 11, 41, 18, GetNameByTag(screens[ps_screen].var1));
  if(ps_focus == 0)
  {
    LcdSetColor(BLACK);
    LcdRect(43, 10, 85, 19);
    LcdSetColor(WHITE);
  };
  LcdText(44, 11, 85, 18, "9234.567");
  LcdSetColor(BLACK);
  LcdText(88, 11, 127, 18, GetUnitByTag(screens[ps_screen].var1));
  
  LcdText(1, 22, 41, 29, "variabl2");
  if(ps_focus == 1)
  {
    LcdSetColor(BLACK);
    LcdRect(43, 21, 85, 30);
    LcdSetColor(WHITE);
  };
  LcdText(44, 22, 85, 29, "9234.567");
  LcdSetColor(BLACK);    
  LcdText(88, 22, 127, 29, "some_tx2");

  LcdText(1, 33, 41, 40, "variabl3");
  if(ps_focus == 2)
  {
    LcdSetColor(BLACK);
    LcdRect(43, 32, 85, 41);
    LcdSetColor(WHITE);
  };
  LcdText(44, 33, 85, 40, "9234.567");
  LcdSetColor(BLACK);    
  LcdText(88, 33, 127, 40, "some_tx3");

  LcdText(1, 44, 41, 51, "variabl4");
  if(ps_focus == 3)
  {
    LcdSetColor(BLACK);
    LcdRect(43, 43, 85, 52);
    LcdSetColor(WHITE);
  };
  LcdText(44, 44, 85, 51, "9234.567");
  LcdSetColor(BLACK);  
  LcdText(88, 44, 127, 51, "some_tx4");
  
  //control buttons
  /*
  if(ps_focus == 4)
  {
    LcdSetColor(BLACK);
    LcdRect(0, 55, 41, 63);
    LcdSetColor(WHITE);
  };
  LcdText(1, 56, 41, 63, "Назад");
  LcdSetColor(BLACK);  

  if(ps_focus == 5)
  {
    LcdSetColor(BLACK);
    LcdRect(43, 55, 85, 63);
    LcdSetColor(WHITE);
  };  
  LcdText(44, 56, 85, 63, "Гл. экр.");
  LcdSetColor(BLACK);
  
  if(ps_focus == 6)
  {
    LcdSetColor(BLACK);
    LcdRect(87, 55, 127, 63);
    LcdSetColor(WHITE);
  };
  LcdText(88, 56, 127, 63, "Вперед");  
  LcdSetColor(BLACK);
  */
  LcdClear();
  DrawButton(0, 53, BTN_BACK, ps_focus == 4);
  DrawButton(42, 53, BTN_HOME, ps_focus == 5);
  DrawButton(84, 53, BTN_FORWARD, ps_focus == 6);
  
  DrawMessageWindow("строка1", "строка2", "строка2", MB_OK + MB_CANCEL);
  
  DrawEditorScreen();
    
  LcdDraw();
}