|
| 1 | +// |
| 2 | +// Anti-aliased font demo |
| 3 | +// |
| 4 | +#include <stdio.h> |
| 5 | +#include "esp_sleep.h" |
| 6 | +#include "driver/gpio.h" |
| 7 | +#include "driver/rtc_io.h" |
| 8 | +#include "driver/i2c.h" |
| 9 | +#include "freertos/FreeRTOS.h" |
| 10 | +#include "freertos/task.h" |
| 11 | + |
| 12 | +#include "../../../../src/FastEPD.h" |
| 13 | +#include "../../../../Fonts/Roboto_Black_80.h" |
| 14 | +#include "../../../../Fonts/Roboto_Black_40.h" |
| 15 | + |
| 16 | +FASTEPDSTATE bbep, virt; |
| 17 | + |
| 18 | +void app_main(void) |
| 19 | +{ |
| 20 | +int rc; |
| 21 | + |
| 22 | +// We have enough PSRAM to allocate full sized buffers |
| 23 | +// for a full screen virtual device and the physical |
| 24 | +// device (M5Stack PaperS3 in this case - 960x540) |
| 25 | +// We'll draw on the virtual memory device, then copy |
| 26 | +// it to the framebuffer of the physical device and |
| 27 | +// do a 16-gray update |
| 28 | + |
| 29 | + bbepInitPanel(&virt, BB_PANEL_VIRTUAL, 0); |
| 30 | + // A virtual panel must be given a size |
| 31 | + bbepSetPanelSize(&virt, 960, 540, 0); |
| 32 | + |
| 33 | + // Predefined devices can have a display size |
| 34 | + // associated with them already |
| 35 | + rc = bbepInitPanel(&bbep, BB_PANEL_M5PAPERS3, 20000000); |
| 36 | + if (rc == BBEP_SUCCESS) { |
| 37 | + bbepSetMode(&virt, BB_MODE_4BPP); // source and destination |
| 38 | + bbepSetMode(&bbep, BB_MODE_4BPP); // need to be the same bit depth |
| 39 | + bbepFillScreen(&virt, 0xf); // fill with white |
| 40 | + |
| 41 | + // The y coordinate represents the character baseline |
| 42 | + // not the upper left corner |
| 43 | + bbepWriteStringCustom(&virt, Roboto_Black_40, 0, 200, "Normal, 1-bit font", BBEP_BLACK); |
| 44 | + virt.anti_alias = 1; // turn on antialiased mode |
| 45 | + // Use a font with a point size 2x bigger to get the same |
| 46 | + // size output in anti-alias mode. (80 vs 40pt) |
| 47 | + bbepWriteStringCustom(&virt, Roboto_Black_80, 0, 400, "Antialiased, 2-bit font", BBEP_BLACK); |
| 48 | + |
| 49 | + // Draw the virtual device framebuffer onto the |
| 50 | + // physical device framebuffer at (0,0) |
| 51 | + bbepDrawSprite(&virt, &bbep, 0, 0, -1); |
| 52 | + |
| 53 | + // Draw the physical device framebuffer onto the Eink panel |
| 54 | + bbepFullUpdate(&bbep, CLEAR_SLOW, 0, NULL); |
| 55 | + } |
| 56 | +} |
0 commit comments