Skip to content

Commit

Permalink
Рефакторинг
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaminiaev committed Dec 31, 2020
1 parent c8dbf02 commit 036c323
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
13 changes: 5 additions & 8 deletions dto.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from tkinter import Text, constants as c

SENSOR_NAME = {
'SERVO_X': 'servo_x',
'SERVO_Y': 'servo_y',
'SERVO_Z': 'servo_z',
'HALL': 'hall',
}


class Dto:

SERVO_X = 'servo_x'
SERVO_Y = 'servo_y'
SERVO_Z = 'servo_z'
HALL = 'hall'

def __init__(self, sensor_name: str = '', frame=None, side=c.TOP):
self.sensor_name = sensor_name
self.var = {
Expand Down
Empty file removed esp8266/mane.py
Empty file.
6 changes: 6 additions & 0 deletions esp8266/mine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import machine

servo = machine.PWM(machine.Pin(13), freq=50)
servo.duty(40)
servo.duty(115)
servo.duty(77)
8 changes: 4 additions & 4 deletions esp8266/scanAlgorithm.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import random

from dto import Dto, SENSOR_NAME
from dto import Dto


class ScanAlgorithm:

def __init__(self):
self.dto_x = Dto(SENSOR_NAME['SERVO_X'])
self.dto_y = Dto(SENSOR_NAME['SERVO_Y'])
self.dto_z = Dto(SENSOR_NAME['SERVO_Z'])
self.dto_x = Dto(Dto.SERVO_X)
self.dto_y = Dto(Dto.SERVO_Y)
self.dto_z = Dto(Dto.SERVO_Z)
self.stop = True

def data_generator(self):
Expand Down
8 changes: 2 additions & 6 deletions graph.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import matplotlib as cm

cm.use('Qt4Agg')
# cm.use("TkAgg")
cm.use("TkAgg")

import json
import os
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
import tkinter as tk
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from colour import Color
import time
import numpy as np

Expand Down Expand Up @@ -50,15 +48,13 @@ def __init__(self, parent, **kw):
self.__x_previous = 0
self.__y_previous = 0
self.__z_previous = 0
self.dots_graph_list = []
self.lines_graph_list = []
self.x_arr, self.y_arr = np.meshgrid(np.arange(0, 50, 1), np.arange(0, 50, 1))
self.data_arr = np.zeros((50, 50))
self.surface = None
self.dots_graph = None
fig = plt.figure()
self.ax = fig.add_subplot(111, projection='3d')

self.ax.mouse_init()
plt.xlim(0, 50 + 2)
plt.ylim(0, 50 + 2)

Expand Down
13 changes: 6 additions & 7 deletions manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@
from graph import Graph, GraphFrame
from tkinter import Frame, Button, Scale, Canvas, StringVar, Entry, constants as c
import tkinter as tk
from dto import Dto, SENSOR_NAME
from dto import Dto
import threading

RELWIDTH = 0.7

CANVAS_SIZE = 1000

WINDOW_SIZE = '800x600'
FRAME_COLOR = '#98a192'
FRAME_COLOR = '#3d3d42'
MAX = 49
MIN = 0
LENGTH = 300


class Manipulator(tk.Tk):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
plt.use("TkAgg")
self.quit = False
self['bg'] = '#fafafa'
self['bg'] = '#ccc'
self.title('Manipulator')
self.wm_attributes('-alpha', 0.7)
self.geometry(WINDOW_SIZE)
Expand Down Expand Up @@ -73,13 +72,13 @@ def __init__(self, tk: Manipulator):
self.__frame_debug = Frame(tk, bg=FRAME_COLOR, bd=2)
self.__frame_debug.place(relx=0.15, rely=0.75, relwidth=RELWIDTH, relheight=0.05)

self.scale_dto_x = Dto(SENSOR_NAME['SERVO_X'], self.__frame_debug, side=c.LEFT)
self.scale_dto_x = Dto(Dto.SERVO_X, self.__frame_debug, side=c.LEFT)
self.__scale_x = Scale(self.__frame_top, from_=MAX, to=MIN, length=LENGTH, label='x',
command=self.scale_dto_x.on_scale)
self.scale_dto_y = Dto(SENSOR_NAME['SERVO_Y'], self.__frame_debug, side=c.RIGHT)
self.scale_dto_y = Dto(Dto.SERVO_Y, self.__frame_debug, side=c.RIGHT)
self.__scale_y = Scale(self.__frame_top, from_=MAX, to=MIN, length=LENGTH, label='y',
command=self.scale_dto_y.on_scale)
self.scale_dto_z = Dto(SENSOR_NAME['SERVO_Z'], self.__frame_debug, c.LEFT)
self.scale_dto_z = Dto(Dto.SERVO_Z, self.__frame_debug, c.LEFT)
self.__scale_z = Scale(self.__frame_top, orient='horizontal', from_=MIN, to=MAX, length=LENGTH, label='z',
command=self.scale_dto_z.on_scale)

Expand Down

0 comments on commit 036c323

Please sign in to comment.