Example #1
0
void
bat_drawstate(void)
{
  if(!lcd_on)
    return;

  raw2percent(get_adcw(BAT_MUX));
  uint16_t v1 = battery_state*VISIBLE_WIDTH/100;

  lcd_line(WINDOW_LEFT,TITLE_HEIGHT-1,          // the green/blue part
                   WINDOW_LEFT+v1,TITLE_HEIGHT-1, 0x0f00);

#ifdef CURV3
  lcd_line(WINDOW_LEFT+v1,TITLE_HEIGHT-1,       // and the red part
           WINDOW_RIGHT,TITLE_HEIGHT-1,
           bit_is_set( PINA, PA4 ) ? 0xf000 : 0xf0);  // charging:blue else red
#else
  uint8_t s1;
  s1  = (bit_is_set( BAT_PIN, BAT_PIN1) ? 2 : 0);
  s1 |= (bit_is_set( BAT_PIN, BAT_PIN2) ? 1 : 0);
  lcd_line(WINDOW_LEFT+v1,TITLE_HEIGHT-1,       // and the red part
           WINDOW_RIGHT,TITLE_HEIGHT-1,
           (s1==2 && USB_IsConnected) ? 0xf0 : 0xf000);// charging:blue else red
#endif

}
Example #2
0
void lcd_rect(const uint8_t x, const uint8_t y, uint8_t width, uint8_t height, const uint8_t mode) 
 { width--;
   height--;
   lcd_line(x, y, x+width, y, mode);	// top
   lcd_line(x, y, x, y+height, mode);	// left
   lcd_line(x, y+height, x+width, y+height, mode);	// bottom
   lcd_line(x+width, y, x+width, y+height, mode);		// right
 }
Example #3
0
// Projects a given star in 3D, and draws it to the screen. The star is drawn
// as a line, with a length proportional to the camera speed to give the
// illusion of non-instantaneous camera exposure. Draws the star in the
// provided colour.
void renderStar(Star star, float speed, int colour)
{
    float mn, mf; int xn, yn, xf, yf;

    // Don't draw a star if it is behind the camera! This should never occur
    // anyway, since we push them back when they pass the camera.
    if (star.z <= 0.0f) return;

    // Work out the perspective multipliers for the near and far points of the
    // line we will draw for the star. Also ensures that we don't draw nothing
    // if the camera is stopped.
    mn = Z_PLANE_DIST / star.z;
    mf = Z_PLANE_DIST / (star.z + max(speed * 2.0f, MIN_SPEED));

    // Make sure the line doesn't go off screen because apparently that crashes
    // the program occasionally.
    mn = min(mn, 0.5f / abs(star.x));
    mn = min(mn, 0.5f / abs(star.y));

    // Using the perspective multipliers, calculate the two (X, Y) coordinate
    // pairs for the star's line. Positions the line to be relative to the
    // centre of the screen, and stretches it.
    xn = (int) ((star.x * mn + 0.5f) * DISPLAY_WIDTH);
    yn = (int) ((star.y * mn + 0.5f) * DISPLAY_HEIGHT);
    xf = (int) ((star.x * mf + 0.5f) * DISPLAY_WIDTH);
    yf = (int) ((star.y * mf + 0.5f) * DISPLAY_HEIGHT);

    // If the line isn't completely off-screen, draw it.
    if (xf >= 0 && xf < DISPLAY_WIDTH && yf >= 0 && yf < DISPLAY_HEIGHT) {
        lcd_line(xn, yn, xf, yf, colour);
    }
}
Example #4
0
void lcd_box(const uint8_t x, const uint8_t y, uint8_t width, const uint8_t height, const uint8_t mode) 
 { uint8_t i;
   if (!width) return; 

   width--;
	
   for (i=y;i<y+height;i++) 
      lcd_line(x, i, x+width, i, mode);
 }
Example #5
0
/*luadoc
@function lcd.drawLine(x1, y1, x2, y2, pattern, flags)

Draws a straight line on LCD

@param x1,y1 (positive numbers) starting coordinate

@param x2,y2 (positive numbers) end coordinate

@param pattern TODO

@param flags TODO

@notice If the start or the end of the line is outside the LCD dimensions, then the
whole line will not be drawn (starting from OpenTX 2.1.5)

@status current Introduced in 2.0.0
*/
static int luaLcdDrawLine(lua_State *L)
{
    if (!luaLcdAllowed) return 0;
    int x1 = luaL_checkinteger(L, 1);
    int y1 = luaL_checkinteger(L, 2);
    int x2 = luaL_checkinteger(L, 3);
    int y2 = luaL_checkinteger(L, 4);
    int pat = luaL_checkinteger(L, 5);
    int flags = luaL_checkinteger(L, 6);
    lcd_line(x1, y1, x2, y2, pat, flags);
    return 0;
}
Example #6
0
void gui_lcd_line(int x, int y, int dx, int dy)
{
	lcd_line(gui_lcd, x, y, dx, dy);
}
Example #7
0
void lcd_line( uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, const uint8_t mode ) 
 { uint8_t length, xTmp, yTmp, i, y, yAlt;
   int16_t m;

   if(x1 == x2) 
    { // vertical line
      // x1|y1 must be the upper point
      if(y1 > y2) 
       { xTmp = x1;
         yTmp = y1;
         x1 = x2;
         y1 = y2;
         x2 = xTmp;
         y2 = yTmp;
       }
      length = y2-y1;
      for(i=0; i<=length; i++) 
         lcd_dot(x1, y1+i, mode);
    } 
   else if(y1 == y2) 
    { // horizontal line
      // x1|y1 must be the left point
      if(x1 > x2) 
       { xTmp = x1;
         yTmp = y1;
         x1 = x2;
         y1 = y2;
         x2 = xTmp;
         y2 = yTmp;
       }

      length = x2-x1;
      for(i=0; i<=length; i++) 
         lcd_dot(x1+i, y1, mode);
       
    } 
   else 
    { // x1 must be smaller than x2
      if(x1 > x2) 
       { xTmp = x1;
         yTmp = y1;
         x1 = x2;
         y1 = y2;
         x2 = xTmp;
         y2 = yTmp;
       }
		
      if((y2-y1) >= (x2-x1) || (y1-y2) >= (x2-x1)) 
       { // angle larger or equal 45°
         length = x2-x1;								// not really the length :)
         m = ((y2-y1)*200)/length;
         yAlt = y1;
         for(i=0; i<=length; i++) 
          { y = ((m*i)/200)+y1;
            if((m*i)%200 >= 100)
               y++;
            else if((m*i)%200 <= -100)
               y--;
				
            lcd_line(x1+i, yAlt, x1+i, y, mode ); /* wuff wuff recurs. */
            if(length<=(y2-y1) && y1 < y2)
               yAlt = y+1;
            else if(length<=(y1-y2) && y1 > y2)
               yAlt = y-1;
            else
               yAlt = y;
          }
       } 
      else
       { // angle smaller 45°
         // y1 must be smaller than y2
         if(y1 > y2)
          { xTmp = x1;
            yTmp = y1;
            x1 = x2;
            y1 = y2;
            x2 = xTmp;
            y2 = yTmp;
          }
         length = y2-y1;
         m = ((x2-x1)*200)/length;
         yAlt = x1;
         for(i=0; i<=length; i++)
          { y = ((m*i)/200)+x1;

            if((m*i)%200 >= 100)
               y++;
            else if((m*i)%200 <= -100)
               y--;

            lcd_line(yAlt, y1+i, y, y1+i, mode); /* wuff */
            if(length<=(x2-x1) && x1 < x2)
               yAlt = y+1;
            else if(length<=(x1-x2) && x1 > x2)
               yAlt = y-1;
            else
               yAlt = y;
          }
       }
    }
 }
Example #8
0
int main(void) {
    cpu_interval = 0;
    int mem_load;
    int display_mode = mode_CPU; 
    char tmp_value[20];
    mem_tot = mem_total()/1024;
    
    lcd_line("    RPi i2c test");
    lcd_line("    Copyright (C)");
    lcd_line("        2013");
    lcd_line("Jesper Stockenstrand");
    usleep(5000000);
    
    for(;;) {
        int cpu_l;
            
        switch (display_mode) {
        
            case mode_CPU:
                cpu_l = cpu_load();
                sprintf(tmp_value,"         %d%%",cpu_l);
                lcd_line("      CPU LOAD  ");
                lcd_line(tmp_value);
                lcd_line("   ");
                lcd_line(">CPU<[MEM][NET][UPT]"); 
                break;
                
            case mode_MEM:
                mem_load = (int)(((double)mem_used()/(double)mem_tot)*100);
                lcd_line("     MEM USAGE      ");
                sprintf(tmp_value,"       %d/%dMb",mem_used(),mem_tot);
                lcd_line(tmp_value);
                sprintf(tmp_value,"         %d%%",mem_load);
                lcd_line(tmp_value);
                lcd_line("[CPU]>MEM<[NET][UPT]");
                break;
                
            case mode_NET:
                lcd_line("    IP ADDRESS      ");
                sprintf(tmp_value,"    %s", net_address());
                lcd_line(tmp_value);
                lcd_line("      ");
                lcd_line("[CPU][MEM]>NET<[UPT]");
                break;
                
            case mode_UPT:
                lcd_line("       UP TIME      ");
                sprintf(tmp_value,"     %d sec",uptime());
                lcd_line(tmp_value);
                lcd_line("     ");
                lcd_line("[CPU][MEM][NET]>UPT<");
                break;
                
            default:
                display_mode = mode_CPU;
                
        }
        
        switch (checkButton()) {
        
            case 1:
                display_mode = mode_CPU;
                break;
                
            case 2:
                display_mode = mode_MEM;
                break;
                
            case 3:
                display_mode = mode_NET;
                break;
            
            case 4:
                display_mode = mode_UPT;
                break;
                
        } 

            
        usleep(10000);
    
    } 
    return(0);
}
Example #9
0
void lcd_status_P(const char* msg) {
  lcd_line((char*)msg, 1, 1);
}
Example #10
0
void lcd_status(char* msg) {
  lcd_line(msg, 1, 0);
}
Example #11
0
void lcd_title_P(const char* msg) {
  lcd_line((char*)msg, 0, 1);
}
Example #12
0
void lcd_title(char* msg) {
  lcd_line(msg, 0, 0);
}