From ddf5f7631e8878cdffc398afc0874d5a7c10ead0 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 4 Mar 2022 15:42:47 +0000 Subject: [PATCH] Badger2040: Use book.txt for ebook example --- micropython/examples/badger2040/ebook.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/micropython/examples/badger2040/ebook.py b/micropython/examples/badger2040/ebook.py index 6a2db0d2..0ebdf407 100644 --- a/micropython/examples/badger2040/ebook.py +++ b/micropython/examples/badger2040/ebook.py @@ -3,12 +3,19 @@ import machine import time import gc + +# **** Put the name of your text file here ***** +text_file = "book.txt" # File must be on the MicroPython device + + try: - open("witw.txt", "r") + open(text_file, "r") except OSError: try: + # If the specified file doesn't exist, + # pre-populate with Wind In The Willows import witw - open("witw.txt", "wb").write(witw.data()) + open(text_file, "wb").write(witw.data()) del witw except ImportError: pass @@ -16,10 +23,6 @@ except OSError: gc.collect() - -# **** Put the name of your text file here ***** -text_file = "witw.txt" # File must be on the MicroPython device - # Global Constants WIDTH = badger2040.WIDTH HEIGHT = badger2040.HEIGHT