Add OLED example
This commit is contained in:
parent
68f7e6027c
commit
cb9fa0cffe
63
OLED/OLED.ino
Normal file
63
OLED/OLED.ino
Normal file
@ -0,0 +1,63 @@
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
static const unsigned char PROGMEM image_window[] = {
|
||||
0x7f, 0x80, 0x7e, 0x80, 0x7f, 0x80, 0x40, 0x80,
|
||||
0xfe, 0x80, 0x82, 0x80, 0x83, 0x80, 0xfe, 0x00};
|
||||
static const unsigned char PROGMEM image_devil[] = {
|
||||
0x30, 0x03, 0x00, 0x60, 0x01, 0x80, 0xe0, 0x01, 0xc0, 0xf3, 0xf3,
|
||||
0xc0, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xc0, 0x7f, 0xff, 0x80, 0x7f,
|
||||
0xff, 0x80, 0x7f, 0xff, 0x80, 0xef, 0xfd, 0xc0, 0xe7, 0xf9, 0xc0,
|
||||
0xe3, 0xf1, 0xc0, 0xe1, 0xe1, 0xc0, 0xf1, 0xe3, 0xc0, 0xff, 0xff,
|
||||
0xc0, 0x7f, 0xff, 0x80, 0x7b, 0xf7, 0x80, 0x3d, 0x2f, 0x00, 0x1e,
|
||||
0x1e, 0x00, 0x0f, 0xfc, 0x00, 0x03, 0xf0, 0x00};
|
||||
|
||||
Adafruit_SSD1306 display(128, 64, &Wire, 4);
|
||||
|
||||
unsigned int COUNT;
|
||||
|
||||
void setup() {
|
||||
COUNT = 0;
|
||||
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1, 2);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
|
||||
display.setCursor(30, 10);
|
||||
display.println("Loading");
|
||||
display.display();
|
||||
// delay(200);
|
||||
display.clearDisplay();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
display.clearDisplay();
|
||||
|
||||
display.drawRect(0, 0, 128, 51, 1);
|
||||
display.drawRect(0, 50, 128, 14, 1);
|
||||
|
||||
display.drawBitmap(6, 24, image_devil, 18, 21, 1);
|
||||
display.drawBitmap(5, 53, image_window, 9, 8, 1);
|
||||
|
||||
display.setTextColor(1);
|
||||
display.setTextSize(1);
|
||||
display.setCursor(17, 53);
|
||||
display.setTextWrap(false);
|
||||
display.print("by Alexander Popov");
|
||||
|
||||
display.setCursor(31, 23);
|
||||
display.setTextWrap(false);
|
||||
display.print("count:");
|
||||
|
||||
display.setTextSize(2);
|
||||
display.setCursor(6, 5);
|
||||
display.setTextWrap(false);
|
||||
display.print("Brake");
|
||||
|
||||
display.setTextSize(3);
|
||||
display.setCursor(71, 9);
|
||||
display.setTextWrap(false);
|
||||
display.print(COUNT);
|
||||
|
||||
display.display();
|
||||
}
|
4
OLED/compile_and_upload.sh
Executable file
4
OLED/compile_and_upload.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
arduino-cli compile -b arduino:avr:uno .
|
||||
arduino-cli upload . -p /dev/ttyACM0 -b arduino:avr:uno
|
Loading…
Reference in New Issue
Block a user