Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "TID12_10.h"
- #include <Keypad.h>
- TID MyTid(7, 5, 6); //D7->SDA, D5->SCL, D6->MRQ
- const byte ROWS = 1;
- const byte COLS = 3;
- char keys[ROWS][COLS] = {
- {'1', '2', '3'}
- };
- byte rowPins[ROWS] = {11}; //connect to the row pinouts of the keypad
- byte colPins[COLS] = {8, 9, 10}; //connect to the column pinouts of the keypad
- Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
- int setmode = 0; //0 nem set - 1 hour - 2 minute
- void setup() {
- MyTid.space1_init(0, 10); //(first position,last position) (i. e. just the first digit)
- MyTid.space2_init(0, 10); //use digit 2 to 10
- MyTid.clear_space(1);
- MyTid.clear_space(2);
- for (int i = 0; i < 40; i++) {
- //MyTid.display_message(" START ", 4, 2);
- MyTid.display_message(" JEZUS SZERET ", 2, 2);
- delay(50);
- }
- resetspaces();
- delay(1000);
- }
- void setbutton() {
- if (setmode == 0) {
- resetspaces();
- MyTid.display_message("SET HOUR ", 1, 2);
- MyTid.setting_hour();
- setmode = 1;
- }
- else if (setmode == 1) {
- resetspaces();
- MyTid.display_message("SET MINUTE", 1, 2);
- MyTid.setting_minute();
- setmode = 2;
- }
- else if (setmode == 2) {
- resetspaces();
- MyTid.display_message("*CLOCK SET*", 1, 2);
- MyTid.setting_stop();
- delay(3000);
- resetspaces();
- setmode = 0;
- }
- else setmode = 0;
- }
- void resetspaces() {
- MyTid.clear_space(1);
- MyTid.clear_space(2);
- }
- void upbutton() {
- if (setmode == 1) MyTid.hour_ff();
- if (setmode == 2) MyTid.min_ff();
- }
- void downbutton() {
- if (setmode == 1) MyTid.hour_rev();
- if (setmode == 2) MyTid.min_rev();
- }
- void loop() {
- MyTid.clear_all_symbols();
- char key = keypad.getKey();
- if (key != NO_KEY) {
- switch (key) {
- case '1' :
- setbutton();
- break;
- case '2' :
- upbutton();
- break;
- case '3' :
- downbutton();
- break;
- default :
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement