├── 80da0e75a59bf6c452952c4b9b3feefd 00_00_00-00_00_30.gif
├── LICENSE
├── README.md
├── image-20220827115830898.png
├── image
├── 80da0e75a59bf6c452952c4b9b3feefd 00_00_00-00_00_30.gif
├── image-20220827115830898.png
├── 微信图片_20220827131439(1)(1).jpg
├── 微信图片_20220827131439(1).jpg
├── 微信图片_20220827131446(1)(1).jpg
├── 微信图片_20220827131446(1).jpg
├── 微信图片_20220827131449(1)(1).jpg
└── 微信图片_20220827131449(1).jpg
├── 天气时钟8-27
├── README.md
├── astronaut
│ ├── img1.dat
│ ├── img10.dat
│ ├── img11.dat
│ ├── img12.dat
│ ├── img13.dat
│ ├── img2.dat
│ ├── img3.dat
│ ├── img4.dat
│ ├── img5.dat
│ ├── img6.dat
│ ├── img7.dat
│ ├── img8.dat
│ └── img9.dat
├── boot.py
├── calendar.py
├── clock.py
├── main.py
├── package
│ ├── GBfont.py
│ ├── VGAfont.py
│ ├── WiFi.py
│ ├── font_gb_16x16.py
│ ├── gb16x16.ttf
│ ├── gb24x24.ttf
│ ├── st7789py.py
│ ├── vga1_12x24.ttf
│ ├── vga1_16x32.ttf
│ ├── vga1_20x40.ttf
│ ├── vga1_24x48.ttf
│ ├── vga1_8x16.ttf
│ └── weather.py
├── picture
│ ├── 0@1x.dat
│ ├── 10@1x.dat
│ ├── 11@1x.dat
│ ├── 12@1x.dat
│ ├── 13@1x.dat
│ ├── 14@1x.dat
│ ├── 15@1x.dat
│ ├── 16@1x.dat
│ ├── 17@1x.dat
│ ├── 18@1x.dat
│ ├── 19@1x.dat
│ ├── 1@1x.dat
│ ├── 20@1x.dat
│ ├── 21@1x.dat
│ ├── 22@1x.dat
│ ├── 23@1x.dat
│ ├── 24@1x.dat
│ ├── 25@1x.dat
│ ├── 26@1x.dat
│ ├── 27@1x.dat
│ ├── 28@1x.dat
│ ├── 29@1x.dat
│ ├── 2@1x.dat
│ ├── 30@1x.dat
│ ├── 31@1x.dat
│ ├── 32@1x.dat
│ ├── 33@1x.dat
│ ├── 34@1x.dat
│ ├── 35@1x.dat
│ ├── 36@1x.dat
│ ├── 37@1x.dat
│ ├── 38@1x.dat
│ ├── 3@1x.dat
│ ├── 4@1x.dat
│ ├── 5@1x.dat
│ ├── 6@1x.dat
│ ├── 7@1x.dat
│ ├── 8@1x.dat
│ └── 9@1x.dat
└── poet.py
├── 微信图片_20220827131439(1)(1).jpg
├── 微信图片_20220827131446(1)(1).jpg
└── 微信图片_20220827131449(1)(1).jpg
/80da0e75a59bf6c452952c4b9b3feefd 00_00_00-00_00_30.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/80da0e75a59bf6c452952c4b9b3feefd 00_00_00-00_00_30.gif
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # esp32 + Python 打造个性化桌面时钟
4 |
5 | ## 一、显示效果
6 |
7 | 按下按键三种模式切换
8 |
9 | 1. 
10 | 2. 
11 | 3. 
12 |
13 | ## 二、硬件准备
14 |
15 | ### 硬件清单:
16 |
17 | | | 名称 | 数量 |
18 | | :--: | :--------------------------: | :--: |
19 | | 1 | 30引脚esp32-s开发板 | 1 |
20 | | 2 | 1kΩ电阻 | 1 |
21 | | 3 | 按键开关 | 1 |
22 | | 4 | 240*240tft屏幕(st7789驱动) | 1 |
23 | | 5 | 杜邦线 | 若干 |
24 |
25 | ### 线路连接:
26 |
27 | 
28 |
29 | ## 三、开源地址
30 |
31 | GitHub:https://github.com/LC044/network-clock
32 |
33 | Gitee:https://gitee.com/shuaikang-zhou/network-clock
34 |
35 | ## 四、原理分析
36 |
37 | ### (一)st7789py.py驱动修改
38 |
39 | ```python
40 | '''
41 | 导入字体
42 | '''
43 | from package import GBfont
44 | from package import font_gb_16x16 as font_gb
45 | from package import VGAfont
46 | GB16 = GBfont.gb2312(16)
47 | GB24 = GBfont.gb2312(24)
48 | GB32 = font_gb.Font32(32)
49 | vga32 = VGAfont.VGAFONT(32)
50 | vga16 = VGAfont.VGAFONT(16)
51 | vga24 = VGAfont.VGAFONT(24)
52 | vga40 = VGAfont.VGAFONT(40)
53 | vga48 = VGAfont.VGAFONT(48)
54 | ```
55 |
56 | 新增PWM背光调节亮度:
57 |
58 | ```python
59 | '''初始化'''
60 | if backlight is not None:
61 | from machine import PWM
62 | self.bl = PWM(self.backlight,freq=1000,duty=128)
63 | def brightness(self,value):
64 | '''
65 | 调节屏幕亮度
66 | value: int 0-1023
67 | '''
68 | self.bl.duty(value)
69 | ```
70 |
71 | 支持更多字号字体,中英文字体,不同字号字体合并:
72 |
73 | ```python
74 | def text(self,size, text, x0, y0, color=WHITE, background=BLACK):
75 | char = text[0].encode('utf-8')
76 | if len(char) == 1:
77 | if size == 0:
78 | pass
79 | elif size == 24:
80 | font_gb = vga24.str(text)
81 | elif size == 16:
82 | font_gb = vga16.str(text)
83 | elif size == 32:
84 | font_gb = vga32.str(text)
85 | elif size == 40:
86 | font_gb = vga40.str(text)
87 | elif size == 48:
88 | font_gb = vga48.str(text)
89 | else:
90 | if size == 16:
91 | font_gb = GB16.str(text)
92 | elif size == 24:
93 | font_gb = GB24.str(text)
94 | elif size == 32:
95 | font_gb = GB32
96 | elif size == 48:
97 | font_gb = GB48
98 | self._text(font_gb,size, text, x0, y0, color, background)
99 | ```
100 |
101 | 提高显示速度,修复颜色bug:
102 |
103 | ```python
104 | def _text(self,font,size, text, x0, y0, color=WHITE, background=BLACK):
105 | self.k = 0
106 | self.num = 4
107 | for char in text:
108 | if (x0+font.WIDTH <= self.width and y0+font.HEIGHT <= self.height):
109 | for line in range(self.num): # 分两次显示,先显示上半边后显示下半边
110 | idx = line * (font.SIZE//self.num)
111 | buffer = b''
112 | for x in range(0,(font.SIZE//self.num),1):
113 | buffer += struct.pack('>8H',
114 | color if font.FONT[char][idx+x] & _BIT7 else background,
115 | color if font.FONT[char][idx+x] & _BIT6 else background,
116 | color if font.FONT[char][idx+x] & _BIT5 else background,
117 | color if font.FONT[char][idx+x] & _BIT4 else background,
118 | color if font.FONT[char][idx+x] & _BIT3 else background,
119 | color if font.FONT[char][idx+x] & _BIT2 else background,
120 | color if font.FONT[char][idx+x] & _BIT1 else background,
121 | color if font.FONT[char][idx+x] & _BIT0 else background,
122 | )
123 | self.blit_buffer(buffer, x0, y0+(font.HEIGHT//self.num)*line, font.WIDTH, font.HEIGHT//self.num)
124 | x0 += font.WIDTH # 显示下一个字的时候x坐标增加字体宽度
125 | ```
126 |
127 | ### (二)连接WiFi,同步时钟(WiFi.py)
128 |
129 | ```python
130 | import ntptime
131 | import network,time
132 | from machine import RTC,Pin
133 | rtc = RTC()
134 | ssid = 'CU_1316' # WiFi 账号
135 | password = 'zhou1316' # WiFi 密码
136 | # 联WIFI
137 | def WIFI_Connect():
138 | wlan = network.WLAN(network.STA_IF) #STA模式
139 | wlan.active(True) #激活接口
140 | start_time=time.time() #记录时间做超时判断
141 | if not wlan.isconnected():
142 | print('connecting to network...')
143 | wlan.connect(ssid, password) #输入WIFI账号密码
144 | while not wlan.isconnected():
145 | if time.time()-start_time > 15 :
146 | print('WIFI Connected Timeout!')
147 | break
148 | if wlan.isconnected():
149 | print('connected!')
150 | print('network information:', wlan.ifconfig())
151 |
152 | # 同步时间
153 | def sync_ntp():
154 | ntptime.NTP_DELTA = 3155644800
155 | ntptime.host = 'ntp1.aliyun.com'
156 | try:
157 | ntptime.settime()
158 | except:
159 | print('同步失败')
160 |
161 | if __name__ == '__main__':
162 | WIFI_Connect()
163 | sync_ntp()
164 | print(rtc.datetime())
165 | print("同步后本地时间:%s" %str(time.localtime()))
166 | ```
167 |
168 | ### (三)获取网络天气、诗词(weather.py)
169 |
170 | 天气API:心知天气
171 |
172 | ```python
173 | def now_weather(self,city):
174 | #34.40:114.96
175 | url = "https://api.seniverse.com/v3/weather/now.json?key={}&location={}&language=zh-Hans&unit=c".format(self.password,city)
176 | result1=urequests.get(url)
177 | j1=ujson.loads(result1.text)
178 | _city = j1['results'][0]['location']['name']
179 | weather = j1['results'][0]['now']['text']
180 | tem = j1['results'][0]['now']['temperature']
181 | code = j1['results'][0]['now']['code']
182 | print(j1['results'][0]['location']['name'],end=' ')
183 | print(j1['results'][0]['now']['text'],end=' ')
184 | print(j1['results'][0]['now']['temperature'],end='℃ ')
185 | print(j1['results'][0]['last_update'])
186 | print('天气代码:',code)
187 | return {
188 | 'city':_city,
189 | 'weather':weather,
190 | 'tem':tem,
191 | 'code':code,
192 | 'height':int(self.img_size(code)[3:]),
193 | 'width':int(self.img_size(code)[0:2])
194 | }
195 | def poet(self):
196 | # 获取句子
197 | url = 'https://api.a632079.me/?max_length=11'
198 | res=urequests.get(url)
199 | dic=ujson.loads(res.text)
200 | print(len(dic['hitokoto']),dic['hitokoto'])
201 | return dic['hitokoto'][:dic['length']]
202 | def jinrishici(self):
203 | # 获取诗词
204 | url = 'https://v2.jinrishici.com/sentence'
205 | headers = {
206 | 'X-User-Token':'EsnWc/+lex+Lgs7/m0clRHToBy/Eejy7'
207 | }
208 | res=urequests.get(url,headers=headers)
209 | dic=ujson.loads(res.text)
210 | if dic['status'] == 'success':
211 | return dic['data']
212 | ```
213 |
214 | ### (四)天气时钟界面(clock.py)
215 |
216 | ```python
217 | def clock(self):
218 | file = [open("./astronaut/img{}.dat".format(i), "rb") for i in range(1, 14)]
219 | #self.tft.brightness(64)
220 | self.init_show() # 初始化显示画面
221 | self.show_city(self.data['city']) # 显示城市
222 | self.show_tem(self.data['tem']) # 显示温度
223 | self.show_weather(self.data) # 显示天气信息
224 | self.init_time() # 初始化时间显示
225 | while True:
226 | if self.mod != _CLOCK:
227 | return
228 | self.t = time.localtime(time.time())
229 | # 每十分钟天气更新一次
230 | if self.t[4]%10==0 and 015:
260 | if '。' in poet[i]:
261 | se = poet[i].split('。')
262 | elif '?' in poet[i]:
263 | se = poet[i].split('?')
264 | elif '!' in poet[i]:
265 | se = poet[i].split('!')
266 | else:
267 | se = poet[i].split(',')
268 | for s in range(len(se)-1):
269 | if len(se[s]) > 15:
270 | p = se[s].split(',')
271 | for pm in p:
272 | poem.append(pm)
273 | else:
274 | poem.append(se[s])
275 | else:
276 | poem.append(poet[i])
277 | y = 50
278 | del poet
279 | self.tft.fill(self.WHITE)
280 | offest = (240-24*len(title))//2
281 | self.tft.text(24, title, offest, 0, self.BLACK, self.WHITE)
282 | offest = 24*len(author)
283 | self.tft.text(24, '{}'.format(author), 240-offest-24, 30, self.BLACK, self.WHITE)
284 | for p in poem:
285 | y = y + 20
286 | offest = (240-16*len(p))//2
287 | self.tft.text(16, p, offest, y, self.BLACK, self.WHITE)
288 | while True:
289 | if self.mod != 1:
290 | return
291 | else:
292 | utime.sleep(0.5)
293 | pass
294 | ```
295 |
296 | ### (六)日历界面(calendar.py)
297 |
298 | ```python
299 | def show(self,month):
300 | begin = 1
301 | y = 35 + 16 + 4+5+10
302 | dx = 34
303 | x = self.week
304 | week_num = 1
305 | while begin <= self.days[month - 1]:
306 | begin += 1
307 | self.week = (self.week + 1) % 7
308 | if self.week % 7 == 0:
309 | week_num += 1
310 | begin = 1
311 | self.week = x
312 | print(week_num)
313 | size = 16 if week_num == 6 else 24
314 | while begin <= self.days[month - 1]:
315 | color = self.RED if begin == self.t[2] else self.WHITE
316 | bg = self.WHITE if begin == self.t[2] else self.BLACK
317 | offest_x = 6 if begin<10 else 0
318 | self.tft.text(size, '{}'.format(begin), 5+dx*x+offest_x, y , color, bg)
319 | begin += 1
320 | x+=1
321 | self.week = (self.week + 1) % 7
322 | #print('%4d' % begin,end=',')
323 | if self.week % 7 == 0:
324 | x=0
325 | y+=30
326 | ```
327 |
328 | ### (七)main.py
329 |
330 | ```python
331 | from machine import Pin, SPI, RTC
332 | from package import st7789py as st
333 | from package import weather
334 | import gc
335 | import time
336 | import clock
337 | import poet
338 | import calendar
339 | _CLOCK = 0
340 | _VERSE = 1
341 | _CALENDAR = 2
342 | class Display():
343 | def __init__(self):
344 | self.tft = st.ST7789(SPI(2, 10000000), 240, 240, reset=Pin(5), dc=Pin(17), cs=Pin(16), backlight=Pin(4), rotation=0)
345 | self.bt = Pin(34, Pin.IN,Pin.PULL_DOWN)
346 | self.bt.irq(trigger=Pin.IRQ_FALLING, handler=self.model)
347 | self.mod = 0
348 | self.weather = weather.Weather()
349 | self.clock = clock.CLOCK(self.tft,self.weather)
350 | self.poem = poet.POET(self.tft,self.weather)
351 | self.calendar = calendar.Calendar(self.tft)
352 | def model(self,*argc):
353 | self.mod=(self.mod+1)%4
354 | self.clock.mod = self.mod
355 | self.poem.mod = self.mod
356 | self.calendar.mod = self.mod
357 | def run(self):
358 | while True:
359 | print(self.mod)
360 | if self.mod == _CLOCK:
361 | self.tft.brightness(128)
362 | self.clock.clock()
363 | elif self.mod == _VERSE:
364 | self.tft.brightness(256)
365 | self.tft.fill(0)
366 | self.poem.show()
367 | elif self.mod == _CALENDAR:
368 | self.tft.brightness(256)
369 | self.calendar.display()
370 | time.sleep(0.5)
371 | gc.collect()
372 | def __del__(self):
373 | pass
374 | D = Display()
375 | D.run()
376 | ```
377 |
378 |
--------------------------------------------------------------------------------
/image-20220827115830898.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image-20220827115830898.png
--------------------------------------------------------------------------------
/image/80da0e75a59bf6c452952c4b9b3feefd 00_00_00-00_00_30.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/80da0e75a59bf6c452952c4b9b3feefd 00_00_00-00_00_30.gif
--------------------------------------------------------------------------------
/image/image-20220827115830898.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/image-20220827115830898.png
--------------------------------------------------------------------------------
/image/微信图片_20220827131439(1)(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/微信图片_20220827131439(1)(1).jpg
--------------------------------------------------------------------------------
/image/微信图片_20220827131439(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/微信图片_20220827131439(1).jpg
--------------------------------------------------------------------------------
/image/微信图片_20220827131446(1)(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/微信图片_20220827131446(1)(1).jpg
--------------------------------------------------------------------------------
/image/微信图片_20220827131446(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/微信图片_20220827131446(1).jpg
--------------------------------------------------------------------------------
/image/微信图片_20220827131449(1)(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/微信图片_20220827131449(1)(1).jpg
--------------------------------------------------------------------------------
/image/微信图片_20220827131449(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/image/微信图片_20220827131449(1).jpg
--------------------------------------------------------------------------------
/天气时钟8-27/README.md:
--------------------------------------------------------------------------------
1 | # 直接将本文件夹所有文件烧录到esp32即可运行
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img1.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img1.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img10.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img10.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img11.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img11.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img12.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img12.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img13.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img13.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img2.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img2.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img3.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img3.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img4.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img4.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img5.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img5.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img6.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img6.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img7.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img7.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img8.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img8.dat
--------------------------------------------------------------------------------
/天气时钟8-27/astronaut/img9.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/astronaut/img9.dat
--------------------------------------------------------------------------------
/天气时钟8-27/boot.py:
--------------------------------------------------------------------------------
1 | # This file is executed on every boot (including wake-boot from deepsleep)
2 | #import esp
3 | #esp.osdebug(None)
4 | #import webrepl
5 | #webrepl.start()
6 |
--------------------------------------------------------------------------------
/天气时钟8-27/calendar.py:
--------------------------------------------------------------------------------
1 | from package import weather
2 | import time
3 | from package import st7789py as st
4 | _CLOCK = 0
5 | _VERSE = 1
6 | class Calendar(object):
7 | days = [31,28,31,30,31,30,31,31,30,31,30,31]
8 | def __init__(self,tft,year=2022):#初始化默认2017年
9 | self.year = year
10 | if self.yearDays(year) == 366:
11 | self.days[1] = 29
12 | self.totalDays = 0
13 | for i in range(1, self.year):
14 | self.totalDays += self.yearDays(i)
15 | self.tft = tft
16 | self.init_color()
17 | self.mod = 2
18 | self.t = time.localtime(time.time())
19 |
20 | #判断每年的天数
21 | def yearDays(self,year):
22 | return 366 if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 else 365
23 | # 查看某个月的日历
24 | def months(self,month):
25 | totalDays = self.totalDays
26 | for i in range(1,month):
27 | totalDays+=self.days[i-1]
28 | #计算确定月份的第一天为周几
29 | self.week = (totalDays+1) % 7
30 | self.show(month)
31 | #查看全年日历
32 | def wholeYear(self):
33 | # 计算确定年份的一月一日为周几
34 | self.week = (self.totalDays+1) % 7
35 | for i in range(1,13):
36 | self.show(i)
37 | def header(self):
38 | y = 35+10
39 | size = 16
40 | self.tft.text(32, '{}'.format(self.t[0]), 0, 0 , self.WHITE, self.BLACK)
41 | self.tft.text(32, '年', 16*4, 0 , self.WHITE, self.BLACK)
42 | self.tft.text(32, '{}'.format(self.t[1]), 64+32, 0 , self.WHITE, self.BLACK)
43 | self.tft.text(32, '月', 96+16, 0 , self.WHITE, self.BLACK)
44 | self.tft.text(size, '日', 10, y , self.WHITE, self.BLACK)
45 | self.tft.text(size, '一', 44, y , self.WHITE, self.BLACK)
46 | self.tft.text(size, '二', 78, y , self.WHITE, self.BLACK)
47 | self.tft.text(size, '三', 112, y , self.WHITE, self.BLACK)
48 | self.tft.text(size, '四', 146, y , self.WHITE, self.BLACK)
49 | self.tft.text(size, '五', 180, y , self.WHITE, self.BLACK)
50 | self.tft.text(size, '六', 214, y , self.WHITE, self.BLACK)
51 | def init_color(self):
52 | self.WHITE = st.color565(255, 255, 255)#RGB
53 | self.BLACK = st.color565(0, 0, 0)
54 | self.RED = st.color565(255, 0, 0)
55 | self.GRAY = st.color565(180, 180, 180)
56 | self.bg = st.color565(80, 80, 80)
57 | def show(self,month):
58 | begin = 1
59 | y = 35 + 16 + 4+5+10
60 | dx = 34
61 | x = self.week
62 | week_num = 1
63 | while begin <= self.days[month - 1]:
64 | begin += 1
65 | self.week = (self.week + 1) % 7
66 | if self.week % 7 == 0:
67 | week_num+=1
68 | begin = 1
69 | self.week = x
70 | print(week_num)
71 | size = 16 if week_num == 6 else 24
72 | while begin <= self.days[month - 1]:
73 | color = self.RED if begin == self.t[2] else self.WHITE
74 | bg = self.WHITE if begin == self.t[2] else self.BLACK
75 | offest_x = 6 if begin<10 else 0
76 | self.tft.text(size, '{}'.format(begin), 5+dx*x+offest_x, y , color, bg)
77 | begin += 1
78 | x+=1
79 | self.week = (self.week + 1) % 7
80 | #print('%4d' % begin,end=',')
81 | if self.week % 7 == 0:
82 | x=0
83 | y+=30
84 | def display(self):
85 | self.tft.fill(0)
86 | self.header()
87 | #self.layout()
88 | self.months(self.t[1])
89 | while True:
90 | if self.mod != 2:
91 | return
92 | else:
93 | time.sleep(0.5)
94 | pass
95 | pass
96 | if __name__=='__main__':
97 | from machine import Pin, SPI, RTC
98 | tft = st.ST7789(SPI(2, 10000000), 240, 240, reset=Pin(17), dc=Pin(2), cs=Pin(5), backlight=Pin(22), rotation=0)
99 | p = Calendar(tft)
100 | start = time.time()
101 | p.display()
102 | end = time.time()
103 | print(end-start)
104 |
--------------------------------------------------------------------------------
/天气时钟8-27/clock.py:
--------------------------------------------------------------------------------
1 | from package import weather
2 | from micropython import const
3 | import time
4 | from package import st7789py as st
5 | import gc
6 | _CLOCK = const(0)
7 | _VERSE = const(1)
8 | _CALENDAR = const(2)
9 | class CLOCK():
10 | __slots__ = 'last_hour', 'last_minute', 'last_month' , 'last_second' , 'last_year', 'last_last_day', 'colck_x', 'clock_y' ,'data','poet','WHITE','BLACK','RED'
11 | def __init__(self,tft,weather):
12 | self.tft = tft
13 | self.init_color()
14 | # 初始化参数
15 | self.mod = 0
16 | self.last_hour = 13
17 | self.last_minute = 14
18 | self.last_second = 0
19 | self.last_year = 0
20 | self.last_month = 0
21 | self.last_day = 0
22 | self.clock_x = 20+24*2-12
23 | self.clock_y = 90
24 | self.boot_animation()
25 | self.Weather = weather
26 | self.city = '34.40:114.96' # 当地经纬度,格式: 纬度:经度
27 | self.data = self.Weather.now_weather(self.city)
28 | self.t = time.localtime(time.time())
29 | self.poet = self.Weather.poet()
30 | def model(self,*argc):
31 | self.mod=(self.mod+1)%4
32 | def init_color(self):
33 | self.WHITE = st.color565(255, 255, 255)#BRG
34 | self.BLACK = st.color565(0, 0, 0)
35 | self.RED = st.color565(0, 255, 0)
36 | def init_show(self):
37 | '''
38 | 初始化显示画面
39 | '''
40 | self.tft.fill(0)
41 | self.tft.text(48, ':', self.clock_x + 24*2, self.clock_y, self.WHITE, self.BLACK)
42 | self.tft.text(24, '周', self.clock_x + 24+12, self.clock_y+48+8, self.WHITE, self.BLACK)
43 | self.tft.text(32, '/', self.clock_x + 24+24, self.clock_y+48+8+24, self.WHITE, self.BLACK)
44 | def init_time(self):
45 | t = time.localtime(time.time())
46 | '''
47 | 第一次显示时间
48 | '''
49 | hour = t[3]
50 | minute = t[4]
51 | second = t[5]
52 | self.tft.text(48, '{:0>2d}'.format(hour), self.clock_x, self.clock_y, self.WHITE, self.BLACK)
53 | self.last_hour = hour
54 | self.tft.text(48, '{:0>2d}'.format(minute), self.clock_x + 24*3, self.clock_y, self.WHITE, self.BLACK)
55 | self.last_minute = minute
56 | year = t[0]
57 | month = t[1]
58 | day = t[2]
59 | # 清空原有内容
60 | self.tft.fill_rect(self.clock_x + 16,self.clock_y+48+8+24,32,32,self.BLACK)
61 | offest_x = 16 if month>9 else 32
62 | self.tft.text(32, '{}'.format(month), self.clock_x + offest_x, self.clock_y+48+8+24, self.WHITE, self.BLACK)
63 | self.last_month = month
64 | self.tft.fill_rect(self.clock_x+24+24+16,self.clock_y+48+8+24,32,32,self.BLACK)
65 | self.tft.text(32, '{}'.format(day), self.clock_x+24+24+16, self.clock_y+48+8+24, self.WHITE, self.BLACK)
66 | e_w, z_w = self.week(t)
67 | self.tft.text(24, z_w, self.clock_x + +24+12+24, self.clock_y+48+8, self.WHITE, self.BLACK)
68 | self.last_day = day
69 | self.show_poet() # 显示诗词
70 | def boot_animation(self):
71 | '''
72 | 开机动画
73 | '''
74 | txt = 'Prepare for a career in tech by joining GitHub Global Campus. Global Campus will help you get the practical industry knowledge you need by giving you access to industry tools, events, learning resources and a growing student community.'
75 | #for t in txt:
76 | self.tft.text(16, txt[:20], 0, 0, self.WHITE, self.BLACK)
77 | self.tft.text(16, txt[20:50], 0, 20, self.WHITE, self.BLACK)
78 | self.tft.text(16, txt[50:60], 0, 40, self.WHITE, self.BLACK)
79 | self.tft.text(16, txt[60:80], 0, 60, self.WHITE, self.BLACK)
80 | self.tft.text(16, txt[80:85], 0, 80, self.WHITE, self.BLACK)
81 | self.tft.text(16, txt[85:110], 0, 100, self.WHITE, self.BLACK)
82 | self.tft.text(16, txt[110:125], 0, 120, self.WHITE, self.BLACK)
83 | self.tft.text(16, txt[125:150], 0, 140, self.WHITE, self.BLACK)
84 | def show_city(self,city):
85 | '''
86 | 显示城市
87 | '''
88 | self.tft.text(16, city, 61+10+32, 16+10, self.WHITE, self.BLACK)
89 | def show_tem(self,temp):
90 | '''
91 | 显示温度
92 | '''
93 | self.tft.text(32, temp, 61+5, 10, self.WHITE, self.BLACK)
94 | self.tft.text(16,'℃' , 61+5+32, 10, self.WHITE, self.BLACK)
95 | def clear(self):
96 | '''
97 | 清空天气显示画面
98 | '''
99 | self.tft.fill_rect(170-24-8,0,24,24*2,self.BLACK)
100 | self.tft.fill_rect(0, 0,61,61,self.BLACK)
101 | def show_weather(self,data):
102 | self.clear()
103 | self.show_tem(data['tem'])
104 | weather = data['weather']
105 | code = data['code']
106 | height = data['height']
107 | width = data['width']
108 | for i in range(len(weather)):
109 | self.tft.text(24, weather[i], 170-24-8, i*24, self.RED, self.BLACK)
110 | f = open('./picture/{}@1x.dat'.format(code),'rb')
111 | # 显示天气图标
112 | for i in range(10,height,10):
113 | data = f.read(width*10*2)
114 | self.tft._set_window(0,i-10,width-1,i)
115 | self.tft._write(None,data)
116 | data = f.read(width*(height%10)*2)
117 | self.tft._set_window(0,(height//10)*10,width-1,height)
118 | self.tft._write(None,data)
119 | f.close()
120 | # 释放内存
121 | del data
122 | gc.collect()
123 |
124 |
125 | def week(self,t):
126 | # 获取星期
127 | week = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
128 | week0 = ['一','二','三','四','五','六','日']
129 | return week[t[6]],week0[t[6]]
130 | def astronaut(self):
131 | file = [open("./astronaut/img{}.dat".format(i), "rb") for i in range(1, 13)]
132 | while True:
133 | for f in file:
134 | f.seek(0)
135 | for row in range(0, 80, 20):
136 | buffer = f.read(4000)
137 | self.tft._set_window(140,row,239,row+19)
138 | self.tft._write(None,buffer)
139 | def show_time(self,t):
140 | t = time.localtime(time.time())
141 | '''
142 | 显示时间
143 | '''
144 | hour = t[3]
145 | minute = t[4]
146 | second = t[5]
147 | ti = "{:0>2d}:{:0>2d}:{:0>2d}".format(hour,minute,second)
148 | #print(ti)
149 | if hour != self.last_hour:
150 | self.tft.text(48, '{:0>2d}'.format(hour), self.clock_x, self.clock_y, self.WHITE, self.BLACK)
151 | self.last_hour = hour
152 | self.poet = self.Weather.poet()
153 | self.show_poet()
154 | if minute != self.last_minute:
155 | self.tft.text(48, '{:0>2d}'.format(minute), self.clock_x + 24*3, self.clock_y, self.WHITE, self.BLACK)
156 | self.last_minute = minute
157 | self.calendar(t)
158 | def show_poet(self):
159 | self.tft.fill_rect(0,61,16*11,16,self.BLACK)
160 | self.tft.text(16, self.poet, 0, 61, self.WHITE, self.BLACK)
161 | def calendar(self,t):
162 | year = t[0]
163 | month = t[1]
164 | day = t[2]
165 | if month != self.last_month:
166 | # 先清空再显示
167 | self.tft.fill_rect(self.clock_x + 16,self.clock_y+48+8+24,32,32,self.BLACK)
168 | offest_x = 16 if month>9 else 32
169 | self.tft.text(32, '{}'.format(month), self.clock_x + offest_x, self.clock_y+48+8+24, self.WHITE, self.BLACK)
170 | self.last_month = month
171 | if day != self.last_day:
172 | # 先清空再显示
173 | self.tft.fill_rect(self.clock_x+24+24+16,self.clock_y+48+8+24,32,32,self.BLACK)
174 | self.tft.text(32, '{}'.format(day), self.clock_x+24+24+16, self.clock_y+48+8+24, self.WHITE, self.BLACK)
175 | e_w, z_w = self.week(t)
176 | self.tft.text(24, z_w, self.clock_x + +24+12+24, self.clock_y+48+8, self.WHITE, self.BLACK)
177 | self.last_day = day
178 |
179 | def clock(self):
180 | file = [open("./astronaut/img{}.dat".format(i), "rb") for i in range(1, 14)]
181 | #self.tft.brightness(64)
182 | self.init_show() # 初始化显示画面
183 | self.show_city(self.data['city']) # 显示城市
184 | self.show_tem(self.data['tem']) # 显示温度
185 | self.show_weather(self.data) # 显示天气信息
186 | self.init_time() # 初始化时间显示
187 | while True:
188 | if self.mod != _CLOCK:
189 | return
190 | self.t = time.localtime(time.time())
191 | # 每十分钟天气更新一次
192 | if self.t[4]%10==0 and 0 m:
43 | high = mid - 1
44 | else:
45 | #return mid
46 | return self.f.read(self.size-3)
47 | #return data[3:]
48 | def __del__(self):
49 | self.f.close()
50 |
51 | if __name__ == '__main__':
52 | F = gb2312(24)
53 | char = F.one_char('你')
54 | print(char)
55 | '''
56 | import utime
57 | #char = F.one_char('a')
58 | #print(char,len(char))
59 | ts = utime.ticks_ms()
60 | t = F.str('风急天高猿啸哀,渚清沙白鸟飞回。')
61 | te = utime.ticks_ms()
62 | tc = te - ts
63 | print(tc/16)
64 | #print(t.HEIGHT,t.FONT)'''
65 |
--------------------------------------------------------------------------------
/天气时钟8-27/package/VGAfont.py:
--------------------------------------------------------------------------------
1 | class Font:
2 | def __init__(self, size):
3 | self.WIDTH = size // 2
4 | self.HEIGHT = size
5 | self.SIZE = size * size // 16
6 | self.FONT = {}
7 |
8 |
9 | class VGAFONT(object):
10 | def __init__(self, size):
11 | self.f = open('./package/vga1_{}x{}.ttf'.format(size//2,size), 'rb')
12 | self.height = size
13 | self.size = size * (size // 8) // 2
14 |
15 | def one_char(self, char):
16 | ascii = ord(char) - 0x20
17 | self.f.seek(ascii*self.size)
18 | return self.f.read(self.size)
19 |
20 |
21 | def str(self, st):
22 | font = Font(self.height)
23 | for s in st:
24 | data = self.one_char(s)
25 | font.FONT[s] = data if data else b'\x00' * self.size
26 | #print(font)
27 | return font
28 |
29 |
30 |
31 | def __del__(self):
32 | self.f.close()
33 |
34 |
35 | if __name__ == '__main__':
36 | F = VGAFONT(48)
37 | import utime
38 | import ustruct as struct
39 | from micropython import const
40 | _BIT7 = const(0x80)
41 | _BIT6 = const(0x40)
42 | _BIT5 = const(0x20)
43 | _BIT4 = const(0x10)
44 | _BIT3 = const(0x08)
45 | _BIT2 = const(0x04)
46 | _BIT1 = const(0x02)
47 | _BIT0 = const(0x01)
48 | #char = F.one_char('a')
49 | #print(char,len(char))
50 | ts = utime.ticks_ms()
51 | text='abcdefg123'
52 | font = F.str(text)
53 | num=2
54 | color = 0
55 | background = 0xff
56 | x0 = 0
57 | for char in text:
58 | #if (x0+font.WIDTH <= self.width and y0+font.HEIGHT <= self.height):
59 | for line in range(num): # 分两次显示,先显示上半边后显示下半边
60 | idx = line * (font.SIZE//num)
61 | buffer = b''
62 | for x in range(0,(font.SIZE//num),4):
63 | buffer += struct.pack('>16H',
64 | color if font.FONT[char][idx+x] & _BIT7 else background,
65 | color if font.FONT[char][idx+x] & _BIT6 else background,
66 | color if font.FONT[char][idx+x] & _BIT5 else background,
67 | color if font.FONT[char][idx+x] & _BIT4 else background,
68 | color if font.FONT[char][idx+x] & _BIT3 else background,
69 | color if font.FONT[char][idx+x] & _BIT2 else background,
70 | color if font.FONT[char][idx+x] & _BIT1 else background,
71 | color if font.FONT[char][idx+x] & _BIT0 else background,
72 | color if font.FONT[char][idx+x+1] & _BIT7 else background,
73 | color if font.FONT[char][idx+x+1] & _BIT6 else background,
74 | color if font.FONT[char][idx+x+1] & _BIT5 else background,
75 | color if font.FONT[char][idx+x+1] & _BIT4 else background,
76 | color if font.FONT[char][idx+x+1] & _BIT3 else background,
77 | color if font.FONT[char][idx+x+1] & _BIT2 else background,
78 | color if font.FONT[char][idx+x+1] & _BIT1 else background,
79 | color if font.FONT[char][idx+x+1] & _BIT0 else background,
80 | color if font.FONT[char][idx+x+2] & _BIT7 else background,
81 | color if font.FONT[char][idx+x+2] & _BIT6 else background,
82 | color if font.FONT[char][idx+x+2] & _BIT5 else background,
83 | color if font.FONT[char][idx+x+2] & _BIT4 else background,
84 | color if font.FONT[char][idx+x+2] & _BIT3 else background,
85 | color if font.FONT[char][idx+x+2] & _BIT2 else background,
86 | color if font.FONT[char][idx+x+2] & _BIT1 else background,
87 | color if font.FONT[char][idx+x+2] & _BIT0 else background,
88 | color if font.FONT[char][idx+x+3] & _BIT7 else background,
89 | color if font.FONT[char][idx+x+3] & _BIT6 else background,
90 | color if font.FONT[char][idx+x+3] & _BIT5 else background,
91 | color if font.FONT[char][idx+x+3] & _BIT4 else background,
92 | color if font.FONT[char][idx+x+3] & _BIT3 else background,
93 | color if font.FONT[char][idx+x+3] & _BIT2 else background,
94 | color if font.FONT[char][idx+x+3] & _BIT1 else background,
95 | color if font.FONT[char][idx+x+3] & _BIT0 else background,
96 | )
97 | x0 += font.WIDTH # 显示下一个字的时候x坐标增加字体宽度
98 | te = utime.ticks_ms()
99 | tc = te - ts
100 | print(tc)
101 | #print(t.HEIGHT, t.FONT)
102 |
103 |
--------------------------------------------------------------------------------
/天气时钟8-27/package/WiFi.py:
--------------------------------------------------------------------------------
1 | import ntptime
2 | import network,time
3 | from machine import RTC,Pin
4 | rtc = RTC()
5 | ssid = 'CU_1316' # WiFi 账号
6 | password = 'zhou1316' # WiFi 密码
7 | # 联WIFI
8 | def WIFI_Connect():
9 | wlan = network.WLAN(network.STA_IF) #STA模式
10 | wlan.active(True) #激活接口
11 | start_time=time.time() #记录时间做超时判断
12 | if not wlan.isconnected():
13 | print('connecting to network...')
14 | wlan.connect(ssid, password) #输入WIFI账号密码
15 | while not wlan.isconnected():
16 | if time.time()-start_time > 15 :
17 | print('WIFI Connected Timeout!')
18 | break
19 | if wlan.isconnected():
20 | print('connected!')
21 | print('network information:', wlan.ifconfig())
22 |
23 | # 同步时间
24 | def sync_ntp():
25 | ntptime.NTP_DELTA = 3155644800
26 | ntptime.host = 'ntp1.aliyun.com'
27 | try:
28 | ntptime.settime()
29 | except:
30 | print('同步失败')
31 |
32 | if __name__ == '__main__':
33 | WIFI_Connect()
34 | sync_ntp()
35 | print(rtc.datetime())
36 | print("同步后本地时间:%s" %str(time.localtime()))
37 |
38 |
39 |
--------------------------------------------------------------------------------
/天气时钟8-27/package/font_gb_16x16.py:
--------------------------------------------------------------------------------
1 | class Font:
2 | def __init__(self, size):
3 | self.WIDTH = size
4 | self.HEIGHT = size
5 | self.SIZE = size * (size // 8)
6 |
7 |
8 | class Font32(Font):
9 | def __init__(self,size):
10 | Font.__init__(self,size)
11 | self.FONT = {
12 | '℃': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
13 | 0x80, 0x00, 0x00, 0x1f, 0xc3, 0xff, 0x00, 0x1d, 0xc7, 0xff, 0xb0, 0x1d, 0xcf, 0x83, 0xf0, 0x1d, 0xde,
14 | 0x00, 0xf0, 0x1f, 0xfc, 0x00, 0x70, 0x07, 0x3c, 0x00, 0x70, 0x00, 0x78, 0x00, 0x30, 0x00, 0x78, 0x00,
15 | 0x30, 0x00, 0x78, 0x00, 0x30, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
16 | 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
17 | 0x3c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x30, 0x00, 0x3e, 0x00, 0x70, 0x00, 0x1f, 0x01, 0xe0, 0x00, 0x0f,
18 | 0x87, 0xc0, 0x00, 0x07, 0xff, 0x80, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
20 | '天': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00,
21 | 0x00, 0x03, 0xe0, 0x0f, 0xff, 0xff, 0xf0, 0x07, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03,
22 | 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x07, 0x80,
23 | 0x70, 0x00, 0x07, 0x80, 0xf8, 0x7f, 0xff, 0xff, 0xfc, 0x38, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00,
24 | 0x00, 0x0f, 0x60, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x00, 0x0e, 0x70, 0x00, 0x00, 0x1e, 0x38, 0x00, 0x00,
25 | 0x1e, 0x3c, 0x00, 0x00, 0x3c, 0x1c, 0x00, 0x00, 0x78, 0x1e, 0x00, 0x00, 0x78, 0x0f, 0x00, 0x00, 0xf0,
26 | 0x07, 0xc0, 0x01, 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0xfc, 0x0f, 0x00, 0x01, 0xfe, 0x3e, 0x00, 0x00,
27 | 0x7c, 0x78, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00],
28 | '阴': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x19, 0xc0, 0x70, 0x1f, 0xff, 0xff, 0xf8, 0x1c,
29 | 0x3d, 0xe0, 0x78, 0x1c, 0x39, 0xe0, 0x70, 0x1c, 0x79, 0xe0, 0x70, 0x1c, 0x71, 0xe0, 0x70, 0x1c, 0x71,
30 | 0xe0, 0x70, 0x1c, 0xe1, 0xe0, 0x70, 0x1c, 0xe1, 0xff, 0xf0, 0x1c, 0xc1, 0xe0, 0x70, 0x1c, 0xe1, 0xe0,
31 | 0x70, 0x1c, 0x71, 0xe0, 0x70, 0x1c, 0x39, 0xe0, 0x70, 0x1c, 0x3d, 0xe0, 0x70, 0x1c, 0x1d, 0xe0, 0x70,
32 | 0x1c, 0x1d, 0xff, 0xf0, 0x1c, 0x1d, 0xe0, 0x70, 0x1f, 0x3d, 0xe0, 0x70, 0x1f, 0xfd, 0xc0, 0x70, 0x1c,
33 | 0xfd, 0xc0, 0x70, 0x1c, 0x7b, 0xc0, 0x70, 0x1c, 0x03, 0xc0, 0x70, 0x1c, 0x03, 0x80, 0x70, 0x1c, 0x07,
34 | 0x80, 0x70, 0x1c, 0x0f, 0x00, 0x70, 0x1c, 0x1e, 0x0f, 0xf0, 0x1c, 0x3c, 0x07, 0xf0, 0x1c, 0x78, 0x01,
35 | 0xf0, 0x1c, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00],
36 | '多': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00,
37 | 0x07, 0xc0, 0x00, 0x00, 0x0f, 0x00, 0xe0, 0x00, 0x3f, 0xff, 0xf0, 0x00, 0x7c, 0x03, 0xf0, 0x00, 0xfe,
38 | 0x07, 0xc0, 0x03, 0xef, 0x0f, 0x80, 0x0f, 0x8f, 0x1f, 0x00, 0x1e, 0x07, 0x7e, 0x00, 0x18, 0x07, 0xf8,
39 | 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x07, 0xfb, 0xf0, 0x00,
40 | 0x3f, 0x87, 0xc0, 0x78, 0x30, 0x0f, 0xff, 0xfc, 0x00, 0x1f, 0x00, 0xfc, 0x00, 0x7c, 0x01, 0xf0, 0x01,
41 | 0xfe, 0x03, 0xe0, 0x03, 0xef, 0x07, 0xc0, 0x0f, 0x87, 0x8f, 0x80, 0x0c, 0x07, 0xbf, 0x00, 0x00, 0x07,
42 | 0xfc, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x07, 0xfc, 0x00,
43 | 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
44 | '云': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 | 0x00, 0x01, 0xc0, 0x00, 0x00, 0x03, 0xe0, 0x07, 0xff, 0xff, 0xe0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 | 0x38, 0x00, 0x00, 0x00, 0x7c, 0x7f, 0xff, 0xff, 0xfe, 0x38, 0x07, 0x80, 0x00, 0x00, 0x0f, 0x00, 0x00,
48 | 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e, 0x18, 0x00, 0x00, 0x3c, 0x1c, 0x00, 0x00,
49 | 0x78, 0x0e, 0x00, 0x00, 0x78, 0x0f, 0x80, 0x00, 0xf0, 0x07, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xc0,
50 | 0x03, 0xe0, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x07, 0xfe, 0x00, 0xf0, 0x07, 0x80, 0x00,
51 | 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
52 | '晴': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x00,
53 | 0x00, 0x1c, 0x78, 0x38, 0xff, 0xff, 0xfc, 0x3f, 0xfc, 0x1c, 0x00, 0x38, 0xf0, 0x1c, 0x00, 0x38, 0xe0,
54 | 0x1c, 0xf0, 0x38, 0xe7, 0xff, 0xf8, 0x38, 0xe3, 0x1c, 0x00, 0x38, 0xe0, 0x1c, 0x18, 0x38, 0xe0, 0x1c,
55 | 0x3c, 0x38, 0xff, 0xff, 0xfe, 0x3f, 0xfc, 0x00, 0x00, 0x38, 0xe7, 0x00, 0xf0, 0x38, 0xe3, 0xff, 0xf0,
56 | 0x38, 0xe3, 0x80, 0xf0, 0x38, 0xe3, 0x80, 0xe0, 0x38, 0xe3, 0xff, 0xe0, 0x38, 0xe3, 0x80, 0xe0, 0x38,
57 | 0xe3, 0x80, 0xe0, 0x3f, 0xe3, 0x80, 0xe0, 0x38, 0xe3, 0xff, 0xe0, 0x38, 0xe3, 0x80, 0xe0, 0x38, 0xe3,
58 | 0x80, 0xe0, 0x30, 0x03, 0x80, 0xe0, 0x00, 0x03, 0x80, 0xe0, 0x00, 0x03, 0x8f, 0xe0, 0x00, 0x03, 0x87,
59 | 0xe0, 0x00, 0x07, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00],
60 | '雨': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
61 | 0x00, 0x00, 0x78, 0x3f, 0xff, 0xff, 0xfc, 0x1c, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03,
62 | 0x80, 0x00, 0x0e, 0x03, 0x80, 0xf0, 0x0f, 0xff, 0xff, 0xf8, 0x0e, 0x03, 0x80, 0xf0, 0x0f, 0xc3, 0xa0,
63 | 0xf0, 0x0f, 0xf3, 0xf8, 0xf0, 0x0e, 0xfb, 0xbe, 0xf0, 0x0e, 0x7f, 0x9e, 0xf0, 0x0e, 0x3f, 0x8e, 0xf0,
64 | 0x0e, 0x3b, 0x8e, 0xf0, 0x0e, 0x1b, 0x86, 0xf0, 0x0f, 0x83, 0x80, 0xf0, 0x0f, 0xe3, 0xf8, 0xf0, 0x0e,
65 | 0xfb, 0xbe, 0xf0, 0x0e, 0x7b, 0x9e, 0xf0, 0x0e, 0x3b, 0x8f, 0xf0, 0x0e, 0x3b, 0x8f, 0xf0, 0x0e, 0x1b,
66 | 0x86, 0xf0, 0x0e, 0x03, 0x80, 0xf0, 0x0e, 0x03, 0x9f, 0xf0, 0x0e, 0x03, 0x9f, 0xe0, 0x0e, 0x03, 0x83,
67 | 0xe0, 0x0e, 0x03, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00],
68 | '大': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00,
69 | 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03,
70 | 0x80, 0x38, 0x00, 0x03, 0x80, 0x7c, 0x7f, 0xff, 0xff, 0xfe, 0x38, 0x03, 0x80, 0x00, 0x00, 0x03, 0xc0,
71 | 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00,
72 | 0x00, 0x07, 0x70, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x00, 0x0f, 0x78, 0x00, 0x00, 0x0e, 0x38, 0x00, 0x00,
73 | 0x1e, 0x1c, 0x00, 0x00, 0x1c, 0x1e, 0x00, 0x00, 0x3c, 0x0f, 0x00, 0x00, 0x78, 0x07, 0x80, 0x00, 0xf0,
74 | 0x07, 0xe0, 0x01, 0xe0, 0x03, 0xf0, 0x03, 0xc0, 0x01, 0xfe, 0x0f, 0x80, 0x00, 0xfe, 0x3e, 0x00, 0x00,
75 | 0x38, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
76 | '小': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00,
77 | 0x01, 0xe0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01,
78 | 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0xf1, 0xcc, 0x00, 0x00, 0xf9, 0xce, 0x00, 0x00, 0xf9, 0xc7,
79 | 0x00, 0x01, 0xf1, 0xc7, 0x80, 0x01, 0xe1, 0xc3, 0xe0, 0x03, 0xc1, 0xc1, 0xf0, 0x03, 0xc1, 0xc0, 0xf0,
80 | 0x07, 0x81, 0xc0, 0xf8, 0x07, 0x01, 0xc0, 0x7c, 0x0f, 0x01, 0xc0, 0x7c, 0x1e, 0x01, 0xc0, 0x3c, 0x1c,
81 | 0x01, 0xc0, 0x3c, 0x38, 0x01, 0xc0, 0x1c, 0x70, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01,
82 | 0xc0, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x0f, 0x80,
83 | 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
84 | '中': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00,
85 | 0x03, 0xc0, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x20, 0x0c, 0x03,
86 | 0x80, 0x78, 0x0f, 0xff, 0xff, 0xf8, 0x0e, 0x03, 0x80, 0x70, 0x0e, 0x03, 0x80, 0x70, 0x0e, 0x03, 0x80,
87 | 0x70, 0x0e, 0x03, 0x80, 0x70, 0x0e, 0x03, 0x80, 0x70, 0x0e, 0x03, 0x80, 0x70, 0x0e, 0x03, 0x80, 0x70,
88 | 0x0e, 0x03, 0x80, 0x70, 0x0f, 0xff, 0xff, 0xf0, 0x0e, 0x03, 0x80, 0x70, 0x0e, 0x03, 0x80, 0x70, 0x1c,
89 | 0x03, 0x80, 0x60, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03,
90 | 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80,
91 | 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00],
92 | '阵': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x38,
93 | 0x78, 0x78, 0x00, 0x3f, 0xf8, 0x70, 0x30, 0x3c, 0x78, 0xf0, 0x78, 0x3c, 0xff, 0xff, 0xfc, 0x3c, 0xee,
94 | 0xe0, 0x00, 0x3c, 0xe0, 0xe0, 0x00, 0x3d, 0xc1, 0xec, 0x00, 0x3d, 0xc1, 0xcf, 0x00, 0x3d, 0x83, 0xce,
95 | 0x00, 0x3d, 0x83, 0xce, 0x00, 0x3d, 0xc3, 0x8e, 0x30, 0x3c, 0xe7, 0x8e, 0x78, 0x3c, 0xff, 0xff, 0xfc,
96 | 0x3c, 0x77, 0xfe, 0x00, 0x3c, 0x78, 0x0e, 0x00, 0x3c, 0x78, 0x0e, 0x00, 0x3c, 0x78, 0x0e, 0x18, 0x3f,
97 | 0xf8, 0x0e, 0x3c, 0x3f, 0xff, 0xff, 0xfe, 0x3d, 0xff, 0xfe, 0x00, 0x3d, 0xc0, 0x0e, 0x00, 0x3c, 0x00,
98 | 0x0e, 0x00, 0x3c, 0x00, 0x0e, 0x00, 0x3c, 0x00, 0x0e, 0x00, 0x3c, 0x00, 0x0e, 0x00, 0x3c, 0x00, 0x0e,
99 | 0x00, 0x3c, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00],
100 | '雾': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x03, 0xff, 0xff, 0xc0, 0x01,
101 | 0xc3, 0xc0, 0x00, 0x06, 0x03, 0xc0, 0x38, 0x0f, 0xff, 0xff, 0xfc, 0x0e, 0x03, 0xc0, 0x7c, 0x1f, 0xff,
102 | 0xff, 0xf0, 0x3e, 0x03, 0xc0, 0xe0, 0x19, 0xff, 0xff, 0x80, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x3b, 0x80,
103 | 0x00, 0x00, 0x7c, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x80, 0x01, 0xf8, 0x1f, 0x80, 0x03, 0xdc, 0x3c, 0x00,
104 | 0x0f, 0x0f, 0xf0, 0x00, 0x0e, 0x07, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xfe, 0x01, 0xff, 0x3f, 0xfe, 0x1f,
105 | 0xe7, 0x87, 0xf8, 0x7c, 0x07, 0x83, 0x80, 0x03, 0xff, 0xff, 0xc0, 0x01, 0xcf, 0x03, 0x80, 0x00, 0x0f,
106 | 0x07, 0x80, 0x00, 0x1e, 0x07, 0x00, 0x00, 0x3c, 0x07, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x07, 0xe0, 0x7e,
107 | 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00],
108 | '年': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x30, 0x03, 0xc0, 0x00, 0x78, 0x03, 0xff, 0xff, 0xfc, 0x07, 0x81, 0xe0, 0x00, 0x07, 0x01, 0xe0, 0x00, 0x0f, 0x01, 0xe0, 0x00, 0x1e, 0x01, 0xe0, 0x00, 0x3c, 0x01, 0xe0, 0xc0, 0x3b, 0x81, 0xe1, 0xe0, 0x73, 0xff, 0xff, 0xf0, 0x03, 0xc1, 0xe0, 0x00, 0x03, 0xc1, 0xe0, 0x00, 0x03, 0xc1, 0xe0, 0x00, 0x03, 0xc1, 0xe0, 0x00, 0x03, 0xc1, 0xe0, 0x18, 0x03, 0xc1, 0xe0, 0x3c, 0x7f, 0xff, 0xff, 0xfe, 0x78, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00],
109 | '月': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xff, 0xff, 0xc0, 0x00, 0xe0, 0x03, 0xc0, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xff, 0xff, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0xff, 0xff, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x01, 0xe0, 0x03, 0x80, 0x01, 0xe0, 0x03, 0x80, 0x01, 0xe0, 0x03, 0x80, 0x01, 0xc0, 0x03, 0x80, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x07, 0x80, 0x03, 0x80, 0x0f, 0x00, 0xff, 0x80, 0x1e, 0x00, 0x7f, 0x80, 0x3c, 0x00, 0x1f, 0x80, 0x70, 0x00, 0x0e, 0x00,
110 | 0x00, 0x00, 0x00, 0x00],
111 | '':'',
112 | '':'',
113 | }
114 | class Font48(Font):
115 | def __init__(self,size):
116 | Font.__init__(self,size)
117 | self.WIDTH = 24
118 | self.SIZE = 144
119 | class Font24(Font):
120 | def __init__(self,size):
121 | Font.__init__(self,size)
122 | self.WIDTH = 12
123 | self.SIZE = 36
124 | class Font16(Font):
125 | def __init__(self,size):
126 | Font.__init__(self,size)
127 | self.WIDTH = 8
128 | self.SIZE = self.SIZE // 2
129 | if __name__ == '__main__':
130 | f32 = Font32(32)
131 | f48 = Font48(48)
132 | print(f32.SIZE)
133 | print(f48.WIDTH)
134 |
--------------------------------------------------------------------------------
/天气时钟8-27/package/gb16x16.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/gb16x16.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/gb24x24.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/gb24x24.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/st7789py.py:
--------------------------------------------------------------------------------
1 | import time
2 | from micropython import const
3 | import ustruct as struct
4 |
5 | '''
6 | 导入字体
7 | '''
8 | from package import GBfont
9 | from package import font_gb_16x16 as font_gb
10 | from package import VGAfont
11 | GB16 = GBfont.gb2312(16)
12 | GB24 = GBfont.gb2312(24)
13 | GB32 = font_gb.Font32(32)
14 | vga32 = VGAfont.VGAFONT(32)
15 | vga16 = VGAfont.VGAFONT(16)
16 | vga24 = VGAfont.VGAFONT(24)
17 | vga40 = VGAfont.VGAFONT(40)
18 | vga48 = VGAfont.VGAFONT(48)
19 | # commands
20 | ST7789_NOP = const(0x00)
21 | ST7789_SWRESET = const(0x01)
22 | ST7789_RDDID = const(0x04)
23 | ST7789_RDDST = const(0x09)
24 |
25 | ST7789_SLPIN = const(0x10)
26 | ST7789_SLPOUT = const(0x11)
27 | ST7789_PTLON = const(0x12)
28 | ST7789_NORON = const(0x13)
29 |
30 | ST7789_INVOFF = const(0x20)
31 | ST7789_INVON = const(0x21)
32 | ST7789_DISPOFF = const(0x28)
33 | ST7789_DISPON = const(0x29)
34 | ST7789_CASET = const(0x2A)
35 | ST7789_RASET = const(0x2B)
36 | ST7789_RAMWR = const(0x2C)
37 | ST7789_RAMRD = const(0x2E)
38 |
39 | ST7789_PTLAR = const(0x30)
40 | ST7789_VSCRDEF = const(0x33)
41 | ST7789_COLMOD = const(0x3A)
42 | ST7789_MADCTL = const(0x36)
43 | ST7789_VSCSAD = const(0x37)
44 |
45 | ST7789_MADCTL_MY = const(0x80)
46 | ST7789_MADCTL_MX = const(0x40)
47 | ST7789_MADCTL_MV = const(0x20)
48 | ST7789_MADCTL_ML = const(0x10)
49 | ST7789_MADCTL_BGR = const(0x08)
50 | ST7789_MADCTL_MH = const(0x04)
51 | ST7789_MADCTL_RGB = const(0x00)
52 |
53 | ST7789_RDID1 = const(0xDA)
54 | ST7789_RDID2 = const(0xDB)
55 | ST7789_RDID3 = const(0xDC)
56 | ST7789_RDID4 = const(0xDD)
57 |
58 | COLOR_MODE_65K = const(0x50)
59 | COLOR_MODE_262K = const(0x60)
60 | COLOR_MODE_12BIT = const(0x03)
61 | COLOR_MODE_16BIT = const(0x05)
62 | COLOR_MODE_18BIT = const(0x06)
63 | COLOR_MODE_16M = const(0x07)
64 |
65 | # Color definitions
66 | BLACK = const(0x0000)
67 | BLUE = const(0x001F)
68 | RED = const(0xF800)
69 | GREEN = const(0x07E0)
70 | CYAN = const(0x07FF)
71 | MAGENTA = const(0xF81F)
72 | YELLOW = const(0xFFE0)
73 | WHITE = const(0xFFFF)
74 |
75 | _ENCODE_PIXEL = ">H"
76 | _ENCODE_POS = ">HH"
77 | _DECODE_PIXEL = ">BBB"
78 |
79 | _BUFFER_SIZE = const(256)
80 |
81 | _BIT7 = const(0x80)
82 | _BIT6 = const(0x40)
83 | _BIT5 = const(0x20)
84 | _BIT4 = const(0x10)
85 | _BIT3 = const(0x08)
86 | _BIT2 = const(0x04)
87 | _BIT1 = const(0x02)
88 | _BIT0 = const(0x01)
89 | _BIT = [_BIT0, _BIT1, _BIT2, _BIT3, _BIT4,_BIT5, _BIT6, _BIT7]
90 | # Rotation tables (width, height, xstart, ystart)[rotation % 4]
91 |
92 | WIDTH_320 = [(240, 320, 0, 0),
93 | (320, 240, 0, 0),
94 | (240, 320, 0, 0),
95 | (320, 240, 0, 0)]
96 |
97 | WIDTH_240 = [(240, 240, 0, 0),
98 | (240, 240, 0, 0),
99 | (240, 240, 0, 80),
100 | (240, 240, 80, 0)]
101 |
102 | WIDTH_135 = [(135, 240, 52, 40),
103 | (240, 135, 40, 53),
104 | (135, 240, 53, 40),
105 | (240, 135, 40, 52)]
106 |
107 | # MADCTL ROTATIONS[rotation % 4]
108 | ROTATIONS = [0x00, 0x60, 0xc0, 0xa0]
109 |
110 |
111 | def color565(red, green=0, blue=0):
112 | """
113 | Convert red, green and blue values (0-255) into a 16-bit 565 encoding.
114 | """
115 | try:
116 | red, green, blue = red # see if the first var is a tuple/list
117 | except TypeError:
118 | pass
119 | return (red & 0xf8) << 8 | (green & 0xfc) << 3 | blue >> 3
120 |
121 |
122 | def _encode_pos(x, y):
123 | """Encode a postion into bytes."""
124 | return struct.pack(_ENCODE_POS, x, y)
125 |
126 |
127 | def _encode_pixel(color):
128 | """Encode a pixel color into bytes."""
129 | return struct.pack(_ENCODE_PIXEL, color)
130 |
131 |
132 | class ST7789():
133 | def __init__(self, spi, width, height, reset=None, dc=None,
134 | cs=None, backlight=None, rotation=0):
135 | self.num = 4
136 | """
137 | Initialize display.
138 | """
139 | if height != 240 or width not in [320, 240, 135]:
140 | raise ValueError(
141 | "Unsupported display. 320x240, 240x240 and 135x240 are supported."
142 | )
143 |
144 | if dc is None:
145 | raise ValueError("dc pin is required.")
146 |
147 | self._display_width = self.width = width
148 | self._display_height = self.height = height
149 | self.xstart = 0
150 | self.ystart = 0
151 | self.spi = spi
152 | self.reset = reset
153 | self.dc = dc
154 | self.cs = cs
155 | self.backlight = backlight
156 | self._rotation = rotation % 4
157 | self.cs.init(self.cs.OUT, value=1)
158 | self.dc.init(self.dc.OUT, value=0)
159 | self.reset.init(self.reset.OUT, value=1)
160 | self.sleep_mode(False)
161 |
162 | self._set_color_mode(COLOR_MODE_65K | COLOR_MODE_16BIT)
163 | time.sleep_ms(50)
164 | self.rotation(self._rotation)
165 | self.inversion_mode(True)
166 | time.sleep_ms(10)
167 | self._write(ST7789_NORON)
168 | time.sleep_ms(10)
169 | if backlight is not None:
170 | from machine import Pin,PWM
171 | self.bl = PWM(self.backlight,freq=1000,duty=128)
172 | self.fill(0)
173 | self._write(ST7789_DISPON)
174 | time.sleep_ms(500)
175 | def brightness(self,value):
176 | '''
177 | 调节背光亮度
178 | value: int 0-1023 建议值 <256
179 | '''
180 | self.bl.duty(value)
181 | def _write(self, command=None, data=None):
182 | """SPI write to the device: commands and data."""
183 | if self.cs:
184 | self.cs.off()
185 |
186 | if command is not None:
187 | self.dc.off()
188 | self.spi.write(bytes([command]))
189 | if data is not None:
190 | self.dc.on()
191 | self.spi.write(data)
192 | if self.cs:
193 | self.cs.on()
194 |
195 | def sleep_mode(self, value):
196 | if value:
197 | self._write(ST7789_SLPIN)
198 | else:
199 | self._write(ST7789_SLPOUT)
200 |
201 | def inversion_mode(self, value):
202 | if value:
203 | self._write(ST7789_INVON)
204 | else:
205 | self._write(ST7789_INVOFF)
206 |
207 | def _set_color_mode(self, mode):
208 | self._write(ST7789_COLMOD, bytes([mode & 0x77]))
209 |
210 | def rotation(self, rotation):
211 | rotation %= 4
212 | self._rotation = rotation
213 | madctl = ROTATIONS[rotation]
214 |
215 | if self._display_width == 320:
216 | table = WIDTH_320
217 | elif self._display_width == 240:
218 | table = WIDTH_240
219 | elif self._display_width == 135:
220 | table = WIDTH_135
221 | else:
222 | raise ValueError(
223 | "Unsupported display. 320x240, 240x240 and 135x240 are supported."
224 | )
225 |
226 | self.width, self.height, self.xstart, self.ystart = table[rotation]
227 | self._write(ST7789_MADCTL, bytes([madctl]))
228 |
229 | def _set_columns(self, start, end):
230 | if start <= end <= self.width:
231 | self._write(ST7789_CASET, _encode_pos(
232 | start+self.xstart, end + self.xstart))
233 |
234 | def _set_rows(self, start, end):
235 | if start <= end <= self.height:
236 | self._write(ST7789_RASET, _encode_pos(
237 | start+self.ystart, end+self.ystart))
238 |
239 | def _set_window(self, x0, y0, x1, y1):
240 | self._set_columns(x0, x1)
241 | self._set_rows(y0, y1)
242 | self._write(ST7789_RAMWR)
243 |
244 | def vline(self, x, y, length, color):
245 | self.fill_rect(x, y, 1, length, color)
246 |
247 | def hline(self, x, y, length, color):
248 | self.fill_rect(x, y, length, 1, color)
249 |
250 | def pixel(self, x, y, color):
251 | self._set_window(x, y, x, y)
252 | self._write(None, _encode_pixel(color))
253 |
254 | def blit_buffer(self, buffer, x, y, width, height):
255 | self._set_window(x, y, x + width - 1, y + height - 1)
256 | self._write(None, buffer)
257 |
258 | def rect(self, x, y, w, h, color):
259 | self.hline(x, y, w, color)
260 | self.vline(x, y, h, color)
261 | self.vline(x + w - 1, y, h, color)
262 | self.hline(x, y + h - 1, w, color)
263 |
264 | def fill_rect(self, x, y, width, height, color):
265 | self._set_window(x, y, x + width - 1, y + height - 1)
266 | chunks, rest = divmod(width * height, _BUFFER_SIZE)
267 | pixel = _encode_pixel(color)
268 | self.dc.on()
269 | if chunks:
270 | data = pixel * _BUFFER_SIZE
271 | for _ in range(chunks):
272 | self._write(None, data)
273 | if rest:
274 | self._write(None, pixel * rest)
275 |
276 | def fill(self, color):
277 | self.fill_rect(0, 0, self.width, self.height, color)
278 |
279 | def line(self, x0, y0, x1, y1, color):
280 | steep = abs(y1 - y0) > abs(x1 - x0)
281 | if steep:
282 | x0, y0 = y0, x0
283 | x1, y1 = y1, x1
284 | if x0 > x1:
285 | x0, x1 = x1, x0
286 | y0, y1 = y1, y0
287 | dx = x1 - x0
288 | dy = abs(y1 - y0)
289 | err = dx // 2
290 | ystep = 1 if y0 < y1 else -1
291 | while x0 <= x1:
292 | if steep:
293 | self.pixel(y0, x0, color)
294 | else:
295 | self.pixel(x0, y0, color)
296 | err -= dy
297 | if err < 0:
298 | y0 += ystep
299 | err += dx
300 | x0 += 1
301 |
302 | def vscrdef(self, tfa, vsa, bfa):
303 | struct.pack(">HHH", tfa, vsa, bfa)
304 | self._write(ST7789_VSCRDEF, struct.pack(">HHH", tfa, vsa, bfa))
305 |
306 | def vscsad(self, vssa):
307 | self._write(ST7789_VSCSAD, struct.pack(">H", vssa))
308 | def _text(self,font,size, text, x0, y0, color=WHITE, background=BLACK):
309 | self.k = 0
310 | self.num = 4
311 | for char in text:
312 | if (x0+font.WIDTH <= self.width and y0+font.HEIGHT <= self.height):
313 | for line in range(self.num): # 分两次显示,先显示上半边后显示下半边
314 | idx = line * (font.SIZE//self.num)
315 | buffer = b''
316 | for x in range(0,(font.SIZE//self.num),1):
317 | buffer += struct.pack('>8H',
318 | color if font.FONT[char][idx+x] & _BIT7 else background,
319 | color if font.FONT[char][idx+x] & _BIT6 else background,
320 | color if font.FONT[char][idx+x] & _BIT5 else background,
321 | color if font.FONT[char][idx+x] & _BIT4 else background,
322 | color if font.FONT[char][idx+x] & _BIT3 else background,
323 | color if font.FONT[char][idx+x] & _BIT2 else background,
324 | color if font.FONT[char][idx+x] & _BIT1 else background,
325 | color if font.FONT[char][idx+x] & _BIT0 else background,
326 | )
327 | self.blit_buffer(buffer, x0, y0+(font.HEIGHT//self.num)*line, font.WIDTH, font.HEIGHT//self.num)
328 | x0 += font.WIDTH # 显示下一个字的时候x坐标增加字体宽度
329 | def _text(self,font,size, text, x0, y0, color=WHITE, background=BLACK):
330 | self.k = 0
331 | self.num = 1
332 | passes, rest = divmod(font.SIZE,16)
333 | for char in text:
334 | if (x0+font.WIDTH <= self.width and y0+font.HEIGHT <= self.height):
335 | buffer = b''
336 | for line in range(passes):
337 | idx = line * 16
338 | x = 0
339 | buffer += struct.pack('>128H',
340 | color if font.FONT[char][idx+x] & _BIT7 else background,
341 | color if font.FONT[char][idx+x] & _BIT6 else background,
342 | color if font.FONT[char][idx+x] & _BIT5 else background,
343 | color if font.FONT[char][idx+x] & _BIT4 else background,
344 | color if font.FONT[char][idx+x] & _BIT3 else background,
345 | color if font.FONT[char][idx+x] & _BIT2 else background,
346 | color if font.FONT[char][idx+x] & _BIT1 else background,
347 | color if font.FONT[char][idx+x] & _BIT0 else background,
348 | color if font.FONT[char][idx+x+1] & _BIT7 else background,
349 | color if font.FONT[char][idx+x+1] & _BIT6 else background,
350 | color if font.FONT[char][idx+x+1] & _BIT5 else background,
351 | color if font.FONT[char][idx+x+1] & _BIT4 else background,
352 | color if font.FONT[char][idx+x+1] & _BIT3 else background,
353 | color if font.FONT[char][idx+x+1] & _BIT2 else background,
354 | color if font.FONT[char][idx+x+1] & _BIT1 else background,
355 | color if font.FONT[char][idx+x+1] & _BIT0 else background,
356 | color if font.FONT[char][idx+x+2] & _BIT7 else background,
357 | color if font.FONT[char][idx+x+2] & _BIT6 else background,
358 | color if font.FONT[char][idx+x+2] & _BIT5 else background,
359 | color if font.FONT[char][idx+x+2] & _BIT4 else background,
360 | color if font.FONT[char][idx+x+2] & _BIT3 else background,
361 | color if font.FONT[char][idx+x+2] & _BIT2 else background,
362 | color if font.FONT[char][idx+x+2] & _BIT1 else background,
363 | color if font.FONT[char][idx+x+2] & _BIT0 else background,
364 | color if font.FONT[char][idx+x+3] & _BIT7 else background,
365 | color if font.FONT[char][idx+x+3] & _BIT6 else background,
366 | color if font.FONT[char][idx+x+3] & _BIT5 else background,
367 | color if font.FONT[char][idx+x+3] & _BIT4 else background,
368 | color if font.FONT[char][idx+x+3] & _BIT3 else background,
369 | color if font.FONT[char][idx+x+3] & _BIT2 else background,
370 | color if font.FONT[char][idx+x+3] & _BIT1 else background,
371 | color if font.FONT[char][idx+x+3] & _BIT0 else background,
372 | color if font.FONT[char][idx+x+4] & _BIT7 else background,
373 | color if font.FONT[char][idx+x+4] & _BIT6 else background,
374 | color if font.FONT[char][idx+x+4] & _BIT5 else background,
375 | color if font.FONT[char][idx+x+4] & _BIT4 else background,
376 | color if font.FONT[char][idx+x+4] & _BIT3 else background,
377 | color if font.FONT[char][idx+x+4] & _BIT2 else background,
378 | color if font.FONT[char][idx+x+4] & _BIT1 else background,
379 | color if font.FONT[char][idx+x+4] & _BIT0 else background,
380 | color if font.FONT[char][idx+x+5] & _BIT7 else background,
381 | color if font.FONT[char][idx+x+5] & _BIT6 else background,
382 | color if font.FONT[char][idx+x+5] & _BIT5 else background,
383 | color if font.FONT[char][idx+x+5] & _BIT4 else background,
384 | color if font.FONT[char][idx+x+5] & _BIT3 else background,
385 | color if font.FONT[char][idx+x+5] & _BIT2 else background,
386 | color if font.FONT[char][idx+x+5] & _BIT1 else background,
387 | color if font.FONT[char][idx+x+5] & _BIT0 else background,
388 | color if font.FONT[char][idx+x+6] & _BIT7 else background,
389 | color if font.FONT[char][idx+x+6] & _BIT6 else background,
390 | color if font.FONT[char][idx+x+6] & _BIT5 else background,
391 | color if font.FONT[char][idx+x+6] & _BIT4 else background,
392 | color if font.FONT[char][idx+x+6] & _BIT3 else background,
393 | color if font.FONT[char][idx+x+6] & _BIT2 else background,
394 | color if font.FONT[char][idx+x+6] & _BIT1 else background,
395 | color if font.FONT[char][idx+x+6] & _BIT0 else background,
396 | color if font.FONT[char][idx+x+7] & _BIT7 else background,
397 | color if font.FONT[char][idx+x+7] & _BIT6 else background,
398 | color if font.FONT[char][idx+x+7] & _BIT5 else background,
399 | color if font.FONT[char][idx+x+7] & _BIT4 else background,
400 | color if font.FONT[char][idx+x+7] & _BIT3 else background,
401 | color if font.FONT[char][idx+x+7] & _BIT2 else background,
402 | color if font.FONT[char][idx+x+7] & _BIT1 else background,
403 | color if font.FONT[char][idx+x+7] & _BIT0 else background,
404 | color if font.FONT[char][idx+x+8] & _BIT7 else background,
405 | color if font.FONT[char][idx+x+8] & _BIT6 else background,
406 | color if font.FONT[char][idx+x+8] & _BIT5 else background,
407 | color if font.FONT[char][idx+x+8] & _BIT4 else background,
408 | color if font.FONT[char][idx+x+8] & _BIT3 else background,
409 | color if font.FONT[char][idx+x+8] & _BIT2 else background,
410 | color if font.FONT[char][idx+x+8] & _BIT1 else background,
411 | color if font.FONT[char][idx+x+8] & _BIT0 else background,
412 | color if font.FONT[char][idx+x+9] & _BIT7 else background,
413 | color if font.FONT[char][idx+x+9] & _BIT6 else background,
414 | color if font.FONT[char][idx+x+9] & _BIT5 else background,
415 | color if font.FONT[char][idx+x+9] & _BIT4 else background,
416 | color if font.FONT[char][idx+x+9] & _BIT3 else background,
417 | color if font.FONT[char][idx+x+9] & _BIT2 else background,
418 | color if font.FONT[char][idx+x+9] & _BIT1 else background,
419 | color if font.FONT[char][idx+x+9] & _BIT0 else background,
420 | color if font.FONT[char][idx+x+10] & _BIT7 else background,
421 | color if font.FONT[char][idx+x+10] & _BIT6 else background,
422 | color if font.FONT[char][idx+x+10] & _BIT5 else background,
423 | color if font.FONT[char][idx+x+10] & _BIT4 else background,
424 | color if font.FONT[char][idx+x+10] & _BIT3 else background,
425 | color if font.FONT[char][idx+x+10] & _BIT2 else background,
426 | color if font.FONT[char][idx+x+10] & _BIT1 else background,
427 | color if font.FONT[char][idx+x+10] & _BIT0 else background,
428 | color if font.FONT[char][idx+x+11] & _BIT7 else background,
429 | color if font.FONT[char][idx+x+11] & _BIT6 else background,
430 | color if font.FONT[char][idx+x+11] & _BIT5 else background,
431 | color if font.FONT[char][idx+x+11] & _BIT4 else background,
432 | color if font.FONT[char][idx+x+11] & _BIT3 else background,
433 | color if font.FONT[char][idx+x+11] & _BIT2 else background,
434 | color if font.FONT[char][idx+x+11] & _BIT1 else background,
435 | color if font.FONT[char][idx+x+11] & _BIT0 else background,
436 | color if font.FONT[char][idx+x+12] & _BIT7 else background,
437 | color if font.FONT[char][idx+x+12] & _BIT6 else background,
438 | color if font.FONT[char][idx+x+12] & _BIT5 else background,
439 | color if font.FONT[char][idx+x+12] & _BIT4 else background,
440 | color if font.FONT[char][idx+x+12] & _BIT3 else background,
441 | color if font.FONT[char][idx+x+12] & _BIT2 else background,
442 | color if font.FONT[char][idx+x+12] & _BIT1 else background,
443 | color if font.FONT[char][idx+x+12] & _BIT0 else background,
444 | color if font.FONT[char][idx+x+13] & _BIT7 else background,
445 | color if font.FONT[char][idx+x+13] & _BIT6 else background,
446 | color if font.FONT[char][idx+x+13] & _BIT5 else background,
447 | color if font.FONT[char][idx+x+13] & _BIT4 else background,
448 | color if font.FONT[char][idx+x+13] & _BIT3 else background,
449 | color if font.FONT[char][idx+x+13] & _BIT2 else background,
450 | color if font.FONT[char][idx+x+13] & _BIT1 else background,
451 | color if font.FONT[char][idx+x+13] & _BIT0 else background,
452 | color if font.FONT[char][idx+x+14] & _BIT7 else background,
453 | color if font.FONT[char][idx+x+14] & _BIT6 else background,
454 | color if font.FONT[char][idx+x+14] & _BIT5 else background,
455 | color if font.FONT[char][idx+x+14] & _BIT4 else background,
456 | color if font.FONT[char][idx+x+14] & _BIT3 else background,
457 | color if font.FONT[char][idx+x+14] & _BIT2 else background,
458 | color if font.FONT[char][idx+x+14] & _BIT1 else background,
459 | color if font.FONT[char][idx+x+14] & _BIT0 else background,
460 | color if font.FONT[char][idx+x+15] & _BIT7 else background,
461 | color if font.FONT[char][idx+x+15] & _BIT6 else background,
462 | color if font.FONT[char][idx+x+15] & _BIT5 else background,
463 | color if font.FONT[char][idx+x+15] & _BIT4 else background,
464 | color if font.FONT[char][idx+x+15] & _BIT3 else background,
465 | color if font.FONT[char][idx+x+15] & _BIT2 else background,
466 | color if font.FONT[char][idx+x+15] & _BIT1 else background,
467 | color if font.FONT[char][idx+x+15] & _BIT0 else background,
468 | )
469 | if rest:
470 | for i in range(rest//4):
471 | idx = i * 4 + font.SIZE - rest
472 | buffer += struct.pack(
473 | '>32H',
474 | color if font.FONT[char][idx] & _BIT7 else background,
475 | color if font.FONT[char][idx] & _BIT6 else background,
476 | color if font.FONT[char][idx] & _BIT5 else background,
477 | color if font.FONT[char][idx] & _BIT4 else background,
478 | color if font.FONT[char][idx] & _BIT3 else background,
479 | color if font.FONT[char][idx] & _BIT2 else background,
480 | color if font.FONT[char][idx] & _BIT1 else background,
481 | color if font.FONT[char][idx] & _BIT0 else background,
482 | color if font.FONT[char][idx+1] & _BIT7 else background,
483 | color if font.FONT[char][idx+1] & _BIT6 else background,
484 | color if font.FONT[char][idx+1] & _BIT5 else background,
485 | color if font.FONT[char][idx+1] & _BIT4 else background,
486 | color if font.FONT[char][idx+1] & _BIT3 else background,
487 | color if font.FONT[char][idx+1] & _BIT2 else background,
488 | color if font.FONT[char][idx+1] & _BIT1 else background,
489 | color if font.FONT[char][idx+1] & _BIT0 else background,
490 | color if font.FONT[char][idx+2] & _BIT7 else background,
491 | color if font.FONT[char][idx+2] & _BIT6 else background,
492 | color if font.FONT[char][idx+2] & _BIT5 else background,
493 | color if font.FONT[char][idx+2] & _BIT4 else background,
494 | color if font.FONT[char][idx+2] & _BIT3 else background,
495 | color if font.FONT[char][idx+2] & _BIT2 else background,
496 | color if font.FONT[char][idx+2] & _BIT1 else background,
497 | color if font.FONT[char][idx+2] & _BIT0 else background,
498 | color if font.FONT[char][idx+3] & _BIT7 else background,
499 | color if font.FONT[char][idx+3] & _BIT6 else background,
500 | color if font.FONT[char][idx+3] & _BIT5 else background,
501 | color if font.FONT[char][idx+3] & _BIT4 else background,
502 | color if font.FONT[char][idx+3] & _BIT3 else background,
503 | color if font.FONT[char][idx+3] & _BIT2 else background,
504 | color if font.FONT[char][idx+3] & _BIT1 else background,
505 | color if font.FONT[char][idx+3] & _BIT0 else background,
506 | )
507 | self.blit_buffer(buffer, x0, y0, font.WIDTH, font.HEIGHT)
508 | x0 += font.WIDTH # 显示下一个字的时候x坐标增加字体宽度
509 | def text(self,size, text, x0, y0, color=WHITE, background=BLACK):
510 | char = text[0].encode('utf-8')
511 | if len(char) == 1:
512 | if size == 0:
513 | pass
514 | elif size == 24:
515 | font_gb = vga24.str(text)
516 | elif size == 16:
517 | font_gb = vga16.str(text)
518 | elif size == 32:
519 | font_gb = vga32.str(text)
520 | elif size == 40:
521 | font_gb = vga40.str(text)
522 | elif size == 48:
523 | font_gb = vga48.str(text)
524 | else:
525 | if size == 16:
526 | font_gb = GB16.str(text)
527 | elif size == 24:
528 | font_gb = GB24.str(text)
529 | elif size == 32:
530 | font_gb = GB32
531 | elif size == 48:
532 | font_gb = GB48
533 | self._text(font_gb,size, text, x0, y0, color, background)
534 |
535 | def bitmap(self, bitmap, x, y, index=0):
536 | bitmap_size = bitmap.HEIGHT * bitmap.WIDTH
537 | buffer_len = bitmap_size * 2
538 | buffer = bytearray(buffer_len)
539 | bs_bit = bitmap.BPP * bitmap_size * index if index > 0 else 0
540 |
541 | for i in range(0, buffer_len, 2):
542 | color_index = 0
543 | for _ in range(bitmap.BPP):
544 | color_index <<= 1
545 | color_index |= (bitmap.BITMAP[bs_bit // 8]
546 | & 1 << (7 - (bs_bit % 8))) > 0
547 | bs_bit += 1
548 |
549 | color = bitmap.PALETTE[color_index]
550 | buffer[i] = color & 0xff00 >> 8
551 | buffer[i + 1] = color_index & 0xff
552 |
553 | to_col = x + bitmap.WIDTH - 1
554 | to_row = y + bitmap.HEIGHT - 1
555 | if self.width > to_col and self.height > to_row:
556 | self._set_window(x, y, to_col, to_row)
557 | self._write(None, buffer)
558 |
559 | # @micropython.native
560 | def write(self, font, string, x, y, fg=WHITE, bg=BLACK):
561 | buffer_len = font.HEIGHT * font.MAX_WIDTH * 2
562 | buffer = bytearray(buffer_len)
563 | fg_hi = (fg & 0xff00) >> 8
564 | fg_lo = fg & 0xff
565 |
566 | bg_hi = (bg & 0xff00) >> 8
567 | bg_lo = bg & 0xff
568 |
569 | for character in string:
570 | try:
571 | char_index = font.MAP.index(character)
572 | offset = char_index * font.OFFSET_WIDTH
573 | bs_bit = font.OFFSETS[offset]
574 | if font.OFFSET_WIDTH > 1:
575 | bs_bit = (bs_bit << 8) + font.OFFSETS[offset + 1]
576 |
577 | if font.OFFSET_WIDTH > 2:
578 | bs_bit = (bs_bit << 8) + font.OFFSETS[offset + 2]
579 |
580 | char_width = font.WIDTHS[char_index]
581 | buffer_needed = char_width * font.HEIGHT * 2
582 |
583 | for i in range(0, buffer_needed, 2):
584 | if font.BITMAPS[bs_bit // 8] & 1 << (7 - (bs_bit % 8)) > 0:
585 | buffer[i] = fg_hi
586 | buffer[i + 1] = fg_lo
587 | else:
588 | buffer[i] = bg_hi
589 | buffer[i + 1] = bg_lo
590 |
591 | bs_bit += 1
592 |
593 | to_col = x + char_width - 1
594 | to_row = y + font.HEIGHT - 1
595 | if self.width > to_col and self.height > to_row:
596 | self._set_window(x, y, to_col, to_row)
597 | self._write(None, buffer[:buffer_needed])
598 |
599 | x += char_width
600 |
601 | except ValueError:
602 | pass
603 |
604 | def write_width(self, font, string):
605 | width = 0
606 | for character in string:
607 | try:
608 | char_index = font.MAP.index(character)
609 | width += font.WIDTHS[char_index]
610 |
611 | except ValueError:
612 | pass
613 |
614 | return width
615 |
--------------------------------------------------------------------------------
/天气时钟8-27/package/vga1_12x24.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/vga1_12x24.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/vga1_16x32.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/vga1_16x32.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/vga1_20x40.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/vga1_20x40.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/vga1_24x48.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/vga1_24x48.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/vga1_8x16.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/package/vga1_8x16.ttf
--------------------------------------------------------------------------------
/天气时钟8-27/package/weather.py:
--------------------------------------------------------------------------------
1 | import urequests
2 | import ujson
3 | from package import WiFi
4 | import uzlib as zlib
5 | FTEXT = 1
6 | FHCRC = 2
7 | FEXTRA = 4
8 | FNAME = 8
9 | FCOMMENT = 16
10 | class Weather():
11 | def __init__(self):
12 | WiFi.WIFI_Connect()
13 | WiFi.sync_ntp()
14 | self.ssid = 'P_083oXK8ImwN8XJl'
15 | self.password ='SpsL1FI3kR56iaePC'
16 | def img_size(self,code):
17 | size = ['48x48','48x48','48x48','48x48',
18 | '58x38','58x41','58x48','58x41',
19 | '58x48','58x38','58x57','58x58',
20 | '58x58','58x57','58x57','58x58',
21 | '58x58','61x61','61x61','58x58',
22 | '58x57','58x58','58x55','58x55',
23 | '58x55','58x58','58x49','58x49',
24 | '58x34','58x34','56x51','58x51',
25 | '58x46','58x46','58x58','58x58',
26 | '58x57','50x58','48x48'
27 | ]
28 | return size[int(code)]
29 | def now_weather(self,city):
30 | #34.40:114.96
31 | url = "https://api.seniverse.com/v3/weather/now.json?key={}&location={}&language=zh-Hans&unit=c".format(self.password,city)
32 | result1=urequests.get(url)
33 | j1=ujson.loads(result1.text)
34 | _city = j1['results'][0]['location']['name']
35 | weather = j1['results'][0]['now']['text']
36 | tem = j1['results'][0]['now']['temperature']
37 | code = j1['results'][0]['now']['code']
38 | print(j1['results'][0]['location']['name'],end=' ')
39 | print(j1['results'][0]['now']['text'],end=' ')
40 | print(j1['results'][0]['now']['temperature'],end='℃ ')
41 | print(j1['results'][0]['last_update'])
42 | print('天气代码:',code)
43 | #print(j1)
44 | return {
45 | 'city':_city,
46 | 'weather':weather,
47 | 'tem':tem,
48 | 'code':code,
49 | 'height':int(self.img_size(code)[3:]),
50 | 'width':int(self.img_size(code)[0:2])
51 | }
52 | def decompress(self,data):
53 | assert data[0] == 0x1f and data[1] == 0x8b
54 | assert data[2] == 8
55 | flg = data[3]
56 | assert flg & 0xe0 == 0
57 | i = 10
58 | if flg & FEXTRA:
59 | i += data[11] << 8 + data[10] + 2
60 | if flg & FNAME:
61 | while data[i]:
62 | i += 1
63 | i += 1
64 | if flg & FCOMMENT:
65 | while data[i]:
66 | i += 1
67 | i += 1
68 | if flg & FHCRC:
69 | i += 2
70 | return zlib.decompress(memoryview(data)[i:], -15)
71 | def air(self,location):
72 | url = 'https://devapi.qweather.com/v7/air/now?key=57f8af25a47443a79c41a1d6f771efc3&location={}'.format(location)
73 | res=urequests.get(url)
74 | data=self.decompress(res.content).decode()
75 | dic=ujson.loads(data)
76 | if dic['code'] == '200':
77 | aqi = dic['now']['aqi']
78 | category = dic['now']['category']
79 | return aqi,category
80 | return None
81 | def HF_weather(self,location):
82 | url = 'https://devapi.qweather.com/v7/weather/now?location=101010100&key=57f8af25a47443a79c41a1d6f771efc3&location={}'.format(location)
83 | res=urequests.get(url)
84 | data=self.decompress(res.content).decode()
85 | dic=ujson.loads(data)
86 | if dic['code'] == '200':
87 | humidity = dic['now']['humidity']
88 | return humidity
89 | return None
90 | def poet(self):
91 | url = 'https://api.a632079.me/?max_length=11'
92 | res=urequests.get(url)
93 | dic=ujson.loads(res.text)
94 | print(len(dic['hitokoto']),dic['hitokoto'])
95 | return dic['hitokoto'][:dic['length']]
96 | def jinrishici(self):
97 | url = 'https://v2.jinrishici.com/sentence'
98 | headers = {
99 | 'X-User-Token':'EsnWc/+lex+Lgs7/m0clRHToBy/Eejy7'
100 | }
101 | res=urequests.get(url,headers=headers)
102 | dic=ujson.loads(res.text)
103 | if dic['status'] == 'success':
104 | return dic['data']
105 | if __name__=='__main__':
106 | W = Weather()
107 | W.jinrishici()
108 |
--------------------------------------------------------------------------------
/天气时钟8-27/picture/0@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/0@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/10@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/10@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/11@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/11@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/12@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/12@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/13@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/13@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/14@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/14@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/15@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/15@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/16@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/16@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/17@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/17@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/18@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/18@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/19@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/19@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/1@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/1@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/20@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/20@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/21@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/21@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/22@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/22@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/23@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/23@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/24@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/24@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/25@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/25@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/26@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/26@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/27@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/27@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/28@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/28@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/29@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/29@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/2@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/2@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/30@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/30@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/31@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/31@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/32@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/32@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/33@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/33@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/34@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/34@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/35@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/35@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/36@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/36@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/37@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/37@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/38@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/38@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/3@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/3@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/4@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/4@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/5@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/5@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/6@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/6@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/7@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/7@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/8@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/8@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/picture/9@1x.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/天气时钟8-27/picture/9@1x.dat
--------------------------------------------------------------------------------
/天气时钟8-27/poet.py:
--------------------------------------------------------------------------------
1 | import utime
2 | from package import st7789py as st
3 | from micropython import const
4 | _CLOCK = const(0)
5 | _VERSE = const(1)
6 | class POET():
7 | def __init__(self,tft,weather):
8 | self.tft = tft
9 | self.Weather = weather
10 | self.init_color()
11 | self.mod = 1
12 | def init_color(self):
13 | self.WHITE = st.color565(255, 255, 255)
14 | self.BLACK = st.color565(0, 0, 0)
15 | self.RED = st.color565(255,0, 0)
16 | def show(self):
17 | try:
18 | poet_data = self.Weather.jinrishici()
19 | author = poet_data['origin']['author']
20 | dynasty = poet_data['origin']['dynasty']
21 | title = poet_data['origin']['title']
22 | poet = poet_data['origin']['content']
23 | except:
24 | pass
25 | poem = []
26 | for i in range(len(poet)):
27 | if len(poet[i])>15:
28 | if '。' in poet[i]:
29 | se = poet[i].split('。')
30 | elif '?' in poet[i]:
31 | se = poet[i].split('?')
32 | elif '!' in poet[i]:
33 | se = poet[i].split('!')
34 | else:
35 | se = poet[i].split(',')
36 | for s in range(len(se)-1):
37 | if len(se[s]) > 15:
38 | p = se[s].split(',')
39 | for pm in p:
40 | poem.append(pm)
41 | else:
42 | poem.append(se[s])
43 | else:
44 | poem.append(poet[i])
45 | y = 50
46 | del poet
47 | self.tft.fill(self.WHITE)
48 | offest = (240-24*len(title))//2
49 | self.tft.text(24, title, offest, 0, self.BLACK, self.WHITE)
50 | offest = 24*len(author)
51 | self.tft.text(24, '{}'.format(author), 240-offest-24, 30, self.BLACK, self.WHITE)
52 | for p in poem:
53 | y = y + 20
54 | offest = (240-16*len(p))//2
55 | self.tft.text(16, p, offest, y, self.BLACK, self.WHITE)
56 | while True:
57 | if self.mod != 1:
58 | return
59 | else:
60 | utime.sleep(0.5)
61 | pass
62 | if __name__=='__main__':
63 | from machine import Pin, SPI, RTC
64 | from package import weather
65 | tft = st.ST7789(SPI(2, 10000000), 240, 240, reset=Pin(5), dc=Pin(17), cs=Pin(16), backlight=Pin(4), rotation=0)
66 | p = POET(tft,weather.Weather())
67 | ts = utime.ticks_ms()
68 | p.show()
69 | te = utime.ticks_ms()
70 | tc = te - ts
71 | print(tc)
--------------------------------------------------------------------------------
/微信图片_20220827131439(1)(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/微信图片_20220827131439(1)(1).jpg
--------------------------------------------------------------------------------
/微信图片_20220827131446(1)(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/微信图片_20220827131446(1)(1).jpg
--------------------------------------------------------------------------------
/微信图片_20220827131449(1)(1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LC044/network-clock/9ade0ee47cc7182de7e18f246c651be313c67766/微信图片_20220827131449(1)(1).jpg
--------------------------------------------------------------------------------