Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WiFi.h> // WiFi library for network
- #include <NtpClientLib.h> // NTP Client library fot network time
- #define b 0 //b szegmens
- #define a 2 //a szegmens
- #define f 4 //f szegmens
- #define g 5 //g szegmens
- #define c 12 //c szegmens
- #define d 13 //d szegmens
- #define e 14 //e szegmens
- #define d1 15
- #define d2 16
- #define d3 17
- #define d4 18
- #define dot 19 //dp led
- unsigned long szeg[80] = {
- 0b00001000000000000000, //x0xxx
- 0b00001001000000000001, //x1xxx
- 0b00001110000000100101, //x2xxx
- 0b00001011000000100101, //x3xxx
- 0b00001001000000110001, //x4xxx
- 0b00001011000000110100, //x5xxx
- 0b00001111000000110100, //x6xxx
- 0b00001001000000000101, //x7xxx
- 0b00001111000000110101, //x8xxx
- 0b00001011000000110101, //x9xxx
- 0b00010111000000010101, //xx0xx
- 0b00010001000000000001, //xx1xx
- 0b00010110000000100101, //xx2xx
- 0b00010011000000100101, //xx3xx
- 0b00010001000000110001, //xx4xx
- 0b00010011000000110100, //xx5xx
- 0b00010111000000110100, //xx6xx
- 0b00010001000000000101, //xx7xx
- 0b00010111000000110101, //xx8xx
- 0b00010011000000110101, //xx9xx
- 0b00100111000000010101, //xxx0x
- 0b00100001000000000001, //xxx1x
- 0b00100110000000100101, //xxx2x
- 0b00100011000000100101, //xxx3x
- 0b00100001000000110001, //xxx4x
- 0b00100011000000110100, //xxx5x
- 0b00100111000000110100, //xxx6x
- 0b00100001000000000101, //xxx7x
- 0b00100111000000110101, //xxx8x
- 0b00100011000000110101, //xxx9x
- 0b01000111000000010101, //xxxx1
- 0b01000001000000000001, //xxxx1
- 0b01000110000000100101, //xxxx2
- 0b01000011000000100101, //xxxx3
- 0b01000001000000110001, //xxxx4
- 0b01000011000000110100, //xxxx5
- 0b01000111000000110100, //xxxx6
- 0b01000001000000000101, //xxxx7
- 0b01000111000000110101, //xxxx8
- 0b01000011000000110101, //xxxx9
- 0b10001000000000000000, //.0xxx
- 0b10001001000000000001, //.1xxx
- 0b10001110000000100101, //.2xxx
- 0b10001011000000100101, //.3xxx
- 0b10001001000000110001, //.4xxx
- 0b10001011000000110100, //.5xxx
- 0b10001111000000110100, //.6xxx
- 0b10001001000000000101, //.7xxx
- 0b10001111000000110101, //.8xxx
- 0b10001011000000110101, //.9xxx
- 0b10010111000000010101, //.x0xx
- 0b10010001000000000001, //.x1xx
- 0b10010110000000100101, //.x2xx
- 0b10010011000000100101, //.x3xx
- 0b10010001000000110001, //.x4xx
- 0b10010011000000110100, //.x5xx
- 0b10010111000000110100, //.x6xx
- 0b10010001000000000101, //.x7xx
- 0b10010111000000110101, //.x8xx
- 0b10010011000000110101, //.x9xx
- 0b10100111000000010101, //.xx0x
- 0b10100001000000000001, //.xx1x
- 0b10100110000000100101, //.xx2x
- 0b10100011000000100101, //.xx3x
- 0b10100001000000110001, //.xx4x
- 0b10100011000000110100, //.xx5x
- 0b10100111000000110100, //.xx6x
- 0b10100001000000000101, //.xx7x
- 0b10100111000000110101, //.xx8x
- 0b10100011000000110101, //.xx9x
- 0b11000111000000010101, //.xxx1
- 0b11000001000000000001, //.xxx1
- 0b11000110000000100101, //.xxx2
- 0b11000011000000100101, //.xxx3
- 0b11000001000000110001, //.xxx4
- 0b11000011000000110100, //.xxx5
- 0b11000111000000110100, //.xxx6
- 0b11000001000000000101, //.xxx7
- 0b11000111000000110101, //.xxx8
- 0b11000011000000110101, //.xxx9
- };
- const char* ssid = "WiFi"; // wifi SSD
- const char* password = "Password"; // wifi password
- String NTPServer = "NTP server"; // NTP server address
- int8_t minutesTimeZone = 0;
- int8_t timeZone = 1; // timezone in central europe (hour)
- String ora1, ora2, perc1, perc2, masod, ido;
- int ORA1,ORA2, PERC1, PERC2, MIN;
- int DELAY =1;
- int pont =0;
- int tomb[4];
- int kiirni=0;
- int digit = 0;
- int counter = 0;
- /* create a hardware timer */
- hw_timer_t * timer = NULL;
- //------------- Kijelző frissítő interrupt rutin --------------------
- void IRAM_ATTR onTimer(){
- kiirni = (tomb[digit] + (10*digit));
- if (counter>=200) kiirni += 40; //pontot kigyújtani
- if (counter>=400) counter=0;
- REG_WRITE(GPIO_OUT_W1TS_REG, szeg[kiirni]);//GPIO2 HIGH (set)
- REG_WRITE(GPIO_OUT_W1TC_REG, ~szeg[kiirni]);//GPIO2 LOW (clear)
- digit++;
- counter++;
- if (digit>=4) digit=0;
- }
- void setup()
- {
- pinMode(a, OUTPUT);
- pinMode(b, OUTPUT);
- pinMode(c, OUTPUT);
- pinMode(d, OUTPUT);
- pinMode(e, OUTPUT);
- pinMode(f, OUTPUT);
- pinMode(g, OUTPUT);
- pinMode(d1, OUTPUT);
- pinMode(d2, OUTPUT);
- pinMode(d3, OUTPUT);
- pinMode(d4, OUTPUT);
- pinMode(dot, OUTPUT);
- WiFi.begin(ssid, password); // initialize WiFi
- NTP.begin (NTPServer, timeZone, true, minutesTimeZone); // initialize NTP
- NTP.setInterval (1440000); // sync interval
- /* Use 1st timer of 4 */
- /* 1 tick take 1/(80MHZ/80) = 1us so we set divider 80 and count up */
- timer = timerBegin(0, 80, true);
- /* Attach onTimer function to our timer */
- timerAttachInterrupt(timer, &onTimer, true);
- /* Set alarm to call onTimer function every second 1 tick is 1us
- => 1 second is 1000000us */
- /* Repeat the alarm (third parameter) */
- timerAlarmWrite(timer, 5000, true); //100Hz
- /* Start an alarm */
- timerAlarmEnable(timer);
- }
- void loop()
- {
- ido = NTP.getTimeDateString ();
- ora1 = (ido.substring(0,1));
- ora2 = (ido.substring(1,2));
- perc1 = (ido.substring(3,4));
- perc2 = (ido.substring(4,5));
- masod = (ido.substring(6,8));
- tomb[0] = ora1.toInt();
- tomb[1] = ora2.toInt();
- tomb[2] = perc1.toInt();
- tomb[3] = perc2.toInt();
- Serial.print(counter);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment