Skip to content

Commit

Permalink
set up service
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellery Newcomer committed Apr 25, 2018
1 parent 5d8edaa commit 19247db
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
6 changes: 4 additions & 2 deletions deploy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from robotpy_installer.installer import SshController

ssh = SshController('10.32.23.6', 'pi', 'raspberry', allow_mitm=True)
ssh = SshController('10.32.23.6', 'pi', 'pypi', allow_mitm=True)
ssh.ssh("mkdir -p /home/pi/squiggly")
ssh.ssh("rm -rf /home/pi/squiggly/*")
ssh.sftp('./src', '/home/pi/squiggly')
ssh.sftp('./src', '/home/pi/squiggly')
ssh.ssh("sudo /etc/init.d/lightshow restart")
35 changes: 35 additions & 0 deletions src/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from threading import Thread

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


import logging
logging.basicConfig(level=logging.DEBUG)

class MyController(Controller):
def __init__(self):
super().__init__()
NetworkTables.initialize("10.32.23.10")
self.table = NetworkTables.getTable("LEDS")
self.table.addEntryListener(self.valueChanged)
self.leds = LEDSubsystem()

self.leds.setDefaultCommand(BlinkyCommand())

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


def valueChanged(self, table, key, value, isNew):
if key == 'nacho':
OtherBlinkyCommand().start()



controller = MyController()
controller.start()


16 changes: 11 additions & 5 deletions src/test2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@
from commands.example import BlinkyCommand, OtherBlinkyCommand
from controller import Controller
from subsystems import LEDSubsystem
from networktables import NetworkTables


import logging
logging.basicConfig(level=logging.DEBUG)

class MyController(Controller):
def __init__(self):
super().__init__()
NetworkTables.initialize("10.32.23.10")
self.table = NetworkTables.getTable("LEDS")
self.table.addEntryListener(self.valueChanged)
self.leds = LEDSubsystem()

self.leds.setDefaultCommand(BlinkyCommand())

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

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

def valueChanged(self, table, key, value, isNew):
if key == 'nacho':
OtherBlinkyCommand().start()



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


5 changes: 4 additions & 1 deletion test_nt_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from networktables import NetworkTables
import time

import logging
logging.basicConfig(level=logging.DEBUG)

NetworkTables.initialize()


while True:
time.sleep(1)
time.sleep(1)

0 comments on commit 19247db

Please sign in to comment.