temporarily removed networking

This commit is contained in:
Nicholas Dyer 2023-11-21 12:50:35 -05:00
parent 2a4762ffaf
commit ffef4bb833
Signed by: ndyer
GPG Key ID: E5426C53DE17E1B2
1 changed files with 13 additions and 12 deletions

View File

@ -9,13 +9,13 @@ QUIT_BUTTON_SIZE = 50
BUTTON_SIZE = (150, 100)
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SERVER_IP = '172.20.100.100'
TCP_PORT = 25813
BUFFER_SIZE = 1024
# SERVER_IP = '172.20.100.100'
# TCP_PORT = 25813
# BUFFER_SIZE = 1024
set_temperature = 74
"""
def send_data(message: str):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((SERVER_IP, TCP_PORT))
@ -24,6 +24,7 @@ def send_data(message: str):
response = s.recv(BUFFER_SIZE)
s.close()
return response
"""
class Button(pygame.Surface):
@ -142,15 +143,15 @@ class Surface(pygame.Surface):
for button in self.buttons:
if button.active:
self.set_temp += button.temp_change
print(send_data(f'SET;{self.set_temp}'))
#print(send_data(f'SET;{self.set_temp}'))
button.update()
self.blit(button, button.rect)
if self.mouse_frame_counter > 75:
request_data = send_data(f'REQ')
split_data = request_data.decode('utf-8').split(';')
if split_data[0] == 'SDATA':
self.current_temp = int(round(float(split_data[1])))
self.set_temp = float(split_data[2])
#request_data = send_data(f'REQ')
#split_data = request_data.decode('utf-8').split(';')
#if split_data[0] == 'SDATA':
# self.current_temp = int(round(float(split_data[1])))
# self.set_temp = float(split_data[2])
self.mouse_frame_counter = 0
text = self.small_font.render(f'Set to {self.set_temp}°F', True, (255, 255, 255))
@ -161,6 +162,6 @@ class Surface(pygame.Surface):
text_rect = text.get_rect()
text_rect.center = (360, 360)
self.blit(text, text_rect)
if self.timeout_frame_counter >= 15*30:
self.timeout_frame_counter = 15*30
if self.timeout_frame_counter >= 15 * 30:
self.timeout_frame_counter = 15 * 30
self.fill((0, 0, 0))