Browse Source

Moving some constants into text module

Matt Sparks 15 years ago
parent
commit
8d4c1117fd
2 changed files with 69 additions and 137 deletions
  1. 1 63
      alphasign/constants.py
  2. 68 74
      alphasign/text.py

+ 1 - 63
alphasign/constants.py

@@ -56,54 +56,6 @@ positions = {
   "right":              "\x32",
 }
 
-# Character Sets
-charsets = {
-  "five_high_std":      "1",
-  "five_stroke":        "2",
-  "seven_high_std":     "3",
-  "seven_stroke":       "4",
-  "seven_high_fancy":   "5",
-  "ten_high_std":       "6",
-  "seven_shadow":       "7",
-  "full_height_fancy":  "8",
-  "full_height_std":    "9",
-  "seven_shadow_fancy": ":",
-  "five_wide":          ";",
-  "seven_wide":         "<",
-  "seven_fancy_wide":   "=",
-  "wide_stroke_five":   ">",
-  # The following four only work on Alpha 2.0 and Alpha 3.0 protocols
-  "five_high_cust":     "W",
-  "seven_high_cust":    "X",
-  "ten_high_cust":      "Y",
-  "fifteen_high_cust":  "Z",
-}
-
-# Extended characters
-extchars = {
-  "up_arrow":           "\x64",
-  "down_arrow":         "\x65",
-  "left_arrow":         "\x66",
-  "right_arrow":        "\x67",
-  "pacman":             "\x68",
-  "sail_boat":          "\x69",
-  "ball":               "\x6A",
-  "telephone":          "\x6B",
-  "heart":              "\x6C",
-  "car":                "\x6D",
-  "handicap":           "\x6E",
-  "rhino":              "\x6F",
-  "mug":                "\x70",
-  "satellite_dish":     "\x71",
-  "copyright_symbol":   "\x72",
-  "male_symbol":        "\x73",
-  "female_symbol":      "\x74",
-  "bottle":             "\x75",
-  "diskette":           "\x76",
-  "printer":            "\x77",
-  "musical_note":       "\x78",
-  "infinity_symbol":    "\x79",
-}
 
 # Counters
 # We have 5 of them.
@@ -115,21 +67,7 @@ counters = {
   5:                    "-",
 }
 
-# Colors
-colors = {
-  "red":                "1",
-  "green":              "2",
-  "amber":              "3",
-  "dim_red":            "4",
-  "dim_green":          "5",
-  "brown":              "6",
-  "orange":             "7",
-  "yellow":             "8",
-  "rainbow_1":          "9",
-  "rainbow_2":          "A",
-  "color_mix":          "B",
-  "autocolor":          "C",
-}
+
 
 # Command Codes
 WRITE_TEXT            = "A"  # Write TEXT file (p18)

+ 68 - 74
alphasign/text.py

@@ -2,6 +2,74 @@ import constants
 from packet import Packet
 
 
+# Colors
+RED       = "\x1C1"
+GREEN     = "\x1C2"
+AMBER     = "\x1C3"
+DIM_RED   = "\x1C4"
+DIM_GREEN = "\x1C5"
+BROWN     = "\x1C6"
+ORANGE    = "\x1C7"
+YELLOW    = "\x1C8"
+RAINBOW_1 = "\x1C9"
+RAINBOW_2 = "\x1CA"
+COLOR_MIX = "\x1CB"
+AUTOCOLOR = "\x1CC"
+# TODO(ms): need support for RGB colors
+
+# Character sets
+FIVE_HIGH_STD      = "\x1A1"
+FIVE_STROKE        = "\x1A2"
+SEVEN_HIGH_STD     = "\x1A3"
+SEVEN_STROKE       = "\x1A4"
+SEVEN_HIGH_FANCY   = "\x1A5"
+TEN_HIGH_STD       = "\x1A6"
+SEVEN_SHADOW       = "\x1A7"
+FULL_HEIGHT_FANCY  = "\x1A8"
+FULL_HEIGHT_STD    = "\x1A9"
+SEVEN_SHADOW_FANCY = "\x1A:"
+FIVE_WIDE          = "\x1A;"
+SEVEN_WIDE         = "\x1A<"
+SEVEN_FANCY_WIDE   = "\x1A="
+WIDE_STROKE_FIVE   = "\x1A>"
+# Alpha 2.0 and 3.0 only
+FIVE_HIGH_CUST     = "\x1AW"
+SEVEN_HIGH_CUST    = "\x1AX"
+TEN_HIGH_CUST      = "\x1AY"
+FIFTEEN_HIGH_CUST  = "\x1AZ"
+
+# Extended characters
+UP_ARROW         = "\x08\x64"
+DOWN_ARROW       = "\x08\x65"
+LEFT_ARROW       = "\x08\x66"
+RIGHT_ARROW      = "\x08\x67"
+PACMAN           = "\x08\x68"
+SAIL_BOAT        = "\x08\x69"
+BALL             = "\x08\x6A"
+TELEPHONE        = "\x08\x6B"
+HEART            = "\x08\x6C"
+CAR              = "\x08\x6D"
+HANDICAP         = "\x08\x6E"
+RHINO            = "\x08\x6F"
+MUG              = "\x08\x70"
+SATELLITE_DISH   = "\x08\x71"
+COPYRIGHT_SYMBOL = "\x08\x72"
+MALE_SYMBOL      = "\x08\x73"
+FEMALE_SYMBOL    = "\x08\x74"
+BOTTLE           = "\x08\x75"
+DISKETTE         = "\x08\x76"
+PRINTER          = "\x08\x77"
+MUSICAL_NOTE     = "\x08\x78"
+INFINITY_SYMBOL  = "\x08\x79"
+
+# Display speeds
+SPEED_1 = "\x15"
+SPEED_2 = "\x16"
+SPEED_3 = "\x17"
+SPEED_4 = "\x18"
+SPEED_5 = "\x19"
+
+
 class Text(object):
   def __init__(self, msg=None, label=None, position=None, mode=None):
     if label is None:
@@ -22,77 +90,3 @@ class Text(object):
 
   def __repr__(self):
     return repr(self.__str__())
-
-
-def color(color="autocolor"):
-  """Returns color code for a specified color.
-
-  Args:
-    color: color string
-
-  Returns:
-    FIXME
-  """
-  if color not in constants.colors:
-    color = "autocolor"
-  return "%s%s" % ("\x1C", constants.colors[color])
-
-
-def charset(charset="five_high_std"):
-  """Returns control code for a specified character set.
-
-  Args:
-    charset: charset name string
-
-  Returns:
-    FIXME
-  """
-  if charset not in constants.charsets:
-    charset = "five_high_std"
-  return "%s%s" % ("\x1A", constants.charsets[charset])
-
-
-def extchar(extchar="left_arrow"):
-  """Returns control code for a specified extended character.
-
-  Args:
-    extchar: extended character name
-
-  Returns:
-    FIXME
-  """
-  if extchar not in constants.extchars:
-    extchar = "left_arrow"
-  return "%s%s" % ("\x08", constants.extchars[extchar])
-
-
-def spacing(option=0):
-  """Returns control code to set the character spacing.
-
-  Args:
-    option: 0 - set proportional characters
-            1 - fixed width left justified characters
-
-  Returns:
-    FIXME
-  """
-  byte = (option == 0) and "0" or "1"
-  return "\x1E%s" % byte
-
-
-def speed(speed):
-  """Set the speed of the scrolling text.
-
-  Args:
-    speed: integer 1 (slowest) through 5 (fastest) inclusive
-
-  Returns:
-    FIXME
-  """
-  if speed < 1:
-    speed = 1
-  elif speed > 5:
-    speed = 5
-
-  n = 20 + speed
-  return chr(n)