Updating the trig keyboard to have numbers
[ejpi] / src / plugins / trig.py
index f3f61e9..5c33a52 100644 (file)
@@ -1,7 +1,6 @@
 from __future__ import division
 
 import os
-import operator
 import math
 import cmath
 
@@ -12,8 +11,72 @@ sys.path.append("../")
 import plugin_utils
 
 
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "trig.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Trigonometry", _MAP_FILE_PATH)
+_NAME = "Trigonometry"
+_ICON = "trig.png"
+_MAP = {
+       "name": _NAME,
+       "keys": {
+               (0, 0): {
+                       "CENTER": {"action": "7", "type": "text", "text": "7", },
+                       "SOUTH": {"action": "[sinh]", "type": "text", "text": "sinh", },
+                       "SOUTH_EAST": {"action": "[cosh]", "type": "text", "text": "cosh", },
+                       "EAST": {"action": "[tanh]", "type": "text", "text": "tanh", },
+                       "showAllSlices": False,
+               },
+               (0, 1): {
+                       "CENTER": {"action": "8", "type": "text", "text": "8", },
+                       "showAllSlices": False,
+               },
+               (0, 2): {
+                       "CENTER": {"action": "9", "type": "text", "text": "9", },
+                       "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
+                       "SOUTH_WEST": {"action": "[acosh]", "type": "text", "text": "acosh", },
+                       "WEST": {"action": "[atanh]", "type": "text", "text": "atanh", },
+                       "showAllSlices": True,
+               },
+               (1, 0): {
+                       "CENTER": {"action": "4", "type": "text", "text": "4", },
+                       "showAllSlices": True,
+               },
+               (1, 1): {
+                       "CENTER": {"action": "5", "type": "text", "text": "5", },
+                       "NORTH": {"action": "[exp]", "type": "text", "text": "e ** x", },
+                       "SOUTH": {"action": "[log]", "type": "text", "text": "ln", },
+                       "WEST": {"action": "e", "type": "text", "text": "e", },
+                       "EAST": {"action": "j", "type": "text", "text": "j", },
+                       "showAllSlices": True,
+               },
+               (1, 2): {
+                       "CENTER": {"action": "6", "type": "text", "text": "6", },
+                       "WEST": {"action": "pi", "type": "text", "text": "pi", },
+                       "NORTH": {"action": "[rad]", "type": "text", "text": "-> rad", },
+                       "SOUTH": {"action": "[deg]", "type": "text", "text": "-> deg", },
+                       "showAllSlices": True,
+               },
+               (2, 0): {
+                       "CENTER": {"action": "1", "type": "text", "text": "1", },
+                       "NORTH": {"action": ".", "type": "text", "text": ".", },
+                       "EAST": {"action": "0", "type": "text", "text": "0", },
+                       "showAllSlices": True,
+               },
+               (2, 1): {
+                       "CENTER": {"action": "2", "type": "text", "text": "2", },
+                       "WEST": {"action": "[sin]", "type": "text", "text": "sin", },
+                       "NORTH": {"action": "[cos]", "type": "text", "text": "cos", },
+                       "EAST": {"action": "[tan]", "type": "text", "text": "tan", },
+                       "showAllSlices": True,
+               },
+               (2, 2): {
+                       "CENTER": {"action": "3", "type": "text", "text": "3", },
+                       "NORTH": {"action": "[asin]", "type": "text", "text": "asin", },
+                       "NORTH_WEST": {"action": "[acos]", "type": "text", "text": "acos", },
+                       "WEST": {"action": "[atan]", "type": "text", "text": "atan", },
+                       "showAllSlices": False,
+               },
+       },
+}
+_ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
 
 pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
 e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))
@@ -34,7 +97,7 @@ def float_or_complex(float_func, complex_func):
        return switching_func
 
 exp = operation.generate_function(float_or_complex(math.exp, cmath.exp), "exp", operation.Function.REP_FUNCTION, 1)
-log = operation.generate_function(float_or_complex(math.exp, cmath.exp), "log", operation.Function.REP_FUNCTION, 1)
+log = operation.generate_function(float_or_complex(math.log, cmath.log), "log", operation.Function.REP_FUNCTION, 1)
 
 PLUGIN.register_operation("exp", exp)
 PLUGIN.register_operation("log", log)