Matériaux à utiliser

1、STONE STWI101WT-01

2、Tête d'imprimante thermique FTP

3、Raspberry Pi pico

4、Machine à monnaie

Fonction

La fonction de contrôle est affichée sur l'écran série, l'interface principale sélectionne l'étage, après être entré dans l'interface principale sélectionne l'espace de stationnement, en même temps il affichera le numéro de l'espace de stationnement dans la zone de texte en haut à droite, puis sélectionne le temps de séjour, c'est deux sélecteurs de texte défilant, puis aussi le même affichera les informations de commande dans la zone de texte en haut à droite, selon le prix unitaire fixe qui se multiplie avec le temps de séjour pour obtenir le prix total. Ensuite, ce n'est que lorsque la place de parking et la durée de séjour sont sélectionnées que vous pouvez passer au bouton de paiement, sinon celui-ci est invalide. Après être entré dans l'écran de paiement, un accepteur de pièces sera utilisé. L'écran affiche alors le nombre de pièces à insérer et le nombre de pièces déjà insérées. Une fois que les pièces ont été introduites, un message de réussite du paiement s'affiche. Vous pouvez alors choisir d'imprimer un petit ticket ou d'imprimer le numéro de la place et l'heure sur le papier thermique.

Circuit

J'ai conçu un circuit par moi-même afin de piloter de nombreux composants, et le schéma général du circuit est le suivant, le coin supérieur gauche est la prise de communication et la prise d'alimentation, en dessous il y a un buzzer (qui n'est pas réellement utilisé dans le circuit), il y a une diode électroluminescente sur la droite, et le coin inférieur droit est un fpc 30pin pour connecter la tête d'impression.

Nom : parking-management-system(6).jpg
Affichages : 105
Taille : 45,5 Ko

code

Code Python : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
from machine import UART,Pin
from time import sleep
import _thread
import rp2
from array import array
import ascii_ku
import speed_motor
from os import uname
#import sys
uart1 = UART(0, baudrate = 115200, tx =Pin(0), rx = Pin(1))
floor1 = ['f', 'l', 'o', 'o', 'r','1']
floor2 = ['f', 'l', 'o', 'o', 'r','2']
floor3 = ['f', 'l', 'o', 'o', 'r','3']
button_cmd = [16,1]
selector_cmd = [16,129]
 
print(uname()[0])
delaytime = 0.0000001 # Printer clock delay
 
coin = Pin(22, Pin.IN,Pin.PULL_UP)
coin_num = 0
 
motor = speed_motor.motor_control(2, 3, 4, 5) # Initialize the printer's internal stepper motor pins, corresponding to the a+/a-/b+/b- of the stepper motor
mov_bit = 0
 
PRINTER_DIN = Pin(20, Pin.OUT)
PRINTER_CLK = Pin(19, Pin.OUT)
PRINTER_LAT = Pin(18, Pin.OUT, Pin.PULL_UP)
 
STB1 = Pin(6, Pin.OUT, Pin.PULL_DOWN)
STB2 = Pin(7, Pin.OUT, Pin.PULL_DOWN)
STB3 = Pin(8, Pin.OUT, Pin.PULL_DOWN)
STB4 = Pin(9, Pin.OUT, Pin.PULL_DOWN)
STB5 = Pin(14, Pin.OUT, Pin.PULL_DOWN)
STB6 = Pin(15, Pin.OUT, Pin.PULL_DOWN)
 
lock = _thread.allocate_lock()
 
ascii_code = ascii_ku.ascii_code() # Importing an ascii character library
 
# shuru = 'aa'
# line_word = []
# for item in range(len(shuru)):
#     line_word.append(shuru[item])
# line_num = len(shuru)
# bottom_line_num = len(shuru)%
# global motor_speed = 0
# global line = 0
 
# if len(shuru) > 6:
#     motor_speed = len(shuru) % 6
#     if (len(shuru) % 6) == 0:
#         motor_speed = 12
# else:
#     motor_speed = len(shuru)
# # print(motor_speed)
#
# line = (len(shuru) // 12) + 1
# if (len(shuru) % 12) == 0:
#     line -= 1
lins = 0
supper = 0
slower = 0
 
danjia = 0
# _thread.start_new_thread(motor.run_stop, (0.005*motor_speed, 26*line))
# _thread.start_new_thread(motor.run_stop, (motor_speed, line))
# _thread.start_new_thread(motor.run_stop, (0.03, 56))
def pay(pay):
    global coin_num
    line_word = {'line_word1':['s','i','t','e',':','F','1','-','0'],'line_word2':['0','d','a','y','2','h','o','u','r'],'line_word3':['t','o','t','a','l',':','4','.','0'],'line_word4':['T','o','t','a','l',':','4','.','0']}
    line_wors = {'line_word1':['U','n','i','t',':','2','.','0','0'],'line_word2':['T','o','t','a','l',':','4','.','0'],
                 'line_word3':['U','n','i','t',':','2','.','0','0'],'line_word4':['T','o','t','a','l',':','5','.','0']}
#     line_word1 = ['S','i','t','e',':','F','1','-','0']
#     line_word2 = ['1','D','a','y','1','H','o','u','r']
#     line_word3 = ['U','n','i','t',':','2','.','0','0']
#     line_word4 = ['T','o','t','a','l',':','5','.','0']
#     line_word1[8]=str(pay[0])
#     line_word2[0]=str(pay[1])
#     line_word2[4]=str(pay[2])
#     line_word4[6]=str(pay[3])
    (line_word['line_word1'])[8]=str(pay[0])
#     (line_word['line_word2'])[0]=str(pay[1])
#     (line_word['line_word2'])[4]=str(pay[2])
#     (line_word['line_word4'])[6]=str(pay[3])
    sleep(1)
    uart1.write('ST<{"cmd_code":"set_value","type":"image_value","widget":"image_value4","value":'+str(pay[3])+'}>ET')
#     sleep(2)
#     print(line_word.get('line_word'+str(1))[0])
#     print('zfdszfz',line_word)
#     sleep(2)
#     uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message5","text":"F1 - '+pay[0]+'"}>ET')
#     uart1.sendbreak()
#     sleep(1)
#     uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message6","text":"'+str(pay[1])+'"}>ET')
#     uart1.sendbreak()
#     sleep(1)
# #     uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message22","text":"'+str(pay[2])+'"}>ET')
#     uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message8","text":"'+str(pay[3])+'"}>ET')
    while True:
        if coin.value()==0:
            coin_num += 1
            print("Number of coins deposited:",coin_num)
            sleep(0.1)
            uart1.write('ST<{"cmd_code":"set_value","type":"image_value","widget":"image_value2","value":'+str(coin_num)+'}>ET')
            if coin_num == pay[3]:
                uart1.write('ST<{"cmd_code":"set_visible","type":"widget","widget":"image37","visible":true}>ET')
 
 
        if uart1.any()>1:
            rx2 = []
            data_name2 = ''
            bin_data = uart1.read(40)
            uart1.sendbreak()
            rx1 = list(bin_data)
            for item in rx1:
                rx2.append(chr(item))
            print(rx2)
            if rx1[3:5:1] == button_cmd:
                data_name_len = rx1[6] - 1
                data_name = rx2[7:data_name_len+6:1]
                data_name2 = ''.join(data_name)
                print(data_name2)
                if data_name2 == 'back':
                    break
                elif data_name2 == 'print' and coin_num == pay[3] and rx1[13] == 2:
                    data_name2=''
                    _thread.start_new_thread(motor.run_stop, (9, 4))
                    for iii in range(1,3):
                        for linss in range(32):
                            supper=slower=0
                            for lins in range(9):
#                                 temp_list=ascii_code.code.get(('line_word'+str(iii))[lins])
#                                 print(temp_list,type(temp_list))
                                if (line_word.get('line_word'+str(iii))[lins]).islower():
                                    word_size24 (ascii_code.code.get(line_word.get('line_word'+str(iii))[lins]), linss%32, lins%12, supper, slower)
                                    slower += 1
                                else:
                                    last_word_size32 (ascii_code.code.get(line_word.get('line_word'+str(iii))[lins]), linss%32, lins%12, supper, slower)
                                    supper += 1
 
                        sleep(6)
#                     for iii in range(1,2):
#                         for linss in range(32):
#                             supper=slower=0
#                             for lins in range(9):
# #                                 temp_list=ascii_code.code.get(('line_word'+str(iii))[lins])
# #                                 print(temp_list,type(temp_list))
#                                 if (line_wors.get('line_word'+str(iii))[lins]).islower():
#                                     word_size24 (ascii_code.code.get(line_wors.get('line_word'+str(iii))[lins]), linss%32, lins%12, supper, slower)
#                                     slower += 1
#                                 else:
#                                     last_word_size32 (ascii_code.code.get(line_wors.get('line_word'+str(iii))[lins]), linss%32, lins%12, supper, slower)
#                                     supper += 1
#                     sleep(6)
#                     for iii in range(1,2):
#                         for linss in range(32):
#                             supper=slower=0
#                             for lins in range(9):
# #                                 temp_list=ascii_code.code.get(('line_word'+str(iii))[lins])
# #                                 print(temp_list,type(temp_list))
#                                 if (line_wors.get('line_word'+str(iii))[lins]).islower():
#                                     word_size24 (ascii_code.code.get(line_wors.get('line_word'+str(iii))[lins]), linss%32, lins%12, supper, slower)
#                                     slower += 1
#                                 else:
#                                     last_word_size32 (ascii_code.code.get(line_wors.get('line_word'+str(iii))[lins]), linss%32, lins%12, supper, slower)
#                                     supper += 1
def floor1def():
    day_jia = 0
    hour_jia = 0
    day_flag = False
    hour_flag = False
    price_flag = False
    posltion = False
    zongjia = 0
    pay1 = [0,0,0,0]
 
    print("floor1 now")
#     uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message3","text":"2.00$/H"}>ET')
    uart1.sendbreak()
    while True:
        if uart1.any()>1:
            rx2 = []
            data_name2 = ''
            bin_data = uart1.read(40)
            uart1.sendbreak()
            rx1 = list(bin_data)
            for item in rx1:
                rx2.append(chr(item))
            print(rx2)
            if rx1[3:5:1] == button_cmd:
                data_name_len = rx1[6] - 1
                data_name = rx2[7:data_name_len+6:1]
                data_name2 = ''.join(data_name)
                print(data_name2)
                if data_name2 == 'back':
                    break
                elif data_name2 == 'position':
                    posltion = True
                    pay1[0]=rx2[15]
                    write1(rx2[15])
                elif data_name2 == 'pay' and posltion and price_flag:
                    uart1.write('ST<{"cmd_code":"open_win","type":"window","widget":"window7"}>ET')
                    pay(pay1)
#                 if data_name2 == 'pay' and posltion = True and (day_flag or hour_flag):
#                     posltion = True
#                     uart1.write('ST<{"cmd_code":"open_win","type":"window","widget":"window7"}>ET')
            if rx1[3:5:1] == selector_cmd:
                data_name_len = rx1[6] - 4
                data_name = rx2[7:data_name_len+7:1]
                data_name2 = ''.join(data_name)
                print(data_name2)
                if data_name2 == 'time_day1':
                    pay1[1]=rx2[19]
                    write2(ord(rx2[19]))
                    day_jia = ord(rx2[19])
                    day_flag = True
                elif data_name2 == 'time_hour1':
                    pay1[2]=rx2[20]
                    write3(ord(rx2[20]))
                    hour_jia = ord(rx2[20])
                    hour_flag = True
            if hour_flag or day_flag:
                price_flag = True
                zongjia = (day_jia*48) + (hour_jia*2)
                pay1[3]=zongjia
                print(str(zongjia))
                uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message4","text":"'+str(zongjia)+'"}>ET')
                hour_flag = day_flag = False
 
def floor2def():
    pass
 
def floor3def():
    pass
 
def write1(num):
    #print(ss)
    for item in range(49,55):
        uart1.write('ST<{"cmd_code":"set_image","type":"image","widget":"image1_'+chr(item)+'","image":"nocar_bg"}>ET')
    uart1.write('ST<{"cmd_code":"set_image","type":"image","widget":"image1_'+num+'","image":"selectedcar_bg2"}>ET')
    uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message1","text":"F1 - '+num+'"}>ET')
 
def write2(num):
#     danjia = 1
    uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message2","text":"'+str(num)+'"}>ET')
#     if danjia == 1:
#         uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message3","text":"2.00$/H"}>ET')
 
def write3(num):
#     danjia = 1
    uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message22","text":"'+str(num)+'"}>ET')
#     if danjia == 1:
#         uart1.write('ST<{"cmd_code":"set_text","type":"edit","widget":"message3","text":"2.00$/H"}>ET')
 
 
 
def last_word_size32 (word_line, linss, lins, supper, slower):
    for mov_bit in range((supper*32)+(slower*24)):
        PRINTER_CLK.value(0)
        sleep(delaytime)
        PRINTER_DIN.value(0)
        PRINTER_CLK.value(1)
        sleep(delaytime)
    for mov_bit in range(31, -1, -1):
        word_bit = (word_line[linss] >> mov_bit)&0b00000000000000000000000000000001
        PRINTER_CLK.value(0)
        sleep(delaytime)
        PRINTER_DIN.value(word_bit)
        PRINTER_CLK.value(1)
        sleep(delaytime)
    for mov_bit in range(352-((supper*32)+(slower*24))):
        PRINTER_CLK.value(0)
        sleep(delaytime)
        PRINTER_DIN.value(0)
        PRINTER_CLK.value(1)
        sleep(delaytime)
    if (supper*32)+(slower*24) < 192:
        PRINTER_LAT.value(0)
        STB1.value(1)
        STB2.value(1)
        STB3.value(1)
        STB4.value(1)
        sleep(0.005)
        STB1.value(0)
        STB2.value(0)
        STB3.value(0)
        STB4.value(0)
        PRINTER_LAT.value(1)
    else:
        PRINTER_LAT.value(0)
        STB4.value(1)
        STB5.value(1)
        STB6.value(1)
        sleep(0.005)
        STB4.value(0)
        STB5.value(0)
        STB6.value(0)
        PRINTER_LAT.value(1)
#         PRINTER_LAT.value(0)
#         STB1.value(1)
#         STB2.value(1)
#         STB3.value(1)
#         STB4.value(1)
#         STB5.value(1)
#         STB6.value(1)
#         sleep(0.005)
#         STB1.value(0)
#         STB2.value(0)
#         STB3.value(0)
#         STB4.value(0)
#         STB5.value(0)
#         STB6.value(0)
#         PRINTER_LAT.value(1)
 
def word_size24 (word_line, linss, lins, supper, slower):
    for mov_bit in range((supper*32)+(slower*24)):
        PRINTER_CLK.value(0)
        sleep(delaytime)
        PRINTER_DIN.value(0)
        PRINTER_CLK.value(1)
        sleep(delaytime)
    for mov_bit in range(23, -1, -1):
        word_bit = (word_line[linss] >> mov_bit)&0b000000000000000000000001
        PRINTER_CLK.value(0)
        sleep(delaytime)
        PRINTER_DIN.value(word_bit)
        PRINTER_CLK.value(1)
        sleep(delaytime)
    for mov_bit in range(360-((supper*32)+(slower*24))):
        PRINTER_CLK.value(0)
        sleep(delaytime)
        PRINTER_DIN.value(0)
        PRINTER_CLK.value(1)
        sleep(delaytime)
    if (supper*32)+(slower*24) < 192:
        PRINTER_LAT.value(0)
        STB1.value(1)
        STB2.value(1)
        STB3.value(1)
        sleep(0.005)
        STB1.value(0)
        STB2.value(0)
        STB3.value(0)
        PRINTER_LAT.value(1)
    else:
        PRINTER_LAT.value(0)
        STB4.value(1)
        STB5.value(1)
        STB6.value(1)
        sleep(0.005)
        STB4.value(0)
        STB5.value(0)
        STB6.value(0)
        PRINTER_LAT.value(1)
#         PRINTER_LAT.value(0)
#         STB1.value(1)
#         STB2.value(1)
#         STB3.value(1)
#         STB4.value(1)
#         STB5.value(1)
#         STB6.value(1)
#         sleep(0.005)
#         STB1.value(0)
#         STB2.value(0)
#         STB3.value(0)
#         STB4.value(0)
#         STB5.value(0)
#         STB6.value(0)
#         PRINTER_LAT.value(1)
 
while True:
    if uart1.any()>1:
        rx2 = []
        data_name2 = ''
        bin_data = uart1.read(40)
        uart1.sendbreak()
        rx1 = list(bin_data)
        for item in rx1:
            rx2.append(chr(item))
        print(rx2)
        if rx2[7:13:1] == floor1:
            floor1def()
        elif rx2[7:13:1] == floor2:
            floor2def()
        elif rx2[7:13:1] == floor3:
            floor3def()
 
for linss in range(32):
    supper=slower=0
    if linss < 32:
        for lins in range(len(line_word)):
#             if lins//12:
#                 break
            if (line_word[lins].isupper() or line_word[lins].isdigit() or line_word[lins].isspace()):
                last_word_size32 (ascii_code.code.get(line_word[lins]), linss%32, lins%12, supper, slower)
                supper += 1
            elif (line_word[lins].islower()):
                word_size24 (ascii_code.code.get(line_word[lins]), linss%32, lins%12, supper, slower)
                slower += 1
    else:
        if linss == 32:
            sleep(5.8)
        for lins in range(motor_speed):
            if (line_word[lins].isupper()):
                last_word_size32 (ascii_code.code.get(line_word[12]), linss%32, lins%12, len(line_word))
#     elif:
#         _thread.start_new_thread(motor.run_stop, (motor_speed, line))
#     for linss in range(32):
#         for lins in range(len(line_word)):
#             if (line_word[lins].isupper()):
#                 last_word_size32 (ascii_code.code.get(line_word[lins]), linss, lins, len(line_word))
 
line_word.clear()

démonstration vidéo