itCommit code. - btcticker - eInk Bitcoin price ticker Err parazyd.org 70 hgit clone https://git.parazyd.org/btcticker URL:https://git.parazyd.org/btcticker parazyd.org 70 1Log /git/btcticker/log.gph parazyd.org 70 1Files /git/btcticker/files.gph parazyd.org 70 1Refs /git/btcticker/refs.gph parazyd.org 70 1README /git/btcticker/file/README.md.gph parazyd.org 70 1LICENSE /git/btcticker/file/LICENSE.gph parazyd.org 70 i--- Err parazyd.org 70 1commit 82552df78bc40de87e59608e561194521fa85d59 /git/btcticker/commit/82552df78bc40de87e59608e561194521fa85d59.gph parazyd.org 70 hAuthor: parazyd URL:mailto:parazyd@dyne.org parazyd.org 70 iDate: Fri, 19 Feb 2021 16:12:08 +0100 Err parazyd.org 70 i Err parazyd.org 70 iCommit code. Err parazyd.org 70 i Err parazyd.org 70 iDiffstat: Err parazyd.org 70 i A LICENSE | 22 ++++++++++++++++++++++ Err parazyd.org 70 i A README.md | 4 ++++ Err parazyd.org 70 i A fonts/PixelSplitter-Bold.ttf | 0 Err parazyd.org 70 i A fonts/googlefonts/LICENSE.txt | 202 +++++++++++++++++++++++++++++++ Err parazyd.org 70 i A fonts/googlefonts/Roboto-Light.ttf | 0 Err parazyd.org 70 i A fonts/googlefonts/Roboto-Medium.ttf | 0 Err parazyd.org 70 i A images/ATH.bmp | 0 Err parazyd.org 70 i A images/currency/bitcoin.bmp | 0 Err parazyd.org 70 i A ticker.py | 169 +++++++++++++++++++++++++++++++ Err parazyd.org 70 i Err parazyd.org 70 i9 files changed, 397 insertions(+), 0 deletions(-) Err parazyd.org 70 i--- Err parazyd.org 70 1diff --git a/LICENSE b/LICENSE /git/btcticker/file/LICENSE.gph parazyd.org 70 it@@ -0,0 +1,22 @@ Err parazyd.org 70 i+MIT License Err parazyd.org 70 i+ Err parazyd.org 70 i+Copyright (c) 2021 parazyd Err parazyd.org 70 i+Copyright (c) 2020 llvll Err parazyd.org 70 i+ Err parazyd.org 70 i+Permission is hereby granted, free of charge, to any person obtaining a copy Err parazyd.org 70 i+of this software and associated documentation files (the "Software"), to deal Err parazyd.org 70 i+in the Software without restriction, including without limitation the rights Err parazyd.org 70 i+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell Err parazyd.org 70 i+copies of the Software, and to permit persons to whom the Software is Err parazyd.org 70 i+furnished to do so, subject to the following conditions: Err parazyd.org 70 i+ Err parazyd.org 70 i+The above copyright notice and this permission notice shall be included in all Err parazyd.org 70 i+copies or substantial portions of the Software. Err parazyd.org 70 i+ Err parazyd.org 70 i+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Err parazyd.org 70 i+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, Err parazyd.org 70 i+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE Err parazyd.org 70 i+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER Err parazyd.org 70 i+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, Err parazyd.org 70 i+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE Err parazyd.org 70 i+SOFTWARE. Err parazyd.org 70 1diff --git a/README.md b/README.md /git/btcticker/file/README.md.gph parazyd.org 70 it@@ -0,0 +1,4 @@ Err parazyd.org 70 i+eInk Bitcoin price ticker Err parazyd.org 70 i+========================= Err parazyd.org 70 i+ Err parazyd.org 70 i+Adapted from https://github.com/llvllch/btcticker Err parazyd.org 70 1diff --git a/fonts/PixelSplitter-Bold.ttf b/fonts/PixelSplitter-Bold.ttf /git/btcticker/file/fonts/PixelSplitter-Bold.ttf.gph parazyd.org 70 iBinary files differ. Err parazyd.org 70 1diff --git a/fonts/googlefonts/LICENSE.txt b/fonts/googlefonts/LICENSE.txt /git/btcticker/file/fonts/googlefonts/LICENSE.txt.gph parazyd.org 70 it@@ -0,0 +1,202 @@ Err parazyd.org 70 i+ Err parazyd.org 70 i+ Apache License Err parazyd.org 70 i+ Version 2.0, January 2004 Err parazyd.org 70 i+ http://www.apache.org/licenses/ Err parazyd.org 70 i+ Err parazyd.org 70 i+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION Err parazyd.org 70 i+ Err parazyd.org 70 i+ 1. Definitions. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "License" shall mean the terms and conditions for use, reproduction, Err parazyd.org 70 i+ and distribution as defined by Sections 1 through 9 of this document. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Licensor" shall mean the copyright owner or entity authorized by Err parazyd.org 70 i+ the copyright owner that is granting the License. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Legal Entity" shall mean the union of the acting entity and all Err parazyd.org 70 i+ other entities that control, are controlled by, or are under common Err parazyd.org 70 i+ control with that entity. For the purposes of this definition, Err parazyd.org 70 i+ "control" means (i) the power, direct or indirect, to cause the Err parazyd.org 70 i+ direction or management of such entity, whether by contract or Err parazyd.org 70 i+ otherwise, or (ii) ownership of fifty percent (50%) or more of the Err parazyd.org 70 i+ outstanding shares, or (iii) beneficial ownership of such entity. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "You" (or "Your") shall mean an individual or Legal Entity Err parazyd.org 70 i+ exercising permissions granted by this License. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Source" form shall mean the preferred form for making modifications, Err parazyd.org 70 i+ including but not limited to software source code, documentation Err parazyd.org 70 i+ source, and configuration files. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Object" form shall mean any form resulting from mechanical Err parazyd.org 70 i+ transformation or translation of a Source form, including but Err parazyd.org 70 i+ not limited to compiled object code, generated documentation, Err parazyd.org 70 i+ and conversions to other media types. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Work" shall mean the work of authorship, whether in Source or Err parazyd.org 70 i+ Object form, made available under the License, as indicated by a Err parazyd.org 70 i+ copyright notice that is included in or attached to the work Err parazyd.org 70 i+ (an example is provided in the Appendix below). Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Derivative Works" shall mean any work, whether in Source or Object Err parazyd.org 70 i+ form, that is based on (or derived from) the Work and for which the Err parazyd.org 70 i+ editorial revisions, annotations, elaborations, or other modifications Err parazyd.org 70 i+ represent, as a whole, an original work of authorship. For the purposes Err parazyd.org 70 i+ of this License, Derivative Works shall not include works that remain Err parazyd.org 70 i+ separable from, or merely link (or bind by name) to the interfaces of, Err parazyd.org 70 i+ the Work and Derivative Works thereof. Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Contribution" shall mean any work of authorship, including Err parazyd.org 70 i+ the original version of the Work and any modifications or additions Err parazyd.org 70 i+ to that Work or Derivative Works thereof, that is intentionally Err parazyd.org 70 i+ submitted to Licensor for inclusion in the Work by the copyright owner Err parazyd.org 70 i+ or by an individual or Legal Entity authorized to submit on behalf of Err parazyd.org 70 i+ the copyright owner. For the purposes of this definition, "submitted" Err parazyd.org 70 i+ means any form of electronic, verbal, or written communication sent Err parazyd.org 70 i+ to the Licensor or its representatives, including but not limited to Err parazyd.org 70 i+ communication on electronic mailing lists, source code control systems, Err parazyd.org 70 i+ and issue tracking systems that are managed by, or on behalf of, the Err parazyd.org 70 i+ Licensor for the purpose of discussing and improving the Work, but Err parazyd.org 70 i+ excluding communication that is conspicuously marked or otherwise Err parazyd.org 70 i+ designated in writing by the copyright owner as "Not a Contribution." Err parazyd.org 70 i+ Err parazyd.org 70 i+ "Contributor" shall mean Licensor and any individual or Legal Entity Err parazyd.org 70 i+ on behalf of whom a Contribution has been received by Licensor and Err parazyd.org 70 i+ subsequently incorporated within the Work. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 2. Grant of Copyright License. Subject to the terms and conditions of Err parazyd.org 70 i+ this License, each Contributor hereby grants to You a perpetual, Err parazyd.org 70 i+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable Err parazyd.org 70 i+ copyright license to reproduce, prepare Derivative Works of, Err parazyd.org 70 i+ publicly display, publicly perform, sublicense, and distribute the Err parazyd.org 70 i+ Work and such Derivative Works in Source or Object form. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 3. Grant of Patent License. Subject to the terms and conditions of Err parazyd.org 70 i+ this License, each Contributor hereby grants to You a perpetual, Err parazyd.org 70 i+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable Err parazyd.org 70 i+ (except as stated in this section) patent license to make, have made, Err parazyd.org 70 i+ use, offer to sell, sell, import, and otherwise transfer the Work, Err parazyd.org 70 i+ where such license applies only to those patent claims licensable Err parazyd.org 70 i+ by such Contributor that are necessarily infringed by their Err parazyd.org 70 i+ Contribution(s) alone or by combination of their Contribution(s) Err parazyd.org 70 i+ with the Work to which such Contribution(s) was submitted. If You Err parazyd.org 70 i+ institute patent litigation against any entity (including a Err parazyd.org 70 i+ cross-claim or counterclaim in a lawsuit) alleging that the Work Err parazyd.org 70 i+ or a Contribution incorporated within the Work constitutes direct Err parazyd.org 70 i+ or contributory patent infringement, then any patent licenses Err parazyd.org 70 i+ granted to You under this License for that Work shall terminate Err parazyd.org 70 i+ as of the date such litigation is filed. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 4. Redistribution. You may reproduce and distribute copies of the Err parazyd.org 70 i+ Work or Derivative Works thereof in any medium, with or without Err parazyd.org 70 i+ modifications, and in Source or Object form, provided that You Err parazyd.org 70 i+ meet the following conditions: Err parazyd.org 70 i+ Err parazyd.org 70 i+ (a) You must give any other recipients of the Work or Err parazyd.org 70 i+ Derivative Works a copy of this License; and Err parazyd.org 70 i+ Err parazyd.org 70 i+ (b) You must cause any modified files to carry prominent notices Err parazyd.org 70 i+ stating that You changed the files; and Err parazyd.org 70 i+ Err parazyd.org 70 i+ (c) You must retain, in the Source form of any Derivative Works Err parazyd.org 70 i+ that You distribute, all copyright, patent, trademark, and Err parazyd.org 70 i+ attribution notices from the Source form of the Work, Err parazyd.org 70 i+ excluding those notices that do not pertain to any part of Err parazyd.org 70 i+ the Derivative Works; and Err parazyd.org 70 i+ Err parazyd.org 70 i+ (d) If the Work includes a "NOTICE" text file as part of its Err parazyd.org 70 i+ distribution, then any Derivative Works that You distribute must Err parazyd.org 70 i+ include a readable copy of the attribution notices contained Err parazyd.org 70 i+ within such NOTICE file, excluding those notices that do not Err parazyd.org 70 i+ pertain to any part of the Derivative Works, in at least one Err parazyd.org 70 i+ of the following places: within a NOTICE text file distributed Err parazyd.org 70 i+ as part of the Derivative Works; within the Source form or Err parazyd.org 70 i+ documentation, if provided along with the Derivative Works; or, Err parazyd.org 70 i+ within a display generated by the Derivative Works, if and Err parazyd.org 70 i+ wherever such third-party notices normally appear. The contents Err parazyd.org 70 i+ of the NOTICE file are for informational purposes only and Err parazyd.org 70 i+ do not modify the License. You may add Your own attribution Err parazyd.org 70 i+ notices within Derivative Works that You distribute, alongside Err parazyd.org 70 i+ or as an addendum to the NOTICE text from the Work, provided Err parazyd.org 70 i+ that such additional attribution notices cannot be construed Err parazyd.org 70 i+ as modifying the License. Err parazyd.org 70 i+ Err parazyd.org 70 i+ You may add Your own copyright statement to Your modifications and Err parazyd.org 70 i+ may provide additional or different license terms and conditions Err parazyd.org 70 i+ for use, reproduction, or distribution of Your modifications, or Err parazyd.org 70 i+ for any such Derivative Works as a whole, provided Your use, Err parazyd.org 70 i+ reproduction, and distribution of the Work otherwise complies with Err parazyd.org 70 i+ the conditions stated in this License. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 5. Submission of Contributions. Unless You explicitly state otherwise, Err parazyd.org 70 i+ any Contribution intentionally submitted for inclusion in the Work Err parazyd.org 70 i+ by You to the Licensor shall be under the terms and conditions of Err parazyd.org 70 i+ this License, without any additional terms or conditions. Err parazyd.org 70 i+ Notwithstanding the above, nothing herein shall supersede or modify Err parazyd.org 70 i+ the terms of any separate license agreement you may have executed Err parazyd.org 70 i+ with Licensor regarding such Contributions. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 6. Trademarks. This License does not grant permission to use the trade Err parazyd.org 70 i+ names, trademarks, service marks, or product names of the Licensor, Err parazyd.org 70 i+ except as required for reasonable and customary use in describing the Err parazyd.org 70 i+ origin of the Work and reproducing the content of the NOTICE file. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 7. Disclaimer of Warranty. Unless required by applicable law or Err parazyd.org 70 i+ agreed to in writing, Licensor provides the Work (and each Err parazyd.org 70 i+ Contributor provides its Contributions) on an "AS IS" BASIS, Err parazyd.org 70 i+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or Err parazyd.org 70 i+ implied, including, without limitation, any warranties or conditions Err parazyd.org 70 i+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A Err parazyd.org 70 i+ PARTICULAR PURPOSE. You are solely responsible for determining the Err parazyd.org 70 i+ appropriateness of using or redistributing the Work and assume any Err parazyd.org 70 i+ risks associated with Your exercise of permissions under this License. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 8. Limitation of Liability. In no event and under no legal theory, Err parazyd.org 70 i+ whether in tort (including negligence), contract, or otherwise, Err parazyd.org 70 i+ unless required by applicable law (such as deliberate and grossly Err parazyd.org 70 i+ negligent acts) or agreed to in writing, shall any Contributor be Err parazyd.org 70 i+ liable to You for damages, including any direct, indirect, special, Err parazyd.org 70 i+ incidental, or consequential damages of any character arising as a Err parazyd.org 70 i+ result of this License or out of the use or inability to use the Err parazyd.org 70 i+ Work (including but not limited to damages for loss of goodwill, Err parazyd.org 70 i+ work stoppage, computer failure or malfunction, or any and all Err parazyd.org 70 i+ other commercial damages or losses), even if such Contributor Err parazyd.org 70 i+ has been advised of the possibility of such damages. Err parazyd.org 70 i+ Err parazyd.org 70 i+ 9. Accepting Warranty or Additional Liability. While redistributing Err parazyd.org 70 i+ the Work or Derivative Works thereof, You may choose to offer, Err parazyd.org 70 i+ and charge a fee for, acceptance of support, warranty, indemnity, Err parazyd.org 70 i+ or other liability obligations and/or rights consistent with this Err parazyd.org 70 i+ License. However, in accepting such obligations, You may act only Err parazyd.org 70 i+ on Your own behalf and on Your sole responsibility, not on behalf Err parazyd.org 70 i+ of any other Contributor, and only if You agree to indemnify, Err parazyd.org 70 i+ defend, and hold each Contributor harmless for any liability Err parazyd.org 70 i+ incurred by, or claims asserted against, such Contributor by reason Err parazyd.org 70 i+ of your accepting any such warranty or additional liability. Err parazyd.org 70 i+ Err parazyd.org 70 i+ END OF TERMS AND CONDITIONS Err parazyd.org 70 i+ Err parazyd.org 70 i+ APPENDIX: How to apply the Apache License to your work. Err parazyd.org 70 i+ Err parazyd.org 70 i+ To apply the Apache License to your work, attach the following Err parazyd.org 70 i+ boilerplate notice, with the fields enclosed by brackets "[]" Err parazyd.org 70 i+ replaced with your own identifying information. (Don't include Err parazyd.org 70 i+ the brackets!) The text should be enclosed in the appropriate Err parazyd.org 70 i+ comment syntax for the file format. We also recommend that a Err parazyd.org 70 i+ file or class name and description of purpose be included on the Err parazyd.org 70 i+ same "printed page" as the copyright notice for easier Err parazyd.org 70 i+ identification within third-party archives. Err parazyd.org 70 i+ Err parazyd.org 70 i+ Copyright [yyyy] [name of copyright owner] Err parazyd.org 70 i+ Err parazyd.org 70 i+ Licensed under the Apache License, Version 2.0 (the "License"); Err parazyd.org 70 i+ you may not use this file except in compliance with the License. Err parazyd.org 70 i+ You may obtain a copy of the License at Err parazyd.org 70 i+ Err parazyd.org 70 i+ http://www.apache.org/licenses/LICENSE-2.0 Err parazyd.org 70 i+ Err parazyd.org 70 i+ Unless required by applicable law or agreed to in writing, software Err parazyd.org 70 i+ distributed under the License is distributed on an "AS IS" BASIS, Err parazyd.org 70 i+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Err parazyd.org 70 i+ See the License for the specific language governing permissions and Err parazyd.org 70 i+ limitations under the License. Err parazyd.org 70 1diff --git a/fonts/googlefonts/Roboto-Light.ttf b/fonts/googlefonts/Roboto-Light.ttf /git/btcticker/file/fonts/googlefonts/Roboto-Light.ttf.gph parazyd.org 70 iBinary files differ. Err parazyd.org 70 1diff --git a/fonts/googlefonts/Roboto-Medium.ttf b/fonts/googlefonts/Roboto-Medium.ttf /git/btcticker/file/fonts/googlefonts/Roboto-Medium.ttf.gph parazyd.org 70 iBinary files differ. Err parazyd.org 70 1diff --git a/images/ATH.bmp b/images/ATH.bmp /git/btcticker/file/images/ATH.bmp.gph parazyd.org 70 iBinary files differ. Err parazyd.org 70 1diff --git a/images/currency/bitcoin.bmp b/images/currency/bitcoin.bmp /git/btcticker/file/images/currency/bitcoin.bmp.gph parazyd.org 70 iBinary files differ. Err parazyd.org 70 1diff --git a/ticker.py b/ticker.py /git/btcticker/file/ticker.py.gph parazyd.org 70 it@@ -0,0 +1,169 @@ Err parazyd.org 70 i+#!/usr/bin/env python3 Err parazyd.org 70 i+# Copyright (c) 2021 parazyd Err parazyd.org 70 i+# Copyright (c) 2020 llvll Err parazyd.org 70 i+# Err parazyd.org 70 i+# Permission is hereby granted, free of charge, to any person obtaining a copy Err parazyd.org 70 i+# of this software and associated documentation files (the "Software"), to deal Err parazyd.org 70 i+# in the Software without restriction, including without limitation the rights Err parazyd.org 70 i+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell Err parazyd.org 70 i+# copies of the Software, and to permit persons to whom the Software is Err parazyd.org 70 i+# furnished to do so, subject to the following conditions: Err parazyd.org 70 i+# Err parazyd.org 70 i+# The above copyright notice and this permission notice shall be included in Err parazyd.org 70 i+# all copies or substantial portions of the Software. Err parazyd.org 70 i+# Err parazyd.org 70 i+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Err parazyd.org 70 i+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, Err parazyd.org 70 i+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE Err parazyd.org 70 i+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER Err parazyd.org 70 i+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, Err parazyd.org 70 i+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE Err parazyd.org 70 i+# SOFTWARE. Err parazyd.org 70 i+""" Err parazyd.org 70 i+Program to create a bitcoin ticker bitmap and show it on a waveshare 2in13_V2 Err parazyd.org 70 i+eink screen (https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT) Err parazyd.org 70 i+""" Err parazyd.org 70 i+ Err parazyd.org 70 i+import sys Err parazyd.org 70 i+from os.path import join, dirname, realpath Err parazyd.org 70 i+from time import time, strftime, sleep Err parazyd.org 70 i+import matplotlib as mpl Err parazyd.org 70 i+import matplotlib.pyplot as plt Err parazyd.org 70 i+import numpy as np Err parazyd.org 70 i+from PIL import Image, ImageFont, ImageDraw Err parazyd.org 70 i+import requests Err parazyd.org 70 i+from waveshare_epd import epd2in13_V2 Err parazyd.org 70 i+mpl.use('Agg') Err parazyd.org 70 i+ Err parazyd.org 70 i+picdir = join(dirname(realpath(__file__)), 'images') Err parazyd.org 70 i+fontdir = join(dirname(realpath(__file__)), 'fonts') Err parazyd.org 70 i+font = ImageFont.truetype(join(fontdir, 'googlefonts/Roboto-Medium.ttf'), 40) Err parazyd.org 70 i+font_date = ImageFont.truetype(join(fontdir, 'PixelSplitter-Bold.ttf'), 11) Err parazyd.org 70 i+ Err parazyd.org 70 i+API = 'https://api.coingecko.com/api/v3/coins' Err parazyd.org 70 i+ Err parazyd.org 70 i+ Err parazyd.org 70 i+def get_data(other): Err parazyd.org 70 i+ """ Grab data from API """ Err parazyd.org 70 i+ days_ago = 7 Err parazyd.org 70 i+ endtime = int(time()) Err parazyd.org 70 i+ starttime = endtime - 60*60*24*days_ago Err parazyd.org 70 i+ Err parazyd.org 70 i+ geckourl = '%s/markets?vs_currency=%s&ids=%s' % (API, 'usd', 'bitcoin') Err parazyd.org 70 i+ liveprice = requests.get(geckourl).json()[0] Err parazyd.org 70 i+ pricenow = float(liveprice['current_price']) Err parazyd.org 70 i+ alltimehigh = float(liveprice['ath']) Err parazyd.org 70 i+ other['volume'] = float(liveprice['total_volume']) Err parazyd.org 70 i+ Err parazyd.org 70 i+ url_hist = '%s/%s/market_chart/range?vs_currency=%s&from=%s&to=%s' % ( Err parazyd.org 70 i+ API, 'bitcoin', 'usd', str(starttime), str(endtime)) Err parazyd.org 70 i+ Err parazyd.org 70 i+ timeseriesarray = requests.get(url_hist).json()['prices'] Err parazyd.org 70 i+ timeseriesstack = [] Err parazyd.org 70 i+ length = len(timeseriesarray) Err parazyd.org 70 i+ i = 0 Err parazyd.org 70 i+ while i < length: Err parazyd.org 70 i+ timeseriesstack.append(float(timeseriesarray[i][1])) Err parazyd.org 70 i+ i += 1 Err parazyd.org 70 i+ Err parazyd.org 70 i+ timeseriesstack.append(pricenow) Err parazyd.org 70 i+ if pricenow > alltimehigh: Err parazyd.org 70 i+ other['ATH'] = True Err parazyd.org 70 i+ else: Err parazyd.org 70 i+ other['ATH'] = False Err parazyd.org 70 i+ return timeseriesstack Err parazyd.org 70 i+ Err parazyd.org 70 i+ Err parazyd.org 70 i+def make_spark(pricestack): Err parazyd.org 70 i+ """ Make a historical plot """ Err parazyd.org 70 i+ _x = pricestack - np.mean(pricestack) Err parazyd.org 70 i+ fig, _ax = plt.subplots(1, 1, figsize=(10, 3)) Err parazyd.org 70 i+ plt.plot(_x, color='k', linewidth=6) Err parazyd.org 70 i+ plt.plot(len(_x)-1, _x[-1], color='r', marker='o') Err parazyd.org 70 i+ Err parazyd.org 70 i+ for _, i in _ax.spines.items(): Err parazyd.org 70 i+ i.set_visible(False) Err parazyd.org 70 i+ _ax.set_xticks = ([]) Err parazyd.org 70 i+ _ax.set_yticks = ([]) Err parazyd.org 70 i+ _ax.axhline(c='k', linewidth=4, linestyle=(0, (5, 2, 1, 2))) Err parazyd.org 70 i+ Err parazyd.org 70 i+ plt.savefig(join(picdir, 'spark.png'), dpi=17) Err parazyd.org 70 i+ imgspk = Image.open(join(picdir, 'spark.png')) Err parazyd.org 70 i+ file_out = join(picdir, 'spark.bmp') Err parazyd.org 70 i+ imgspk.save(file_out) Err parazyd.org 70 i+ plt.clf() Err parazyd.org 70 i+ _ax.cla() Err parazyd.org 70 i+ plt.close(fig) Err parazyd.org 70 i+ Err parazyd.org 70 i+ Err parazyd.org 70 i+def update_display(pricestack, other, epd): Err parazyd.org 70 i+ """ Create an image from the data and send it to the display """ Err parazyd.org 70 i+ days_ago = 7 Err parazyd.org 70 i+ pricenow = pricestack[-1] Err parazyd.org 70 i+ currencythumbnail = 'currency/bitcoin.bmp' Err parazyd.org 70 i+ tokenfilename = join(picdir, currencythumbnail) Err parazyd.org 70 i+ sparkbitmap = Image.open(join(picdir, 'spark.bmp')) Err parazyd.org 70 i+ athbitmap = Image.open(join(picdir, 'ATH.bmp')) Err parazyd.org 70 i+ tokenimage = Image.open(tokenfilename) Err parazyd.org 70 i+ Err parazyd.org 70 i+ pricechange = str('%+d' % round( Err parazyd.org 70 i+ (pricestack[-1]-pricestack[0]) / pricestack[-1]*100, 2))+'%' Err parazyd.org 70 i+ if pricenow > 1000: Err parazyd.org 70 i+ pricenowstring = format(int(pricenow), ',') Err parazyd.org 70 i+ else: Err parazyd.org 70 i+ pricenowstring = str(float('%.5g' % pricenow)) Err parazyd.org 70 i+ Err parazyd.org 70 i+ image = Image.new('L', (250, 122), 255) Err parazyd.org 70 i+ draw = ImageDraw.Draw(image) Err parazyd.org 70 i+ if other['ATH'] is True: Err parazyd.org 70 i+ image.paste(athbitmap, (15, 30)) Err parazyd.org 70 i+ else: Err parazyd.org 70 i+ image.paste(tokenimage, (0, 15)) Err parazyd.org 70 i+ Err parazyd.org 70 i+ image.paste(sparkbitmap, (80, 15)) Err parazyd.org 70 i+ draw.text((130, 66), str(days_ago) + 'day : ' + pricechange, Err parazyd.org 70 i+ font=font_date, fill=0) Err parazyd.org 70 i+ draw.text((96, 73), '$'+pricenowstring, font=font, fill=0) Err parazyd.org 70 i+ Err parazyd.org 70 i+ draw.text((95, 5), str(strftime('%H:%M %a %d %b %Y')), font=font_date, Err parazyd.org 70 i+ fill=0) Err parazyd.org 70 i+ Err parazyd.org 70 i+ # image.save('pic.bmp') Err parazyd.org 70 i+ epd.display(epd.getbuffer(image)) Err parazyd.org 70 i+ Err parazyd.org 70 i+ Err parazyd.org 70 i+def main(): Err parazyd.org 70 i+ """ main routine """ Err parazyd.org 70 i+ def fullupdate(epd): Err parazyd.org 70 i+ other = {} Err parazyd.org 70 i+ pricestack = get_data(other) Err parazyd.org 70 i+ make_spark(pricestack) Err parazyd.org 70 i+ update_display(pricestack, other, epd) Err parazyd.org 70 i+ lastgrab = time() Err parazyd.org 70 i+ return lastgrab Err parazyd.org 70 i+ Err parazyd.org 70 i+ try: Err parazyd.org 70 i+ data_pulled = False Err parazyd.org 70 i+ lastcoinfetch = time() Err parazyd.org 70 i+ Err parazyd.org 70 i+ epd = epd2in13_V2.EPD() Err parazyd.org 70 i+ epd.init(epd.FULL_UPDATE) Err parazyd.org 70 i+ epd.Clear(0xFF) Err parazyd.org 70 i+ # epd = None Err parazyd.org 70 i+ Err parazyd.org 70 i+ while True: Err parazyd.org 70 i+ if (time() - lastcoinfetch > float(120)) or data_pulled is False: Err parazyd.org 70 i+ lastcoinfetch = fullupdate(epd) Err parazyd.org 70 i+ data_pulled = True Err parazyd.org 70 i+ sleep(5) Err parazyd.org 70 i+ except KeyboardInterrupt: Err parazyd.org 70 i+ epd.sleep() Err parazyd.org 70 i+ epd.Dev_exit() Err parazyd.org 70 i+ epd2in13_V2.epdconfig.module_exit() Err parazyd.org 70 i+ return 1 Err parazyd.org 70 i+ Err parazyd.org 70 i+ return 1 Err parazyd.org 70 i+ Err parazyd.org 70 i+ Err parazyd.org 70 i+if __name__ == '__main__': Err parazyd.org 70 i+ sys.exit(main()) Err parazyd.org 70 .