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 <Wire.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_SSD1306.h>
|
#include <Adafruit_SSD1306.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||||
#define SCREEN_HEIGHT 64 // OLED display height, 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 MotorDelay = 1;
|
||||||
unsigned char MotorDelayOld = 0;
|
unsigned char MotorDelayOld = 0;
|
||||||
|
unsigned char MotorDelayEEPROM = 0;
|
||||||
|
unsigned long previousMillis = 0;
|
||||||
int UP = 0;
|
int UP = 0;
|
||||||
int DOWN = 0;
|
int DOWN = 0;
|
||||||
int ENTER = 0;
|
int ENTER = 0;
|
||||||
|
@ -95,7 +98,6 @@ void setup() {
|
||||||
pinMode(SCK, INPUT);
|
pinMode(SCK, INPUT);
|
||||||
pinMode(MOSI, INPUT);
|
pinMode(MOSI, INPUT);
|
||||||
pinMode(MISO, INPUT);
|
pinMode(MISO, INPUT);
|
||||||
|
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||||
|
@ -108,9 +110,13 @@ pinMode(MISO, INPUT);
|
||||||
// Clear the buffer
|
// Clear the buffer
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.display();
|
display.display();
|
||||||
|
MotorDelayEEPROM = EEPROM.read(0);
|
||||||
|
MotorDelay = MotorDelayEEPROM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
UP = digitalRead(SCK);
|
UP = digitalRead(SCK);
|
||||||
DOWN = digitalRead(MOSI);
|
DOWN = digitalRead(MOSI);
|
||||||
ENTER = digitalRead(MISO);
|
ENTER = digitalRead(MISO);
|
||||||
|
@ -119,7 +125,7 @@ void loop() {
|
||||||
display.setCursor(0,0); // Start at top-left corner
|
display.setCursor(0,0); // Start at top-left corner
|
||||||
if (MotorDelay != MotorDelayOld){
|
if (MotorDelay != MotorDelayOld){
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayOld);
|
display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM);
|
||||||
display.display();
|
display.display();
|
||||||
MotorDelayOld = MotorDelay;
|
MotorDelayOld = MotorDelay;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +135,21 @@ void loop() {
|
||||||
if(DOWN == 1 && DOWN != DOWN_OLD){
|
if(DOWN == 1 && DOWN != DOWN_OLD){
|
||||||
MotorDelay--;
|
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;
|
UP_OLD = UP;
|
||||||
DOWN_OLD = DOWN;
|
DOWN_OLD = DOWN;
|
||||||
ENTER_OLD = ENTER;
|
ENTER_OLD = ENTER;
|
||||||
|
|
|
@ -35,6 +35,7 @@ Arduino Programm für unsere EtiMa
|
||||||
- Adadfruit 1306 Library
|
- Adadfruit 1306 Library
|
||||||
- Adafruit GFX library
|
- Adafruit GFX library
|
||||||
- Adafruit_BusIO library
|
- Adafruit_BusIO library
|
||||||
|
- EEPROM.h library
|
||||||
- EtiMa: LT 50 (Von verschiedensten chinesischen Herstellern unter ähnlichem Namen)
|
- EtiMa: LT 50 (Von verschiedensten chinesischen Herstellern unter ähnlichem Namen)
|
||||||
|
|
||||||
Bei der in Deutschland gekauften Etiketiermaschine war trotz Metalgehäuse
|
Bei der in Deutschland gekauften Etiketiermaschine war trotz Metalgehäuse
|
||||||
|
|
Loading…
Reference in a new issue