summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/calculator.c211
1 files changed, 67 insertions, 144 deletions
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 257a279839..1630f03877 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -20,58 +20,31 @@
/*
00 01 21 22 23 43 44 45 65 66 67 87 88 89 109110111
00 |-----------|-----------|-----------|-----------|-----------|
-01 |
- | | | | |
- |
-***********|
-***********|
-***********|
-***********|
-***********|
- |
-***********|
-***********|
-***********|
-***********|
-***********|
-11 |
- | | | | |
+01 | | | | | |
+ |***********|***********|***********|***********|***********|
+ |***********|***********|***********|***********|***********|
+11 | | | | | |
12 |-----------|-----------|-----------|-----------|-----------|
13 |-----------|-----------|-----------|-----------|-----------| y1
-14 |
- | | | | |
-
+14 | | | | | |
| | | | | |
-22 |
- | | | | |
+22 | | | | | |
23 |-----------|-----------|-----------|-----------|-----------| y2
-24 |
- | | | | |
-
+24 | | | | | |
| | | | | |
-32 |
- | | | | |
+32 | | | | | |
33 |-----------|-----------|-----------|-----------|-----------| y3
-34 |
- | | | | |
-
+34 | | | | | |
| | | | | |
-42 |
- | | | | |
+42 | | | | | |
43 |-----------|-----------|-----------|-----------|-----------| y4
-44 |
- | | | | |
-
+44 | | | | | |
| | | | | |
-52 |
- | | | | |
+52 | | | | | |
53 |-----------|-----------|-----------|-----------|-----------| y5
-54 |
- | | | | |
-
+54 | | | | | |
| | | | | |
-62 |
- | | | | |
+62 | | | | | |
63 |-----------|-----------|-----------|-----------|-----------| y6
x0 x1 x2 x3 x4 x5
*/
@@ -227,106 +200,56 @@ enum {cal_normal, /* 0, normal status, display result */
/* constant table for CORDIC algorithm */
double cordicTable[51][2]= {
/* pow(2,0) - pow(2,-50) atan(pow(2,0) - atan(pow(2,-50) */
- {1e+00,
- 7.853981633974483e-01},
- {5e-01,
- 4.636476090008061e-01},
- {2.5e-01,
- 2.449786631268641e-01},
- {1.25e-01,
- 1.243549945467614e-01},
- {6.25e-02,
- 6.241880999595735e-02},
- {3.125e-02,
- 3.123983343026828e-02},
- {1.5625e-02,
- 1.562372862047683e-02},
- {7.8125e-03,
- 7.812341060101111e-03},
- {3.90625e-03,
- 3.906230131966972e-03},
- {1.953125e-03,
- 1.953122516478819e-03},
- {9.765625e-04,
- 9.765621895593195e-04},
- {4.8828125e-04,
- 4.882812111948983e-04},
- {2.44140625e-04,
- 2.441406201493618e-04},
- {1.220703125e-04,
- 1.220703118936702e-04},
- {6.103515625e-05,
- 6.103515617420877e-05},
- {3.0517578125e-05,
- 3.051757811552610e-05},
- {1.52587890625e-05,
- 1.525878906131576e-05},
- {7.62939453125e-06,
- 7.629394531101970e-06},
- {3.814697265625e-06,
- 3.814697265606496e-06},
- {1.9073486328125e-06,
- 1.907348632810187e-06},
- {9.5367431640625e-07,
- 9.536743164059608e-07},
- {4.76837158203125e-07,
- 4.768371582030888e-07},
- {2.384185791015625e-07,
- 2.384185791015580e-07},
- {1.1920928955078125e-07,
- 1.192092895507807e-07},
- {5.9604644775390625e-08,
- 5.960464477539055e-08},
- {2.98023223876953125e-08,
- 2.980232238769530e-08},
- {1.490116119384765625e-08,
- 1.490116119384765e-08},
- {7.450580596923828125e-09,
- 7.450580596923828e-09},
- {3.7252902984619140625e-09,
- 3.725290298461914e-09},
- {1.86264514923095703125e-09,
- 1.862645149230957e-09},
- {9.31322574615478515625e-10,
- 9.313225746154785e-10},
- {4.656612873077392578125e-10,
- 4.656612873077393e-10},
- {2.3283064365386962890625e-10,
- 2.328306436538696e-10},
- {1.16415321826934814453125e-10,
- 1.164153218269348e-10},
- {5.82076609134674072265625e-11,
- 5.820766091346741e-11},
- {2.910383045673370361328125e-11,
- 2.910383045673370e-11},
- {1.4551915228366851806640625e-11,
- 1.455191522836685e-11},
- {7.2759576141834259033203125e-12,
- 7.275957614183426e-12},
- {3.63797880709171295166015625e-12,
- 3.637978807091713e-12},
- {1.818989403545856475830078125e-12,
- 1.818989403545856e-12},
- {9.094947017729282379150390625e-13,
- 9.094947017729282e-13},
- {4.5474735088646411895751953125e-13,
- 4.547473508864641e-13},
- {2.27373675443232059478759765625e-13,
- 2.273736754432321e-13},
- {1.136868377216160297393798828125e-13,
- 1.136868377216160e-13},
- {5.684341886080801486968994140625e-14,
- 5.684341886080801e-14},
- {2.8421709430404007434844970703125e-14,
- 2.842170943040401e-14},
- {1.42108547152020037174224853515625e-14,
- 1.421085471520200e-14},
- {7.10542735760100185871124267578125e-15,
- 7.105427357601002e-15},
- {3.552713678800500929355621337890625e-15,
- 3.552713678800501e-15},
- {1.7763568394002504646778106689453125e-15,
- 1.776356839400250e-15},
+ {1e+00, 7.853981633974483e-01},
+ {5e-01, 4.636476090008061e-01},
+ {2.5e-01, 2.449786631268641e-01},
+ {1.25e-01, 1.243549945467614e-01},
+ {6.25e-02, 6.241880999595735e-02},
+ {3.125e-02, 3.123983343026828e-02},
+ {1.5625e-02, 1.562372862047683e-02},
+ {7.8125e-03, 7.812341060101111e-03},
+ {3.90625e-03, 3.906230131966972e-03},
+ {1.953125e-03, 1.953122516478819e-03},
+ {9.765625e-04, 9.765621895593195e-04},
+ {4.8828125e-04, 4.882812111948983e-04},
+ {2.44140625e-04, 2.441406201493618e-04},
+ {1.220703125e-04, 1.220703118936702e-04},
+ {6.103515625e-05, 6.103515617420877e-05},
+ {3.0517578125e-05, 3.051757811552610e-05},
+ {1.52587890625e-05, 1.525878906131576e-05},
+ {7.62939453125e-06, 7.629394531101970e-06},
+ {3.814697265625e-06, 3.814697265606496e-06},
+ {1.9073486328125e-06, 1.907348632810187e-06},
+ {9.5367431640625e-07, 9.536743164059608e-07},
+ {4.76837158203125e-07, 4.768371582030888e-07},
+ {2.384185791015625e-07, 2.384185791015580e-07},
+ {1.1920928955078125e-07, 1.192092895507807e-07},
+ {5.9604644775390625e-08, 5.960464477539055e-08},
+ {2.98023223876953125e-08, 2.980232238769530e-08},
+ {1.490116119384765625e-08, 1.490116119384765e-08},
+ {7.450580596923828125e-09, 7.450580596923828e-09},
+ {3.7252902984619140625e-09, 3.725290298461914e-09},
+ {1.86264514923095703125e-09, 1.862645149230957e-09},
+ {9.31322574615478515625e-10, 9.313225746154785e-10},
+ {4.656612873077392578125e-10, 4.656612873077393e-10},
+ {2.3283064365386962890625e-10, 2.328306436538696e-10},
+ {1.16415321826934814453125e-10, 1.164153218269348e-10},
+ {5.82076609134674072265625e-11, 5.820766091346741e-11},
+ {2.910383045673370361328125e-11, 2.910383045673370e-11},
+ {1.4551915228366851806640625e-11, 1.455191522836685e-11},
+ {7.2759576141834259033203125e-12, 7.275957614183426e-12},
+ {3.63797880709171295166015625e-12, 3.637978807091713e-12},
+ {1.818989403545856475830078125e-12, 1.818989403545856e-12},
+ {9.094947017729282379150390625e-13, 9.094947017729282e-13},
+ {4.5474735088646411895751953125e-13, 4.547473508864641e-13},
+ {2.27373675443232059478759765625e-13, 2.273736754432321e-13},
+ {1.136868377216160297393798828125e-13, 1.136868377216160e-13},
+ {5.684341886080801486968994140625e-14, 5.684341886080801e-14},
+ {2.8421709430404007434844970703125e-14, 2.842170943040401e-14},
+ {1.42108547152020037174224853515625e-14, 1.421085471520200e-14},
+ {7.10542735760100185871124267578125e-15, 7.105427357601002e-15},
+ {3.552713678800500929355621337890625e-15, 3.552713678800501e-15},
+ {1.7763568394002504646778106689453125e-15, 1.776356839400250e-15},
{8.8817841970012523233890533447265625e-16, 8.881784197001252e-16}
};
@@ -1383,9 +1306,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
calStatus = cal_exit;
printResult();
break;
- case SYS_USB_CONNECTED:
- rb->usb_screen();
- return PLUGIN_USB_CONNECTED;
+ default:
+ if(rb->default_event_handler(btn) == SYS_USB_CONNECTED)
+ return PLUGIN_USB_CONNECTED;
break;
} /* switch (btn) */
} /* while (calStatus != cal_exit ) */