Lesen und Schreiben der Motornachlaufzeit ins EEPROM mit Entertaste zugefügt
This commit is contained in:
parent
f675cc5a56
commit
ae78a24959
|
@ -2,6 +2,7 @@
|
|||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
|
@ -84,6 +85,8 @@ B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00
|
|||
};
|
||||
unsigned char MotorDelay = 1;
|
||||
unsigned char MotorDelayOld = 0;
|
||||
unsigned char MotorDelayEEPROM = 0;
|
||||
unsigned long previousMillis = 0;
|
||||
int UP = 0;
|
||||
int DOWN = 0;
|
||||
int ENTER = 0;
|
||||
|
@ -95,7 +98,6 @@ void setup() {
|
|||
pinMode(SCK, INPUT);
|
||||
pinMode(MOSI, INPUT);
|
||||
pinMode(MISO, INPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
|
@ -108,9 +110,13 @@ pinMode(MISO, INPUT);
|
|||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
MotorDelayEEPROM = EEPROM.read(0);
|
||||
MotorDelay = MotorDelayEEPROM;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
UP = digitalRead(SCK);
|
||||
DOWN = digitalRead(MOSI);
|
||||
ENTER = digitalRead(MISO);
|
||||
|
@ -119,7 +125,7 @@ void loop() {
|
|||
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.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM);
|
||||
display.display();
|
||||
MotorDelayOld = MotorDelay;
|
||||
}
|
||||
|
@ -129,6 +135,21 @@ void loop() {
|
|||
if(DOWN == 1 && DOWN != DOWN_OLD){
|
||||
MotorDelay--;
|
||||
}
|
||||
if (ENTER == 1){
|
||||
if (currentMillis - previousMillis >= 2000) {
|
||||
// save the last time you blinked the LED
|
||||
previousMillis = currentMillis;
|
||||
EEPROM.write(0, MotorDelay);
|
||||
MotorDelayEEPROM = EEPROM.read(0);
|
||||
display.clearDisplay();
|
||||
display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM);
|
||||
display.display();
|
||||
MotorDelayOld = MotorDelay;
|
||||
}
|
||||
}
|
||||
else {
|
||||
previousMillis = currentMillis;
|
||||
}
|
||||
UP_OLD = UP;
|
||||
DOWN_OLD = DOWN;
|
||||
ENTER_OLD = ENTER;
|
||||
|
|
|
@ -35,6 +35,7 @@ Arduino Programm für unsere EtiMa
|
|||
- Adadfruit 1306 Library
|
||||
- Adafruit GFX library
|
||||
- Adafruit_BusIO library
|
||||
- EEPROM.h library
|
||||
- EtiMa: LT 50 (Von verschiedensten chinesischen Herstellern unter ähnlichem Namen)
|
||||
|
||||
Bei der in Deutschland gekauften Etiketiermaschine war trotz Metalgehäuse
|
||||
|
|
Loading…
Reference in a new issue