Skip to content

Commit

Permalink
be pycharming
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellery Newcomer committed Apr 3, 2018
1 parent da43f71 commit b1292b9
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 83 deletions.
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,50 @@
/__pycache__
*.pyc

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/
cmake-build-release/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests
14 changes: 14 additions & 0 deletions .idea/lightshow.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 0 additions & 38 deletions scheduler_test.py

This file was deleted.

2 changes: 1 addition & 1 deletion colorcycletemplate.py → src/colorcycletemplate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import apa102
from subsystems import apa102
import time

class ColorCycleTemplate:
Expand Down
File renamed without changes.
52 changes: 8 additions & 44 deletions test2_2.py → src/commands/example.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
from controller import Controller
from threading import Thread
from apa102 import APA102
import wpilib
from wpilib.command import Subsystem, Command
from wpilib.command import Command
from subsystems import LEDSubsystem

class LEDSubsystem(Subsystem, APA102):
def __init__(self):
Subsystem.__init__(self)
APA102.__init__(self,
numLEDs=144,
globalBrightness=5,
order='rgb')

def initDefaultCommand(self):
self.setDefaultCommand(StrafeyCommand())

led_subsystem = None

class StrafeyCommand(Command):
class BlinkyCommand(Command):
def __init__(self):
super().__init__()
self.leds = led_subsystem
self.leds = LEDSubsystem.getInstance()
self.requires(self.leds)
self.timer = wpilib.Timer()
self.state = False
Expand All @@ -30,6 +16,7 @@ def initialize(self):
self.timer.start()

def execute(self):
# this method is executed approximately once every 5 ms
if self.timer.get() > 0.5:
self.timer.reset()
if self.state:
Expand All @@ -46,10 +33,11 @@ def isFinished(self):
def end(self):
self.leds.clearStrip()

class StrafeyCommand2(Command):

class OtherBlinkyCommand(Command):
def __init__(self):
super().__init__()
self.leds = led_subsystem
self.leds = LEDSubsystem.getInstance()
self.requires(self.leds)
self.timer = wpilib.Timer()
self.state = False
Expand Down Expand Up @@ -77,27 +65,3 @@ def isFinished(self):

def end(self):
self.leds.clearStrip()


class MyController(Controller):
def __init__(self):
global led_subsystem
super().__init__()
led_subsystem = self.leds = LEDSubsystem()

def shutdown(self):
self.leds.clearStrip()

def scheduleit(self):
print('schiedule')
import time
time.sleep(2)
StrafeyCommand2().start()



controller = MyController()
Thread(target=lambda: controller.scheduleit()).start()
controller.start()


File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/subsystems/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .apa102 import APA102
from wpilib.command import Subsystem


class LEDSubsystem(Subsystem, APA102):
@classmethod
def getInstance(cls):
return cls.instance

def __init__(self):
Subsystem.__init__(self)
APA102.__init__(self,
numLEDs=144,
globalBrightness=5,
order='rgb')
LEDSubsystem.instance = self

File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions src/test2_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from threading import Thread

from commands.example import BlinkyCommand, OtherBlinkyCommand
from controller import Controller
from subsystems import LEDSubsystem


class MyController(Controller):
def __init__(self):
super().__init__()
self.leds = LEDSubsystem()

self.leds.setDefaultCommand(BlinkyCommand())

def shutdown(self):
self.leds.clearStrip()

def scheduleit(self):
import time
time.sleep(2)
OtherBlinkyCommand().start()



controller = MyController()
Thread(target=lambda: controller.scheduleit()).start()
controller.start()


File renamed without changes.
File renamed without changes.

0 comments on commit b1292b9

Please sign in to comment.