![](/media/cache/profiles/Pass2.jpg.50x50_q85.jpg)
KL25Z program that calculates the difference in days, hours, minutes, between two dates. Needs a terminal on the PC side to communicate with the program. Terminal must have local echo on. Terminal Data input needs some improvement.
Diff: main.cpp
- Revision:
- 4:b0884b059d7e
- Parent:
- 3:add864dd8eab
--- a/main.cpp Fri May 22 08:58:12 2015 +0000 +++ b/main.cpp Fri May 22 09:24:10 2015 +0000 @@ -3,10 +3,10 @@ LESEM ENAUTICA 2014 Luis Sousa aluno 11001 */ -//#include <stdio.h> +#include <stdio.h> -#include "mbed.h" -Serial pc(USBTX, USBRX); +//#include "mbed.h" +//Serial pc(USBTX, USBRX); int readkbd(void); int bissexto(int ano); @@ -173,8 +173,8 @@ printf("\r\n\nNovo Calculo de datas? (S/N) "); // opcao=getc(); - scanf(" %c", &opcao); -// opcao = getchar(); */ +// scanf(" %c", &opcao); + opcao = getchar(); if((opcao =='S')||(opcao =='s')) continuar=1; else { continuar=0; @@ -278,14 +278,14 @@ int sair=0; while (!sair) { //enquanto nao for enter, le - char ch = pc.getc(); + char ch = getchar(); if(ch >= '0' && ch <= '9') { // 0 .. 9? value = (value * 10) + (ch - '0'); // sim, acumula - pc.putc(ch); + putchar(ch); } else { if (ch==13) sair=1; //else if (ch==8) printf("\b"); - else printf(">C%i<",ch); + //else printf(">C%i<",ch); } } printf("\r\nValor introduzido: %i",value);