summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/calculator.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 2d276c1747..2c16e03c9c 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -101,13 +101,6 @@ PLUGIN_HEADER
101#define X_4_POS (X_3_POS + REC_WIDTH) /* x4 = 88 */ 101#define X_4_POS (X_3_POS + REC_WIDTH) /* x4 = 88 */
102#define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */ 102#define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */
103 103
104#define TEXT_1_POS (Y_1_POS-10) /* y1 = 2 */ /* blank height = 12 */
105#define TEXT_2_POS (Y_2_POS-8) /* y2 = 15 */ /* blank height = 9 */
106#define TEXT_3_POS (Y_3_POS-8) /* y3 = 25 */
107#define TEXT_4_POS (Y_4_POS-8) /* y4 = 35 */
108#define TEXT_5_POS (Y_5_POS-8) /* y5 = 45 */
109#define TEXT_6_POS (Y_6_POS-8) /* y6 = 55 */
110
111#define SIGN(x) ((x)<0?-1:1) 104#define SIGN(x) ((x)<0?-1:1)
112#define ABS(x) ((x)<0?-(x):(x)) 105#define ABS(x) ((x)<0?-(x):(x))
113 106
@@ -373,7 +366,8 @@ PLUGIN_HEADER
373#endif 366#endif
374 367
375#include "lib/touchscreen.h" 368#include "lib/touchscreen.h"
376static struct ts_raster calc_raster = { X_0_POS, Y_1_POS, BUTTON_COLS*REC_WIDTH, BUTTON_ROWS*REC_HEIGHT, REC_WIDTH, REC_HEIGHT }; 369static struct ts_raster calc_raster = { X_0_POS, Y_1_POS,
370 BUTTON_COLS*REC_WIDTH, BUTTON_ROWS*REC_HEIGHT, REC_WIDTH, REC_HEIGHT };
377#endif 371#endif
378 372
379enum { 373enum {
@@ -387,7 +381,7 @@ unsigned char* buttonChar[2][5][5] = {
387 { "4" , "5" , "6" , "*" , "x^2" }, 381 { "4" , "5" , "6" , "*" , "x^2" },
388 { "1" , "2" , "3" , "-" , "1/x" }, 382 { "1" , "2" , "3" , "-" , "1/x" },
389 { "0" , "+/-", "." , "+" , "=" } }, 383 { "0" , "+/-", "." , "+" , "=" } },
390 384
391 { { "n!" , "PI" , "1st" , "sin" , "asi" }, 385 { { "n!" , "PI" , "1st" , "sin" , "asi" },
392 { "7" , "8" , "9" , "cos" , "aco" }, 386 { "7" , "8" , "9" , "cos" , "aco" },
393 { "4" , "5" , "6" , "tan" , "ata" }, 387 { "4" , "5" , "6" , "tan" , "ata" },
@@ -652,8 +646,8 @@ void cal_initial (void)
652{ 646{
653 int w,h; 647 int w,h;
654 648
655 rb->lcd_getstringsize("A",&w,&h); 649 rb->lcd_getstringsize("2nd",&w,&h);
656 if (h >= REC_HEIGHT) 650 if (w > REC_WIDTH || h > REC_HEIGHT)
657 rb->lcd_setfont(FONT_SYSFIXED); 651 rb->lcd_setfont(FONT_SYSFIXED);
658 652
659 rb->lcd_clear_display(); 653 rb->lcd_clear_display();
@@ -949,7 +943,7 @@ static void move_with_wrap_and_shift(
949 int *dimen2, int dimen2_delta, int dimen2_modulo) 943 int *dimen2, int dimen2_delta, int dimen2_modulo)
950{ 944{
951 bool wrapped = false; 945 bool wrapped = false;
952 946
953 *dimen1 += dimen1_delta; 947 *dimen1 += dimen1_delta;
954 if (*dimen1 < 0) 948 if (*dimen1 < 0)
955 { 949 {
@@ -961,7 +955,7 @@ static void move_with_wrap_and_shift(
961 *dimen1 = 0; 955 *dimen1 = 0;
962 wrapped = true; 956 wrapped = true;
963 } 957 }
964 958
965 if (wrapped) 959 if (wrapped)
966 { 960 {
967 /* Make the dividend always positive to be sure about the result. 961 /* Make the dividend always positive to be sure about the result.
@@ -1011,23 +1005,22 @@ pos is the position that needs animation. pos = [1~18]
1011----------------------------------------------------------------------- */ 1005----------------------------------------------------------------------- */
1012void deleteAnimation(int pos) 1006void deleteAnimation(int pos)
1013{ 1007{
1014 int k; 1008 int k, w, h, x;
1015 if (pos<1 || pos >18) 1009 if (pos<1 || pos >18)
1016 return; 1010 return;
1017 pos--;
1018 rb->lcd_fillrect(1+pos*6, TEXT_1_POS, 6, 8);
1019 rb->lcd_update_rect(1+pos*6, TEXT_1_POS, 6, 8);
1020 1011
1021 for (k=1;k<=4;k++){ 1012 rb->lcd_getstringsize("0", &w, &h);
1022 rb->sleep(HZ/32); 1013 x = (pos==1? 4: LCD_WIDTH - 4 - w);
1014
1015 for (k=0;k<4;k++){
1023 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 1016 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
1024 rb->lcd_fillrect(1+pos*6, TEXT_1_POS, 6, 8); 1017 rb->lcd_fillrect(x, Y_1_POS - h -1, w, h);
1025 rb->lcd_set_drawmode(DRMODE_SOLID); 1018 rb->lcd_set_drawmode(DRMODE_SOLID);
1026 rb->lcd_fillrect(1+pos*6+1+k, TEXT_1_POS+k, 1019 rb->lcd_fillrect(x + (w*k)/8, Y_1_POS - h -1 + (h*k)/8,
1027 (5-2*k)>0?(5-2*k):1, (7-2*k)>0?(7-2*k):1 ); 1020 (w*(4-k))/4, (h*(4-k))/4);
1028 rb->lcd_update_rect(1+pos*6, TEXT_1_POS, 6, 8); 1021 rb->lcd_update_rect(x, Y_1_POS - h -1, w, h);
1022 rb->sleep(HZ/32);
1029 } 1023 }
1030
1031} 1024}
1032 1025
1033/* ----------------------------------------------------------------------- 1026/* -----------------------------------------------------------------------