Skip to content

Commit

Permalink
bugfix: video and lock status mistake + deactivate lock and call button
Browse files Browse the repository at this point in the history
  • Loading branch information
isra67 committed Oct 2, 2017
1 parent 8ec03bc commit ce5353e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 30 deletions.
Binary file added imgs/w_call_grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/w_lock_grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions indoor.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[command]
screen_saver = 0
screen_saver = 45
watches = analog
brightness = 110
dnd_mode = False
Expand All @@ -15,8 +15,8 @@ sip_authentication_name = 48

[devices]
ringtone = tone2.wav
volume = 50
micvolume = 40
volume = 90
micvolume = 30

[gui]
screen_mode = 4
Expand All @@ -25,7 +25,7 @@ outgoing_calls = 1

[common]
server_ip_address_1 = 192.168.1.250
server_ip_address_2 = 192.168.1.251:8080
server_ip_address_2 =
server_ip_address_3 = 192.168.1.251:8080
server_ip_address_4 = 192.168.1.250
server_stream_2 = http://192.168.1.250:80/video.mjpg
Expand All @@ -52,7 +52,7 @@ netmask = 255.255.255.0
[about]
serial = 0000000085a5ba7f
app_name = Indoor 2.0
app_ver = 2.0.0.2
app_ver = 2.0.0.3
uptime = 22:00:30.530000
licencekey = 8685-dd0892-31e0-854a5a-9480
buttonregs = button_regs
Expand Down
4 changes: 3 additions & 1 deletion my_lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
KIVY_CONFIG_FILE = '/root/.kivy/config.ini'

APP_NAME = '-Indoor-2.0-'
APP_VERSION_CODE = '2.0.0.2'
APP_VERSION_CODE = '2.0.0.3'

SCREEN_SAVER = 0
WATCHES = 'analog'
Expand All @@ -46,6 +46,7 @@
HANGUP_CALL_IMG = 'imgs/w_call-disconnect.png'
ERROR_CALL_IMG = 'imgs/nothing.png' # 'imgs/w_call-reject.png'
DND_CALL_IMG = 'imgs/w_call-dnd.png'
UNUSED_CALL_IMG = 'imgs/w_call_grey.png'

VOLUME_IMG = 'imgs/w_speaker.png'
MICROPHONE_IMG = 'imgs/w_microphone.png'
Expand All @@ -55,6 +56,7 @@
LOCK_IMG = 'imgs/w_lock.png'
UNLOCK_IMG = 'imgs/w_unlock.png'
INACTIVE_LOCK_IMG = 'imgs/w_nolock.png'
UNUSED_LOCK_IMG = 'imgs/w_lock_grey.png'

NO_IMG = 'imgs/nothing.png'

Expand Down
Binary file modified my_lib/constants.pyc
Binary file not shown.
68 changes: 44 additions & 24 deletions pjindoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,16 @@ def startThread(self):
"start communication thread to external devicer"
Logger.debug('%s: (%d)' % (whoami(), self.screenIndex))

self.locks = 0x55
sendNodeInfo('[***]LOCK: %d %.2x' % (self.screenIndex, self.locks))

self.socket = None
self.bgrThread = Thread(target=self.tcpip_worker, kwargs={'addr': self.serverAddr})
self.bgrThread.daemon = True
self.bgrThread.start()
if len(self.serverAddr):
self.bgrThread = Thread(target=self.tcpip_worker, kwargs={'addr': self.serverAddr})
self.bgrThread.daemon = True
self.bgrThread.start()
else:
self.bgrThread = None


# ###############################################################
Expand Down Expand Up @@ -468,7 +474,7 @@ def initPlayer(self):
# ###############################################################
def checkLoop(self, dt):
"check video player state"
global mainLayout, current_call, active_display_index
#global mainLayout, current_call, active_display_index

Logger.trace('%s: (%d)' % (whoami(), self.screenIndex))

Expand All @@ -478,7 +484,7 @@ def checkLoop(self, dt):

self.dbus_command(TRANSPARENCY_VIDEO_CMD + [str(val)])

if not self.bgrThread.isAlive(): self.startThread()
if self.bgrThread and not self.bgrThread.isAlive(): self.startThread()


# ###############################################################
Expand Down Expand Up @@ -541,6 +547,7 @@ def tcpip_worker(self, addr):
self.socket.send(SERVER_REQ)
break
except IOError as e:
self.socket = None
Logger.warning('%s: (%d) %s CONNECT ERROR %s' % (whoami(), self.screenIndex, addr, str(e)))
#return
time.sleep(60)
Expand All @@ -560,10 +567,12 @@ def tcpip_worker(self, addr):
continue
else:
# a "real" error occurred
self.socket = None
Logger.warning('%s: (%d) %s ERROR: %s' % (whoami(), self.screenIndex, addr, str(e)))
msg = ''
break
except: pass
except:
self.socket = None

if len(msg) > 0:
# got a message, do something
Expand All @@ -579,6 +588,8 @@ def tcpip_worker(self, addr):
self.socket.close()
except: pass

self.socket = None

try:
time.sleep(5)
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand Down Expand Up @@ -663,7 +674,7 @@ def hidePlayer(self):
# ###############################################################
def setActive(self, active=True):
"add or remove active flag"
global current_call, scr_mode
global current_call, scr_mode, mainLayout, docall_button_global

Logger.debug('%s: index=%d active=%d' % (whoami(), self.screenIndex, active))

Expand All @@ -673,6 +684,15 @@ def setActive(self, active=True):

self.actScreen.bgcolor = self.color

if active:
# change phone icon
docall_button_global.imgpath = DND_CALL_IMG if mainLayout.dnd_mode else MAKE_CALL_IMG
docall_button_global.imgpath = docall_button_global.imgpath if len(self.sipcall) else UNUSED_CALL_IMG
# # enable/disable lock buttons
# val = False if self.bgrThread and self.bgrThread.isAlive() else True
# mainLayout.btnDoor1.disabled = val
# mainLayout.btnDoor2.disabled = mainLayout.btnDoor1.disabled


# ###############################################################
def printInfo(self):
Expand Down Expand Up @@ -1083,6 +1103,8 @@ def init_screen(self):

self.setButtons(False)

self.refreshLockIcons()

self.displays[0].setActive()


Expand Down Expand Up @@ -1382,13 +1404,16 @@ def setLockIcons(self, scrnIdx, locks):
"set lock icons"
global active_display_index

Logger.trace('%s: id=%d locks=%.2x' % (whoami(), scrnIdx, locks))
Logger.debug('%s: id=%d locks=%.2x' % (whoami(), scrnIdx, locks))

img = LOCK_IMG if active_display_index == scrnIdx else INACTIVE_LOCK_IMG
idi = len(self.btnDoor1.children[0].children) - 1 - scrnIdx
img = LOCK_IMG if active_display_index == scrnIdx else INACTIVE_LOCK_IMG

lockimg1 = UNLOCK_IMG if (locks & 0x0f) else img
lockimg2 = UNLOCK_IMG if (locks & 0xf0) else img
if locks == 0x55:
lockimg1 = lockimg2 = UNUSED_LOCK_IMG
else:
lockimg1 = UNLOCK_IMG if (locks & 0x0f) else img
lockimg2 = UNLOCK_IMG if (locks & 0xf0) else img

self.btnDoor1.children[0].children[idi].source = lockimg1
self.btnDoor2.children[0].children[idi].source = lockimg2
Expand All @@ -1404,16 +1429,8 @@ def refreshLockIcons(self):
s = len(self.btnDoor1.children[0].children)

for idx, d in enumerate(self.displays):
locks = d.locks

img = LOCK_IMG if active_display_index == idx else INACTIVE_LOCK_IMG
idi = len(self.btnDoor1.children[0].children) - 1 - idx

lockimg1 = UNLOCK_IMG if (locks & 0x0f) else img
lockimg2 = UNLOCK_IMG if (locks & 0xf0) else img

self.btnDoor1.children[0].children[idi].source = lockimg1
self.btnDoor2.children[0].children[idi].source = lockimg2
idi = s - 1 - idx
self.setLockIcons(idx, d.locks)


# ###############################################################
Expand Down Expand Up @@ -1717,12 +1734,17 @@ def callback_set_voice(self, value=-1):
# ###############################################################
def restart_player_window(self, idx):
"process is bad - restart"
global active_display_index

Logger.info('%s: idx=%d' % (whoami(), idx))

self.displays[idx].hidePlayer()
send_command("ps aux | grep omxplayer%d | grep -v grep | awk '{print $2}' | xargs kill -9" % idx)
send_command('%s%d' % (CMD_KILL, procs[idx].pid))

active_display_index = idx
self.displays[idx].setActive(True)


# ###############################################################
def supporter1(self, dt):
Expand All @@ -1734,7 +1756,7 @@ def supporter1(self, dt):

# ###############################################################
def checkDoubleTap(self,touch):
"check if triple tap is in valid area, if yes -> finish app"
"check if double tap is in valid area, if yes -> finish app"
Logger.info('%s:' % whoami())

x = touch.x
Expand Down Expand Up @@ -1944,8 +1966,6 @@ def setButtons(self, visible):
self.btnAreaH.add_widget(self.btnScrSaver, cnt)
self.btnAreaH.add_widget(self.btnSettings)

# docall_button_global.disabled = self.outgoing_mode == False

if docall_button_global.disabled:
Clock.schedule_once(self.enable_btn_docall)

Expand Down

0 comments on commit ce5353e

Please sign in to comment.