Laboratorio CAD / Mbed 2 deprecated Cassaforte5dic18

Dependencies:   mbed Servo KeypadLib TextLCD

Files at this revision

API Documentation at this revision

Comitter:
Virgi97
Date:
Tue Dec 04 10:11:08 2018 +0000
Child:
1:02c938489de7
Commit message:
Cassciaforte

Changed in this revision

Cassaforte.cpp Show annotated file Show diff for this revision Revisions of this file
Cassaforte.h Show annotated file Show diff for this revision Revisions of this file
Servo.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cassaforte.cpp	Tue Dec 04 10:11:08 2018 +0000
@@ -0,0 +1,65 @@
+#include "Cassaforte.h"
+#include "TextLCD.h"
+#include "Servo.h"
+I2C i2c(D14, D15);
+//InterruptIn button(PC_13);
+TextLCD_I2C lcd(&i2c, 0x4E, TextLCD_I2C::LCD16x2, TextLCD_I2C::HD44780);
+DigitalOut led(LED1);
+Servo servo(D3);
+bool sensore = false;
+
+void inizializza(){
+    lcd.setMode(TextLCD_I2C::DispOn);
+    lcd.setCursor(TextLCD_I2C::CurOn_BlkOn);
+    if (sensore == true)
+        chiuso();
+        else aperto();
+    }
+
+void scrivi(char parola[]){
+    lcd.cls();
+    lcd.printf("%s\n", parola);
+    }
+    
+void cambioCodice(){
+    led=!led;
+    scrivi("Cambio codice   di apertura");
+    lcd.setAddress(11,1);
+    wait(3);
+    lcd.cls();
+    scrivi("Digitare il nuo_vo codice:");
+    lcd.setAddress(10,1);
+    inserimento();
+    led=!led;
+    }
+    
+void inserimento(){
+        /*for (int i=0; i<4; i++){
+            wait(1);
+            lcd.putc(i);
+            wait(1);
+            lcd.setAddress(11+i,1);
+            }*/
+        wait(1);
+        lcd.putc('1');
+        wait(1);
+        lcd.setAddress(11,1);
+        lcd.putc('2');
+        wait(1);
+        lcd.setAddress(12,1);
+        lcd.putc('3');
+        wait(1);
+        lcd.setAddress(13,1);
+        lcd.putc('4');
+        wait(1); 
+    }
+    
+void chiuso(){
+    servo.position(-90);
+    
+    }
+    
+void aperto(){
+    servo.position(-90);
+    
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cassaforte.h	Tue Dec 04 10:11:08 2018 +0000
@@ -0,0 +1,10 @@
+#ifndef Cassaforte_H
+#define Cassaforte_H
+#include "mbed.h"
+void inizializza();
+void scrivi(char parola[]);
+void cambioCodice();
+void inserimento();
+void chiuso();
+void aperto();
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Tue Dec 04 10:11:08 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Dec 04 10:11:08 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/foreste/code/TextLCD/#fa02cddf2fd8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 04 10:11:08 2018 +0000
@@ -0,0 +1,51 @@
+#include "Cassaforte.h"
+//#include "mbed.h"
+//#include <TextLCD.h>
+//I2C i2c(D14, D15);
+//TextLCD_I2C lcd(&i2c, 0x4E, TextLCD_I2C::LCD16x2, TextLCD_I2C::HD44780);
+/*DigitalOut led(LED1);
+void scrivi(char parola[]);
+void cambioCodice();
+void inserisci();*/
+InterruptIn button(PC_13);
+
+int main() {
+    /*lcd.setMode(TextLCD_I2C::DispOn);
+    lcd.setCursor(TextLCD_I2C::CurOn_BlkOn);*/
+    inizializza();
+    button.rise(&cambioCodice);
+        while(1) {
+            scrivi("Cassaforte");
+            wait(0.2);
+        }
+}
+
+/*void scrivi(char parola[]){
+    lcd.cls();
+    lcd.printf("%s\n", parola);
+    }
+    
+void cambioCodice(){
+    scrivi("Cambio codice   di apertura");
+    lcd.setAddress(11,1);
+    wait(3);
+    lcd.cls();
+    scrivi("Digitare il nuo_ vo codice:");
+    lcd.setAddress(10,1);
+    inserisci();
+    }
+    
+void inserisci(){
+        wait(1);
+        lcd.putc('1');
+        wait(1);
+        lcd.setAddress(11,1);
+        lcd.putc('2');
+        wait(1);
+        lcd.setAddress(12,1);
+        lcd.putc('3');
+        wait(1);
+        lcd.setAddress(13,1);
+        lcd.putc('4');
+        wait(1);        
+    }*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 04 10:11:08 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file