From b113d3566c64e087beab51322633aae2319f6355 Mon Sep 17 00:00:00 2001
From: Russ Hughes Contents: Contents: Contents: Contents: Contents: Contents: Flying toasters sprite demo using bitmaps created from spritesheet using
ImageMagick’s convert and imgtobitmap.py utility. See the maketoast script in the utils directory for details. Test for font2bitmap converter for the driver.
See the font2bitmap program in the utils directory. Test for font2bitmap converter for the driver.
See the font2bitmap program in the utils directory. Contents: Contents:
diff --git a/docs/_modules/st7789py.html b/docs/_modules/st7789py.html
index e080424..8558f29 100644
--- a/docs/_modules/st7789py.html
+++ b/docs/_modules/st7789py.html
@@ -13,6 +13,8 @@
+
+
@@ -29,6 +31,7 @@
+
@@ -82,7 +85,7 @@
-
@@ -337,11 +340,11 @@
ST7789 driver class
Args:
- spi (spi): spi object
- width (int): display width
- height (int): display height
+ spi (spi): spi object **Required**
+ width (int): display width **Required**
+ height (int): display height **Required**
reset (pin): reset pin
- dc (pin): dc pin
+ dc (pin): dc pin **Required**
cs (pin): cs pin
backlight(pin): backlight pin
rotation (int): display rotation
@@ -350,7 +353,7 @@
- 2-Inverted Portrait
- 3-Inverted Landscape
"""
- def __init__(self, spi, width, height, reset, dc,
+ def __init__(self, spi, width, height, reset=None, dc=None,
cs=None, backlight=None, rotation=0):
"""
Initialize display.
@@ -360,6 +363,9 @@
"Unsupported display. 320x240, 240x240 and 135x240 are supported."
)
+ if dc is None:
+ raise ValueError("dc pin is required.")
+
self._display_width = self.width = width
self._display_height = self.height = height
self.xstart = 0
diff --git a/docs/_sources/fonts.rst.txt b/docs/_sources/fonts.rst.txt
index 939c607..c334f96 100644
--- a/docs/_sources/fonts.rst.txt
+++ b/docs/_sources/fonts.rst.txt
@@ -55,8 +55,8 @@ Example use:
-8x8 Fonts
----------
+8x8 Rom Fonts
+-------------
.. figure:: _static/vga1_8x8.png
:align: center
@@ -72,8 +72,8 @@ Example use:
|
-8x16 Fonts
-----------
+8x16 Rom Fonts
+--------------
.. figure:: _static/vga1_8x16.png
:align: center
@@ -89,8 +89,8 @@ Example use:
|
-16x16 Fonts
------------
+16x16 Rom Fonts
+---------------
.. figure:: _static/vga1_16x16.png
:align: center
@@ -120,8 +120,8 @@ Example use:
|
-16x32 Fonts
------------
+16x32 Rom Fonts
+---------------
.. figure:: _static/vga1_16x32.png
:align: center
diff --git a/docs/_static/basic.css b/docs/_static/basic.css
index b3bdc00..912859b 100644
--- a/docs/_static/basic.css
+++ b/docs/_static/basic.css
@@ -130,7 +130,7 @@ ul.search li a {
font-weight: bold;
}
-ul.search li div.context {
+ul.search li p.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
@@ -508,6 +508,63 @@ table.hlist td {
vertical-align: top;
}
+/* -- object description styles --------------------------------------------- */
+
+.sig {
+ font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
+}
+
+.sig-name, code.descname {
+ background-color: transparent;
+ font-weight: bold;
+}
+
+.sig-name {
+ font-size: 1.1em;
+}
+
+code.descname {
+ font-size: 1.2em;
+}
+
+.sig-prename, code.descclassname {
+ background-color: transparent;
+}
+
+.optional {
+ font-size: 1.3em;
+}
+
+.sig-paren {
+ font-size: larger;
+}
+
+.sig-param.n {
+ font-style: italic;
+}
+
+/* C++ specific styling */
+
+.sig-inline.c-texpr,
+.sig-inline.cpp-texpr {
+ font-family: unset;
+}
+
+.sig.c .k, .sig.c .kt,
+.sig.cpp .k, .sig.cpp .kt {
+ color: #0033B3;
+}
+
+.sig.c .m,
+.sig.cpp .m {
+ color: #1750EB;
+}
+
+.sig.c .s, .sig.c .sc,
+.sig.cpp .s, .sig.cpp .sc {
+ color: #067D17;
+}
+
/* -- other body styles ----------------------------------------------------- */
@@ -634,14 +691,6 @@ dl.glossary dt {
font-size: 1.1em;
}
-.optional {
- font-size: 1.3em;
-}
-
-.sig-paren {
- font-size: larger;
-}
-
.versionmodified {
font-style: italic;
}
@@ -770,8 +819,12 @@ div.code-block-caption code {
table.highlighttable td.linenos,
span.linenos,
-div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
- user-select: none;
+div.highlight span.gp { /* gp: Generic.Prompt */
+ user-select: none;
+ -webkit-user-select: text; /* Safari fallback only */
+ -webkit-user-select: none; /* Chrome/Safari */
+ -moz-user-select: none; /* Firefox */
+ -ms-user-select: none; /* IE10+ */
}
div.code-block-caption span.caption-number {
@@ -786,16 +839,6 @@ div.literal-block-wrapper {
margin: 1em 0;
}
-code.descname {
- background-color: transparent;
- font-weight: bold;
- font-size: 1.2em;
-}
-
-code.descclassname {
- background-color: transparent;
-}
-
code.xref, a code {
background-color: transparent;
font-weight: bold;
diff --git a/docs/_static/doctools.js b/docs/_static/doctools.js
index 61ac9d2..8cbf1b1 100644
--- a/docs/_static/doctools.js
+++ b/docs/_static/doctools.js
@@ -301,12 +301,14 @@ var Documentation = {
window.location.href = prevHref;
return false;
}
+ break;
case 39: // right
var nextHref = $('link[rel="next"]').prop('href');
if (nextHref) {
window.location.href = nextHref;
return false;
}
+ break;
}
}
});
diff --git a/docs/_static/searchtools.js b/docs/_static/searchtools.js
index 1a90152..e09f926 100644
--- a/docs/_static/searchtools.js
+++ b/docs/_static/searchtools.js
@@ -509,7 +509,7 @@ var Search = {
var excerpt = ((start > 0) ? '...' : '') +
$.trim(text.substr(start, 240)) +
((start + 240 - text.length) ? '...' : '');
- var rv = $('').text(excerpt);
+ var rv = $('').text(excerpt);
$.each(hlwords, function() {
rv = rv.highlightText(this, 'highlighted');
});
diff --git a/docs/_static/underscore-1.12.0.js b/docs/_static/underscore-1.13.1.js
similarity index 94%
rename from docs/_static/underscore-1.12.0.js
rename to docs/_static/underscore-1.13.1.js
index 3af6352..ffd77af 100644
--- a/docs/_static/underscore-1.12.0.js
+++ b/docs/_static/underscore-1.13.1.js
@@ -1,19 +1,19 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define('underscore', factory) :
- (global = global || self, (function () {
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
var current = global._;
var exports = global._ = factory();
exports.noConflict = function () { global._ = current; return exports; };
}()));
}(this, (function () {
- // Underscore.js 1.12.0
+ // Underscore.js 1.13.1
// https://underscorejs.org
- // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ // (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
// Current version.
- var VERSION = '1.12.0';
+ var VERSION = '1.13.1';
// Establish the root object, `window` (`self`) in the browser, `global`
// on the server, or `this` in some virtual machines. We use `self`
@@ -170,7 +170,7 @@
var isArray = nativeIsArray || tagTester('Array');
// Internal function to check whether `key` is an own property name of `obj`.
- function has(obj, key) {
+ function has$1(obj, key) {
return obj != null && hasOwnProperty.call(obj, key);
}
@@ -181,7 +181,7 @@
(function() {
if (!isArguments(arguments)) {
isArguments = function(obj) {
- return has(obj, 'callee');
+ return has$1(obj, 'callee');
};
}
}());
@@ -268,7 +268,7 @@
// Constructor is a special case.
var prop = 'constructor';
- if (has(obj, prop) && !keys.contains(prop)) keys.push(prop);
+ if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop);
while (nonEnumIdx--) {
prop = nonEnumerableProps[nonEnumIdx];
@@ -284,7 +284,7 @@
if (!isObject(obj)) return [];
if (nativeKeys) return nativeKeys(obj);
var keys = [];
- for (var key in obj) if (has(obj, key)) keys.push(key);
+ for (var key in obj) if (has$1(obj, key)) keys.push(key);
// Ahem, IE < 9.
if (hasEnumBug) collectNonEnumProps(obj, keys);
return keys;
@@ -318,24 +318,24 @@
// If Underscore is called as a function, it returns a wrapped object that can
// be used OO-style. This wrapper holds altered versions of all functions added
// through `_.mixin`. Wrapped objects may be chained.
- function _(obj) {
- if (obj instanceof _) return obj;
- if (!(this instanceof _)) return new _(obj);
+ function _$1(obj) {
+ if (obj instanceof _$1) return obj;
+ if (!(this instanceof _$1)) return new _$1(obj);
this._wrapped = obj;
}
- _.VERSION = VERSION;
+ _$1.VERSION = VERSION;
// Extracts the result from a wrapped and chained object.
- _.prototype.value = function() {
+ _$1.prototype.value = function() {
return this._wrapped;
};
// Provide unwrapping proxies for some methods used in engine operations
// such as arithmetic and JSON stringification.
- _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
+ _$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
- _.prototype.toString = function() {
+ _$1.prototype.toString = function() {
return String(this._wrapped);
};
@@ -370,8 +370,8 @@
// Internal recursive comparison function for `_.isEqual`.
function deepEq(a, b, aStack, bStack) {
// Unwrap any wrapped objects.
- if (a instanceof _) a = a._wrapped;
- if (b instanceof _) b = b._wrapped;
+ if (a instanceof _$1) a = a._wrapped;
+ if (b instanceof _$1) b = b._wrapped;
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className !== toString.call(b)) return false;
@@ -463,7 +463,7 @@
while (length--) {
// Deep compare each member
key = _keys[length];
- if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
+ if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
}
}
// Remove the first object from the stack of traversed objects.
@@ -642,15 +642,15 @@
// Normalize a (deep) property `path` to array.
// Like `_.iteratee`, this function can be customized.
- function toPath(path) {
+ function toPath$1(path) {
return isArray(path) ? path : [path];
}
- _.toPath = toPath;
+ _$1.toPath = toPath$1;
// Internal wrapper for `_.toPath` to enable minification.
// Similar to `cb` for `_.iteratee`.
- function toPath$1(path) {
- return _.toPath(path);
+ function toPath(path) {
+ return _$1.toPath(path);
}
// Internal function to obtain a nested property in `obj` along `path`.
@@ -668,19 +668,19 @@
// `undefined`, return `defaultValue` instead.
// The `path` is normalized through `_.toPath`.
function get(object, path, defaultValue) {
- var value = deepGet(object, toPath$1(path));
+ var value = deepGet(object, toPath(path));
return isUndefined(value) ? defaultValue : value;
}
// Shortcut function for checking if an object has a given property directly on
// itself (in other words, not on a prototype). Unlike the internal `has`
// function, this public version can also traverse nested properties.
- function has$1(obj, path) {
- path = toPath$1(path);
+ function has(obj, path) {
+ path = toPath(path);
var length = path.length;
for (var i = 0; i < length; i++) {
var key = path[i];
- if (!has(obj, key)) return false;
+ if (!has$1(obj, key)) return false;
obj = obj[key];
}
return !!length;
@@ -703,7 +703,7 @@
// Creates a function that, when passed an object, will traverse that object’s
// properties down the given `path`, specified as an array of keys or indices.
function property(path) {
- path = toPath$1(path);
+ path = toPath(path);
return function(obj) {
return deepGet(obj, path);
};
@@ -747,12 +747,12 @@
function iteratee(value, context) {
return baseIteratee(value, context, Infinity);
}
- _.iteratee = iteratee;
+ _$1.iteratee = iteratee;
// The function we call internally to generate a callback. It invokes
// `_.iteratee` if overridden, otherwise `baseIteratee`.
function cb(value, context, argCount) {
- if (_.iteratee !== iteratee) return _.iteratee(value, context);
+ if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context);
return baseIteratee(value, context, argCount);
}
@@ -840,7 +840,7 @@
// By default, Underscore uses ERB-style template delimiters. Change the
// following template settings to use alternative delimiters.
- var templateSettings = _.templateSettings = {
+ var templateSettings = _$1.templateSettings = {
evaluate: /<%([\s\S]+?)%>/g,
interpolate: /<%=([\s\S]+?)%>/g,
escape: /<%-([\s\S]+?)%>/g
@@ -868,13 +868,20 @@
return '\\' + escapes[match];
}
+ // In order to prevent third-party code injection through
+ // `_.templateSettings.variable`, we test it against the following regular
+ // expression. It is intentionally a bit more liberal than just matching valid
+ // identifiers, but still prevents possible loopholes through defaults or
+ // destructuring assignment.
+ var bareIdentifier = /^\s*(\w|\$)+\s*$/;
+
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
// NB: `oldSettings` only exists for backwards compatibility.
function template(text, settings, oldSettings) {
if (!settings && oldSettings) settings = oldSettings;
- settings = defaults({}, settings, _.templateSettings);
+ settings = defaults({}, settings, _$1.templateSettings);
// Combine delimiters into one regular expression via alternation.
var matcher = RegExp([
@@ -903,8 +910,17 @@
});
source += "';\n";
- // If a variable is not specified, place data values in local scope.
- if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
+ var argument = settings.variable;
+ if (argument) {
+ // Insure against third-party code injection. (CVE-2021-23358)
+ if (!bareIdentifier.test(argument)) throw new Error(
+ 'variable is not a bare identifier: ' + argument
+ );
+ } else {
+ // If a variable is not specified, place data values in local scope.
+ source = 'with(obj||{}){\n' + source + '}\n';
+ argument = 'obj';
+ }
source = "var __t,__p='',__j=Array.prototype.join," +
"print=function(){__p+=__j.call(arguments,'');};\n" +
@@ -912,18 +928,17 @@
var render;
try {
- render = new Function(settings.variable || 'obj', '_', source);
+ render = new Function(argument, '_', source);
} catch (e) {
e.source = source;
throw e;
}
var template = function(data) {
- return render.call(this, data, _);
+ return render.call(this, data, _$1);
};
// Provide the compiled source as a convenience for precompilation.
- var argument = settings.variable || 'obj';
template.source = 'function(' + argument + '){\n' + source + '}';
return template;
@@ -933,7 +948,7 @@
// is invoked with its parent as context. Returns the value of the final
// child, or `fallback` if any child is undefined.
function result(obj, path, fallback) {
- path = toPath$1(path);
+ path = toPath(path);
var length = path.length;
if (!length) {
return isFunction$1(fallback) ? fallback.call(obj) : fallback;
@@ -959,7 +974,7 @@
// Start chaining a wrapped Underscore object.
function chain(obj) {
- var instance = _(obj);
+ var instance = _$1(obj);
instance._chain = true;
return instance;
}
@@ -993,7 +1008,7 @@
return bound;
});
- partial.placeholder = _;
+ partial.placeholder = _$1;
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally).
@@ -1012,7 +1027,7 @@
var isArrayLike = createSizePropertyCheck(getLength);
// Internal implementation of a recursive `flatten` function.
- function flatten(input, depth, strict, output) {
+ function flatten$1(input, depth, strict, output) {
output = output || [];
if (!depth && depth !== 0) {
depth = Infinity;
@@ -1025,7 +1040,7 @@
if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
// Flatten current level of array or arguments object.
if (depth > 1) {
- flatten(value, depth - 1, strict, output);
+ flatten$1(value, depth - 1, strict, output);
idx = output.length;
} else {
var j = 0, len = value.length;
@@ -1042,7 +1057,7 @@
// are the method names to be bound. Useful for ensuring that all callbacks
// defined on an object belong to it.
var bindAll = restArguments(function(obj, keys) {
- keys = flatten(keys, false, false);
+ keys = flatten$1(keys, false, false);
var index = keys.length;
if (index < 1) throw new Error('bindAll must be passed function names');
while (index--) {
@@ -1057,7 +1072,7 @@
var memoize = function(key) {
var cache = memoize.cache;
var address = '' + (hasher ? hasher.apply(this, arguments) : key);
- if (!has(cache, address)) cache[address] = func.apply(this, arguments);
+ if (!has$1(cache, address)) cache[address] = func.apply(this, arguments);
return cache[address];
};
memoize.cache = {};
@@ -1074,7 +1089,7 @@
// Defers a function, scheduling it to run after the current call stack has
// cleared.
- var defer = partial(delay, _, 1);
+ var defer = partial(delay, _$1, 1);
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
@@ -1420,7 +1435,7 @@
if (isFunction$1(path)) {
func = path;
} else {
- path = toPath$1(path);
+ path = toPath(path);
contextPath = path.slice(0, -1);
path = path[path.length - 1];
}
@@ -1562,7 +1577,7 @@
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
var groupBy = group(function(result, value, key) {
- if (has(result, key)) result[key].push(value); else result[key] = [value];
+ if (has$1(result, key)) result[key].push(value); else result[key] = [value];
});
// Indexes the object's values by a criterion, similar to `_.groupBy`, but for
@@ -1575,7 +1590,7 @@
// either a string attribute to count by, or a function that returns the
// criterion.
var countBy = group(function(result, value, key) {
- if (has(result, key)) result[key]++; else result[key] = 1;
+ if (has$1(result, key)) result[key]++; else result[key] = 1;
});
// Split a collection into two arrays: one whose elements all pass the given
@@ -1618,7 +1633,7 @@
keys = allKeys(obj);
} else {
iteratee = keyInObj;
- keys = flatten(keys, false, false);
+ keys = flatten$1(keys, false, false);
obj = Object(obj);
}
for (var i = 0, length = keys.length; i < length; i++) {
@@ -1636,7 +1651,7 @@
iteratee = negate(iteratee);
if (keys.length > 1) context = keys[1];
} else {
- keys = map(flatten(keys, false, false), String);
+ keys = map(flatten$1(keys, false, false), String);
iteratee = function(value, key) {
return !contains(keys, key);
};
@@ -1681,14 +1696,14 @@
// Flatten out an array, either recursively (by default), or up to `depth`.
// Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
- function flatten$1(array, depth) {
- return flatten(array, depth, false);
+ function flatten(array, depth) {
+ return flatten$1(array, depth, false);
}
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
var difference = restArguments(function(array, rest) {
- rest = flatten(rest, true, true);
+ rest = flatten$1(rest, true, true);
return filter(array, function(value){
return !contains(rest, value);
});
@@ -1734,7 +1749,7 @@
// Produce an array that contains the union: each distinct element from all of
// the passed-in arrays.
var union = restArguments(function(arrays) {
- return uniq(flatten(arrays, true, true));
+ return uniq(flatten$1(arrays, true, true));
});
// Produce an array that contains every item shared between all the
@@ -1821,26 +1836,26 @@
// Helper function to continue chaining intermediate results.
function chainResult(instance, obj) {
- return instance._chain ? _(obj).chain() : obj;
+ return instance._chain ? _$1(obj).chain() : obj;
}
// Add your own custom functions to the Underscore object.
function mixin(obj) {
each(functions(obj), function(name) {
- var func = _[name] = obj[name];
- _.prototype[name] = function() {
+ var func = _$1[name] = obj[name];
+ _$1.prototype[name] = function() {
var args = [this._wrapped];
push.apply(args, arguments);
- return chainResult(this, func.apply(_, args));
+ return chainResult(this, func.apply(_$1, args));
};
});
- return _;
+ return _$1;
}
// Add all mutator `Array` functions to the wrapper.
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
var method = ArrayProto[name];
- _.prototype[name] = function() {
+ _$1.prototype[name] = function() {
var obj = this._wrapped;
if (obj != null) {
method.apply(obj, arguments);
@@ -1855,7 +1870,7 @@
// Add all accessor `Array` functions to the wrapper.
each(['concat', 'join', 'slice'], function(name) {
var method = ArrayProto[name];
- _.prototype[name] = function() {
+ _$1.prototype[name] = function() {
var obj = this._wrapped;
if (obj != null) obj = method.apply(obj, arguments);
return chainResult(this, obj);
@@ -1909,12 +1924,12 @@
clone: clone,
tap: tap,
get: get,
- has: has$1,
+ has: has,
mapObject: mapObject,
identity: identity,
constant: constant,
noop: noop,
- toPath: toPath,
+ toPath: toPath$1,
property: property,
propertyOf: propertyOf,
matcher: matcher,
@@ -1997,7 +2012,7 @@
tail: rest,
drop: rest,
compact: compact,
- flatten: flatten$1,
+ flatten: flatten,
without: without,
uniq: uniq,
unique: uniq,
@@ -2011,17 +2026,17 @@
range: range,
chunk: chunk,
mixin: mixin,
- 'default': _
+ 'default': _$1
};
// Default Export
// Add all of the Underscore functions to the wrapper object.
- var _$1 = mixin(allExports);
+ var _ = mixin(allExports);
// Legacy Node.js API.
- _$1._ = _$1;
+ _._ = _;
- return _$1;
+ return _;
})));
-//# sourceMappingURL=underscore.js.map
+//# sourceMappingURL=underscore-umd.js.map
diff --git a/docs/_static/underscore.js b/docs/_static/underscore.js
index 166240e..cf177d4 100644
--- a/docs/_static/underscore.js
+++ b/docs/_static/underscore.js
@@ -1,6 +1,6 @@
-!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n=n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){
-// Underscore.js 1.12.0
+!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n="undefined"!=typeof globalThis?globalThis:n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){
+// Underscore.js 1.13.1
// https://underscorejs.org
-// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+// (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
-var n="1.12.0",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,g=isFinite,d=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u
@@ -181,1039 +184,545 @@ locations. See
ttgo_lines.py¶
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
"""
-lines.py
-
- Draws lines and rectangles in random colors at random locations on the
- display.
-
-"""
-import random
-from machine import Pin, SoftSPI
-import st7789py as st7789
-
-
-def main():
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=0)
-
- tft.fill(st7789.BLACK)
-
- while True:
- tft.line(
- random.randint(0, tft.width),
- random.randint(0, tft.height),
- random.randint(0, tft.width),
- random.randint(0, tft.height),
- st7789.color565(
- random.getrandbits(8),
- random.getrandbits(8),
- random.getrandbits(8)
- )
- )
-
- width = random.randint(0, tft.width // 2)
- height = random.randint(0, tft.height // 2)
- col = random.randint(0, tft.width - width)
- row = random.randint(0, tft.height - height)
- tft.fill_rect(
- col,
- row,
- width,
- height,
- st7789.color565(
- random.getrandbits(8),
- random.getrandbits(8),
- random.getrandbits(8)
- )
- )
-
-
-main()
+
1"""
+ 2lines.py
+ 3
+ 4 Draws lines and rectangles in random colors at random locations on the
+ 5 display.
+ 6
+ 7"""
+ 8import random
+ 9from machine import Pin, SoftSPI
+10import st7789py as st7789
+11
+12
+13def main():
+14 spi = SoftSPI(
+15 baudrate=20000000,
+16 polarity=1,
+17 phase=0,
+18 sck=Pin(18),
+19 mosi=Pin(19),
+20 miso=Pin(13))
+21
+22 tft = st7789.ST7789(
+23 spi,
+24 135,
+25 240,
+26 reset=Pin(23, Pin.OUT),
+27 cs=Pin(5, Pin.OUT),
+28 dc=Pin(16, Pin.OUT),
+29 backlight=Pin(4, Pin.OUT),
+30 rotation=0)
+31
+32 tft.fill(st7789.BLACK)
+33
+34 while True:
+35 tft.line(
+36 random.randint(0, tft.width),
+37 random.randint(0, tft.height),
+38 random.randint(0, tft.width),
+39 random.randint(0, tft.height),
+40 st7789.color565(
+41 random.getrandbits(8),
+42 random.getrandbits(8),
+43 random.getrandbits(8)
+44 )
+45 )
+46
+47 width = random.randint(0, tft.width // 2)
+48 height = random.randint(0, tft.height // 2)
+49 col = random.randint(0, tft.width - width)
+50 row = random.randint(0, tft.height - height)
+51 tft.fill_rect(
+52 col,
+53 row,
+54 width,
+55 height,
+56 st7789.color565(
+57 random.getrandbits(8),
+58 random.getrandbits(8),
+59 random.getrandbits(8)
+60 )
+61 )
+62
+63
+64main()
ttgo_hello.py¶
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
"""
-ttgo_hello.py
-
- Writes "Hello!" in random colors at random locations on a
- LILYGO® TTGO T-Display.
-
- https://www.youtube.com/watch?v=atBa0BYPAAc
-
-"""
-import random
-from machine import Pin, SoftSPI
-import st7789py as st7789
-
-# Choose a font
-
-# from romfonts import vga1_8x8 as font
-# from romfonts import vga2_8x8 as font
-# from romfonts import vga1_8x16 as font
-# from romfonts import vga2_8x16 as font
-# from romfonts import vga1_16x16 as font
-# from romfonts import vga1_bold_16x16 as font
-# from romfonts import vga2_16x16 as font
-# from romfonts import vga2_bold_16x16 as font
-# from romfonts import vga1_16x32 as font
-# from romfonts import vga1_bold_16x32 as font
-# from romfonts import vga2_16x32 as font
-from romfonts import vga2_bold_16x32 as font
-
-
-def main():
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=0)
-
- while True:
- for rotation in range(4):
- tft.rotation(rotation)
- tft.fill(0)
- col_max = tft.width - font.WIDTH*6
- row_max = tft.height - font.HEIGHT
-
- for _ in range(100):
- tft.text(
- font,
- "Hello!",
- random.randint(0, col_max),
- random.randint(0, row_max),
- st7789.color565(
- random.getrandbits(8),
- random.getrandbits(8),
- random.getrandbits(8)),
- st7789.color565(
- random.getrandbits(8),
- random.getrandbits(8),
- random.getrandbits(8))
- )
-
-
-main()
+
1"""
+ 2ttgo_hello.py
+ 3
+ 4 Writes "Hello!" in random colors at random locations on a
+ 5 LILYGO® TTGO T-Display.
+ 6
+ 7 https://www.youtube.com/watch?v=atBa0BYPAAc
+ 8
+ 9"""
+10import random
+11from machine import Pin, SoftSPI
+12import st7789py as st7789
+13
+14# Choose a font
+15
+16# from romfonts import vga1_8x8 as font
+17# from romfonts import vga2_8x8 as font
+18# from romfonts import vga1_8x16 as font
+19# from romfonts import vga2_8x16 as font
+20# from romfonts import vga1_16x16 as font
+21# from romfonts import vga1_bold_16x16 as font
+22# from romfonts import vga2_16x16 as font
+23# from romfonts import vga2_bold_16x16 as font
+24# from romfonts import vga1_16x32 as font
+25# from romfonts import vga1_bold_16x32 as font
+26# from romfonts import vga2_16x32 as font
+27from romfonts import vga2_bold_16x32 as font
+28
+29
+30def main():
+31 spi = SoftSPI(
+32 baudrate=20000000,
+33 polarity=1,
+34 phase=0,
+35 sck=Pin(18),
+36 mosi=Pin(19),
+37 miso=Pin(13))
+38
+39 tft = st7789.ST7789(
+40 spi,
+41 135,
+42 240,
+43 reset=Pin(23, Pin.OUT),
+44 cs=Pin(5, Pin.OUT),
+45 dc=Pin(16, Pin.OUT),
+46 backlight=Pin(4, Pin.OUT),
+47 rotation=0)
+48
+49 while True:
+50 for rotation in range(4):
+51 tft.rotation(rotation)
+52 tft.fill(0)
+53 col_max = tft.width - font.WIDTH*6
+54 row_max = tft.height - font.HEIGHT
+55
+56 for _ in range(100):
+57 tft.text(
+58 font,
+59 "Hello!",
+60 random.randint(0, col_max),
+61 random.randint(0, row_max),
+62 st7789.color565(
+63 random.getrandbits(8),
+64 random.getrandbits(8),
+65 random.getrandbits(8)),
+66 st7789.color565(
+67 random.getrandbits(8),
+68 random.getrandbits(8),
+69 random.getrandbits(8))
+70 )
+71
+72
+73main()
ttgo_fonts.py¶
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
"""
-ttgo_fonts.py
-
- Pages through all characters of four fonts on the LILYGO® TTGO T-Display.
-
- https://www.youtube.com/watch?v=2cnAhEucPD4
-
-"""
-import utime
-from machine import Pin, SoftSPI
-import st7789py as st7789
-
-# Choose fonts
-
-# from romfonts import vga1_8x8 as font
-from romfonts import vga2_8x8 as font1
-# from romfonts import vga1_8x16 as font
-from romfonts import vga2_8x16 as font2
-# from romfonts import vga1_16x16 as font
-# from romfonts import vga1_bold_16x16 as font
-# from romfonts import vga2_16x16 as font
-from romfonts import vga2_bold_16x16 as font3
-# from romfonts import vga1_16x32 as font
-# from romfonts import vga1_bold_16x32 as font
-# from romfonts import vga2_16x32 as font
-from romfonts import vga2_bold_16x32 as font4
-
-
-def main():
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=0)
-
- tft.vscrdef(40, 240, 40)
-
- while True:
- for font in (font1, font2, font3, font4):
- tft.fill(st7789.BLUE)
- line = 0
- col = 0
-
- for char in range(font.FIRST, font.LAST):
- tft.text(font, chr(char), col, line, st7789.WHITE, st7789.BLUE)
- col += font.WIDTH
- if col > tft.width - font.WIDTH:
- col = 0
- line += font.HEIGHT
-
- if line > tft.height-font.HEIGHT:
- utime.sleep(3)
- tft.fill(st7789.BLUE)
- line = 0
- col = 0
-
- utime.sleep(3)
-
-
-main()
+
1"""
+ 2ttgo_fonts.py
+ 3
+ 4 Pages through all characters of four fonts on the LILYGO® TTGO T-Display.
+ 5
+ 6 https://www.youtube.com/watch?v=2cnAhEucPD4
+ 7
+ 8"""
+ 9import utime
+10from machine import Pin, SoftSPI
+11import st7789py as st7789
+12
+13# Choose fonts
+14
+15# from romfonts import vga1_8x8 as font
+16from romfonts import vga2_8x8 as font1
+17# from romfonts import vga1_8x16 as font
+18from romfonts import vga2_8x16 as font2
+19# from romfonts import vga1_16x16 as font
+20# from romfonts import vga1_bold_16x16 as font
+21# from romfonts import vga2_16x16 as font
+22from romfonts import vga2_bold_16x16 as font3
+23# from romfonts import vga1_16x32 as font
+24# from romfonts import vga1_bold_16x32 as font
+25# from romfonts import vga2_16x32 as font
+26from romfonts import vga2_bold_16x32 as font4
+27
+28
+29def main():
+30 spi = SoftSPI(
+31 baudrate=20000000,
+32 polarity=1,
+33 phase=0,
+34 sck=Pin(18),
+35 mosi=Pin(19),
+36 miso=Pin(13))
+37
+38 tft = st7789.ST7789(
+39 spi,
+40 135,
+41 240,
+42 reset=Pin(23, Pin.OUT),
+43 cs=Pin(5, Pin.OUT),
+44 dc=Pin(16, Pin.OUT),
+45 backlight=Pin(4, Pin.OUT),
+46 rotation=0)
+47
+48 tft.vscrdef(40, 240, 40)
+49
+50 while True:
+51 for font in (font1, font2, font3, font4):
+52 tft.fill(st7789.BLUE)
+53 line = 0
+54 col = 0
+55
+56 for char in range(font.FIRST, font.LAST):
+57 tft.text(font, chr(char), col, line, st7789.WHITE, st7789.BLUE)
+58 col += font.WIDTH
+59 if col > tft.width - font.WIDTH:
+60 col = 0
+61 line += font.HEIGHT
+62
+63 if line > tft.height-font.HEIGHT:
+64 utime.sleep(3)
+65 tft.fill(st7789.BLUE)
+66 line = 0
+67 col = 0
+68
+69 utime.sleep(3)
+70
+71
+72main()
ttgo_scroll.py¶
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
"""
-ttgo_fonts.py
-
- Smoothly scrolls all font characters up the screen on the LILYGO® TTGO
- T-Display. Only works with fonts with heights that are even multiples of
- the screen height, (i.e. 8 or 16 pixels high)
-
-"""
-import utime
-import random
-from machine import Pin, SoftSPI
-import st7789py as st7789
-
-# choose a font
-
-# from romfonts import vga1_8x8 as font
-# from romfonts import vga2_8x8 as font
-# from romfonts import vga1_8x16 as font
-# from romfonts import vga2_8x16 as font
-# from romfonts import vga1_16x16 as font
-# from romfonts import vga1_bold_16x16 as font
-# from romfonts import vga2_16x16 as font
-from romfonts import vga2_bold_16x16 as font
-
-
-def main():
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=0)
-
- last_line = tft.height - font.HEIGHT
- tfa = 40
- tfb = 40
- tft.vscrdef(tfa, 240, tfb)
-
- tft.fill(st7789.BLUE)
- scroll = 0
- character = 0
- while True:
- tft.fill_rect(0, scroll, tft.width, 1, st7789.BLUE)
-
- if scroll % font.HEIGHT == 0:
- tft.text(
- font,
- '\\x{:02x}= {:s} '.format(character, chr(character)),
- 0,
- (scroll + last_line) % tft.height,
- st7789.WHITE,
- st7789.BLUE)
-
- character = character + 1 if character < 256 else 0
-
- tft.vscsad(scroll + tfa)
- scroll += 1
-
- if scroll == tft.height:
- scroll = 0
-
- utime.sleep(0.01)
-
-
-main()
+
1"""
+ 2ttgo_fonts.py
+ 3
+ 4 Smoothly scrolls all font characters up the screen on the LILYGO® TTGO
+ 5 T-Display. Only works with fonts with heights that are even multiples of
+ 6 the screen height, (i.e. 8 or 16 pixels high)
+ 7
+ 8"""
+ 9import utime
+10import random
+11from machine import Pin, SoftSPI
+12import st7789py as st7789
+13
+14# choose a font
+15
+16# from romfonts import vga1_8x8 as font
+17# from romfonts import vga2_8x8 as font
+18# from romfonts import vga1_8x16 as font
+19# from romfonts import vga2_8x16 as font
+20# from romfonts import vga1_16x16 as font
+21# from romfonts import vga1_bold_16x16 as font
+22# from romfonts import vga2_16x16 as font
+23from romfonts import vga2_bold_16x16 as font
+24
+25
+26def main():
+27 spi = SoftSPI(
+28 baudrate=20000000,
+29 polarity=1,
+30 phase=0,
+31 sck=Pin(18),
+32 mosi=Pin(19),
+33 miso=Pin(13))
+34
+35 tft = st7789.ST7789(
+36 spi,
+37 135,
+38 240,
+39 reset=Pin(23, Pin.OUT),
+40 cs=Pin(5, Pin.OUT),
+41 dc=Pin(16, Pin.OUT),
+42 backlight=Pin(4, Pin.OUT),
+43 rotation=0)
+44
+45 last_line = tft.height - font.HEIGHT
+46 tfa = 40
+47 tfb = 40
+48 tft.vscrdef(tfa, 240, tfb)
+49
+50 tft.fill(st7789.BLUE)
+51 scroll = 0
+52 character = 0
+53 while True:
+54 tft.fill_rect(0, scroll, tft.width, 1, st7789.BLUE)
+55
+56 if scroll % font.HEIGHT == 0:
+57 tft.text(
+58 font,
+59 '\\x{:02x}= {:s} '.format(character, chr(character)),
+60 0,
+61 (scroll + last_line) % tft.height,
+62 st7789.WHITE,
+63 st7789.BLUE)
+64
+65 character = character + 1 if character < 256 else 0
+66
+67 tft.vscsad(scroll + tfa)
+68 scroll += 1
+69
+70 if scroll == tft.height:
+71 scroll = 0
+72
+73 utime.sleep(0.01)
+74
+75
+76main()
toasters.py¶
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
"""
-toasters.py
-
- An example using bitmap to draw sprites on the display.
-
- Spritesheet from CircuitPython_Flying_Toasters
- https://learn.adafruit.com/circuitpython-sprite-animation-pendant-mario-clouds-flying-toasters
-
-"""
-
-import random
-from machine import Pin, SoftSPI
-import st7789py as st7789
-import t1, t2, t3, t4, t5
-
-TOASTERS = [t1, t2, t3, t4]
-TOAST = [t5]
-
-
-class toast():
- '''
- toast class to keep track of a sprites locaton and step
- '''
- def __init__(self, sprites, x, y):
- self.sprites = sprites
- self.steps = len(sprites)
- self.x = x
- self.y = y
- self.step = random.randint(0, self.steps-1)
- self.speed = random.randint(2, 5)
-
- def move(self):
- if self.x <= 0:
- self.speed = random.randint(2, 5)
- self.x = 135 - 64
-
- self.step += 1
- self.step %= self.steps
- self.x -= self.speed
-
-
-def main():
- """
- Initialize the display and draw flying toasters and toast
- """
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=0)
-
- tft.fill(st7789.BLACK)
- # create toast spites in random positions
- sprites = [
- toast(TOASTERS, 135-64, 0),
- toast(TOAST, 135-64*2, 80),
- toast(TOASTERS, 135-64*4, 160)
- ]
-
- # move and draw sprites
- while True:
- for man in sprites:
- bitmap = man.sprites[man.step]
- tft.fill_rect(
- man.x+bitmap.WIDTH-man.speed,
- man.y,
- man.speed,
- bitmap.HEIGHT,
- st7789.BLACK)
-
- man.move()
-
- if man.x > 0:
- tft.bitmap(bitmap, man.x, man.y)
- else:
- tft.fill_rect(
- 0,
- man.y,
- bitmap.WIDTH,
- bitmap.HEIGHT,
- st7789.BLACK)
-
-
-main()
+
1"""
+ 2toasters.py
+ 3
+ 4 An example using bitmap to draw sprites on the display.
+ 5
+ 6 Spritesheet from CircuitPython_Flying_Toasters
+ 7 https://learn.adafruit.com/circuitpython-sprite-animation-pendant-mario-clouds-flying-toasters
+ 8
+ 9"""
+10
+11import random
+12from machine import Pin, SoftSPI
+13import st7789py as st7789
+14import t1, t2, t3, t4, t5
+15
+16TOASTERS = [t1, t2, t3, t4]
+17TOAST = [t5]
+18
+19
+20class toast():
+21 '''
+22 toast class to keep track of a sprites locaton and step
+23 '''
+24 def __init__(self, sprites, x, y):
+25 self.sprites = sprites
+26 self.steps = len(sprites)
+27 self.x = x
+28 self.y = y
+29 self.step = random.randint(0, self.steps-1)
+30 self.speed = random.randint(2, 5)
+31
+32 def move(self):
+33 if self.x <= 0:
+34 self.speed = random.randint(2, 5)
+35 self.x = 135 - 64
+36
+37 self.step += 1
+38 self.step %= self.steps
+39 self.x -= self.speed
+40
+41
+42def main():
+43 """
+44 Initialize the display and draw flying toasters and toast
+45 """
+46 spi = SoftSPI(
+47 baudrate=20000000,
+48 polarity=1,
+49 phase=0,
+50 sck=Pin(18),
+51 mosi=Pin(19),
+52 miso=Pin(13))
+53
+54 tft = st7789.ST7789(
+55 spi,
+56 135,
+57 240,
+58 reset=Pin(23, Pin.OUT),
+59 cs=Pin(5, Pin.OUT),
+60 dc=Pin(16, Pin.OUT),
+61 backlight=Pin(4, Pin.OUT),
+62 rotation=0)
+63
+64 tft.fill(st7789.BLACK)
+65 # create toast spites in random positions
+66 sprites = [
+67 toast(TOASTERS, 135-64, 0),
+68 toast(TOAST, 135-64*2, 80),
+69 toast(TOASTERS, 135-64*4, 160)
+70 ]
+71
+72 # move and draw sprites
+73 while True:
+74 for man in sprites:
+75 bitmap = man.sprites[man.step]
+76 tft.fill_rect(
+77 man.x+bitmap.WIDTH-man.speed,
+78 man.y,
+79 man.speed,
+80 bitmap.HEIGHT,
+81 st7789.BLACK)
+82
+83 man.move()
+84
+85 if man.x > 0:
+86 tft.bitmap(bitmap, man.x, man.y)
+87 else:
+88 tft.fill_rect(
+89 0,
+90 man.y,
+91 bitmap.WIDTH,
+92 bitmap.HEIGHT,
+93 st7789.BLACK)
+94
+95
+96main()
chango.py¶
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
"""
-chango.py
-
- Test for font2bitmap converter for the driver.
- See the font2bitmap program in the utils directory.
-"""
-
-from machine import Pin, SoftSPI
-import st7789py as st7789
-import gc
-from truetype import chango_16 as font_16
-from truetype import chango_32 as font_32
-from truetype import chango_64 as font_64
-
-gc.collect()
-
-
-def main():
- # enable display and clear screen
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=1)
-
- tft.fill(st7789.BLACK)
-
- row = 0
- tft.write(font_16, "abcdefghijklmnopqrst", 0, row, st7789.RED)
- row += font_16.HEIGHT
-
- tft.write(font_32, "abcdefghij", 0, row, st7789.GREEN)
- row += font_32.HEIGHT
-
- tft.write(font_64, "abcd", 0, row, st7789.BLUE)
- row += font_64.HEIGHT
-
-
-main()
+
1"""
+ 2chango.py
+ 3
+ 4 Test for font2bitmap converter for the driver.
+ 5 See the font2bitmap program in the utils directory.
+ 6"""
+ 7
+ 8from machine import Pin, SoftSPI
+ 9import st7789py as st7789
+10import gc
+11from truetype import chango_16 as font_16
+12from truetype import chango_32 as font_32
+13from truetype import chango_64 as font_64
+14
+15gc.collect()
+16
+17
+18def main():
+19 # enable display and clear screen
+20 spi = SoftSPI(
+21 baudrate=20000000,
+22 polarity=1,
+23 phase=0,
+24 sck=Pin(18),
+25 mosi=Pin(19),
+26 miso=Pin(13))
+27
+28 tft = st7789.ST7789(
+29 spi,
+30 135,
+31 240,
+32 reset=Pin(23, Pin.OUT),
+33 cs=Pin(5, Pin.OUT),
+34 dc=Pin(16, Pin.OUT),
+35 backlight=Pin(4, Pin.OUT),
+36 rotation=1)
+37
+38 tft.fill(st7789.BLACK)
+39
+40 row = 0
+41 tft.write(font_16, "abcdefghijklmnopqrst", 0, row, st7789.RED)
+42 row += font_16.HEIGHT
+43
+44 tft.write(font_32, "abcdefghij", 0, row, st7789.GREEN)
+45 row += font_32.HEIGHT
+46
+47 tft.write(font_64, "abcd", 0, row, st7789.BLUE)
+48 row += font_64.HEIGHT
+49
+50
+51main()
noto_fonts.py¶
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
"""
-noto_fonts Writes the names of three Noto fonts centered on the display
- using the font. The fonts were converted from True Type fonts using
- the font2bitmap utility.
-"""
-
-from machine import SoftSPI, Pin
-import st7789py as st7789
-
-from truetype import NotoSans_32 as noto_sans
-from truetype import NotoSerif_32 as noto_serif
-from truetype import NotoSansMono_32 as noto_mono
-
-
-def main():
-
- def center(font, string, row, color=st7789.WHITE):
- screen = tft.width # get screen width
- width = tft.write_width(font, string) # get the width of the string
- if width and width < screen: # if the string < display
- col = tft.width // 2 - width // 2 # find the column to center
- else: # otherwise
- col = 0 # left justify
-
- tft.write(font, string, col, row, color) # and write the string
-
- try:
- spi = SoftSPI(
- baudrate=20000000,
- polarity=1,
- phase=0,
- sck=Pin(18),
- mosi=Pin(19),
- miso=Pin(13))
-
- tft = st7789.ST7789(
- spi,
- 135,
- 240,
- reset=Pin(23, Pin.OUT),
- cs=Pin(5, Pin.OUT),
- dc=Pin(16, Pin.OUT),
- backlight=Pin(4, Pin.OUT),
- rotation=1)
-
- # enable display and clear screen
- tft.fill(st7789.BLACK)
-
- row = 16
-
- # center the name of the first font, using the font
- center(noto_sans, "NotoSans", row, st7789.RED)
- row += noto_sans.HEIGHT
-
- # center the name of the second font, using the font
- center(noto_serif, "NotoSerif", row, st7789.GREEN)
- row += noto_serif.HEIGHT
-
- # center the name of the third font, using the font
- center(noto_mono, "NotoSansMono", row, st7789.BLUE)
- row += noto_mono.HEIGHT
-
- finally:
- # shutdown spi
- if 'spi' in locals():
- spi.deinit()
-
-
-main()
+
1"""
+ 2noto_fonts Writes the names of three Noto fonts centered on the display
+ 3 using the font. The fonts were converted from True Type fonts using
+ 4 the font2bitmap utility.
+ 5"""
+ 6
+ 7from machine import SoftSPI, Pin
+ 8import st7789py as st7789
+ 9
+10from truetype import NotoSans_32 as noto_sans
+11from truetype import NotoSerif_32 as noto_serif
+12from truetype import NotoSansMono_32 as noto_mono
+13
+14
+15def main():
+16
+17 def center(font, string, row, color=st7789.WHITE):
+18 screen = tft.width # get screen width
+19 width = tft.write_width(font, string) # get the width of the string
+20 if width and width < screen: # if the string < display
+21 col = tft.width // 2 - width // 2 # find the column to center
+22 else: # otherwise
+23 col = 0 # left justify
+24
+25 tft.write(font, string, col, row, color) # and write the string
+26
+27 try:
+28 spi = SoftSPI(
+29 baudrate=20000000,
+30 polarity=1,
+31 phase=0,
+32 sck=Pin(18),
+33 mosi=Pin(19),
+34 miso=Pin(13))
+35
+36 tft = st7789.ST7789(
+37 spi,
+38 135,
+39 240,
+40 reset=Pin(23, Pin.OUT),
+41 cs=Pin(5, Pin.OUT),
+42 dc=Pin(16, Pin.OUT),
+43 backlight=Pin(4, Pin.OUT),
+44 rotation=1)
+45
+46 # enable display and clear screen
+47 tft.fill(st7789.BLACK)
+48
+49 row = 16
+50
+51 # center the name of the first font, using the font
+52 center(noto_sans, "NotoSans", row, st7789.RED)
+53 row += noto_sans.HEIGHT
+54
+55 # center the name of the second font, using the font
+56 center(noto_serif, "NotoSerif", row, st7789.GREEN)
+57 row += noto_serif.HEIGHT
+58
+59 # center the name of the third font, using the font
+60 center(noto_mono, "NotoSansMono", row, st7789.BLUE)
+61 row += noto_mono.HEIGHT
+62
+63 finally:
+64 # shutdown spi
+65 if 'spi' in locals():
+66 spi.deinit()
+67
+68
+69main()
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 | """converted from vga_8x8.bin """
-
-# font width
-WIDTH = 8
-
-# font height
-HEIGHT = 8
-
-# first character in front
-FIRST = 0x20
-
-# last character in font
-LAST = 0x7f
-
-# bitmap of each character from FIRST to LAST
-_FONT =\
-b'\x00\x00\x00\x00\x00\x00\x00\x00'\
-b'\x18\x3c\x3c\x18\x18\x00\x18\x00'\
-b'\x66\x66\x24\x00\x00\x00\x00\x00'\
-
-... many more lines of data...
-
-b'\x70\x18\x18\x0e\x18\x18\x70\x00'\
-b'\x76\xdc\x00\x00\x00\x00\x00\x00'\
-b'\x00\x10\x38\x6c\xc6\xc6\xfe\x00'\
-
-FONT = memoryview(_FONT)
+ |
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 | # -*- coding: utf-8 -*-
-# Converted from Chango-Regular.ttf using:
-# ./font2bitmap.py Chango-Regular.ttf 16 -c 0x20-0x7f
-
-# Maps the order of the character data
-MAP = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
-
-# Number of color bits per pixel, currently only 1 is used but could be
-# increased to support antialiased or smoothed fonts in the future.
-BPP = 1
-
-# Font height
-HEIGHT = 17
-
-# Font max width
-MAX_WIDTH = 24
-
-# one byte per character table of widths in the same order as the MAP string
-_WIDTHS = \
- b'\x06\x08\x0a\x0e\x0d\x18\x10\x06\x08\x08\x0a\x0d\x06\x08\x06\x0b'\
-
- ... more lines of data...
-
- b'\x0d\x0d\x0b\x0a\x0b\x0e\x0c\x12\x0d\x0c\x0b\x09\x06\x09\x0e\x0b'
-
-# OFFSET_WIDTH bytes per character in the same order as the MAP string
-# to the start of each character in bits.
-OFFSET_WIDTH = 2
-_OFFSETS = \
- b'\x00\x00\x00\x66\x00\xee\x01\x98\x02\x86\x03\x63\x04\xfb\x06\x0b'\
-
- ... more lines of data...
-
- b'\x49\x94\x4a\x71\x4b\x3d\x4b\xf8\x4c\x91\x4c\xf7\x4d\x90\x4e\x7e'
-
-# character bitmaps per character in the same order as the MAP string.
-# Note: character data may not start on byte boundaries
-_BITMAPS =\
- b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x61'\
-
- ... many more lines of data...
-
- b'\x3d\xe3\xfc\x00\x00\x00\x00\x00'
-
-WIDTHS = memoryview(_WIDTHS)
-OFFSETS = memoryview(_OFFSETS)
-BITMAPS = memoryview(_BITMAPS)
+ |
vga1_8x8.py: 128 Character 8x8 Font¶
@@ -378,8 +309,8 @@ the negative glyph.left fix from peterhinch’s font conversion programvga1_8x16.py: 128 Character 8x16 Font¶
@@ -396,7 +327,7 @@ the negative glyph.left fix from peterhinch’s font conversion programvga1_16x16.py: 128 Character 16x16 Thin Font¶
@@ -426,8 +357,8 @@ the negative glyph.left fix from peterhinch’s font conversion programvga1_16x32.py: 128 Character 16x32 Thin Font¶
diff --git a/docs/genindex.html b/docs/genindex.html index c736913..868647b 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -13,6 +13,8 @@ + + @@ -29,6 +31,7 @@ + @@ -82,7 +85,7 @@ -Contents:
+Contents:
Contents:
+Contents:
Contents:
+Contents:
Contents:
+Contents:
Contents:
+Contents:
Contents:
+Contents:
Drawing converted bitmaps
st7789py.
color565
(red, green=0, blue=0)[source]¶Convert red, green and blue values (0-255) into a 16-bit 565 encoding.
st7789py.
ST7789
(spi, width, height, reset, dc, cs=None, backlight=None, rotation=0)[source]¶ST7789 driver class
spi (spi) – spi object
width (int) – display width
height (int) – display height
spi (spi) – spi object Required
width (int) – display width Required
height (int) – display height Required
reset (pin) – reset pin
dc (pin) – dc pin
dc (pin) – dc pin Required
cs (pin) – cs pin
backlight (pin) – backlight pin
rotation (int) – display rotation @@ -238,20 +241,20 @@ BIOS text mode fonts.
sleep_mode
(value)[source]¶Enable or disable display sleep mode.
inversion_mode
(value)[source]¶Enable or disable display inversion mode.
rotation
(rotation)[source]¶Set display rotation.
vline
(x, y, length, color)[source]¶Draw vertical line at the given location and color.
hline
(x, y, length, color)[source]¶Draw horizontal line at the given location and color.
pixel
(x, y, color)[source]¶Draw a pixel at the given location and color.
blit_buffer
(buffer, x, y, width, height)[source]¶Copy buffer to display at the given location.
rect
(x, y, w, h, color)[source]¶Draw a rectangle at the given location, size and color.
fill_rect
(x, y, width, height, color)[source]¶Draw a rectangle at the given location, size and filled with color.
fill
(color)[source]¶Fill the entire FrameBuffer with the specified color.
line
(x0, y0, x1, y1, color)[source]¶Draw a single pixel wide line starting at x0, y0 and ending at x1, y1.
vscrdef
(tfa, vsa, bfa)[source]¶Set Vertical Scrolling Definition.
To scroll a 135x240 display these values should be 40, 240, 40. There are 40 lines above the display that are not shown followed by @@ -441,8 +444,8 @@ changing the TFA, VSA and BFA values.
vscsad
(vssa)[source]¶Set Vertical Scroll Start Address of RAM.
Defines which line in the Frame Memory will be written as the first line after the last line of the Top Fixed Area on the display
@@ -460,8 +463,8 @@ utime.sleep(0.01)text
(font, text, x0, y0, color=micropython.const, background=micropython.const)[source]¶Draw text on display in specified font and colors. 8 and 16 bit wide fonts are supported.
bitmap
(bitmap, x, y, index=0)[source]¶Draw a bitmap on display at the specified column and row
write
(font, string, x, y, fg=micropython.const, bg=micropython.const)[source]¶Write a string using a converted true-type font on the display starting at the specified column and row
write_width
(font, string)[source]¶Returns the width in pixels of the string if it was written with the specified font
*Z
zeO6mEXK&HaRiuvz%c12NwD9^^LHcVTa|TV16{x!vbRn-lgd~_4zI89o#iy|lj$wkV
z000R$Nkl
z1^JCMHWoX>KcE5H!$Z2=P~lsuVHl1N508goN#QMas>7DwWDox*n&i@|Ua1i@wO>=@
zhVGH;Nl0$KK84(QGo$tq-gn$Xvx{Km1