Пример #1
0
// used to do circles and roundrects!
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
                uint8_t cornername, int16_t delta, uint16_t color) {

  int16_t f     = 1 - r;
  int16_t ddF_x = 1;
  int16_t ddF_y = -2 * r;
  int16_t x     = 0;
  int16_t y     = r;

  while (x<y) {
    if (f >= 0) {
      y--;
      ddF_y += 2;
      f     += ddF_y;
    }
    x++;
    ddF_x += 2;
    f     += ddF_x;

    if (cornername & 0x1) {
      LCD_DrawFastVLine(x0+x, y0-y, 2*y+1+delta, color);
      LCD_DrawFastVLine(x0+y, y0-x, 2*x+1+delta, color);
    }
    if (cornername & 0x2) {
      LCD_DrawFastVLine(x0-x, y0-y, 2*y+1+delta, color);
      LCD_DrawFastVLine(x0-y, y0-x, 2*x+1+delta, color);
    }
  }
}
Пример #2
0
// draw a rectangle
void LCD_DrawRect(u16 x, u16 y, u16 w, u16 h, u16 color)
{
  LCD_DrawFastHLine(x, y, w, color);
  LCD_DrawFastHLine(x, y+h-1, w, color);
  LCD_DrawFastVLine(x, y, h, color);
  LCD_DrawFastVLine(x+w-1, y, h, color);
}
Пример #3
0
// draw a rounded rectangle!
void LCD_DrawRoundRect(u16 x, u16 y, u16 w, u16 h, u16 r, u16 color)
{
  // smarter version
  LCD_DrawFastHLine(x+r  , y    , w-2*r, color); // Top
  LCD_DrawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom
  LCD_DrawFastVLine(  x    , y+r  , h-2*r, color); // Left
  LCD_DrawFastVLine(  x+w-1, y+r  , h-2*r, color); // Right
  // draw four corners
  drawCircleHelper(x+r    , y+r    , r, 1, color);
  drawCircleHelper(x+w-r-1, y+r    , r, 2, color);
  drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
  drawCircleHelper(x+r    , y+h-r-1, r, 8, color);
}
Пример #4
0
// used to do circles and roundrects!
void fillCircleHelper(int x0, int y0, int r,
                unsigned cornername, int delta, unsigned color) {
  struct circle c = {1 - r, 1, -2 * r, 0, r};

  while (c.x<c.y) {
    _calcCircleHelper(&c);
    if (cornername & 0x1) {
      LCD_DrawFastVLine(x0+c.x, y0-c.y, 2*c.y+1+delta, color);
      LCD_DrawFastVLine(x0+c.y, y0-c.x, 2*c.x+1+delta, color);
    }
    if (cornername & 0x2) {
      LCD_DrawFastVLine(x0-c.x, y0-c.y, 2*c.y+1+delta, color);
      LCD_DrawFastVLine(x0-c.y, y0-c.x, 2*c.x+1+delta, color);
    }
  }
}
Пример #5
0
void _draw_channels()
{
    const unsigned offset = HEADER_HEIGHT + LINE_HEIGHT;
    int col, height;

    // draw rssi values
    for (int i = 0; i < Scanner.chan_max - Scanner.chan_min; i++) {
        col = (LCD_WIDTH - (Scanner.chan_max - Scanner.chan_min)) / 2 + i;
        if (sp->mode == PEAK_MODE) {
            height = Scanner.rssi_peak[i] * (LCD_HEIGHT - offset) / 0x1F;
        } else {
            height = Scanner.rssi[i] * (LCD_HEIGHT - offset) / 0x1F;
        }
        LCD_DrawFastVLine(col, offset, LCD_HEIGHT - offset - height, 0);
        LCD_DrawFastVLine(col, LCD_HEIGHT - height, height, 1);

        if (sp->mode == PEAK_HOLD_AVERAGE_MODE) {
            height = Scanner.rssi_peak[i] * (LCD_HEIGHT - offset) / 0x1F;
            LCD_DrawPixelXY(col, LCD_HEIGHT - height, 1);
        }
    }
}
Пример #6
0
void LCD_FillCircle(u16 x0, u16 y0, u16 r, u16 color)
{
    LCD_DrawFastVLine(x0, y0-r, 2*r+1, color);
    fillCircleHelper(x0, y0, r, 3, 0, color);
}
Пример #7
0
static void draw_target(u16 x, u16 y)
{
    LCD_DrawFastHLine(x - 5, y, 11, SMALLBOX_FONT.font_color);
    LCD_DrawFastVLine(x, y - 5, 11, SMALLBOX_FONT.font_color);
}
Пример #8
0
void GUI_DrawXYGraph(struct guiObject *obj)
{
    struct guiBox *box = &obj->box;
    struct guiXYGraph *graph = (struct guiXYGraph *)obj;
    u32 x, y;

    #define VAL_TO_X(xval) \
        (u32)(box->x + (((s32)(xval)) - graph->min_x) * box->width / (1 + graph->max_x - graph->min_x))
    #define VAL_TO_Y(yval) \
        (u32)(box->y + box->height - (((s32)(yval)) - graph->min_y) * box->height / (1 + graph->max_y - graph->min_y))
    _GUI_DrawMappedStart();
    _GUI_ClearMappedBox(box, Display.xygraph.bg_color);
    if (graph->grid_x) {
        int xval;
        for (xval = graph->min_x + graph->grid_x; xval < graph->max_x; xval += graph->grid_x) {
            if (! xval)
                continue;
            x = VAL_TO_X(xval);
            //LCD_DrawDashedVLine(x, box->y, box->height, 5, RGB888_to_RGB565(0x30, 0x30, 0x30));
            LCD_DrawFastVLine(x, box->y, box->height, Display.xygraph.grid_color);
        }
    }
    if (graph->grid_y) {
        int yval;
        for (yval = graph->min_y + graph->grid_y; yval < graph->max_y; yval += graph->grid_y) {
            if (! yval)
                continue;
            y = VAL_TO_Y(yval);
            //LCD_DrawDashedHLine(box->x, y, box->width, 5, RGB888_to_RGB565(0x30, 0x30, 0x30));
            LCD_DrawFastHLine(box->x, y, box->width, Display.xygraph.grid_color);
        }
    }
    if (graph->min_x < 0 && graph->max_x > 0) {
        int x = box->x + box->width * (0 - graph->min_x) / (graph->max_x - graph->min_x);
        LCD_DrawFastVLine(x, box->y, box->height, Display.xygraph.axis_color);
    }
    if (graph->min_y < 0 && graph->max_y > 0) {
        y = box->y + box->height - box->height * (0 - graph->min_y) / (graph->max_y - graph->min_y);
        LCD_DrawFastHLine(box->x, y, box->width, Display.xygraph.axis_color);
    }
    u16 lastx = box->x;
    u16 lasty = box->y + box->height -1;
    LCD_DrawStart(box->x, box->y, box->x + box->width - 1, box->y + box->height - 1, DRAW_NWSE);
    for (x = 0; x < box->width; x++) {
        s32 xval, yval;
        xval = graph->min_x + x * (1 + graph->max_x - graph->min_x) / box->width;
        yval = graph->CallBack(xval, graph->cb_data);
        y = (yval - graph->min_y) * box->height / (1 + graph->max_y - graph->min_y);
        //printf("(%d, %d - %d, %d) -> (%d, %d)\n",
        //       (int)lastx, (int)lasty, (int)x, (int)y, (int)xval, (int)yval);
        if (x != 0) {
            LCD_DrawLine(lastx, lasty, x + box->x, box->y + box->height - y - 1, Display.xygraph.fg_color); //Yellow
        }
        lastx = x + box->x;
        lasty = box->y + box->height - y - 1;
    }
    LCD_DrawStop();
    if (graph->point_cb) {
        u8 pos = 0;
        s16 xval, yval;
        while (graph->point_cb(&xval, &yval, pos++, graph->cb_data)) {
            s16 x1 = VAL_TO_X(xval);
            s16 y1 = VAL_TO_Y(yval);
            s16 x2 = x1 + 2;
            s16 y2 = y1 + 2;
            //bounds check
            x1 = ( x1 < 2 + box->x) ? box->x : x1 - 2;
            y1 = ( y1 < 2 + box->y) ? box->y : y1 - 2;
            if ( x2 >= box->x + box->width)
                x2 = box->x + box->width - 1;
            if ( y2 >= box->y + box->height)
                y2 = box->y + box->height - 1;
            LCD_FillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, Display.xygraph.point_color);
        }
    }
    if(Display.xygraph.outline_color != Display.xygraph.bg_color)
        LCD_DrawRect(box->x, box->y, box->width, box->height, Display.xygraph.outline_color);
    _GUI_DrawMappedStop();
}