Skip to content

Commit

Permalink
expa 18 modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak committed Aug 26, 2018
1 parent c062d8d commit 11d63df
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/drivers/gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def __init__(self):
self.config1 = 0x00
self.port0 = 0b00000000
self.port1 = 0b00000000
self.devices0 = ['mount_pwr', 'laser_pwr', '12V_3', '12V_4', 'laser_status', None, None, None]
self.devices0 = ['mount_pwr', 'laser_pwr', '12V_3', 'laser_status', 'Empty', None, None, None]
#self.devices0 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
self.devices1 = [None, None, None, None, None, None, None, None]

rospy.Subscriber("/gpio/gpio_mount", String, callback_btn)
self.pub_status = rospy.Publisher('/gpio/gpio_status', String, queue_size=10)
self.pub_status = rospy.Publisher('/gpio/gpio_status', String, queue_size=2, latch=True)

AromNode.__init__(self)
self.set_feature('gpio_set_port',{'ports': 8, 'devices': str(self.devices0) ,'subscrib': '/gpio/gpio_mount'})
Expand Down
71 changes: 37 additions & 34 deletions src/drivers/io/io_keyboard
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class user_input(arom_helper.AromNode):

self.led_status = 0
self.layer_count = 2
self.toggle_button = 172
self.toggle_button = 69
self.setLayer()
self.device1 = evdev.InputDevice('/dev/input/event2')
self.device2 = evdev.InputDevice('/dev/input/event3')
self.device1 = evdev.InputDevice('/dev/input/event6')
self.device2 = evdev.InputDevice('/dev/input/event5')
self.device1.grab()
self.device2.grab()

Expand Down Expand Up @@ -100,46 +100,48 @@ class user_input(arom_helper.AromNode):
}]

keymap_zvpp = [{
172: 'shift',
15: 'dome_a',
155: 'dome_b',
140: 'tracking_toggle',
69: 'telescopeA_close',
98: 'telescopeB_close',
55: 'telescopeC_close',
14: None,
71: 'telescopeA_irisM',
72: 'telescopeB_irisM',
73: 'telescopeC_irisM',
74: None,
75: 'telescopeA_irisP',
76: 'telescopeB_irisP',
77: 'telescopeC_irisP',
78: None,
79: 'telescopeA_focusM',
80: 'telescopeB_focusM',
81: 'telescopeC_focusM',
82: 'telescopeA_focusP',
11: 'telescopeB_focusP',
83: 'telescopeC_focusP',
69: 'shift',
15: None,
155: None,
140: None,
690: None,
98: None,
51: 'A',
55: None,
14: 'gpio_3_toggle',
71: None,
72: 'DEC_P',
73: None,
74: 'B',
75: 'RA_M',
76: 'STOP',
77: 'RA_P',
78: 'C',
79: None,
80: 'DEC_M',
81: None,
82: None,
11: None,
83: None,
96: None,
},{
172: 'shift',
15: 'dome_a',
155: 'dome_b',
140: 'tracking_toggle',
69: 'RA_center',
98: 'DEC_center',
69: 'shift',
15: None,
155: None,
140: None,
690: None,
98: None,
51: 'A',
55: None,
14: None,
14: 'gpio_3_toggle',
71: None,
72: 'DEC_P',
73: None,
74: None,
74: 'B',
75: 'RA_P',
76: 'STOP',
77: 'RA_M',
78: None,
78: 'C',
79: None,
80: 'DEC_M',
81: None,
Expand All @@ -161,6 +163,7 @@ class user_input(arom_helper.AromNode):
while True:
dev_out = dev.next()
if dev_out.type == ecodes.EV_KEY and dev_out.value in [0,1]:
print(dev_out)
data.append(self.GetKey(dev_out))
except Exception as e:
pass
Expand Down
10 changes: 7 additions & 3 deletions src/drivers/lcd_client
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class lcdClient(AromNode):

rospy.Subscriber("/arom/UI/buttons", std_msgs.msg.String, self.callback_btn)
rospy.Subscriber("/arom/node/lcdText", std_msgs.msg.String, self.callback_btn)
rospy.Subscriber("/arom/node/lcdText", std_msgs.msg.String, self.callback_btn)
#rospy.Subscriber("/arom/node/lcdText", std_msgs.msg.String, self.callback_btn)
self.lcdText_pub = rospy.Publisher('/arom/node/lcdText', std_msgs.msg.String, queue_size=5)


Expand Down Expand Up @@ -72,7 +72,7 @@ class lcdClient(AromNode):
self.pymlab(device="StatusLCD", method="home")

time.sleep(0.5)
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA="Welcome...", lineB="AROM MLAB.cz")))
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA="Welcome ...", lineB="AROM MLAB.cz")))

print "-------------"

Expand All @@ -97,15 +97,19 @@ class lcdClient(AromNode):
elif last_data[0] == 'KEY_POWER':
print "lightOff"
self.pymlab(device="StatusLCD", method="light")
else:
#self.setLCD("TEST", "test")
print "Data not sended to LCD display"


except Exception, e:
print e
time.sleep(0.1)

def setLCD(self, lineA, lineB):
self.pymlab(device="StatusLCD", method="clear")
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=str(lineA), lineB=str(lineB))))
self.lcdText_pub.publish(str(lineA)+"\n"+str(lineB))
#self.lcdText_pub.publish(str(lineA)+"\n"+str(lineB))


def callback_btn(self,recive):
Expand Down
138 changes: 138 additions & 0 deletions src/drivers/lcd_client.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math
import time
import rospy
import std_msgs
import json
import os
from std_msgs.msg import String
from std_msgs.msg import Float32
from arom.srv import *
from arom.msg import *
import numpy as np
from __init__ import AromNode


aws_data = {}
btn_data = []

def callback_aws(recive):
global aws_data
for i, type in enumerate(recive.type):
aws_data[type] = recive.value[i]
#print aws_data

def callback_btn(recive):
global btn_data
btn_data.append(recive.data)
#print recive, btn_data

class lcdClient(AromNode):
node_name = "lcd_client"
node_type = "lcd_client"
node_pymlab = True
btn_data = []

def __init__(self):
print os.path.abspath(__file__)

rospy.Subscriber("/arom/UI/buttons", std_msgs.msg.String, self.callback_btn)
rospy.Subscriber("/arom/node/lcdText", std_msgs.msg.String, self.callback_btn)
rospy.Subscriber("/arom/node/lcdText", std_msgs.msg.String, self.callback_btn)
self.lcdText_pub = rospy.Publisher('/arom/node/lcdText', std_msgs.msg.String, queue_size=5)


AromNode.__init__(self)
self.set_feature('display_show',{'rows': 2, 'cols': 16, 'publish': '/arom/node/lcdText'})
#self.set_feature('display_show',{'rows': rows, 'cols': cols, 'publish': '/arom/node/lcdText'})
#self.set_feature('display_control', {'up': 'KEY_VOLUMEUP', 'down': 'KEY_VOLUMEDOWN', 'back': 'KEY_F2', 'enter': 'KEY_F3', 'subscrib': '/arom/UI/buttons'})


rospy.Subscriber(name = "/arom/node%s/rows" %(rospy.get_name()), data_class = std_msgs.msg.String, callback = self.RowData, callback_args=None)
rospy.Subscriber(name = "/arom/node%s/row1" %(rospy.get_name()), data_class = std_msgs.msg.String, callback = self.RowData, callback_args=1)
rospy.Subscriber(name = "/arom/node%s/row2" %(rospy.get_name()), data_class = std_msgs.msg.String, callback = self.RowData, callback_args=2)
rospy.Subscriber(name = "/arom/node%s/row3" %(rospy.get_name()), data_class = std_msgs.msg.String, callback = self.RowData, callback_args=3)
rospy.Subscriber(name = "/arom/node%s/row4" %(rospy.get_name()), data_class = std_msgs.msg.String, callback = self.RowData, callback_args=4)


##
## Konec zakladni inicializace
##

self.rows = 2
self.cols = 16

print "zinicializovano"

self.pymlab(device="StatusLCD", method="reset")
self.pymlab(device="StatusLCD", method="init")
self.pymlab(device="StatusLCD", method="clear")
self.pymlab(device="StatusLCD", method="home")

time.sleep(0.5)
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA="Welcome...", lineB="AROM MLAB.cz")))

print "-------------"


rate = rospy.Rate(10)
ra = 0
dec = 90
while not rospy.is_shutdown():
try:
if len(self.btn_data) > 0:
print self.btn_data[0], len(self.btn_data)
lastBtn = self.btn_data[0]
last_data = lastBtn.split(" ")
self.btn_data.pop(0)

print "incomming:", last_data

if last_data[0] == 'KEY_MENU':
print "light"
self.pymlab(device="StatusLCD", method="lightToggle")

elif last_data[0] == 'KEY_POWER':
print "lightOff"
self.pymlab(device="StatusLCD", method="light")


except Exception, e:
print e
time.sleep(0.1)

def setLCD(self, lineA, lineB):
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=str(lineA), lineB=str(lineB))))
self.lcdText_pub.publish(str(lineA)+"\n"+str(lineB))


def callback_btn(self,recive):
self.btn_data.append(recive.data)

def RowData(self, recive, arg = None):
print "RowData", arg, recive
recive = str(recive.data)

if not arg:
recive += "\n " # tohle je ochrana pred tim, kdyz retezec nebude obsahovat EOL retezec
recive = recive.splitlines()
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=str(recive[0]), lineB=str(recive[1]))))
self.lcdText_pub.publish(str(recive[0])+"\n"+str(recive[1]))
elif arg == 1:
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=str(recive), lineB = None) ))
self.lcdText_pub.publish(str(recive)+"\n"+str(""))
elif arg == 2:
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=None, lineB = str(recive) )))
self.lcdText_pub.publish(str("")+"\n"+str(recive))
elif arg == 3:
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=None, lineB = None )))
elif arg == 4:
self.pymlab(device="StatusLCD", method="putsFull", parameters=str(dict(lineA=None, lineB = None )))



if __name__ == '__main__':
m = lcdClient()

Loading

0 comments on commit 11d63df

Please sign in to comment.