git rm --cached lib/libssd1306/bld/

gui-dev
Ondřej Hruška 2 years ago
parent 317aed825e
commit 3124b29176
  1. 2
      Makefile
  2. BIN
      lib/libssd1306/bld/intf/i2c/ssd1306_i2c.o
  3. BIN
      lib/libssd1306/bld/intf/i2c/ssd1306_i2c_embedded.o
  4. BIN
      lib/libssd1306/bld/intf/i2c/ssd1306_i2c_twi.o
  5. BIN
      lib/libssd1306/bld/intf/spi/ssd1306_spi.o
  6. BIN
      lib/libssd1306/bld/intf/spi/ssd1306_spi_avr.o
  7. BIN
      lib/libssd1306/bld/intf/spi/ssd1306_spi_usi.o
  8. BIN
      lib/libssd1306/bld/intf/ssd1306_interface.o
  9. BIN
      lib/libssd1306/bld/intf/uart/ssd1306_uart_builtin.o
  10. BIN
      lib/libssd1306/bld/intf/vga/atmega328p/vga128x64.o
  11. BIN
      lib/libssd1306/bld/intf/vga/atmega328p/vga96x40.o
  12. BIN
      lib/libssd1306/bld/intf/vga/esp32/CompositeOutput.o
  13. BIN
      lib/libssd1306/bld/intf/vga/esp32/vga128x64.o
  14. BIN
      lib/libssd1306/bld/intf/vga/vga.o
  15. BIN
      lib/libssd1306/bld/lcd/lcd_common.o
  16. BIN
      lib/libssd1306/bld/lcd/lcd_il9163.o
  17. BIN
      lib/libssd1306/bld/lcd/lcd_ili9341.o
  18. BIN
      lib/libssd1306/bld/lcd/lcd_pcd8544.o
  19. BIN
      lib/libssd1306/bld/lcd/oled_sh1106.o
  20. BIN
      lib/libssd1306/bld/lcd/oled_ssd1306.o
  21. BIN
      lib/libssd1306/bld/lcd/oled_ssd1325.o
  22. BIN
      lib/libssd1306/bld/lcd/oled_ssd1327.o
  23. BIN
      lib/libssd1306/bld/lcd/oled_ssd1331.o
  24. BIN
      lib/libssd1306/bld/lcd/oled_ssd1351.o
  25. BIN
      lib/libssd1306/bld/lcd/oled_template.o
  26. BIN
      lib/libssd1306/bld/lcd/vga_monitor.o
  27. BIN
      lib/libssd1306/bld/libssd1306.a
  28. BIN
      lib/libssd1306/bld/nano_engine/canvas.o
  29. BIN
      lib/libssd1306/bld/nano_engine/core.o
  30. BIN
      lib/libssd1306/bld/nano_gfx.o
  31. BIN
      lib/libssd1306/bld/sprite_pool.o
  32. BIN
      lib/libssd1306/bld/ssd1306_16bit.o
  33. BIN
      lib/libssd1306/bld/ssd1306_1bit.o
  34. BIN
      lib/libssd1306/bld/ssd1306_8bit.o
  35. BIN
      lib/libssd1306/bld/ssd1306_console.o
  36. BIN
      lib/libssd1306/bld/ssd1306_fonts.o
  37. BIN
      lib/libssd1306/bld/ssd1306_generic.o
  38. BIN
      lib/libssd1306/bld/ssd1306_hal/arduino/platform.o
  39. BIN
      lib/libssd1306/bld/ssd1306_hal/avr/platform.o
  40. BIN
      lib/libssd1306/bld/ssd1306_hal/energia/platform.o
  41. BIN
      lib/libssd1306/bld/ssd1306_hal/linux/platform.o
  42. BIN
      lib/libssd1306/bld/ssd1306_hal/mingw/platform.o
  43. BIN
      lib/libssd1306/bld/ssd1306_hal/stm32/platform.o
  44. BIN
      lib/libssd1306/bld/ssd1306_hal/template/platform.o
  45. BIN
      lib/libssd1306/bld/ssd1306_menu.o
  46. BIN
      lib/libssd1306/bld/ssd1306_uart.o
  47. 361
      src/framebuffer.c
  48. 63
      src/framebuffer.h
  49. 6
      src/framebuffer_config.h

@ -77,7 +77,7 @@ size: $(TARGET).elf
# Build the display library # Build the display library
lib/libssd1306/bld/libssd1306.a: lib/libssd1306/bld/libssd1306.a:
$(MAKE) -C lib/libssd1306/ -f Makefile.avr MCU=atmega328p $(MAKE) -C lib/libssd1306/src/ -f Makefile.avr MCU=atmega328p
$(TARGET).elf: $(OBJECTS) lib/libssd1306/bld/libssd1306.a | $(BUILD_DIR) $(TARGET).elf: $(OBJECTS) lib/libssd1306/bld/libssd1306.a | $(BUILD_DIR)
$(LD) $(CFLAGS) $(LFLAGS) -o $@ $^ lib/libssd1306/bld/libssd1306.a $(LD) $(CFLAGS) $(LFLAGS) -o $@ $^ lib/libssd1306/bld/libssd1306.a

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -4,138 +4,134 @@
#include "framebuffer.h" #include "framebuffer.h"
#define MIN(a,b) ((a)>(b)?(b):(a)) #define MIN(a, b) ((a)>(b)?(b):(a))
#define MAX(a,b) ((a)>(b)?(a):(b)) #define MAX(a, b) ((a)>(b)?(a):(b))
#include <string.h> #include <string.h>
uint8_t fb[(FBH / 8) * FBW]; uint8_t fb[(FBH / 8) * FBW];
/** Fill with a vertical pattern, 1 byte */ /** Fill with a vertical pattern, 1 byte */
void fb_fill(uint8_t pattern) { void fb_fill(uint8_t pattern)
{
memset(fb, pattern, sizeof(fb)); memset(fb, pattern, sizeof(fb));
} }
void fb_clear() { static void draw_mask(fbsize_t idx, uint8_t mask, uint8_t color)
fb_fill(0); {
if (color != 0) {
fb[idx] |= mask;
} else {
fb[idx] &= ~mask;
}
} }
void fb_px(uint8_t x, uint8_t y, uint8_t color) { void fb_px(fbpos_t x, fbpos_t y, uint8_t color)
if (x >= FBW || y >= FBH) return; {
const uint8_t row = y / 8; if (x >= FBW || y >= FBH) { return; }
const uint8_t rowrem = y % 8; const fbpos_t row = y / 8;
const uint16_t cell = (uint16_t) x + (uint16_t) row * FBW; const fbpos_t rowrem = y % 8;
if (color) { const fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
fb[cell] |= (1 << rowrem); draw_mask(cell, 1 << rowrem, color);
}
uint8_t fb_getpx(fbpos_t x, fbpos_t y)
{
if (x >= FBW || y >= FBH) { return 0; }
const fbpos_t row = y / 8;
const fbpos_t rowrem = y % 8;
const fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
if (fb[cell] & (1 << rowrem)) {
return 0xFF;
} else { } else {
fb[cell] &= ~(1 << rowrem); return 0x00;
} }
} }
void fb_hline(uint8_t x, uint8_t y, uint8_t w, uint8_t color) { void fb_hline(fbpos_t x, fbpos_t y, fbpos_t w, uint8_t color)
if (x >= FBW || y >= FBH) return; {
if (x >= FBW || y >= FBH) { return; }
w = MIN(FBW - x, w); w = MIN(FBW - x, w);
const uint8_t row = y / 8; const fbpos_t row = y / 8;
const uint8_t rowrem = y % 8; const fbpos_t rowrem = y % 8;
uint16_t cell = (uint16_t) x + (uint16_t) row * FBW; fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
for(uint8_t i = 0; i < w; i++) { for (uint8_t i = 0; i < w; i++) {
if (color) { draw_mask(cell, 1 << rowrem, color);
fb[cell] |= (1 << rowrem);
} else {
fb[cell] &= ~(1 << rowrem);
}
cell++; cell++;
} }
} }
void fb_vline(uint8_t x, uint8_t y, uint8_t h, uint8_t color) { void fb_vline(fbpos_t x, fbpos_t y, fbpos_t h, uint8_t color)
if (x >= FBW || y >= FBH) return; {
if (x >= FBW || y >= FBH) { return; }
h = MIN(FBH - y - 1, h); h = MIN(FBH - y - 1, h);
const uint8_t row = y / 8; const fbpos_t row = y / 8;
const uint8_t rowrem = y % 8; const fbpos_t rowrem = y % 8;
uint16_t cell = (uint16_t) x + (uint16_t) row * FBW; uint16_t cell = (uint16_t) x + (uint16_t) row * FBW;
if (rowrem + h < 8) { if (rowrem + h < 8) {
// all within one cell // all within one cell
uint8_t mask = (0xFF << rowrem) & (0xFF >> (h-rowrem)); const uint8_t mask = (0xFF << rowrem) & (0xFF >> (8 - h - rowrem));
if (color) { draw_mask(cell, mask, color);
fb[cell] |= mask;
} else {
fb[cell] &= ~mask;
}
return; return;
} else { } else {
// First // First
uint8_t mask = (0xFF << rowrem); draw_mask(cell, 0xFF << rowrem, color);
if (color) { h -= (rowrem == 0 ? 8 : (8 - rowrem));
fb[cell] |= mask;
} else {
fb[cell] &= ~mask;
}
h -= rowrem;
uint8_t whole_cells = h / 8; const fbpos_t whole_cells = h / 8;
h -= whole_cells * 8; if (whole_cells > 0) {
for(uint8_t i = 0; i < whole_cells; i++) { h -= whole_cells * 8;
cell += FBW; for (fbpos_t i = 0; i < whole_cells; i++) {
if (color) { cell += FBW;
fb[cell] = 0xFF; draw_mask(cell, 0xFF, color);
} else {
fb[cell] = 0;
} }
} }
// last // last
mask = (0xFF >> (8-h)); cell += FBW;
if (color) { draw_mask(cell, 0xFF >> (8 - h), color);
fb[cell] |= mask;
} else {
fb[cell] &= ~mask;
}
} }
} }
void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color) { void fb_rect(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, uint8_t color)
if (x >= FBW || y >= FBH) return; {
w = MIN(FBW - x - 1, w); if (x >= FBW || y >= FBH) { return; }
h = MIN(FBH - y - 1, h); w = MIN(FBW - x, w);
const uint8_t row = y / 8; h = MIN(FBH - y, h);
const uint8_t rowrem = y % 8; const fbpos_t row = y / 8;
uint16_t cell = (uint16_t) x + (uint16_t) row * FBW; const fbpos_t rowrem = y % 8;
fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
if (rowrem + h <= 8) { if (w == 1 && h == 1) {
fb_px(x, y, color);
} else if (w == 1) {
fb_vline(x, y, h, color);
} else if (h == 1) {
fb_hline(x, y, w, color);
} else if (rowrem + h <= 8) {
// all within one cell // all within one cell
uint8_t mask = (0xFF << rowrem) & (0xFF >> (8 - (h - rowrem))); uint8_t mask = (0xFF << rowrem) & (0xFF >> (8 - h - rowrem));
for(uint8_t i = 0; i < w; i++) { for (fbpos_t i = 0; i < w; i++) {
if (color) { draw_mask(cell + i, mask, color);
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
} }
return; return;
} else { } else {
// First // First
uint8_t mask = (0xFF << rowrem); uint8_t mask = (0xFF << rowrem);
for(uint8_t i = 0; i < w; i++) { for (fbpos_t i = 0; i < w; i++) {
if (color) { draw_mask(cell + i, mask, color);
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
} }
h -= 8 - rowrem; h -= 8 - rowrem;
uint8_t whole_cells = h / 8; const fbpos_t whole_cells = h / 8;
h -= whole_cells * 8; if (whole_cells > 0) {
for(uint8_t j = 0; j < whole_cells; j++) { h -= whole_cells * 8;
cell += FBW; for (fbpos_t j = 0; j < whole_cells; j++) {
for(uint8_t i = 0; i < w; i++) { cell += FBW;
if (color) { for (fbpos_t i = 0; i < w; i++) {
fb[cell + i] = 0xFF; draw_mask(cell + i, 0xFF, color);
} else {
fb[cell + i] = 0;
} }
} }
} }
@ -143,109 +139,64 @@ void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color) {
cell += FBW; cell += FBW;
// last // last
mask = (0xFF >> (8-h)); mask = (0xFF >> (8 - h));
for(uint8_t i = 0; i < w; i++) { for (fbpos_t i = 0; i < w; i++) {
if (color) { draw_mask(cell + i, mask, color);
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
} }
} }
} }
void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t color) { void fb_frame(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t thickness, uint8_t color)
if (x >= FBW || y >= FBH) return; {
const uint8_t w0 = w; if (thickness == 0) {
const uint8_t h0 = h; return;
} else if (thickness == 1) {
fb_hline(x, y, w, color);
fb_vline(x, y, h, color);
fb_hline(x, y + h - 1, w, color);
fb_vline(x + w - 1, y, h, color);
} else {
fb_rect(x, y, w, thickness, color);
fb_rect(x, y + h - thickness, w, thickness, color);
fb_rect(x, y + thickness, thickness, h - 2 * thickness, color);
fb_rect(x + w - thickness, y + thickness, thickness, h - 2 * thickness, color);
}
}
void fb_bitmap(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, uint8_t color)
{
if (x >= FBW || y >= FBH) { return; }
const fbpos_t w0 = w;
w = MIN(FBW - x - 1, w); w = MIN(FBW - x - 1, w);
h = MIN(FBH - y - 1, h); h = MIN(FBH - y - 1, h);
const uint8_t row = y / 8; const fbpos_t row = y / 8;
const uint8_t rowrem = y % 8; const fbpos_t rowrem = y % 8;
uint16_t cell = (uint16_t) x + (uint16_t) row * FBW; fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
if (rowrem + h <= 8) { if (rowrem + h <= 8) {
for(uint8_t i = 0; i < w; i++) { for (fbpos_t i = 0; i < w; i++) {
// all within one cell // all within one cell
uint8_t mask = (map[i] & (0xFF >> (8-h))) << rowrem; const uint8_t mask = (map[i] & (0xFF >> (8 - h))) << rowrem;
if (color) { draw_mask(cell + i, mask, color);
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
} }
return; return;
} else if (rowrem == 0) {
// Optimization
uint8_t mapc0 = 0;
// First
for(uint8_t i = 0; i < w; i++) {
uint8_t mask = map[i];
if (color) {
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
}
h -= 8;
// Middle
uint8_t whole_cells = h / 8;
h -= whole_cells * 8;
for(uint8_t j = 0; j < whole_cells; j++) {
cell += FBW;
mapc0 += w0;
for(uint8_t i = 0; i < w; i++) {
uint8_t mask = map[i + mapc0];
if (color) {
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
}
}
// last
mapc0 += w0;
cell += FBW;
// last
for(uint8_t i = 0; i < w; i++) {
uint8_t mask = map[i + mapc0] & (0xFF >> (8-h));
if (color) {
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
}
} else { } else {
uint8_t mapc0 = 0; fbsize_t mapc0 = 0;
// Draw the bitmap slice-by-slice based on how rows of the bitmap intersect with rows of the canvas.
// This could be optimized to walk each row of the canvas only once, but the code would get bigger.
while (h > 0) { while (h > 0) {
// First for (fbpos_t i = 0; i < w; i++) {
for (uint8_t i = 0; i < w; i++) { const uint8_t mask = (map[i + mapc0] & (0xFF >> rowrem)) << rowrem;
uint8_t mask = (map[i + mapc0] & (0xFF >> rowrem)) << rowrem; draw_mask(cell + i, mask, color);
if (color) {
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
}
} }
//mapc0 += w0;
cell += FBW; cell += FBW;
// leftover of the first row in map if (rowrem != 0) {
for (fbpos_t i = 0; i < w; i++) {
// last const uint8_t mask = (map[i + mapc0] & (0xFF << (8 - rowrem))) >> (8 - rowrem);
for (uint8_t i = 0; i < w; i++) { draw_mask(cell + i, mask, color);
uint8_t mask = (map[i + mapc0] & (0xFF << (8 - rowrem))) >> (8 - rowrem);
if (color) {
fb[cell + i] |= mask;
} else {
fb[cell + i] &= ~mask;
} }
} }
@ -259,3 +210,73 @@ void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, u
} }
} }
enum SevenSegBars {
T = 1, RT = 2, RB = 4, B = 8, LB = 16, LT = 32, M = 64
};
static const uint8_t PROGMEM seven[] = {
[0] = T | RT | RB | B | LB | LT,
[1] = RT | RB,
[2] = T | RT | M | LB | B,
[3] = T | RT | M | RB | B,
[4] = RT | RB | M | LT,
[5] = T | LT | M | RB | B,
[6] = T | LT | LB | B | RB | M,
[7] = T | RT | RB,
[8] = T | LT | RT | LB | RB | B | M,
[9] = T | LT | RT | RB | B | M,
};
fbpos_t fb_7seg_dig(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, uint8_t digit, uint8_t color)
{
const uint8_t mask = digit > 9 ? 0 : pgm_read_byte(&seven[digit]);
const fbpos_t wi = w - th * 2;
const fbpos_t hi = (h - th * 3) / 2;
bool bcolor = !color; // changed for XOR
fb_rect(x + th,
y,
wi,
th, bcolor ^ (bool) (mask & T));
fb_rect(x + th,
y + th + hi,
wi,
th, bcolor ^ (bool) (mask & M));
fb_rect(x + th,
y + th * 2 + hi * 2,
wi,
th, bcolor ^ (bool) (mask & B));
fb_rect(x,
y + th,
th,
hi, bcolor ^ (bool) (mask & LT));
fb_rect(x + th + wi,
y + hi + th,
th,
hi, bcolor ^ (bool) (mask & LB));
fb_rect(x + th + wi,
y + th,
th,
hi, bcolor ^ (bool) (mask & RT));
fb_rect(x + th + wi,
y + th * 2 + hi,
th,
hi, bcolor ^ (bool) (mask & RB));
return w;
}
fbpos_t fb_7seg_period(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, uint8_t color)
{
const fbpos_t hi = (h - th * 3) / 2;
fb_rect(x, y + hi * 2 + th * 2, th, th, color);
return th;
}

@ -13,6 +13,9 @@
#define FBSET 0xFF #define FBSET 0xFF
#define FBCLEAR 0x00 #define FBCLEAR 0x00
typedef uint16_t fbsize_t;
typedef uint8_t fbpos_t;
/// Framebuffer backing array. /// Framebuffer backing array.
/// ///
/// The format is the native format for SSD1306: array of bytes representing pixels in 8 rows at once, LSB is the topmost row. /// The format is the native format for SSD1306: array of bytes representing pixels in 8 rows at once, LSB is the topmost row.
@ -26,16 +29,62 @@
/// and more bytes continue rows 8-15 and so on /// and more bytes continue rows 8-15 and so on
extern uint8_t fb[(FBH / 8) * FBW]; extern uint8_t fb[(FBH / 8) * FBW];
/// Fill the entire screen with a byte pattern.
/// Use 0xFF or 0x00 for a solid fill. Other patterns may be used to create horizontal stripes.
void fb_fill(uint8_t pattern); void fb_fill(uint8_t pattern);
void fb_clear(void);
void fb_px(uint8_t x, uint8_t y, uint8_t color); /// Clear the display (fill with 0x00)
void fb_hline(uint8_t x, uint8_t y, uint8_t w, uint8_t color); static inline void fb_clear(void)
void fb_vline(uint8_t x, uint8_t y, uint8_t h, uint8_t color); {
void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color); fb_fill(0);
void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t color); }
/// Set a single pixel
void fb_px(fbpos_t x, fbpos_t y, uint8_t color);
/// Get pixel color
uint8_t fb_getpx(fbpos_t x, fbpos_t y);
/// Draw a horizontal line
void fb_hline(fbpos_t x, fbpos_t y, fbpos_t w, uint8_t color);
/// Draw a vertical line
void fb_vline(fbpos_t x, fbpos_t y, fbpos_t h, uint8_t color);
/// Draw a filled rect
void fb_rect(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, uint8_t color);
/// Draw a frame (unfilled rect)
void fb_frame(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t thickness, uint8_t color);
/// Draw a bitmap
void fb_bitmap(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, uint8_t color);
/// Draw a 7-segment digit. Returns its width (without spacing)
///
/// \param x - pos X (left top)
/// \param y - pos Y (left top)
/// \param w - full digit width
/// \param h - full digit height; will be adjusted down if needed
/// \param th - thickness
/// \param digit - digit 0-9
/// \return width taken
fbpos_t fb_7seg_dig(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, uint8_t digit, uint8_t color);
/// Draw a 7-segment period. Returns its width (without spacing).
/// Digit height is (w * 2 - th)
///
/// \param x - pos X (digit left top)
/// \param y - pos Y (digit left top)
/// \param w - full digit width
/// \param h - full digit height; will be adjusted down if needed
/// \param th - thickness
/// \return width taken
fbpos_t fb_7seg_period(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, uint8_t color);
/// Output the framebuffer array `fb` to the display device. /// Output the framebuffer array `fb` to the display device.
///
/// The user must implement this
extern void fb_blit(void); extern void fb_blit(void);
#endif //FRAMEBUFFER_H #endif //FRAMEBUFFER_H

@ -4,4 +4,10 @@
#define FBW 128 #define FBW 128
#define FBH 32 #define FBH 32
#include <avr/pgmspace.h>
/*
#define PROGMEM
#define pgm_read_byte(adr) (*adr)
*/
#endif /* FRAMEBUFFER_CONFIG_H */ #endif /* FRAMEBUFFER_CONFIG_H */

Loading…
Cancel
Save