import logging from tools import KAPCOMLog # Logging _log = KAPCOMLog("SevenSegment", logging.WARN) log = _log.log class SevenSegment(object): formats = [ "default" ] def __init__(self, name, api, options=None): """Initialize pin with parameters""" # Set core attributes self.device = None self.arduino = None self.name = name self.api = api # Pre-set extra attributes self.type = "default" self.length = 8 self.offset = 0 self.decimals = 3 self.pad = " " # Override defaults with passed values
import logging from datetime import datetime try: import pyautogui except ImportError: print("Pyautogui not found. Keypresses will not work.") from pin import DigitalIn, DigitalOut from tools import KAPCOMLog # Logging _log = KAPCOMLog("Mod", logging.WARN) log = _log.log class Mod(object): def __init__(self, arduino, name, api, modifier, indicator, button, options=None): """Initialize modifier with parameters""" if options is None: options = {} # Set core attributes
import platform import logging import serial from tools import KAPCOMLog if platform.system() == 'Windows': import _winreg as winreg import itertools elif platform.system() == 'Darwin': from serial.tools import list_ports else: import glob # Logging _log = KAPCOMLog("Arduino", logging.INFO) log = _log.log class Arduino(object): def __init__(self, name, uuid=None, port=None, baud=115200, timeout=2, s=None, silent=True): """Initializes serial communication with Arduino""" self.name = name self.connected = False
import threading import logging sys.path.append(os.getcwd() + "/pyksp") import pyksp from arduino import Arduino from pin import DigitalIn, DigitalOut, AnalogIn, AnalogOut from mod import Mod from joy import Joy from bargraph import Bargraph from sevensegment import SevenSegment from tools import KAPCOMLog # Logging _log = KAPCOMLog("KAPCOM", logging.INFO) log = _log.log class KAPCOM(object): """Creates an interface between the Arduino serial connection and Telemachus library.""" # Define subscriptions for PyKSP to use subscriptions = { "pause_state", "vessel_altitude", "vessel_apoapsis", "vessel_periapsis", "vessel_velocity", "vessel_orbital_velocity", "vessel_surface_velocity", "vessel_atmospheric_density", "vessel_surface_speed", "vessel_gee_force", "vessel_inclination", "vessel_asl_height", "resource_ox_max", "resource_ox_current", "resource_lf_max", "resource_lf_current", "resource_sf_max", "resource_sf_current", "resource_mp_max", "resource_mp_current",
import sys import os import platform import time import datetime import socket import atexit import json import logging except ImportError: print("Failed to import necessary core modules.") exit() from tools import KAPCOMLog _log = KAPCOMLog("Setup", logging.INFO) log = _log.log tryinstall = False log.info("Checking Python version") if "2.7" in sys.version.partition(' ')[0]: log.info("OK") else: log.critical("Failed") log.critical("Please use Python 2.7") exit(1) # Check for pip log.info("Checking for pip") try:
from abc import ABCMeta, abstractmethod from datetime import datetime import logging try: import pyautogui except ImportError: print("Pyautogui not found. Keypresses will not work.") from tools import KAPCOMLog # Logging _log = KAPCOMLog("Pin", logging.WARN) log = _log.log class _Pin(object): __metaclass__ = ABCMeta # Core Class Members # name # api # pin # value # arduino # format # invert # cooldown # _lastupdate # _lastvalue
import sys import logging from pin import AnalogIn, DigitalIn from tools import KAPCOMLog # Logging _log = KAPCOMLog("Joy", logging.WARN) log = _log.log class Joy(object): def __init__(self, arduino, name, api, x, y, z, button, options=None): all_options = {'format': 'floatpoint'} button_options = {'format': 'value'} try: invert_button = options['invertButton'] button_options['invert'] = invert_button except (KeyError, TypeError): button_options = None try: x_options = all_options.copy() invert_x = options['invertX'] x_options['invert'] = invert_x except (KeyError, TypeError): x_options = None try: y_options = all_options.copy()
import logging from datetime import datetime from tools import KAPCOMLog # Logging _log = KAPCOMLog("Bargraph", logging.WARN) log = _log.log class Bargraph(object): formats = ["default", "red", "yellow", "green", "rainbow", "delta"] def __init__(self, name, api, options=None): """Initialize pin with parameters""" # Set core attributes self.device = None self.arduino = None self.name = name self.api = api # Pre-set extra attributes self.type = "delta" self.max = 100 self.showdelta = 60 * 1000 # Override defaults with passed values if options: for key in options: setattr(self, key, options[key])