Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
todd-herbert authored Mar 26, 2021
1 parent e797bba commit f85b8e6
Show file tree
Hide file tree
Showing 72 changed files with 24,221 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/bitmap_data/bitmap_data.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//DEMO: Bitmap Data
//=================================
//You may sometime have the need to draw raw bitmap data to the screen
//This is is possible with drawBitmap()
//One possible application here is that drawBitmap accepts data from SRAM, where as drawXBitmap will only draw from PROGMEM

#include "heltec_213r_v2.h"

//Sample set of raw bitmap data
#include "pencils.h"

Heltec_213R_V2 panel(/* DC PIN */ 8, /* CS PIN */ 10, /* BUSY PIN */ 7);

void setup() {
panel.begin();

panel.setRotation(1); //Don't forget to set the correct orientation, so your image fits how you intended

//Bitmap image data comes in all sorts of weird formats. To get it to work, you might have to play with the settings.
panel.setFlip(panel.FLIP_NONE); //If your image comes out flipped, change this
panel.setDefaultColor(panel.BLACK); //If you get a negative of your image, try setting the background to black, and drawing the data as white

while( panel.calculating() ) {
panel.drawBitmap(0, 0, pencils, pencils_width, pencils_height, panel.WHITE);
}
}

void loop() {}
130 changes: 130 additions & 0 deletions examples/bitmap_data/pencils.h

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions examples/fonts/fonts.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//DEMO: Using fonts
//================================================

#include "heltec_213r_v2.h"

//Include the font you want from the Fonts folder. I believe that they take up a bit of memory, so maybe don't include them all
#include "Fonts/FreeSerifBold12pt7b.h"

Heltec_213R_V2 panel(/* DC PIN */ 8, /* CS PIN */ 10, /* BUSY PIN */ 7);

void setup() {
panel.begin();
panel.setRotation(1); //Landscape, text fits better that way

panel.setFont( &FreeSerifBold12pt7b ); //Pass (the address of) the font to the library
panel.setTextColor(panel.RED); //Red text

while( panel.calculating() ) {

panel.setCursor(30, 50); //Set the (word-processor-like) cursor to the abritrary position of x=30, y=50
panel.print("Fancy fonty text.");

} //Note: setCursor needs to run inside of the calculating() loop, as it moves along with each letter typed.
//This means we need to shunt it back to the start again when we recalculate the next section of the screen
}

void loop() { }
55 changes: 55 additions & 0 deletions examples/getTextBounds/getTextBounds.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//DEMO: Placing text accurately with getTextBounds()
//================================================
//NOTE: THIS FUNCTION DOES NOT APPEAR TO WORK CORRECTLY WITH THE BUILT-IN FALLBACK FONT
//So be sure to use setFont()!
//This is an error in GFX_Root and not an error with the Heltec_213R_V2 library

#include "heltec_213r_v2.h"

#include "Fonts/FreeSerifBoldItalic9pt7b.h" //Include the particular font

Heltec_213R_V2 panel(/* DC PIN */ 8, /* CS PIN */ 10, /* BUSY PIN */ 7);

void setup() {
panel.begin();
panel.setRotation(1); //Landscape

panel.setFont( &FreeSerifBoldItalic9pt7b ); //Pass (the address of) the font to the library
const char *text = {"Fancy fonty text."};

//Precisely place our text using getTextBounds()
//================================================


int16_t text_top_edge; //These will receive information about how much space our text will take up
int16_t text_left_edge;
uint16_t text_width;
uint16_t text_height;

//This will tell us where the bounds of the text would be, if we setCursor(0,0) and then print(text)
//Note that the variables are passed by reference
panel.getTextBounds(text, 0, 0, &text_left_edge, &text_top_edge, &text_width, &text_height);

//We can use this information in our loop to help place the string
//We'll show off and alight our text right
//setCursor()'s Y value is the imaginary line that the characters sit on. In this case, slightly above the base of the screen
uint16_t cursor_demo_x = panel.right() - text_width;
uint16_t cursor_demo_y = panel.bottom() - 30;



//Graphics GO!
//==============================================

while( panel.calculating() ) {

panel.setCursor(cursor_demo_x, cursor_demo_y);
panel.print(text);

//Lets draw a line across the screen at cursor height, to really make the point clear
panel.drawLine(0, cursor_demo_y, panel.right(), cursor_demo_y, panel.RED);

}
}

void loop() { }
33 changes: 33 additions & 0 deletions examples/rotation/rotation.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//DEMO: setRotation() printing text different orientations
//================================================

#include "heltec_213r_v2.h"

Heltec_213R_V2 panel(/* DC PIN */ 8, /* CS PIN */ 10, /* BUSY PIN */ 7);

void setup() {
panel.begin();
panel.setTextSize(2);

while( panel.calculating() ) {

panel.setRotation(0);
panel.setCursor(10, 10);
panel.print("Zero");

panel.setRotation(1);
panel.setCursor(10, 10);
panel.print("One");

panel.setRotation(2);
panel.setCursor(10, 10);
panel.print("Two");

panel.setRotation(3);
panel.setCursor(10, 10);
panel.print("Three");

}
}

void loop() { }
30 changes: 30 additions & 0 deletions examples/shapes/shapes.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//DEMO: Shapes - Kandinsky would be proud
//================================================

#include "heltec_213r_v2.h"


Heltec_213R_V2 panel(/* DC PIN */ 8, /* CS PIN */ 10, /* BUSY PIN */ 7);

void setup() {
panel.begin();
panel.setRotation(3); //Landscape, rotated 270 degrees from upright

panel.setDefaultColor(panel.RED); //Our background color is now red

while( panel.calculating() ) {

panel.drawRoundRect(120, 20, 80, 60, 10, panel.WHITE); //Hollow
panel.fillRoundRect(130, 30, 85, 65, 10, panel.WHITE); //Filled

panel.fillRect(160, 50, 30, 30, panel.RED); //Drawing with our background color can help "erase" things

panel.fillCircle(40, -10, 25, panel.BLACK); //Drawing out of bounds is allowed
panel.drawLine(40, -10, 300, 500, panel.WHITE); // <-- !!! But don't go crazy as every pixel gets processed, even if most of them are offscreen

panel.fillTriangle(0,0, 30,panel.bottom(), 60,panel.bottom(), panel.BLACK); //Handy functions like bottom() make drawing easier
panel.fillCircle(panel.centerX(), panel.centerY(), 20, panel.BLACK); //Right in the center
}
}

void loop() {}
22 changes: 22 additions & 0 deletions examples/spot/spot.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//DEMO: A bare minimum example - one big ol' spot
//================================================

#include "heltec_213r_v2.h"

Heltec_213R_V2 panel(/* DC PIN */ 8, /* CS PIN */ 10, /* BUSY PIN */ 7);

void setup() {
//Get everything ready
panel.begin();

//All drawing commands go intside this WHILE
while ( panel.calculating() ) {
//================================
//Graphics commands here
//For example:
panel.fillCircle(50, 100, 20, panel.RED);
//================================
}
}

void loop() {}
Loading

0 comments on commit f85b8e6

Please sign in to comment.