Exemple #1
0
/*
 * Draw a rectangle frame.
 */
void oledFrame(int x1, int y1, int x2, int y2) {
  for (int x = x1; x <= x2; x++) {
    oledDrawPixel(x, y1);
    oledDrawPixel(x, y2);
  }
  for (int y = y1 + 1; y < y2; y++) {
    oledDrawPixel(x1, y);
    oledDrawPixel(x2, y);
  }
}
Exemple #2
0
void oledDrawChar(int x, int y, char c, int font) {
  if (x >= OLED_WIDTH || y >= OLED_HEIGHT || y <= -FONT_HEIGHT) {
    return;
  }

  int zoom = (font & FONT_DOUBLE ? 2 : 1);
  int char_width = fontCharWidth(font & 0x7f, c);
  const uint8_t *char_data = fontCharData(font & 0x7f, c);

  if (x <= -char_width * zoom) {
    return;
  }

  for (int xo = 0; xo < char_width; xo++) {
    for (int yo = 0; yo < FONT_HEIGHT; yo++) {
      if (char_data[xo] & (1 << (FONT_HEIGHT - 1 - yo))) {
        if (zoom <= 1) {
          oledDrawPixel(x + xo, y + yo);
        } else {
          oledBox(x + xo * zoom, y + yo * zoom, x + (xo + 1) * zoom - 1,
                  y + (yo + 1) * zoom - 1, true);
        }
      }
    }
  }
}
Exemple #3
0
void oledHLine(int y) {
  if (y < 0 || y >= OLED_HEIGHT) {
    return;
  }
  for (int x = 0; x < OLED_WIDTH; x++) {
    oledDrawPixel(x, y);
  }
}
Exemple #4
0
void oledBox(int x1, int y1, int x2, int y2, char val)
{
	int x, y;
	for (x = x1; x <= x2; x++) {
		for (y = y1; y <= y2; y++) {
			val ? oledDrawPixel(x, y) : oledClearPixel(x, y);
		}
	}
}
Exemple #5
0
/*
 * Draw a filled rectangle.
 */
void oledBox(int x1, int y1, int x2, int y2, bool set)
{
	int x, y;
	for (x = x1; x <= x2; x++) {
		for (y = y1; y <= y2; y++) {
			set ? oledDrawPixel(x, y) : oledClearPixel(x, y);
		}
	}
}
Exemple #6
0
/*
 * Draw a filled rectangle.
 */
void oledBox(int x1, int y1, int x2, int y2, bool set) {
  x1 = MAX(x1, 0);
  y1 = MAX(y1, 0);
  x2 = MIN(x2, OLED_WIDTH - 1);
  y2 = MIN(y2, OLED_HEIGHT - 1);
  for (int x = x1; x <= x2; x++) {
    for (int y = y1; y <= y2; y++) {
      set ? oledDrawPixel(x, y) : oledClearPixel(x, y);
    }
  }
}
Exemple #7
0
void oledDrawBitmap(int x, int y, const BITMAP *bmp) {
  for (int i = 0; i < bmp->width; i++) {
    for (int j = 0; j < bmp->height; j++) {
      if (bmp->data[(i / 8) + j * bmp->width / 8] & (1 << (7 - i % 8))) {
        oledDrawPixel(x + i, y + j);
      } else {
        oledClearPixel(x + i, y + j);
      }
    }
  }
}
Exemple #8
0
void oledDrawChar(int x, int y, char c)
{
	int char_width;
	const uint8_t *char_data;

	if ((x >= OLED_WIDTH) || (y >= OLED_HEIGHT)) return;

	char_width = fontCharWidth(c);
	char_data = fontCharData(c);

	int xoffset, yoffset;
	for (xoffset = 0; xoffset < char_width; xoffset++) {
		for (yoffset = 0; yoffset < FONT_HEIGHT; yoffset++) {
			if (char_data[xoffset] & (1 << (FONT_HEIGHT - 1 - yoffset))) {
				oledDrawPixel(x + xoffset, y + yoffset);
			}
		}
	}
}
Exemple #9
0
void oledDrawChar(int x, int y, char c)
{
	uint8_t width, *column;

	if ((x >= OLED_WIDTH) || (y >= OLED_HEIGHT)) return;

	if ((c < FONT_START) || (c > FONT_END)) {
		c = '_';
	}

	width = font_data[(int)(c - FONT_START)][0];
	column = (uint8_t *)(font_data[(int)(c - FONT_START)] + 1);

	int xoffset, yoffset;
	for (xoffset = 0; xoffset < width; xoffset++) {
		for (yoffset = 0; yoffset < FONT_HEIGHT; yoffset++) {
			if (column[xoffset] & (1 << (FONT_HEIGHT - 1 - yoffset))) {
				oledDrawPixel(x + xoffset, y + yoffset);
			}
		}
	}
}
Exemple #10
0
void oledDrawChar(int x, int y, char c, int zoom)
{
	int char_width;
	const uint8_t *char_data;

	if ((x >= OLED_WIDTH) || (y >= OLED_HEIGHT)) return;

	char_width = fontCharWidth(c);
	char_data = fontCharData(c);

	int xo, yo;
	for (xo = 0; xo < char_width; xo++) {
		for (yo = 0; yo < FONT_HEIGHT; yo++) {
			if (char_data[xo] & (1 << (FONT_HEIGHT - 1 - yo))) {
				if (zoom <= 1) {
					oledDrawPixel(x + xo, y + yo);
				} else {
					oledBox(x + xo * zoom, y + yo * zoom, x + (xo + 1) * zoom - 1, y + (yo + 1) * zoom - 1, true);
				}
			}
		}
	}
}
Exemple #11
0
void oledHLine(int y) {
	int x;
	for (x = 0; x < OLED_WIDTH; x++) {
		oledDrawPixel(x, y);
	}
}