LV03_US_Grupa03_Tim07_Zadatak01 Haris Imamovic Halilbegovic Kemal

Dependencies:   N5110 mbed

Fork of US2016_LV3_Z1 by Emir Sokic

Files at this revision

API Documentation at this revision

Comitter:
2016US_HarisImamovic
Date:
Mon Mar 21 17:47:31 2016 +0000
Parent:
0:6ebfd28a8b0c
Child:
2:369ce3ec6248
Commit message:
LV03_US_Grupa03_Tim07_Zadatak01

Changed in this revision

N5110.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
--- a/N5110.lib	Wed Mar 09 08:30:01 2016 +0000
+++ b/N5110.lib	Mon Mar 21 17:47:31 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/eencae/code/N5110/#ba8addc061ea
+http://mbed.org/users/eencae/code/N5110/#d7d51a91afef
--- a/main.cpp	Wed Mar 09 08:30:01 2016 +0000
+++ b/main.cpp	Mon Mar 21 17:47:31 2016 +0000
@@ -1,22 +1,58 @@
 #include "mbed.h"
 #include "N5110.h"
+#include "string.h"
 #define dp23 P0_0
 
+#define STRUJA 0.00033  // 3.3V/10kOhm = 0.33 mA
+#define NAPAJANJE 3.3   // Vcc = 3.3V
+
 //N5110 lcd(VCC,SCE,RST,DC,MOSI,SCLK,LED));
 N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
 
 DigitalOut enable(dp14);
+AnalogIn napon(dp9);
+DigitalIn taster(dp1);
+
+char rezultat[5], buffer[5], strBuffer[14];
+
+void ispisiNapon() {
+    lcd.clear();
+    
+    float tmp2 = napon*NAPAJANJE;
+    sprintf(strBuffer, "U = %2.2fV", tmp2);
+    lcd.printString(strBuffer, 0, 0);
+  
+}
+
+void ispisiOtpor() {
+    lcd.clear();
+    
+    float tmp = (napon/STRUJA)*NAPAJANJE;
+    sprintf(strBuffer, "R = %2.2fO", tmp);
+    lcd.printString(strBuffer, 0, 0);
+}
+
+
+int counter = 0;
+
+void klik() { 
+    if(counter%2 == 1) {
+        ispisiNapon();
+        wait(0.4);
+    }
+    else {
+        ispisiOtpor();
+        wait(0.4);
+    }   
+}
 
 int main() {
-    
-    //deaktivacija led dioda
-    enable=1;
-    
-    //inicijalizacija displeja
-    lcd.init();
-    
-    //prikaz stringa
-    lcd.printString("Mi volimo US!",0,0);
-    
-    while(1);
+    enable = 1;
+    lcd.init();    
+
+    while(1) {
+        if(taster == 1) counter++;
+        klik();
+        wait(0.2);
+    }
 }