Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- https://playground.arduino.cc/Code/HoldButton
- */
- void setup() {
- }
- int RA8875_INT = 10;
- int buttonhoch = LOW;
- int buttonrunter = LOW;
- int buttonlinks = LOW;
- int buttonrechts = LOW;
- int menuchoice = 0;
- int uhrstunde = 0;
- int uhrminute = 0;
- int timerminute = 0;
- int timersekunde = 0;
- int timeredittoggle = 0;
- int timeredit = 0;
- int timereditdigit = 0; //1-4
- int digitplace[4] = {50, 100, 150, 200};
- int setdigithelper = LOW;
- int ledState[4] = {LOW, LOW, LOW, LOW}; // ledState used to set the LED
- int buttonwait = 1000;
- int buttonpin = 15;
- int menu = 0; //0=timer 1=clock
- boolean button_press = false;
- // Generally, you should use "unsigned long" for variables that hold time
- unsigned long previousMillis[6] = {500, 500, 500, 500, 500, 500}; // will store last time LED was updated
- unsigned long currentMillis = millis();
- // constants won't change:
- const long interval[6] = {1000, 1000, 1000, 1000, 1000, 1000};
- //Menü 1x kurz =Uhr/Timer.. 1x Lang = Uhr/Timer stellen Uhr->/Sommer/Winterzeit
- //menuchoice: 0=Uhr, 1=Timer 2=menu (5Sekunden drücken.. Uhr stellen, Sommerzeit)
- void loop() {
- currentMillis = millis();
- checkBlinking();
- //switchmenuchoice();
- int countspeed = 0;
- if (menu == 1) {
- }
- switch (menuchoice) {
- case 1:
- //Screen clear
- //4 Optionen geviertelt/halbiert
- //
- break;
- default: ; break;
- }
- }
- void checkBlinking() {
- if (currentMillis - previousMillis[0] >= interval[0]) {
- previousMillis[0] = currentMillis;
- timeredit = !timeredit;
- if (setdigithelper == LOW)
- {
- timeredit == LOW; setdigithelper = HIGH;
- }
- if (timeredit == LOW) {
- //Paint zahl timereditdigit digitplace
- } else {
- //Paint Black Space timereditdigit
- }
- }
- }
- void switchmenuchoice() {
- if (currentMillis - previousMillis[1] >= interval[1]) {
- previousMillis[1] = currentMillis;
- timeredit = !timeredit;
- if (menuchoice == 0) {
- menuchoice = 1;
- //Uhr
- } else {
- menuchoice = 0;
- //Timer
- }
- }
- }
- int button = 0;
- int helpinterval = 1000;
- void longhold() {
- if (currentMillis - previousMillis[2] >= interval[2]) {
- previousMillis[2] = currentMillis;
- timeredit = !timeredit;
- if (menuchoice == 0) {
- menuchoice = 1;
- //Paint zahl timereditdigit digitplace
- } else {
- menuchoice = 0;
- //Paint Black Space timereditdigit
- }
- } else if (button == LOW) {
- previousMillis[2] = currentMillis;
- interval[2] - 100 ;
- }
- }
- int countwait = 1000;
- void hold_button() {
- if(buttonpin == LOW ){
- if ( currentMillis - previousMillis[3] >= interval[3])
- {
- if (currentMillis - previousMillis[4] >= interval[4]) {
- previousMillis[4] = currentMillis;
- button_press = true;
- } else {
- previousMillis[4] = currentMillis;
- }
- }else{
- button_press = false;
- }
- }else button_press = false;
- }
- void countspeed() {
- if (button_press)
- if (currentMillis - previousMillis[5] >= countwait) {
- previousMillis[5] = currentMillis;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement