Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 09, 2016, 04:44:22 04:44


Login with username, password and session length


Pages: [1]
Print
Author Topic: Watch speaks the hours  (Read 1621 times)
0 Members and 1 Guest are viewing this topic.
o_cientista
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 1
-Receive: 4


« on: May 15, 2012, 02:09:13 02:09 »

Good morning, friends!
     I want to make a watch that speaks the hours with PIC and CCS C ISD25120 language, but one that is found in BASIC. I wanted to do in CCS C. because he wanted to adapt my usage. Can anyone turn this source code in CCS C? Thank you.

Agui is the link of the project and the source code below: http://www.freewebs.com/glafebre/relojparlante.htm


'PIC a utilizar
Device 16F871
'Frecuencia
XTAL 4
'declaracion del LCD
Declare LCD_TYPE 0
Declare LCD_DTPIN PORTC.4 
Declare LCD_ENPIN PORTC.2
Declare LCD_RSPIN PORTC.3
Declare LCD_INTERFACE 4
Declare LCD_LINES 2
'teclado matricial
Declare KEYPAD_PORT PORTD

'---- DECLARACION DE LOS PINES DEL BUS I2C -------
SCL_PIN   = PORTB.7
SDA_PIN   = PORTB.6
'todos los puertos digitales
ALL_DIGITAL true
'variables

Dim tecla As Byte
Dim cont As Byte
Dim cont1 As Byte
Dim var1 As Byte
Dim segu As Byte   
Dim minu As Byte                   
Dim hora As Byte                                       
Dim minu1 As Byte
Dim minu2 As Byte
Dim diaS As Byte                     
Dim diaF As Byte                   
Dim mes  As Byte                   
Dim anio As Byte                   
Dim eeprom As Byte
Dim control As Byte
Dim aux As Byte
Dim STRING1[10] As Byte
Dim horario As Bit
Symbol CE = PORTE.0
Symbol PD = PORTE.1
Symbol PR = PORTE.2
Symbol EOM = PORTC.0

TRISA = 0

DelayMS 500

cont=0
cont1=0

Cls

PORTA = 0
High CE

GoSub grabar_RTC

'Programa principal
inicio:
    GoSub leer_RTC
    tecla = InKey
    Print At 1,12,DEC2 cont,"-"
    Print At 1,15,DEC2 cont1,
    Select Case tecla
        Case 0:  'para grabar
            GoSub antirebote 'antirebote de tecla
            GoSub grabar
        Case 1:  'para reproducir el msg seleccionado
            GoSub antirebote 'antirebote de tecla
            GoSub reproducir
        Case 2                       
            cont1=cont1+1
            GoSub antirebote 'antirebote de tecla
        Case 3
            cont1=cont1-1     
            If cont1<0 Then
                cont1=0
            EndIf
            GoSub antirebote 'antirebote de tecla                                     
        Case 5
            GoSub reproducir_HORA
        Case 6
            cont=cont+1
            GoSub antirebote
        Case 7
            cont=cont-1     
            If cont<0 Then
                cont=0
            EndIf
            GoSub antirebote   
        Case 8
            GoSub antirebote
            GoSub reproducir_HORA
    EndSelect
    GoTo inicio
   
'Subrutinas
grabar:
    PORTA=cont
    High PD: DelayMS 10
    Low PR:Low PD:High CE
    Print At 2,1, "LISTO     "
    DelayMS 2000
    Print At 2,1, "AHORA"
    Low CE
    DelayMS 1000
    Print At 2,1, "FINALIZADO"
    High CE
    Return
   
' --------------------------------------------------------
   
reproducir:
    PORTA=cont1
    Print At 2,1, "REPRODUCIR"
    High PR: Low PD: Low CE
    While EOM <> 0  'buble para esperar el bajo en EOM para saber
    Wend            'cuando ha finalizado el mensaje
    High CE
    Print At 2,1, "                "
    Return
   
' --------------------------------------------------------

antirebote:
    While tecla<>16   'antirebote
        tecla=InKey
    Wend
    Return
   
' --------------------------------------------------------

grabar_RTC:

    BusOut %11010000,0,[$00] 'segundos
    DelayMS 50                   
    BusOut %11010000,1,[$59]  'mitutos
    DelayMS 50 
    BusOut %11010000,2,[$10] 'horas   
    DelayMS 50 
    BusOut %11010000,3,[$4]  'dia de la semana 
    DelayMS 50                             
    BusOut %11010000,4,[$19] 'dia del mes   
    DelayMS 50 
    BusOut %11010000,5,[$07] 'mes   
    DelayMS 50 
    BusOut %11010000,6,[$06] 'año 
    DelayMS 50
    BusOut %11010000,7,[$10] 'frec 1hz
    DelayMS 50                       
    Return   
   
'---------------------------------------------------------

leer_RTC:           

    BusIn %11010000,0,[segu]
    BusIn %11010000,1,[minu]   
    BusIn %11010000,2,[hora]   
    BusIn %11010000,3,[diaS]
    BusIn %11010000,4,[diaF]             
    BusIn %11010000,5,[mes]
    BusIn %11010000,6,[anio]

    Print At 1,1, HEX2 hora,":",HEX2 minu,":",HEX2 segu," "   

    If diaS=$1 Then Print At 2,1, "Dom."   
    If diaS=$2 Then Print At 2,1, "Lun."
    If diaS=$3 Then Print At 2,1, "Mar."
    If diaS=$4 Then Print At 2,1, "Mie."
    If diaS=$5 Then Print At 2,1, "Jue."
    If diaS=$6 Then Print At 2,1, "Vie."
    If diaS=$7 Then Print At 2,1, "Sab."
   
    Print At 2,6,HEX2 diaF,"/"
    Print At 2,11," /20",HEX2 anio

    If mes=$1 Then Print At 2,9, "Ene"     
    If mes=$2 Then Print At 2,9, "Feb"
    If mes=$3 Then Print At 2,9, "Mar"
    If mes=$4 Then Print At 2,9, "Abr"
    If mes=$5 Then Print At 2,9, "May"
    If mes=$6 Then Print At 2,9, "Jun"
    If mes=$7 Then Print At 2,9, "Jul"
    If mes=$8 Then Print At 2,9, "Ago"
    If mes=$9 Then Print At 2,9, "Sep"
    If mes=$10 Then Print At 2,9, "Oct"
    If mes=$11 Then Print At 2,9, "Nov"
    If mes=$12 Then Print At 2,9, "Dic"
    Return
   
reproducir_HORA:
    GoSub leer_RTC
   
    '--------------- son

    cont1=21
    GoSub reproducir
    DelayMS 100

    '--------------- las

    cont1=22
    GoSub reproducir
    DelayMS 100

    '--------------- HORAS

    If hora>=10 And hora<32 Then
        hora=hora-6
    EndIf
    If hora>=32 And hora<48 Then '20
        hora=hora-12
    EndIf
   
    If hora>12 Then
        hora=hora-12
        horario=1
    Else
        horario=0
    EndIf   
    cont1=hora
    GoSub reproducir
    DelayMS 100
   
    '--------------- AM/PM
   
    If horario=1 Then
        cont1=24
    Else
        cont1=23
    EndIf
    GoSub reproducir
    DelayMS 100

   
    '--------------- Y

    cont1=20
    GoSub reproducir
    DelayMS 100
   
    '---------------  MINUTOS

    If minu>=10 And minu<32 Then '10
        minu=minu-6
    EndIf
    If minu>=32 And minu<48 Then '20
        minu=minu-12
    EndIf
    If minu>=48 And minu<64 Then '30
        minu=minu-18
    EndIf
    If minu>=64 And minu<80 Then '40
        minu=minu-24
    EndIf
    If minu>=80 And minu<96 Then '50
        minu=minu-30
    EndIf
    Select Case minu
        Case 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
            cont1=minu
            GoSub reproducir
        Case Else
            minu2=Dig minu, 1
            minu2=minu2*10
            cont1=minu2
            Select Case cont1
                Case 20
                    cont1=16
                Case 30
                    cont1=17
                Case 40
                    cont1=18
                Case 50
                    cont1=19
            EndSelect
            GoSub reproducir
            DelayMS 100
            '-------------------
            If minu<>20 And minu<>30 And minu<>40 And minu<>50 Then
                cont1=20
                GoSub reproducir
                DelayMS 100
                '-------------------
                minu1=Dig minu, 0
                cont1=minu1
                GoSub reproducir
            EndIf
        EndSelect
        DelayMS 100

    '--------------- MINUTOS (PALABRA)

    cont1=25
    GoSub reproducir

    Return   
End
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2018

Thank You
-Given: 514
-Receive: 477


Top Topic Starter


« Reply #1 on: May 20, 2012, 12:22:02 00:22 »

google is your friend
Logged

nothing to say..
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC