|
| 1 | + |
| 2 | +#include "heltec.h" |
| 3 | +#include "Arduino.h" |
| 4 | + |
| 5 | + SSD1306Wire display(0x3c, SDA_OLED, SCL_OLED, RST_OLED); |
| 6 | + |
| 7 | +void printBuffer(void) { |
| 8 | + // Initialize the log buffer |
| 9 | + // allocate memory to store 8 lines of text and 30 chars per line. |
| 10 | + display.setLogBuffer(5, 30); |
| 11 | + |
| 12 | + // Some test data |
| 13 | + const char* test[] = { |
| 14 | + "Hello", |
| 15 | + "World" , |
| 16 | + "----", |
| 17 | + "Show off", |
| 18 | + "how", |
| 19 | + "the log buffer", |
| 20 | + "is", |
| 21 | + "working.", |
| 22 | + "Even", |
| 23 | + "scrolling is", |
| 24 | + "working" |
| 25 | + }; |
| 26 | + |
| 27 | + for (uint8_t i = 0; i < 11; i++) { |
| 28 | + display.clear(); |
| 29 | + // Print to the screen |
| 30 | + display.println(test[i]); |
| 31 | + // Draw it to the internal screen buffer |
| 32 | + display.drawLogBuffer(0, 0); |
| 33 | + // Display it on the screen |
| 34 | + display.display(); |
| 35 | + delay(500); |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +void VextON(void) |
| 40 | +{ |
| 41 | + pinMode(Vext,OUTPUT); |
| 42 | + digitalWrite(Vext, LOW); |
| 43 | +} |
| 44 | + |
| 45 | +void VextOFF(void) //Vext default OFF |
| 46 | +{ |
| 47 | + pinMode(Vext,OUTPUT); |
| 48 | + digitalWrite(Vext, HIGH); |
| 49 | +} |
| 50 | + |
| 51 | +void setup() { |
| 52 | + |
| 53 | + VextON(); |
| 54 | + delay(100); |
| 55 | + |
| 56 | + display.init(); |
| 57 | + display.clear(); |
| 58 | + display.display(); |
| 59 | + |
| 60 | + display.setContrast(255); |
| 61 | + |
| 62 | + printBuffer(); |
| 63 | + delay(1000); |
| 64 | + |
| 65 | + display.setTextAlignment(TEXT_ALIGN_CENTER); |
| 66 | + display.clear(); |
| 67 | + display.display(); |
| 68 | + display.screenRotate(ANGLE_0_DEGREE); |
| 69 | + display.setFont(ArialMT_Plain_16); |
| 70 | + display.drawString(64, 32-16/2, "ROTATE_0"); |
| 71 | + display.display(); |
| 72 | + delay(2000); |
| 73 | + |
| 74 | + display.clear(); |
| 75 | + display.display(); |
| 76 | + display.screenRotate(ANGLE_90_DEGREE); |
| 77 | + display.setFont(ArialMT_Plain_10); |
| 78 | + display.drawString(32, 64-10/2, "ROTATE_90"); |
| 79 | + display.display(); |
| 80 | + delay(2000); |
| 81 | + |
| 82 | + display.clear(); |
| 83 | + display.display(); |
| 84 | + display.screenRotate(ANGLE_180_DEGREE); |
| 85 | + display.setFont(ArialMT_Plain_16); |
| 86 | + display.drawString(64, 32-16/2, "ROTATE_180"); |
| 87 | + display.display(); |
| 88 | + delay(2000); |
| 89 | + |
| 90 | + display.clear(); |
| 91 | + display.display(); |
| 92 | + display.screenRotate(ANGLE_270_DEGREE); |
| 93 | + display.setFont(ArialMT_Plain_10); |
| 94 | + display.drawString(32, 64-10/2, "ROTATE_270"); |
| 95 | + display.display(); |
| 96 | + delay(2000); |
| 97 | +} |
| 98 | + |
| 99 | +void loop() { } |
0 commit comments