Startgrafik, und Buttonfunktionen zum einstellen der Motornachlaufzeit zugefügt
This commit is contained in:
parent
878bb2f440
commit
f675cc5a56
|
@ -11,10 +11,91 @@
|
|||
// On an arduino UNO: A4(SDA), A5(SCL)
|
||||
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
|
||||
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
|
||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
#define LOGO_HEIGHT 64
|
||||
#define LOGO_WIDTH 64
|
||||
static const unsigned char PROGMEM logo_bmp[] =
|
||||
{ B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B00000000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B00000000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B00000000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B00000000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B11110000, B00001111, B00001111, B00000000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B00001111, B00001111, B00000000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B00001111, B00001111, B00000000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B00001111, B00001111, B00000000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B11111111, B00001111, B11110000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B11111111, B00001111, B11110000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B11111111, B00001111, B11110000, B11110000, B00000000,
|
||||
B00000000, B00000000, B11110000, B11111111, B00001111, B11110000, B11110000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B11110000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B11110000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B11110000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00000000, B11110000, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00001111, B11111111, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00001111, B11111111, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00001111, B11111111, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00001111, B00001111, B11111111, B00001111, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B11111111, B00001111, B11110000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00001111, B00001111, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00001111, B00001111, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00001111, B00001111, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00001111, B00001111, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B11110000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
|
||||
};
|
||||
unsigned char MotorDelay = 1;
|
||||
unsigned char MotorDelayOld = 0;
|
||||
int UP = 0;
|
||||
int DOWN = 0;
|
||||
int ENTER = 0;
|
||||
int UP_OLD = 0;
|
||||
int DOWN_OLD = 0;
|
||||
int ENTER_OLD = 0;
|
||||
|
||||
void setup() {
|
||||
pinMode(SCK, INPUT);
|
||||
pinMode(MOSI, INPUT);
|
||||
pinMode(MISO, INPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
|
@ -22,18 +103,43 @@ void setup() {
|
|||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
// Show initial display buffer contents on the screen --
|
||||
// the library initializes this with an Adafruit splash screen.
|
||||
display.display();
|
||||
testdrawbitmap(); // Draw a small bitmap image
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
|
||||
// testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
UP = digitalRead(SCK);
|
||||
DOWN = digitalRead(MOSI);
|
||||
ENTER = digitalRead(MISO);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(SSD1306_WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
if (MotorDelay != MotorDelayOld){
|
||||
display.clearDisplay();
|
||||
display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayOld);
|
||||
display.display();
|
||||
MotorDelayOld = MotorDelay;
|
||||
}
|
||||
if(UP == 1 && UP != UP_OLD){
|
||||
MotorDelay++;
|
||||
}
|
||||
if(DOWN == 1 && DOWN != DOWN_OLD){
|
||||
MotorDelay--;
|
||||
}
|
||||
UP_OLD = UP;
|
||||
DOWN_OLD = DOWN;
|
||||
ENTER_OLD = ENTER;
|
||||
}
|
||||
|
||||
void testdrawbitmap(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.drawBitmap(
|
||||
(display.width() - LOGO_WIDTH ) / 2,
|
||||
(display.height() - LOGO_HEIGHT) / 2,
|
||||
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
|
||||
display.display();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue