]> bicyclesonthemoon.info Git - staf/staf/commitdiff
fix calculator v2.2
authorb <rowerynaksiezycu@gmail.com>
Tue, 15 Dec 2020 09:16:16 +0000 (10:16 +0100)
committerb <rowerynaksiezycu@gmail.com>
Tue, 15 Dec 2020 09:16:16 +0000 (10:16 +0100)
main.c

diff --git a/main.c b/main.c
index 8d6ede5980bfad6bb617767c8f4e64f2a0a24544..53eb7a93ad44c58347ab6b9a56cce930a5bdc9e2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,8 +1,8 @@
-// SilentTimer Action Figure software, v2.1
+// SilentTimer Action Figure software, v2.2
 // main.c
 // The main c file.
 // 
-// 27.06.2020
+// 14.12.2020
 // Copyright (C) 2014-2017, 2020  Balthasar SzczepaƄski
 // 
 // This program is free software: you can redistribute it and/or modify
                        P2IFG=0;
                
                if(event)
-                       _BIC_SR_IRQ(OSCOFF|CPUOFF|SCG1|SCG0); //escaoe low power mode
+                       _BIC_SR_IRQ(OSCOFF|CPUOFF|SCG1|SCG0); //escape low power mode
                return;
        }
 
@@ -534,7 +534,8 @@ void leave (void) //to execute when leaving an edit state
                        {
                                calcdata[2]=settime[0];
                                calcdata[3]=settime[1];
-                               if ((settime[1] & 0xF0)==0xA0) //minus sign encoded as 0xA
+                               calcdata[6] &= ~0x0c; //clear old flags 
+                               if ((settime[1] & 0xf0)==0xa0) //minus sign encoded as 0xA
                                {
                                        calcdata[6] |= 0x04;
                                        calcdata[3] &= 0x0f;
@@ -703,7 +704,9 @@ void enter (void) //to execute when entering a state
                        {
                                settime[0] = calcdata[2];
                                settime[1] = calcdata[3];
-                               settime[2] = (calcdata[6]>>2)&0x03;
+                               if (calcdata[6]&0x04)
+                                       settime[1] |= 0xA0; //restore minus sign
+                               settime[2] = (calcdata[6]&0x08)>>3; //restore decimal point
                        }
                        else
                        {
@@ -990,7 +993,7 @@ void showvalue () //determine what to show on display
                        break;
                case MODE_VER:
                        dispvalue[4] = SYMB_NUL;
-                       dispvalue[5] = SYMB_1;
+                       dispvalue[5] = SYMB_2;
                        dispvalue[6] = SYMB_2;
                        dispvalue[7] = SYMB_NUL;
                        dot |= 0x02; //.
@@ -1113,8 +1116,9 @@ int main( void )
        P1OUT =0xff; //display data on p1
        P1DIR =0xff;
        
-       P3OUT &=0x0f; //display control on p3.4-7
-       P3DIR |=0xf0; 
+       P3OUT  =0x01; 
+       P3DIR |=0xf1; //display control on p3.4-7, RTC CS on p3.0
+       P3SEL =0x0e; // SPI on p3.1, 3.2, 3.3
        
        dispvalue[0]=SYMB_NUL;
        dispvalue[1]=SYMB_o;
@@ -1150,10 +1154,6 @@ int main( void )
                
        //init SPI
        
-       P3SEL =0x0e; // SPI on p3.1, 3.2, 3.3
-       P3OUT |=0x01;
-       P3DIR |=0x01; //RTC CS on p3.0
-       
        U0CTL =
                SWRST| //reset
                MM| //master
@@ -1698,9 +1698,9 @@ int main( void )
                                                for (i=0; i<8; ++i)
                                                {
                                                        if (i != 4)
-                                                               sendhex(time[i]); //hs
+                                                               sendhex(time[i]);
                                                }
-                                               sendhex(lastyear[4]); //yL
+                                               sendhex(lastyear[4]); //yH
                                                break;
                                        case 'H': //get state
                                                sendhex(mode);
@@ -1722,8 +1722,8 @@ int main( void )
                                                sendhex(run);
                                                break;
                                        case 'M': //get version
-                                               sendhex(1);
-                                               sendhex(2);
+                                               sendhex(2); //vL
+                                               sendhex(2); //vH
                                                break;
                                        case 'N': //get pinout
                                                sendhex(PIN_AB);
@@ -1750,7 +1750,7 @@ int main( void )
                                        case 'Q': //get diit
                                                sendhex(digit);
                                                break;
-                                       case 'R': //set memory
+                                       case 'R': //read memory
                                                p = (unsigned char*)(*((unsigned short*)rxdata));
                                                sendhex(*p);
                                                break;