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

View File

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