diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2011-10-15 20:38:08 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2011-10-15 20:38:08 +0000 |
commit | fe67a87885816448e78a99ef0cbe8fd331c3b103 (patch) | |
tree | 29f3d6453ed3af2b8a4c35f27d6520de2d768da0 /apps/plugins/calculator.c | |
parent | 2176fb38b61c72d09dc2b344f956a9b1c69c361d (diff) | |
download | rockbox-fe67a87885816448e78a99ef0cbe8fd331c3b103.tar.gz rockbox-fe67a87885816448e78a99ef0cbe8fd331c3b103.zip |
plugins: another round of making local functions static
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30758 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/calculator.c')
-rw-r--r-- | apps/plugins/calculator.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c index 607f563b5a..994b066e7b 100644 --- a/apps/plugins/calculator.c +++ b/apps/plugins/calculator.c | |||
@@ -546,7 +546,7 @@ enum {cal_normal, /* 0, normal status, display result */ | |||
546 | } calStatus; | 546 | } calStatus; |
547 | 547 | ||
548 | /* constant table for CORDIC algorithm */ | 548 | /* constant table for CORDIC algorithm */ |
549 | double cordicTable[51][2]= { | 549 | static const double cordicTable[51][2]= { |
550 | /* pow(2,0) - pow(2,-50) atan(pow(2,0) - atan(pow(2,-50) */ | 550 | /* pow(2,0) - pow(2,-50) atan(pow(2,0) - atan(pow(2,-50) */ |
551 | {1e+00, 7.853981633974483e-01}, | 551 | {1e+00, 7.853981633974483e-01}, |
552 | {5e-01, 4.636476090008061e-01}, | 552 | {5e-01, 4.636476090008061e-01}, |
@@ -601,21 +601,21 @@ double cordicTable[51][2]= { | |||
601 | {8.8817841970012523233890533447265625e-16, 8.881784197001252e-16} | 601 | {8.8817841970012523233890533447265625e-16, 8.881784197001252e-16} |
602 | }; | 602 | }; |
603 | 603 | ||
604 | void doMultiple(double* operandOne, int* powerOne, | 604 | static void doMultiple(double* operandOne, int* powerOne, |
605 | double operandTwo, int powerTwo); | 605 | double operandTwo, int powerTwo); |
606 | void doAdd (double* operandOne, int* powerOne, | 606 | static void doAdd (double* operandOne, int* powerOne, |
607 | double operandTwo, int powerTwo); | 607 | double operandTwo, int powerTwo); |
608 | void printResult(void); | 608 | static void printResult(void); |
609 | void formatResult(void); | 609 | static void formatResult(void); |
610 | void oneOperand(void); | 610 | static void oneOperand(void); |
611 | 611 | ||
612 | void drawLines(void); | 612 | static void drawLines(void); |
613 | void drawButtons(int group); | 613 | static void drawButtons(int group); |
614 | 614 | ||
615 | /* ----------------------------------------------------------------------- | 615 | /* ----------------------------------------------------------------------- |
616 | Handy funtions | 616 | Handy functions |
617 | ----------------------------------------------------------------------- */ | 617 | ----------------------------------------------------------------------- */ |
618 | void cleartypingbuf(void) | 618 | static void cleartypingbuf(void) |
619 | { | 619 | { |
620 | int k; | 620 | int k; |
621 | for( k=1; k<=(DIGITLEN+1); k++) | 621 | for( k=1; k<=(DIGITLEN+1); k++) |
@@ -623,21 +623,21 @@ void cleartypingbuf(void) | |||
623 | typingbuf[0] = ' '; | 623 | typingbuf[0] = ' '; |
624 | typingbufPointer = typingbuf+1; | 624 | typingbufPointer = typingbuf+1; |
625 | } | 625 | } |
626 | void clearbuf(void) | 626 | static void clearbuf(void) |
627 | { | 627 | { |
628 | int k; | 628 | int k; |
629 | for(k=0;k<18;k++) | 629 | for(k=0;k<18;k++) |
630 | buf[k]=' '; | 630 | buf[k]=' '; |
631 | buf[18] = 0; | 631 | buf[18] = 0; |
632 | } | 632 | } |
633 | void clearResult(void) | 633 | static void clearResult(void) |
634 | { | 634 | { |
635 | result = 0; | 635 | result = 0; |
636 | power = 0; | 636 | power = 0; |
637 | modifier = 0.1; | 637 | modifier = 0.1; |
638 | } | 638 | } |
639 | 639 | ||
640 | void clearInput(void) | 640 | static void clearInput(void) |
641 | { | 641 | { |
642 | calStatus = cal_normal; | 642 | calStatus = cal_normal; |
643 | clearResult(); | 643 | clearResult(); |
@@ -647,25 +647,25 @@ void clearInput(void) | |||
647 | drawLines(); | 647 | drawLines(); |
648 | } | 648 | } |
649 | 649 | ||
650 | void clearOperand(void) | 650 | static void clearOperand(void) |
651 | { | 651 | { |
652 | operand = 0; | 652 | operand = 0; |
653 | operandPower = 0; | 653 | operandPower = 0; |
654 | } | 654 | } |
655 | 655 | ||
656 | void clearMemTemp(void) | 656 | static void clearMemTemp(void) |
657 | { | 657 | { |
658 | memTemp = 0; | 658 | memTemp = 0; |
659 | memTempPower = 0; | 659 | memTempPower = 0; |
660 | } | 660 | } |
661 | 661 | ||
662 | void clearOper(void) | 662 | static void clearOper(void) |
663 | { | 663 | { |
664 | oper = ' '; | 664 | oper = ' '; |
665 | operInputted = false; | 665 | operInputted = false; |
666 | } | 666 | } |
667 | 667 | ||
668 | void clearMem(void) | 668 | static void clearMem(void) |
669 | { | 669 | { |
670 | clearInput(); | 670 | clearInput(); |
671 | clearMemTemp(); | 671 | clearMemTemp(); |
@@ -674,7 +674,7 @@ void clearMem(void) | |||
674 | btn = BUTTON_NONE; | 674 | btn = BUTTON_NONE; |
675 | } | 675 | } |
676 | 676 | ||
677 | void switchOperands(void) | 677 | static void switchOperands(void) |
678 | { | 678 | { |
679 | double tempr = operand; | 679 | double tempr = operand; |
680 | int tempp = operandPower; | 680 | int tempp = operandPower; |
@@ -684,7 +684,7 @@ void switchOperands(void) | |||
684 | power = tempp; | 684 | power = tempp; |
685 | } | 685 | } |
686 | 686 | ||
687 | void drawLines(void) | 687 | static void drawLines(void) |
688 | { | 688 | { |
689 | int i; | 689 | int i; |
690 | rb->lcd_hline(0, LCD_WIDTH, Y_1_POS-1); | 690 | rb->lcd_hline(0, LCD_WIDTH, Y_1_POS-1); |
@@ -694,7 +694,7 @@ void drawLines(void) | |||
694 | rb->lcd_vline(X_1_POS+i*REC_WIDTH, Y_1_POS, LCD_HEIGHT); | 694 | rb->lcd_vline(X_1_POS+i*REC_WIDTH, Y_1_POS, LCD_HEIGHT); |
695 | } | 695 | } |
696 | 696 | ||
697 | void drawButtons(int group) | 697 | static void drawButtons(int group) |
698 | { | 698 | { |
699 | int i, j, w, h; | 699 | int i, j, w, h; |
700 | for (i = 0; i <= 4; i++){ | 700 | for (i = 0; i <= 4; i++){ |
@@ -722,7 +722,7 @@ void drawButtons(int group) | |||
722 | /* ----------------------------------------------------------------------- | 722 | /* ----------------------------------------------------------------------- |
723 | Initiate calculator | 723 | Initiate calculator |
724 | ----------------------------------------------------------------------- */ | 724 | ----------------------------------------------------------------------- */ |
725 | void cal_initial (void) | 725 | static void cal_initial (void) |
726 | { | 726 | { |
727 | int w,h; | 727 | int w,h; |
728 | 728 | ||
@@ -761,7 +761,7 @@ void cal_initial (void) | |||
761 | in it's private case for sqrt. | 761 | in it's private case for sqrt. |
762 | Thanks BlueChip for his intro text and Dave Straayer for the actual name. | 762 | Thanks BlueChip for his intro text and Dave Straayer for the actual name. |
763 | ----------------------------------------------------------------------- */ | 763 | ----------------------------------------------------------------------- */ |
764 | double mySqrt(double square) | 764 | static double mySqrt(double square) |
765 | { | 765 | { |
766 | int k = 0; | 766 | int k = 0; |
767 | double temp = 0; | 767 | double temp = 0; |
@@ -781,7 +781,7 @@ double mySqrt(double square) | |||
781 | transcendFunc can do sin,cos,log,exp | 781 | transcendFunc can do sin,cos,log,exp |
782 | input parameter is angle | 782 | input parameter is angle |
783 | ----------------------------------------------------------------------- */ | 783 | ----------------------------------------------------------------------- */ |
784 | void transcendFunc(char* func, double* tt, int* ttPower) | 784 | static void transcendFunc(char* func, double* tt, int* ttPower) |
785 | { | 785 | { |
786 | double t = (*tt)*M_PI/180; int tPower = *ttPower; | 786 | double t = (*tt)*M_PI/180; int tPower = *ttPower; |
787 | int sign = 1; | 787 | int sign = 1; |
@@ -861,8 +861,8 @@ void transcendFunc(char* func, double* tt, int* ttPower) | |||
861 | /* ----------------------------------------------------------------------- | 861 | /* ----------------------------------------------------------------------- |
862 | add in scientific number format | 862 | add in scientific number format |
863 | ----------------------------------------------------------------------- */ | 863 | ----------------------------------------------------------------------- */ |
864 | void doAdd (double* operandOne, int* powerOne, | 864 | static void doAdd (double* operandOne, int* powerOne, |
865 | double operandTwo, int powerTwo) | 865 | double operandTwo, int powerTwo) |
866 | { | 866 | { |
867 | if ( *powerOne >= powerTwo ){ | 867 | if ( *powerOne >= powerTwo ){ |
868 | if (*powerOne - powerTwo <= DIGITLEN+1){ | 868 | if (*powerOne - powerTwo <= DIGITLEN+1){ |
@@ -891,8 +891,8 @@ void doAdd (double* operandOne, int* powerOne, | |||
891 | /* ----------------------------------------------------------------------- | 891 | /* ----------------------------------------------------------------------- |
892 | multiple in scientific number format | 892 | multiple in scientific number format |
893 | ----------------------------------------------------------------------- */ | 893 | ----------------------------------------------------------------------- */ |
894 | void doMultiple(double* operandOne, int* powerOne, | 894 | static void doMultiple(double* operandOne, int* powerOne, |
895 | double operandTwo, int powerTwo) | 895 | double operandTwo, int powerTwo) |
896 | { | 896 | { |
897 | (*operandOne) *= operandTwo; | 897 | (*operandOne) *= operandTwo; |
898 | (*powerOne) += powerTwo; | 898 | (*powerOne) += powerTwo; |
@@ -901,7 +901,7 @@ void doMultiple(double* operandOne, int* powerOne, | |||
901 | /* ----------------------------------------------------------------------- | 901 | /* ----------------------------------------------------------------------- |
902 | Handles all one operand calculations | 902 | Handles all one operand calculations |
903 | ----------------------------------------------------------------------- */ | 903 | ----------------------------------------------------------------------- */ |
904 | void oneOperand(void) | 904 | static void oneOperand(void) |
905 | { | 905 | { |
906 | int k = 0; | 906 | int k = 0; |
907 | if (buttonGroup == basicButtons){ | 907 | if (buttonGroup == basicButtons){ |
@@ -988,7 +988,7 @@ void oneOperand(void) | |||
988 | /* ----------------------------------------------------------------------- | 988 | /* ----------------------------------------------------------------------- |
989 | Handles all two operands calculations | 989 | Handles all two operands calculations |
990 | ----------------------------------------------------------------------- */ | 990 | ----------------------------------------------------------------------- */ |
991 | void twoOperands(void) | 991 | static void twoOperands(void) |
992 | { | 992 | { |
993 | switch(oper){ | 993 | switch(oper){ |
994 | case '-': | 994 | case '-': |
@@ -1048,7 +1048,7 @@ static void move_with_wrap_and_shift( | |||
1048 | Print buttons when switching 1st and 2nd | 1048 | Print buttons when switching 1st and 2nd |
1049 | int group = {basicButtons, sciButtons} | 1049 | int group = {basicButtons, sciButtons} |
1050 | ----------------------------------------------------------------------- */ | 1050 | ----------------------------------------------------------------------- */ |
1051 | void printButtonGroups(int group) | 1051 | static void printButtonGroups(int group) |
1052 | { | 1052 | { |
1053 | drawButtons(group); | 1053 | drawButtons(group); |
1054 | drawLines(); | 1054 | drawLines(); |
@@ -1057,7 +1057,7 @@ void printButtonGroups(int group) | |||
1057 | /* ----------------------------------------------------------------------- | 1057 | /* ----------------------------------------------------------------------- |
1058 | flash the currently marked button | 1058 | flash the currently marked button |
1059 | ----------------------------------------------------------------------- */ | 1059 | ----------------------------------------------------------------------- */ |
1060 | void flashButton(void) | 1060 | static void flashButton(void) |
1061 | { | 1061 | { |
1062 | int k, w, h; | 1062 | int k, w, h; |
1063 | for (k=2;k>0;k--) | 1063 | for (k=2;k>0;k--) |
@@ -1083,7 +1083,8 @@ void flashButton(void) | |||
1083 | /* ----------------------------------------------------------------------- | 1083 | /* ----------------------------------------------------------------------- |
1084 | pos is the position that needs animation. pos = [1~18] | 1084 | pos is the position that needs animation. pos = [1~18] |
1085 | ----------------------------------------------------------------------- */ | 1085 | ----------------------------------------------------------------------- */ |
1086 | void deleteAnimation(int pos) | 1086 | #if defined(CALCULATOR_CLEAR) || defined(CALCULATOR_OPERATORS) |
1087 | static void deleteAnimation(int pos) | ||
1087 | { | 1088 | { |
1088 | int k, w, h, x; | 1089 | int k, w, h, x; |
1089 | if (pos<1 || pos >18) | 1090 | if (pos<1 || pos >18) |
@@ -1102,6 +1103,7 @@ void deleteAnimation(int pos) | |||
1102 | rb->sleep(HZ/32); | 1103 | rb->sleep(HZ/32); |
1103 | } | 1104 | } |
1104 | } | 1105 | } |
1106 | #endif | ||
1105 | 1107 | ||
1106 | /* ----------------------------------------------------------------------- | 1108 | /* ----------------------------------------------------------------------- |
1107 | result may be one of these formats: | 1109 | result may be one of these formats: |
@@ -1114,7 +1116,7 @@ formatResult() change result to standard format: 0.xxxx | |||
1114 | if result is close to 0, let it be 0; | 1116 | if result is close to 0, let it be 0; |
1115 | if result is close to 1, let it be 0.1 and power++; | 1117 | if result is close to 1, let it be 0.1 and power++; |
1116 | ----------------------------------------------------------------------- */ | 1118 | ----------------------------------------------------------------------- */ |
1117 | void formatResult(void) | 1119 | static void formatResult(void) |
1118 | { | 1120 | { |
1119 | int resultsign = SIGN(result); | 1121 | int resultsign = SIGN(result); |
1120 | result = ABS(result); | 1122 | result = ABS(result); |
@@ -1160,7 +1162,7 @@ case SCIENTIFIC_FORMAT, let temppower = 1; | |||
1160 | case temppower > 0: print '.' in the middle | 1162 | case temppower > 0: print '.' in the middle |
1161 | case temppower <= 0: print '.' in the begining | 1163 | case temppower <= 0: print '.' in the begining |
1162 | ----------------------------------------------------------------------- */ | 1164 | ----------------------------------------------------------------------- */ |
1163 | void result2typingbuf(void) | 1165 | static void result2typingbuf(void) |
1164 | { | 1166 | { |
1165 | bool haveDot = false; | 1167 | bool haveDot = false; |
1166 | char tempchar = 0; | 1168 | char tempchar = 0; |
@@ -1244,7 +1246,7 @@ void result2typingbuf(void) | |||
1244 | /* ----------------------------------------------------------------------- | 1246 | /* ----------------------------------------------------------------------- |
1245 | printResult() generates LCD display. | 1247 | printResult() generates LCD display. |
1246 | ----------------------------------------------------------------------- */ | 1248 | ----------------------------------------------------------------------- */ |
1247 | void printResult(void) | 1249 | static void printResult(void) |
1248 | { | 1250 | { |
1249 | int k, w, h; | 1251 | int k, w, h; |
1250 | 1252 | ||
@@ -1321,7 +1323,7 @@ void printResult(void) | |||
1321 | Process typing buttons: 1-9, '.', sign | 1323 | Process typing buttons: 1-9, '.', sign |
1322 | main operand "result" and typingbuf are processed seperately here. | 1324 | main operand "result" and typingbuf are processed seperately here. |
1323 | ----------------------------------------------------------------------- */ | 1325 | ----------------------------------------------------------------------- */ |
1324 | void typingProcess(void){ | 1326 | static void typingProcess(void){ |
1325 | switch( CAL_BUTTON ){ | 1327 | switch( CAL_BUTTON ){ |
1326 | case btn_sign: | 1328 | case btn_sign: |
1327 | if (calStatus == cal_typing || | 1329 | if (calStatus == cal_typing || |
@@ -1395,7 +1397,8 @@ void typingProcess(void){ | |||
1395 | Handle delete operation | 1397 | Handle delete operation |
1396 | main operand "result" and typingbuf are processed seperately here. | 1398 | main operand "result" and typingbuf are processed seperately here. |
1397 | ----------------------------------------------------------------------- */ | 1399 | ----------------------------------------------------------------------- */ |
1398 | void doDelete(void){ | 1400 | #ifdef CALCULATOR_CLEAR |
1401 | static void doDelete(void){ | ||
1399 | deleteAnimation(18); | 1402 | deleteAnimation(18); |
1400 | switch(calStatus){ | 1403 | switch(calStatus){ |
1401 | case cal_dotted: | 1404 | case cal_dotted: |
@@ -1434,10 +1437,11 @@ void doDelete(void){ | |||
1434 | break; | 1437 | break; |
1435 | } | 1438 | } |
1436 | } | 1439 | } |
1440 | #endif | ||
1437 | /* ----------------------------------------------------------------------- | 1441 | /* ----------------------------------------------------------------------- |
1438 | Handle buttons on basic screen | 1442 | Handle buttons on basic screen |
1439 | ----------------------------------------------------------------------- */ | 1443 | ----------------------------------------------------------------------- */ |
1440 | void basicButtonsProcess(void){ | 1444 | static void basicButtonsProcess(void){ |
1441 | switch (btn) { | 1445 | switch (btn) { |
1442 | case CALCULATOR_INPUT: | 1446 | case CALCULATOR_INPUT: |
1443 | if (calStatus == cal_error && (CAL_BUTTON != btn_C) ) break; | 1447 | if (calStatus == cal_error && (CAL_BUTTON != btn_C) ) break; |
@@ -1538,7 +1542,7 @@ void basicButtonsProcess(void){ | |||
1538 | /* ----------------------------------------------------------------------- | 1542 | /* ----------------------------------------------------------------------- |
1539 | Handle buttons on scientific screen | 1543 | Handle buttons on scientific screen |
1540 | ----------------------------------------------------------------------- */ | 1544 | ----------------------------------------------------------------------- */ |
1541 | void sciButtonsProcess(void){ | 1545 | static void sciButtonsProcess(void){ |
1542 | switch (btn) { | 1546 | switch (btn) { |
1543 | case CALCULATOR_INPUT: | 1547 | case CALCULATOR_INPUT: |
1544 | if (calStatus == cal_error && (CAL_BUTTON != sci_sci) ) break; | 1548 | if (calStatus == cal_error && (CAL_BUTTON != sci_sci) ) break; |
@@ -1613,7 +1617,7 @@ void sciButtonsProcess(void){ | |||
1613 | move button index | 1617 | move button index |
1614 | Invert display new button, invert back previous button | 1618 | Invert display new button, invert back previous button |
1615 | ----------------------------------------------------------------------- */ | 1619 | ----------------------------------------------------------------------- */ |
1616 | int handleButton(int button){ | 1620 | static int handleButton(int button){ |
1617 | switch(button) | 1621 | switch(button) |
1618 | { | 1622 | { |
1619 | case CALCULATOR_INPUT: | 1623 | case CALCULATOR_INPUT: |
@@ -1721,9 +1725,6 @@ int handleButton(int button){ | |||
1721 | } | 1725 | } |
1722 | 1726 | ||
1723 | return 0; | 1727 | return 0; |
1724 | |||
1725 | prev_btn_row = btn_row; | ||
1726 | prev_btn_col = btn_col; | ||
1727 | } | 1728 | } |
1728 | 1729 | ||
1729 | /* ----------------------------------------------------------------------- | 1730 | /* ----------------------------------------------------------------------- |