|
| 1 | +// |
| 2 | +// FastEPD Sprite Example |
| 3 | +// Written by Larry Bank August 23, 2025 |
| 4 | +// Copyright (c) 2025 BitBank Software, Inc. All rights reserved |
| 5 | +// |
| 6 | +// Sprites in FastEPD refer to virtual drawing surfaces. |
| 7 | +// in other words, instances of the FastEPD class without |
| 8 | +// a physical Eink panel. Their purpose is to allow easy |
| 9 | +// re-use of prepared graphics to composite a scene or to |
| 10 | +// make use of the FastEPD font and graphics functions for |
| 11 | +// an external program to utilize. |
| 12 | +// |
| 13 | +// 1-bpp sprites can be drawn on 4-bpp surfaces, but not the reverse |
| 14 | +// |
| 15 | +#include <FastEPD.h> |
| 16 | +#include "Roboto_Regular_20.h" |
| 17 | +#include "courierprime_14.h" |
| 18 | +FASTEPD epaper; |
| 19 | +FASTEPD sprite1, sprite2; |
| 20 | + |
| 21 | +void setup() |
| 22 | +{ |
| 23 | + sprite1.initSprite(128, 64); // allocate the memory for 2 small drawing surfaces |
| 24 | + sprite2.initSprite(128, 64); |
| 25 | + epaper.initPanel(BB_PANEL_V7_RAW); // defaults to 1-bit mode |
| 26 | + epaper.setPanelSize(1280, 720); |
| 27 | + epaper.fillScreen(BBEP_WHITE); |
| 28 | + epaper.fullUpdate(); // clear the screen to white to begin |
| 29 | + sprite1.fillScreen(BBEP_WHITE); |
| 30 | + sprite1.setFont(courierprime_14); |
| 31 | + sprite1.setCursor(0, 24); |
| 32 | + sprite1.print("Sprite1"); |
| 33 | + sprite2.fillScreen(BBEP_WHITE); |
| 34 | + sprite2.setFont(Roboto_Regular_20); |
| 35 | + sprite2.setCursor(0, 32); |
| 36 | + sprite2.print("Sprite2"); |
| 37 | + for (int i=0; i<epaper.width(); i += 160) { |
| 38 | + epaper.drawSprite(&sprite1, i, 0); |
| 39 | + epaper.drawSprite(&sprite2, i, 256); |
| 40 | + } |
| 41 | + epaper.fullUpdate(); |
| 42 | +} /* setup() */ |
| 43 | + |
| 44 | +void loop() |
| 45 | +{ |
| 46 | +} /* loop() */ |
| 47 | + |
0 commit comments