Advertisement
j0h

Harmonograh_Interface

j0h
Dec 30th, 2022 (edited)
1,757
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Bounce.h>
  2. #include <Wire.h>
  3. #include "RTClib.h" //adafruit time lib
  4. Bounce button2 = Bounce(2, 10);  
  5. Bounce button3 = Bounce(3, 10);  // <pin><debounce time in ms>
  6.  
  7. RTC_DS1307 rtc;
  8.  
  9. void setup() {
  10.   pinMode(2, INPUT_PULLUP);
  11.   pinMode(3, INPUT_PULLUP);
  12.  
  13.     Serial.begin(57600);
  14.     Wire.begin();
  15.     rtc.begin();
  16.  
  17.   if (! rtc.isrunning()) {
  18.    // Serial.println("RTC is NOT running!");
  19.     // following line sets the RTC to the date & time this sketch was compiled
  20.     rtc.adjust(DateTime(__DATE__, __TIME__));
  21.   }
  22. }
  23. void neu();
  24. void save(uint32_t unix_time);
  25. int dtime=200;
  26. void loop() {
  27.   //delay(150);
  28. uint32_t unix_time = rtc.now().unixtime();  
  29. //Serial.println(unix_time);
  30.   button2.update();
  31.   button3.update();
  32.   if (button2.fallingEdge()) {
  33. neu();
  34.   }
  35. if (button3.fallingEdge()) {
  36. save(unix_time);
  37.   }
  38.  }
  39. void neu(){
  40.      Keyboard.press(MODIFIERKEY_CTRL);
  41.      Keyboard.press(KEY_N);
  42.     delay(dtime);
  43.      Keyboard.release(MODIFIERKEY_CTRL);
  44.      Keyboard.release(KEY_N);
  45.        delay(dtime);
  46.      Keyboard.press(KEY_TAB);
  47.     // delay(dtime);
  48.      Keyboard.release(KEY_TAB);
  49.      Keyboard.press(KEY_ENTER);
  50.       //delay(dtime);
  51.      Keyboard.release(KEY_ENTER);
  52.      delay(dtime);
  53.   }
  54.  
  55. void save(uint32_t unix_time){
  56.      Keyboard.press(MODIFIERKEY_CTRL);
  57.      Keyboard.press(KEY_S);
  58.     delay(dtime);
  59.      Keyboard.release(MODIFIERKEY_CTRL);
  60.      Keyboard.release(KEY_S);
  61.        delay(dtime);
  62.      Keyboard.print("img/");
  63.      Keyboard.print(unix_time);
  64.      Keyboard.print(".png");
  65.      //Keyboard.press(KEY_TAB);
  66.     // delay(dtime);
  67.      Keyboard.release(KEY_TAB);
  68.      Keyboard.press(KEY_ENTER);
  69.       //delay(dtime);
  70.      Keyboard.release(KEY_ENTER);
  71.      delay(dtime);
  72.      neu();
  73.   }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement