Cita.
In illio tempor Caesare dixit ad milites suos: ¡Milites! Si deambulandun per la via publicam vieribus mulieribus quid dixieribus "... morenus ...". Non facendum caso, putaverant sunt. Fin de la cita.
Fórmula Magistral: Tómese un tercio de
RRBOARD2, añádasele otro tercio de
DS1307 desatado y por último mézclese con una pizca de
Flex_LCD y tendremos un
Reloj. (Sí, eso, un simple reloj, nada mas que un reloj, un reloj a secas, como millones de relojes que hay por el mundo)

Pero si además le construimos una rutina que sea capaz de
convertir de Números Arábigos a Números Romanos tendremos exactamente lo que dice el Título del Proyecto:
Romanus Horae ad RR2 targetatis ó Un PIC hablando Latín Clásico.

GeSHi (c):
------
const int8 Numeros[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
char H_in_RomanusNumericum[12];
char M_in_RomanusNumericum[12];
char S_in_RomanusNumericum[12];
------
void dec_to_roman(int8 LI, char* ptr){
char tmp[12];
char* ptmp = (char*) tmp;
strcpy(ptr,"");
// transformo de la tabla Arábiga a la Románica Latinitatis
// { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
// { 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M'};
for(i=12;i!=255;i--){
while(LI >= Numeros[i]){
LI = LI - Numeros[i];
Switch(i){
case 0:
strcpy(ptmp,"I\0");
break;
case 1:
strcpy(ptmp,"IV\0");
break;
case 2:
strcpy(ptmp,"V\0");
break;
case 3:
strcpy(ptmp,"IX\0");
break;
case 4:
strcpy(ptmp,"X\0");
break;
case 5:
strcpy(ptmp,"XL\0");
break;
case 6:
strcpy(ptmp,"L\0");
break;
case 7:
strcpy(ptmp,"XC\0");
break;
case 8:
strcpy(ptmp,"C\0");
break;
case 9:
strcpy(ptmp,"CD\0");
break;
case 10:
strcpy(ptmp,"D\0");
break;
case 11:
strcpy(ptmp,"CM\0");
break;
case 12:
strcpy(ptmp,"M\0");
break;
}
ptr=strcat(ptr,ptmp);
}
}
}
-----
ds1307_get_time(hrs,min,sec);
dec_to_roman(hrs, (char*) H_in_RomanusNumericum);
dec_to_roman(min, (char*) M_in_RomanusNumericum);
dec_to_roman(sec, (char*) S_in_RomanusNumericum);
Pasen y sírvanse de ello.



GeSHi (c):
// Real Time Clock & NVRAM
// Hardware DS1307 of Dallas Maxim
// With interface I2C
// Output over LCD & RSD232
// Clock in Arabic and Roman Numbers
// by Redpic
#include <18f4550.h>
#fuses HS,MCLR,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOPBADEN,NOLVP,NOCPD,NODEBUG,NOWRT,NOVREGEN
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <string.h>
// Libreria DS1307.c //////////////////////////////////////////////////////////
#define RTC_SDA PIN_B0
#define RTC_SCL PIN_B1
#define USE_INTERRUPTS 1
#include "..\..\lib\ds1307.c"
// Libreria FLEX_LCD_2.c ///////////////////////////////////////////////////////
#define LCD_DB4 PIN_D7
#define LCD_DB5 PIN_D6
#define LCD_DB6 PIN_D5
#define LCD_DB7 PIN_D4
#define USE_LCD_RW 1
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
#define LCD_E PIN_D3
#include "..\..\lib\flex_lcd_2.c"
///////////////////////////////////////////////////////////////////////////////
const int8 Numeros[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
char H_in_RomanusNumericum[12];
char M_in_RomanusNumericum[12];
char S_in_RomanusNumericum[12];
///////////////////////////////////////////////////////////////////////////////
int1 flanco=0;
int1 dump=0;
int n,i=0x00;
char c=0x00;
char rec=0x00;
byte sec;
byte min;
byte hrs;
byte day;
byte month;
byte yr;
byte dow;
char sdow[11];
char LCDText[34];
//-----------------------------------------------------------------------------
void dec_to_roman(int8 LI, char* ptr){
char tmp[12];
char* ptmp = (char*) tmp;
strcpy(ptr,"");
// transformo de la tabla Arábiga a la Románica Latinitatis
// { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
// { 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M'};
for(i=12;i!=255;i--){
while(LI >= Numeros[i]){
LI = LI - Numeros[i];
Switch(i){
case 0:
strcpy(ptmp,"I\0");
break;
case 1:
strcpy(ptmp,"IV\0");
break;
case 2:
strcpy(ptmp,"V\0");
break;
case 3:
strcpy(ptmp,"IX\0");
break;
case 4:
strcpy(ptmp,"X\0");
break;
case 5:
strcpy(ptmp,"XL\0");
break;
case 6:
strcpy(ptmp,"L\0");
break;
case 7:
strcpy(ptmp,"XC\0");
break;
case 8:
strcpy(ptmp,"C\0");
break;
case 9:
strcpy(ptmp,"CD\0");
break;
case 10:
strcpy(ptmp,"D\0");
break;
case 11:
strcpy(ptmp,"CM\0");
break;
case 12:
strcpy(ptmp,"M\0");
break;
}
ptr=strcat(ptr,ptmp);
}
}
}
void flash_porte(void){
for(i=0;i<3;i++){
output_e(0x07);
delay_ms(75);
output_e(0x00);
delay_ms(75);
}
}
void lee_y_escribe_lcd_time(void){
ds1307_get_time(hrs,min,sec);
printf("%2u:%2u:%2u\r\n",hrs,min,sec
);
dec_to_roman(hrs, (char*) H_in_RomanusNumericum);
dec_to_roman(min, (char*) M_in_RomanusNumericum);
dec_to_roman(sec, (char*) S_in_RomanusNumericum);
printf("%s %s %s",H_in_RomanusNumericum,M_in_RomanusNumericum,S_in_RomanusNumericum
);
strcpy(LCDText,"");
sprintf(LCDText,"\f%2u:%2u:%2u \r\n%s %s %s",hrs,min,sec,H_in_RomanusNumericum,M_in_RomanusNumericum,S_in_RomanusNumericum);
lcd_put_string((char*) LCDText);
}
// INTERRUPCION por EXT2 Clock Out --------------------------------------------
#int_ext2
ext2_handler() {
if(flanco==1){
ext_int_edge(2,H_TO_L);
output_high(PIN_E0);
}else{
ext_int_edge(2,L_TO_H);
output_low(PIN_E0);
dump=1;
}
++flanco;
}
//-----------------------------------------------------------------------------
void main() {
disable_interrupts(global);
disable_interrupts(int_timer1);
disable_interrupts(int_rda);
disable_interrupts(int_ext);
disable_interrupts(int_ext1);
disable_interrupts(int_ext2);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_psp(PSP_DISABLED);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_0(RTCC_OFF);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
port_b_pullups(FALSE);
set_tris_b(0b00000111);
set_tris_e(0b00010000);
output_e(0x00);
set_tris_c(0b10000000);
delay_ms(500);
lcd_init();
flash_porte();
ext_int_edge(2,H_TO_L);
flanco=0;
enable_interrupts(int_ext2);
enable_interrupts(global);
ds1307_init(DS1307_OUT_ON_DISABLED_HIHG | DS1307_OUT_ENABLED | DS1307_OUT_1_HZ);
printf("\r\nRomanus Horae ad RR2 targetatis\r\n\n");
do{
if(dump==1){
dump=0;
lee_y_escribe_lcd_time();
}
} while (TRUE);
}