Programski kod sata/brojača. Izveden pomoću 4 tipkala i LCD zaslonom rezolucije 16x2 točaka.

Dependencies:   mbed Bljeskalica TextLCD

Prikaz trenutnog vremena i datuma na LCD zaslonu rezolucije 16x2 točaka. U gornjem redu prikazuje se datum u formatu: dan/mjesec/godina, a u donjem redu vrijeme u formatu: sat/minuta/sekunda. Podešenje vremena i datuma je pomoću tipkala i to u inkrementima po 1 (sekunda, minuta, sat, dan, mjesec, godina).

Files at this revision

API Documentation at this revision

Comitter:
dariojankovic
Date:
Thu Jun 11 22:28:08 2020 +0000
Commit message:
Proba

Changed in this revision

Bljeskalica.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
tipkala.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 1c9b141ec08b Bljeskalica.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bljeskalica.lib	Thu Jun 11 22:28:08 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dariojankovic/code/Bljeskalica/#93d73c414233
diff -r 000000000000 -r 1c9b141ec08b TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu Jun 11 22:28:08 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 1c9b141ec08b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 11 22:28:08 2020 +0000
@@ -0,0 +1,24 @@
+#include "main.h"
+
+int main() {
+    
+    DAN_SAT.mode(PullUp);
+    MJESEC_MINUTA.mode(PullUp);
+    GODINA_SEKUNDA.mode(PullUp);
+    DATUM.mode(PullUp);
+    VRIJEME.mode(PullUp);
+    
+    debounce.start();
+    DAN_SAT.fall(&toggle_DAN_SAT);
+    MJESEC_MINUTA.fall(&toggle_MJESEC_MINUTA);
+    GODINA_SEKUNDA.fall(&toggle_GODINA_SEKUNDA);
+    DATUM.fall(&toggle_DATUM);
+    
+    led.flash(5);
+        
+    LCD.cls();
+        
+    while(1) {
+        ZASLON();
+    wait(1); }           
+ }
\ No newline at end of file
diff -r 000000000000 -r 1c9b141ec08b main.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Thu Jun 11 22:28:08 2020 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "Flasher.h"
+#include "tipkala.h"
+
+TextLCD LCD (p19, p20, p21, p22, p23, p24); //RS,E,D0,D1,D2,D3
+
+Flasher led(LED1);
+
+int MENU = 0; 
+
+void ZASLON();
+
+void vrijeme() {
+    set_time(1577836800+offset); }
+
+void ZASLON() {
+    time_t seconds = time(NULL);
+        
+        if (MENU==0) {
+        LCD.cls(); 
+        LCD.locate(2,0);
+        char day[16];
+
+        strftime(day, 16, "%d/%m/%y %a\n", localtime(&seconds));
+        LCD.printf("%s", day);
+        
+        char time[16];
+        strftime(time, 16, "%H:%M:%S\n", localtime(&seconds));
+        LCD.locate(4,1);
+        LCD.printf("%s", time);}
+}
+
diff -r 000000000000 -r 1c9b141ec08b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 11 22:28:08 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
diff -r 000000000000 -r 1c9b141ec08b tipkala.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tipkala.h	Thu Jun 11 22:28:08 2020 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+
+InterruptIn DAN_SAT (p5);
+InterruptIn MJESEC_MINUTA (p6);
+InterruptIn GODINA_SEKUNDA(p7);
+InterruptIn DATUM(p8);
+InterruptIn VRIJEME(p9);
+
+Ticker STOPERICA;
+Timer debounce;
+
+uint32_t offset = 0;
+int UVIJET = 0;
+
+void vrijeme();
+
+
+void toggle_DAN_SAT(){
+ if(debounce.read_ms()>250) { 
+        switch (UVIJET) {
+        case 1: offset+=86400;
+          break;
+        case 2: offset+=3600;
+          break;         }
+    debounce.reset();
+    vrijeme(); }
+ }
+
+void toggle_MJESEC_MINUTA() {
+ if(debounce.read_ms()>250) {
+        switch (UVIJET) {
+        case 1: offset+=2678400;
+          break;
+        case 2: offset+=60;
+          break; }
+    debounce.reset(); 
+    vrijeme(); }
+ }
+  
+void toggle_GODINA_SEKUNDA() {
+ if(debounce.read_ms()>250)  {
+        switch (UVIJET) {
+        case 1: offset+=31622400;
+          break;
+        case 2: offset+=1;
+          break; }
+    debounce.reset(); 
+    vrijeme(); }
+ }
+ 
+ void toggle_DATUM() {
+ if(debounce.read_ms()>250) {
+  if (UVIJET<=1){
+        UVIJET+=1; }
+  else UVIJET=0;
+    debounce.reset(); }}
\ No newline at end of file