diff --git a/.gitignore b/.gitignore index 49eae98..79c1355 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .vscode .idea __pycache__ -sphinx *~ *.pyc *.o diff --git a/docs/.buildinfo b/docs/.buildinfo index 26e2102..c734010 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 78614e3006fc5cc56d2562d24941cf0c +config: db5947919316628e816682c8ca6bb96d tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_modules/index.html b/docs/_modules/index.html index a22a7e1..701b3bf 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -13,6 +13,8 @@ + + @@ -29,6 +31,7 @@ + @@ -82,7 +85,7 @@ -

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 @@ -

Contents:

+

Contents:

@@ -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=0&&t<=m}}function $(n){return function(r){return null==r?void 0:r[n]}}var G=$("byteLength"),H=J(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:K(!1),Y=$("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e":">",'"':""","'":"'","`":"`"},Kn=Ln(Cn),Jn=Ln(_n(Cn)),$n=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=0;function Zn(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var nr=j((function(n,r){var t=nr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a1)er(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var cr=nr(fr,2);function lr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o0?0:u-1;o>=0&&o0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),C))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a=3;return r(n,Fn(t,u,4),e,o)}}var wr=_r(1),Ar=_r(-1);function xr(n,r,t){var e=[];return r=qn(r,t),mr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Sr(n,r,t){r=qn(r,t);for(var e=!tr(n)&&nn(n),u=(e||n).length,o=0;o=0}var Er=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),jr(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Br(n,r){return jr(n,Rn(r))}function Nr(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ao&&(o=e);else r=qn(r,t),mr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Ir(n,r,t){if(null==r||t)return tr(n)||(n=jn(n)),n[Wn(n.length-1)];var e=tr(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i1&&(e=Fn(e,r[1])),r=an(n)):(e=Pr,r=er(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u1&&(t=r[1])):(r=jr(er(r,!1,!1),String),e=function(n,t){return!Mr(r,t)}),qr(n,e,t)}));function Wr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function zr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:Wr(n,n.length-r)}function Lr(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=er(r,!0,!0),xr(n,(function(n){return!Mr(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);ir?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o=function(r,t){e=null,t&&(u=n.apply(r,t))},i=j((function(i){if(e&&clearTimeout(e),t){var a=!e;e=setTimeout(o,r),a&&(u=n.apply(this,i))}else e=or(o,r,this,i);return u}));return i.cancel=function(){clearTimeout(e),e=null},i},wrap:function(n,r){return nr(r,n)},negate:ar,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:fr,once:cr,findKey:lr,findIndex:pr,findLastIndex:vr,sortedIndex:hr,indexOf:gr,lastIndexOf:dr,find:br,detect:br,findWhere:function(n,r){return br(n,Dn(r))},each:mr,forEach:mr,map:jr,collect:jr,reduce:wr,foldl:wr,inject:wr,reduceRight:Ar,foldr:Ar,filter:xr,select:xr,reject:function(n,r,t){return xr(n,ar(qn(r)),t)},every:Sr,all:Sr,some:Or,any:Or,contains:Mr,includes:Mr,include:Mr,invoke:Er,pluck:Br,where:function(n,r){return xr(n,Dn(r))},max:Nr,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ae||void 0===t)return 1;if(t=0&&t<=m}}function J(n){return function(r){return null==r?void 0:r[n]}}var G=J("byteLength"),H=K(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:C(!1),Y=J("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e":">",'"':""","'":"'","`":"`"},Cn=Ln($n),Kn=Ln(_n($n)),Jn=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=/^\s*(\w|\$)+\s*$/;var Zn=0;function nr(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var rr=j((function(n,r){var t=rr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a1)ur(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var lr=rr(cr,2);function sr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o0?0:u-1;o>=0&&o0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),$))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a=3;return r(n,Fn(t,u,4),e,o)}}var Ar=wr(1),xr=wr(-1);function Sr(n,r,t){var e=[];return r=qn(r,t),jr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Or(n,r,t){r=qn(r,t);for(var e=!er(n)&&nn(n),u=(e||n).length,o=0;o=0}var Br=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),_r(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Nr(n,r){return _r(n,Rn(r))}function Ir(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=er(n)?n:jn(n)).length;ao&&(o=e);else r=qn(r,t),jr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Tr(n,r,t){if(null==r||t)return er(n)||(n=jn(n)),n[Wn(n.length-1)];var e=er(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i1&&(e=Fn(e,r[1])),r=an(n)):(e=qr,r=ur(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u1&&(t=r[1])):(r=_r(ur(r,!1,!1),String),e=function(n,t){return!Er(r,t)}),Ur(n,e,t)}));function zr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function Lr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:zr(n,n.length-r)}function $r(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=ur(r,!0,!0),Sr(n,(function(n){return!Er(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);ir?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o,i,a,f=function(){var c=zn()-u;r>c?e=setTimeout(f,r-c):(e=null,t||(i=n.apply(a,o)),e||(o=a=null))},c=j((function(c){return a=this,o=c,u=zn(),e||(e=setTimeout(f,r),t&&(i=n.apply(a,o))),i}));return c.cancel=function(){clearTimeout(e),e=o=a=null},c},wrap:function(n,r){return rr(r,n)},negate:fr,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:cr,once:lr,findKey:sr,findIndex:vr,findLastIndex:hr,sortedIndex:yr,indexOf:gr,lastIndexOf:br,find:mr,detect:mr,findWhere:function(n,r){return mr(n,Dn(r))},each:jr,forEach:jr,map:_r,collect:_r,reduce:Ar,foldl:Ar,inject:Ar,reduceRight:xr,foldr:xr,filter:Sr,select:Sr,reject:function(n,r,t){return Sr(n,fr(qn(r)),t)},every:Or,all:Or,some:Mr,any:Mr,contains:Er,includes:Er,include:Er,invoke:Br,pluck:Nr,where:function(n,r){return Sr(n,Dn(r))},max:Ir,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=er(n)?n:jn(n)).length;ae||void 0===t)return 1;if(t + + @@ -29,6 +31,7 @@ + @@ -84,7 +87,7 @@ -

Contents:

+

Contents:

@@ -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

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.

-
 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

Test for font2bitmap converter for the driver. See the font2bitmap program in the utils directory.

-
 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

Test for font2bitmap converter for the driver. See the font2bitmap program in the utils directory.

-
 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()
 
-
+
diff --git a/docs/fonts.html b/docs/fonts.html index 3575f16..19c5fba 100644 --- a/docs/fonts.html +++ b/docs/fonts.html @@ -13,6 +13,8 @@ + + @@ -29,6 +31,7 @@ + @@ -83,7 +86,7 @@ -

Contents:

+

Contents:

@@ -193,61 +196,35 @@ character is 256 pixels or less. They are written using the write method.

Sample converted romfont font module.
-
 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"""converted from vga_8x8.bin """
+ 2
+ 3# font width
+ 4WIDTH = 8
+ 5
+ 6# font height
+ 7HEIGHT = 8
+ 8
+ 9# first character in front
+10FIRST = 0x20
+11
+12# last character in font
+13LAST = 0x7f
+14
+15# bitmap of each character from FIRST to LAST
+16_FONT =\
+17b'\x00\x00\x00\x00\x00\x00\x00\x00'\
+18b'\x18\x3c\x3c\x18\x18\x00\x18\x00'\
+19b'\x66\x66\x24\x00\x00\x00\x00\x00'\
+20
+21... many more lines of data...
+22
+23b'\x70\x18\x18\x0e\x18\x18\x70\x00'\
+24b'\x76\xdc\x00\x00\x00\x00\x00\x00'\
+25b'\x00\x10\x38\x6c\xc6\xc6\xfe\x00'\
+26
+27FONT = memoryview(_FONT)
 
-
+
@@ -264,105 +241,59 @@ the negative glyph.left fix from peterhinch’s font conversion program
Sample converted TrueType font module.
-
 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)
+
 1# -*- coding: utf-8 -*-
+ 2# Converted from Chango-Regular.ttf using:
+ 3#     ./font2bitmap.py Chango-Regular.ttf 16 -c 0x20-0x7f
+ 4
+ 5# Maps the order of the character data
+ 6MAP = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
+ 7
+ 8# Number of color bits per pixel, currently only 1 is used but could be
+ 9# increased to support antialiased or smoothed fonts in the future.
+10BPP = 1
+11
+12# Font height
+13HEIGHT = 17
+14
+15# Font max width
+16MAX_WIDTH = 24
+17
+18# one byte per character table of widths in the same order as the MAP string
+19_WIDTHS = \
+20    b'\x06\x08\x0a\x0e\x0d\x18\x10\x06\x08\x08\x0a\x0d\x06\x08\x06\x0b'\
+21
+22    ... more lines of data...
+23
+24    b'\x0d\x0d\x0b\x0a\x0b\x0e\x0c\x12\x0d\x0c\x0b\x09\x06\x09\x0e\x0b'
+25
+26# OFFSET_WIDTH bytes per character in the same order as the MAP string
+27# to the start of each character in bits.
+28OFFSET_WIDTH = 2
+29_OFFSETS = \
+30    b'\x00\x00\x00\x66\x00\xee\x01\x98\x02\x86\x03\x63\x04\xfb\x06\x0b'\
+31
+32    ... more lines of data...
+33
+34    b'\x49\x94\x4a\x71\x4b\x3d\x4b\xf8\x4c\x91\x4c\xf7\x4d\x90\x4e\x7e'
+35
+36# character bitmaps per character in the same order as the MAP string.
+37# Note: character data may not start on byte boundaries
+38_BITMAPS =\
+39    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x61'\
+40
+41    ... many more lines of data...
+42
+43    b'\x3d\xe3\xfc\x00\x00\x00\x00\x00'
+44
+45WIDTHS = memoryview(_WIDTHS)
+46OFFSETS = memoryview(_OFFSETS)
+47BITMAPS = memoryview(_BITMAPS)
 
-
-
-

8x8 Fonts

+
+
+

8x8 Rom Fonts

_images/vga1_8x8.png

vga1_8x8.py: 128 Character 8x8 Font

@@ -378,8 +309,8 @@ the negative glyph.left fix from peterhinch’s font conversion program

-
-

8x16 Fonts

+
+

8x16 Rom Fonts

_images/vga1_8x16.png

vga1_8x16.py: 128 Character 8x16 Font

@@ -396,7 +327,7 @@ the negative glyph.left fix from peterhinch’s font conversion program
-

16x16 Fonts

+

16x16 Rom Fonts

_images/vga1_16x16.png

vga1_16x16.py: 128 Character 16x16 Thin Font

@@ -426,8 +357,8 @@ the negative glyph.left fix from peterhinch’s font conversion program

-
-

16x32 Fonts

+
+

16x32 Rom Fonts

_images/vga1_16x32.png

vga1_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:

diff --git a/docs/index.html b/docs/index.html index 0da4ed6..c16c21a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -13,6 +13,8 @@ + + @@ -29,6 +31,7 @@ + @@ -83,7 +86,7 @@ -

Contents:

+

Contents:

@@ -181,7 +184,7 @@ bit wide bitmap fonts with heights that are multiples of 8. Included are 12 bitmap fonts derived from classic pc text mode fonts.

-

Contents:

+

Contents:

diff --git a/docs/objects.inv b/docs/objects.inv index 2af6bad..851c2c2 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/py-modindex.html b/docs/py-modindex.html index c9b9849..5159367 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -13,6 +13,8 @@ + + @@ -29,6 +31,7 @@ + @@ -89,7 +92,7 @@ -

Contents:

+

Contents:

diff --git a/docs/search.html b/docs/search.html index 79425f5..cd34c25 100644 --- a/docs/search.html +++ b/docs/search.html @@ -13,6 +13,8 @@ + + @@ -30,6 +32,7 @@ + @@ -85,7 +88,7 @@ -

Contents:

+

Contents:

diff --git a/docs/searchindex.js b/docs/searchindex.js index 7429627..df0e5a6 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["examples","fonts","index","st7789py"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["examples.rst","fonts.rst","index.rst","st7789py.rst"],objects:{"":{st7789py:[3,0,0,"-"]},"st7789py.ST7789":{bitmap:[3,2,1,""],blit_buffer:[3,2,1,""],fill:[3,2,1,""],fill_rect:[3,2,1,""],hard_reset:[3,2,1,""],hline:[3,2,1,""],inversion_mode:[3,2,1,""],line:[3,2,1,""],pixel:[3,2,1,""],rect:[3,2,1,""],rotation:[3,2,1,""],sleep_mode:[3,2,1,""],soft_reset:[3,2,1,""],text:[3,2,1,""],vline:[3,2,1,""],vscrdef:[3,2,1,""],vscsad:[3,2,1,""],write:[3,2,1,""],write_width:[3,2,1,""]},st7789py:{ST7789:[3,1,1,""],color565:[3,3,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function"},terms:{"0123456789":1,"0123456789abcedf":1,"02x":0,"0x20":1,"0x7f":1,"100":0,"127":1,"128":1,"135":0,"135x240":3,"160":0,"16x16":2,"16x32":2,"16x6":1,"20000000":0,"2019":3,"2020":3,"2021":3,"240":[0,3],"240x240":3,"255":3,"256":[0,1],"280":3,"2cnaheucpd4":0,"320x240":3,"565":3,"8x16":2,"8x8":2,"byte":[1,3],"char":[0,1],"class":[0,1,3],"const":3,"default":3,"final":0,"import":0,"int":3,"long":1,"return":3,"true":[0,2,3],"try":0,"while":0,AND:3,BUT:3,FOR:3,NOT:3,THE:3,The:[0,1,3],There:3,These:0,USE:3,Use:1,WITH:3,__init__:0,_bitmap:1,_font:1,_offset:1,_width:1,abcd:0,abcdefghij:0,abcdefghijklmnopqrst:0,abcdefghijklmnopqrstuvwxyz:1,abov:3,action:3,adafruit:0,add:3,added:2,address:3,after:3,all:[0,1,3],ani:[1,3],anim:0,antialias:1,area:3,aris:3,associ:3,atba0bypaac:0,author:3,avail:[0,1],background:3,backlight:[0,3],bader:1,base:[2,3],baudrat:0,belokobylskii:3,bfa:3,bin:1,bio:[1,3],bit:[1,2,3],bitmap:[0,1,2,3],bitmap_modul:3,black:[0,3],blit_buff:3,blog:1,blue:[0,3],bold:1,bool:3,bottom:3,boundari:1,bpp:1,buffer:3,can:1,center:0,chang:3,chango:[1,2],chango_16:0,chango_32:0,chango_64:0,charact:[0,1,3],charg:3,choos:0,chr:0,circuitpython:0,circuitpython_flying_toast:0,claim:3,classic:[2,3],clear:0,cloud:0,code:1,col:0,col_max:0,collect:0,color565:[0,3],color:[0,1,3],column:[0,3],com:[0,1,2,3],compil:1,condit:3,connect:3,contain:[1,3],contract:3,convers:2,convert:[0,1,3],coordin:3,copi:3,copyright:3,corner:3,could:[1,3],cover:3,creat:0,current:1,damag:3,dan:1,data:[1,3],dbader:1,deal:3,def:0,defin:3,definit:3,deinit:0,demo:0,deriv:[2,3],detail:[0,1],devbi:[2,3],directori:[0,1],disabl:3,displai:[0,2,3],distribut:3,document:3,draw:[0,2,3],driver:[0,1,3],each:1,els:0,enabl:[0,3],encod:3,end:3,entir:3,even:0,event:3,exampl:[1,2,3],express:3,fals:3,file:[1,3],fill:[0,3],fill_rect:[0,3],find:0,first:[0,1,3],fit:3,fix:[1,3],fly:0,follow:3,font1:0,font2:0,font2bitmap:[0,1],font3:0,font4:0,font:[0,2,3],font_16:0,font_32:0,font_64:0,font_from_romfont:1,foreground:3,format:0,four:0,frame:3,framebuff:3,free:3,freetyp:1,from:[0,1,2,3],front:1,furnish:3,futur:1,get:0,getrandbit:0,github:[0,1,2,3],given:3,glyph:1,grant:3,green:[0,3],handl:1,hard:3,hard_reset:3,hardwar:3,height:[0,1,2,3],hello:0,herebi:3,high:0,hline:3,holder:3,horizont:3,http:[0,1,2,3],hugh:3,imag:1,imagemagick:0,imgtobitmap:0,impli:3,includ:[1,2,3],incorpor:3,increas:1,index:3,inform:0,initi:0,input:1,invers:3,inversion_mod:3,invert:3,ivan:3,justifi:0,keep:0,kind:3,landscap:3,last:[0,1,3],last_lin:0,learn:0,left:[0,1,3],len:0,length:3,less:1,liabil:3,liabl:3,licens:3,lilygo:0,limit:[1,3],line:[0,1,3],local:0,locat:[0,3],locaton:0,machin:0,mai:1,main:0,maketoast:0,man:0,mani:1,map:1,mario:0,max:1,max_width:1,measur:3,memori:[1,3],memoryview:1,merchant:3,merg:3,method:1,micropython:[1,2,3],miso:0,mit:3,mode:[2,3],modifi:3,modul:[1,2,3],monochrom:1,more:[0,1,3],mosi:0,move:0,mpy:1,multipl:[0,2,3],name:0,neg:1,none:3,noninfring:3,note:1,notic:3,noto:0,noto_font:2,noto_mono:0,noto_san:0,noto_serif:0,notosan:[0,1],notosans_32:0,notosansmono:0,notosansmono_32:0,notoserif:0,notoserif_32:0,number:1,object:3,obtain:3,off:3,offset:1,offset_width:1,one:1,onli:[0,1],option:[1,3],order:1,org:1,other:3,otherwis:[0,3],out:[0,3],output:1,page:0,paramet:3,particular:3,pendant:0,per:1,permiss:3,permit:3,person:3,peterhinch:1,phase:0,pin:[0,3],pixel:[0,1,3],point:3,polar:0,portion:3,portrait:3,posit:0,post:1,pre:1,program:[1,2],proport:1,provid:3,publish:3,purpos:3,python:1,ram:3,randint:0,random:0,rang:[0,3],rect:3,rectangl:[0,3],red:[0,3],reduc:1,refer:2,regular:1,render:1,repo:1,requir:1,reset:[0,3],restrict:3,right:3,rom:2,romfont:[0,1],rotat:[0,2,3],row:[0,3],row_max:0,run:0,russ:3,same:[1,3],sampl:1,sck:0,screen:0,script:0,scroll:[0,2,3],second:0,see:[0,1],self:0,sell:3,set:[1,3],shall:3,should:3,shown:3,shutdown:0,significantli:1,singl:3,size:[1,3],sleep:[0,3],sleep_mod:3,smooth:1,smoothli:0,soft:3,soft_reset:3,softspi:0,softwar:3,sourc:3,spacerac:1,specifi:[1,3],speed:0,spi:[0,3],spite:0,sprite:0,spritesheet:0,st7789:[0,2,3],st7789py:0,st7789py_mpi:[2,3],start:[1,3],step:0,str:3,string:[0,1,3],subject:3,sublicens:3,substanti:3,support:[1,2,3],tabl:1,term:3,test:0,text:[0,1,2,3],tfa:[0,3],tfb:0,tft:[0,2,3],thei:1,them:3,thi:[1,3],thin:1,third:0,three:0,through:0,toast:0,toaster:2,top:3,tort:3,track:0,truetyp:[0,1,3],ttf:1,ttgo:0,ttgo_font:2,ttgo_hello:2,ttgo_lin:2,ttgo_scrol:2,two:1,type:[0,2,3],under:3,use:[1,3],used:1,uses:1,using:[0,1,2,3],usual:0,utf:1,util:[0,1],utim:[0,3],valu:3,vertic:3,vga1_16x16:[0,1],vga1_16x32:[0,1],vga1_8x16:[0,1],vga1_8x8:[0,1],vga1_bold_16x16:[0,1],vga1_bold_16x32:[0,1],vga2_16x16:[0,1],vga2_16x32:[0,1],vga2_8x16:[0,1],vga2_8x8:[0,1],vga2_bold_16x16:[0,1],vga2_bold_16x32:[0,1],vga_8x8:1,view:3,vline:3,vsa:3,vscrdef:[0,3],vscsad:[0,3],vssa:3,warranti:3,watch:0,were:0,whether:3,which:3,white:[0,3],whom:3,wide:[2,3],widest:1,width:[0,1,3],without:3,work:[0,3],write:[0,1,3],write_width:[0,3],written:[1,3],www:0,x00:1,x01:1,x02:1,x03:1,x04:1,x06:1,x08:1,x09:1,x0a:1,x0b:1,x0c:1,x0d:1,x0e:1,x10:1,x12:1,x18:1,x24:1,x38:1,x3c:1,x3d:1,x49:1,x4a:1,x4b:1,x4c:1,x4d:1,x4e:1,x61:1,x63:1,x66:1,x6c:1,x70:1,x71:1,x76:1,x7e:1,x86:1,x90:1,x91:1,x94:1,x98:1,xc6:1,xdc:1,xe3:1,xee:1,xf7:1,xf8:1,xfb:1,xfc:1,xfe:1,xinyuan:0,you:3,youtub:0},titles:["Example Programs","Fonts","st7789py Driver","st7789py Reference"],titleterms:{"16x16":1,"16x32":1,"8x16":1,"8x8":1,"true":1,chango:0,content:2,convers:1,driver:2,exampl:0,font:1,index:2,noto_font:0,program:0,refer:3,rom:1,st7789py:[2,3],toaster:0,ttgo_font:0,ttgo_hello:0,ttgo_lin:0,ttgo_scrol:0,type:1}}) \ No newline at end of file +Search.setIndex({docnames:["examples","fonts","index","st7789py"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.todo":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["examples.rst","fonts.rst","index.rst","st7789py.rst"],objects:{"":{st7789py:[3,0,0,"-"]},"st7789py.ST7789":{bitmap:[3,2,1,""],blit_buffer:[3,2,1,""],fill:[3,2,1,""],fill_rect:[3,2,1,""],hard_reset:[3,2,1,""],hline:[3,2,1,""],inversion_mode:[3,2,1,""],line:[3,2,1,""],pixel:[3,2,1,""],rect:[3,2,1,""],rotation:[3,2,1,""],sleep_mode:[3,2,1,""],soft_reset:[3,2,1,""],text:[3,2,1,""],vline:[3,2,1,""],vscrdef:[3,2,1,""],vscsad:[3,2,1,""],write:[3,2,1,""],write_width:[3,2,1,""]},st7789py:{ST7789:[3,1,1,""],color565:[3,3,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function"},terms:{"0":[0,3],"01":[0,3],"0123456789":1,"0123456789abcedf":1,"02x":0,"0x20":1,"0x7f":1,"1":[0,1,3],"100":0,"12":[2,3],"127":1,"128":1,"13":0,"135":0,"135x240":3,"16":[0,1,2,3],"160":0,"16x16":2,"16x32":2,"16x6":1,"17":1,"18":0,"19":0,"2":[0,1,3],"20000000":0,"2019":3,"2020":3,"2021":3,"23":0,"24":1,"240":[0,3],"240x240":3,"255":3,"256":[0,1],"280":3,"2cnaheucpd4":0,"3":[0,3],"32":1,"320x240":3,"4":0,"40":[0,3],"5":0,"565":3,"6":0,"64":0,"8":[0,1,2,3],"80":0,"8x16":2,"8x8":2,"byte":[1,3],"char":[0,1],"class":[0,1,3],"const":3,"default":3,"do":3,"final":0,"import":0,"int":3,"long":1,"return":3,"true":[0,2,3],"try":0,"while":0,A:3,AND:3,AS:3,BE:3,BUT:3,FOR:3,IN:3,IS:3,NO:3,NOT:3,OF:3,OR:3,THE:3,TO:3,The:[0,1,3],There:3,These:0,To:3,WITH:3,_:[0,1],__init__:0,_bitmap:1,_font:1,_offset:1,_width:1,abcd:0,abcdefghij:0,abcdefghijklmnopqrst:0,abcdefghijklmnopqrstuvwxyz:1,abov:3,action:3,ad:2,adafruit:0,add:3,address:3,after:3,all:[0,1,3],an:[0,3],ani:[1,3],anim:0,antialias:1,ar:[0,1,2,3],area:3,aris:3,associ:3,atba0bypaac:0,author:3,avail:[0,1],b:1,background:3,backlight:[0,3],bader:1,base:[2,3],baudrat:0,belokobylskii:3,bfa:3,bg:3,bin:1,bio:[1,3],bit:[1,2,3],bitmap:[0,1,2,3],bitmap_modul:3,black:[0,3],blit_buff:3,blog:1,blue:[0,3],bold:1,bool:3,bottom:3,boundari:1,bpp:1,buffer:3,c:[1,3],can:1,center:0,chang:3,chango:[1,2],chango_16:0,chango_32:0,chango_64:0,charact:[0,1,3],charg:3,choos:0,chr:0,circuitpython:0,circuitpython_flying_toast:0,claim:3,classic:[2,3],clear:0,cloud:0,code:1,col:0,col_max:0,collect:0,color565:[0,3],color:[0,1,3],column:[0,3],com:[0,1,2,3],compil:1,condit:3,connect:3,contain:[1,3],contract:3,convers:2,convert:[0,1,3],coordin:3,copi:3,copyright:3,corner:3,could:[1,3],cover:3,creat:0,cs:[0,3],current:1,damag:3,dan:1,data:[1,3],dbader:1,dc:[0,3],deal:3,def:0,defin:3,definit:3,deinit:0,demo:0,deriv:[2,3],detail:[0,1],devbi:[2,3],directori:[0,1],disabl:3,displai:[0,2,3],distribut:3,document:3,draw:[0,2,3],driver:[0,1,3],e:0,each:1,els:0,enabl:[0,3],encod:3,end:3,entir:3,even:0,event:3,exampl:[1,2,3],express:3,f:1,fals:3,fg:3,file:[1,3],fill:[0,3],fill_rect:[0,3],find:0,first:[0,1,3],fit:3,fix:[1,3],fly:0,follow:3,font1:0,font2:0,font2bitmap:[0,1],font3:0,font4:0,font:[0,2,3],font_16:0,font_32:0,font_64:0,font_from_romfont:1,foreground:3,format:0,four:0,frame:3,framebuff:3,free:3,freetyp:1,from:[0,1,2,3],front:1,furnish:3,futur:1,gc:0,get:0,getrandbit:0,github:[0,1,2,3],given:3,glyph:1,grant:3,green:[0,3],h:[1,3],handl:1,hard:3,hard_reset:3,hardwar:3,height:[0,1,2,3],hello:0,herebi:3,high:0,hline:3,holder:3,horizont:3,http:[0,1,2,3],hugh:3,i:[0,1,2],imag:1,imagemagick:0,imgtobitmap:0,impli:3,includ:[1,2,3],incorpor:3,increas:1,index:3,inform:0,initi:0,input:1,invers:3,inversion_mod:3,invert:3,ivan:3,justifi:0,keep:0,kind:3,l:1,landscap:3,last:[0,1,3],last_lin:0,learn:0,left:[0,1,3],len:0,length:3,less:1,liabil:3,liabl:3,licens:3,lilygo:0,limit:[1,3],line:[0,1,3],local:0,locat:[0,3],locaton:0,machin:0,mai:1,main:0,maketoast:0,man:0,mani:1,map:1,mario:0,max:1,max_width:1,measur:3,memori:[1,3],memoryview:1,merchant:3,merg:3,method:1,micropython:[1,2,3],miso:0,mit:3,mode:[2,3],modifi:3,modul:[1,2,3],monochrom:1,more:[0,1,3],mosi:0,move:0,mpy:1,multipl:[0,2,3],name:0,neg:1,none:3,noninfring:3,note:1,notic:3,noto:0,noto_font:2,noto_mono:0,noto_san:0,noto_serif:0,notosan:[0,1],notosans_32:0,notosansmono:0,notosansmono_32:0,notoserif:0,notoserif_32:0,number:1,o:1,object:3,obtain:3,off:3,offset:1,offset_width:1,one:1,onli:[0,1],option:[1,3],order:1,org:1,other:3,otherwis:[0,3],out:[0,3],output:1,page:0,paramet:3,particular:3,pc:[1,2,3],pendant:0,per:1,permiss:3,permit:3,person:3,peterhinch:1,phase:0,pin:[0,3],pixel:[0,1,3],point:3,polar:0,portion:3,portrait:3,posit:0,post:1,pre:1,program:[1,2],proport:1,provid:3,publish:3,purpos:3,py:[1,2],python:1,ram:3,randint:0,random:0,rang:[0,3],rect:3,rectangl:[0,3],red:[0,3],reduc:1,refer:2,regular:1,render:1,repo:1,requir:[1,3],reset:[0,3],restrict:3,right:3,rom:2,romfont:[0,1],rotat:[0,2,3],row:[0,3],row_max:0,run:0,russ:3,s:[0,1,3],same:[1,3],sampl:1,sck:0,screen:0,script:0,scroll:[0,2,3],second:0,see:[0,1],self:0,sell:3,set:[1,3],shall:3,should:3,shown:3,shutdown:0,significantli:1,singl:3,size:[1,3],sleep:[0,3],sleep_mod:3,smooth:1,smoothli:0,so:3,soft:3,soft_reset:3,softspi:0,softwar:3,sourc:3,spacerac:1,specifi:[1,3],speed:0,spi:[0,3],spite:0,sprite:0,spritesheet:0,st7789:[0,2,3],st7789py:0,st7789py_mpi:[2,3],start:[1,3],step:0,str:3,string:[0,1,3],subject:3,sublicens:3,substanti:3,support:[1,2,3],t1:0,t2:0,t3:0,t4:0,t5:0,t:0,tabl:1,term:3,test:0,text:[0,1,2,3],tfa:[0,3],tfb:0,tft:[0,2,3],thei:1,them:3,thi:[1,3],thin:1,third:0,three:0,through:0,toast:0,toaster:2,top:3,tort:3,track:0,truetyp:[0,1,3],ttf:1,ttgo:0,ttgo_font:2,ttgo_hello:2,ttgo_lin:2,ttgo_scrol:2,two:1,type:[0,2,3],under:3,up:0,us:[0,1,2,3],usual:0,utf:1,util:[0,1],utim:[0,3],v:0,valu:3,vertic:3,vga1_16x16:[0,1],vga1_16x32:[0,1],vga1_8x16:[0,1],vga1_8x8:[0,1],vga1_bold_16x16:[0,1],vga1_bold_16x32:[0,1],vga2_16x16:[0,1],vga2_16x32:[0,1],vga2_8x16:[0,1],vga2_8x8:[0,1],vga2_bold_16x16:[0,1],vga2_bold_16x32:[0,1],vga_8x8:1,view:3,vline:3,vsa:3,vscrdef:[0,3],vscsad:[0,3],vssa:3,w:3,wa:3,warranti:3,watch:0,were:0,whether:3,which:3,white:[0,3],whom:3,wide:[2,3],widest:1,width:[0,1,3],without:3,work:[0,3],write:[0,1,3],write_width:[0,3],written:[1,3],www:0,x00:1,x01:1,x02:1,x03:1,x04:1,x06:1,x08:1,x09:1,x0:3,x0a:1,x0b:1,x0c:1,x0d:1,x0e:1,x10:1,x12:1,x18:1,x1:3,x24:1,x38:1,x3c:1,x3d:1,x49:1,x4a:1,x4b:1,x4c:1,x4d:1,x4e:1,x61:1,x63:1,x66:1,x6c:1,x70:1,x71:1,x76:1,x7e:1,x86:1,x90:1,x91:1,x94:1,x98:1,x:[0,3],xc6:1,xdc:1,xe3:1,xee:1,xf7:1,xf8:1,xfb:1,xfc:1,xfe:1,xinyuan:0,y0:3,y1:3,y:[0,3],you:3,youtub:0},titles:["Example Programs","Fonts","st7789py Driver","st7789py Reference"],titleterms:{"16x16":1,"16x32":1,"8x16":1,"8x8":1,"true":1,chango:0,content:2,convers:1,driver:2,exampl:0,font:1,index:2,noto_font:0,program:0,py:0,refer:3,rom:1,st7789py:[2,3],toaster:0,ttgo_font:0,ttgo_hello:0,ttgo_lin:0,ttgo_scrol:0,type:1}}) \ No newline at end of file diff --git a/docs/st7789py.html b/docs/st7789py.html index dd0a363..943673b 100644 --- a/docs/st7789py.html +++ b/docs/st7789py.html @@ -13,6 +13,8 @@ + + @@ -29,6 +31,7 @@ + @@ -84,7 +87,7 @@ -

Contents:

+

Contents:

@@ -210,23 +213,23 @@ BIOS text mode fonts.

  • Drawing converted bitmaps

  • -
    -st7789py.color565(red, green=0, blue=0)[source]
    +
    +st7789py.color565(red, green=0, blue=0)[source]

    Convert red, green and blue values (0-255) into a 16-bit 565 encoding.

    -
    -class st7789py.ST7789(spi, width, height, reset, dc, cs=None, backlight=None, rotation=0)[source]
    +
    +class st7789py.ST7789(spi, width, height, reset=None, dc=None, cs=None, backlight=None, rotation=0)[source]

    ST7789 driver class

    Parameters
      -
    • 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.

    -
    -hard_reset()[source]
    +
    +hard_reset()[source]

    Hard reset display.

    -
    -soft_reset()[source]
    +
    +soft_reset()[source]

    Soft reset display.

    -
    -sleep_mode(value)[source]
    +
    +sleep_mode(value)[source]

    Enable or disable display sleep mode.

    Parameters
    @@ -264,8 +267,8 @@ BIOS text mode fonts.

    -
    -inversion_mode(value)[source]
    +
    +inversion_mode(value)[source]

    Enable or disable display inversion mode.

    Parameters
    @@ -278,8 +281,8 @@ BIOS text mode fonts.

    -
    -rotation(rotation)[source]
    +
    +rotation(rotation)[source]

    Set display rotation.

    Parameters
    @@ -295,8 +298,8 @@ BIOS text mode fonts.

    -
    -vline(x, y, length, color)[source]
    +
    +vline(x, y, length, color)[source]

    Draw vertical line at the given location and color.

    Parameters
    @@ -311,8 +314,8 @@ BIOS text mode fonts.

    -
    -hline(x, y, length, color)[source]
    +
    +hline(x, y, length, color)[source]

    Draw horizontal line at the given location and color.

    Parameters
    @@ -327,8 +330,8 @@ BIOS text mode fonts.

    -
    -pixel(x, y, color)[source]
    +
    +pixel(x, y, color)[source]

    Draw a pixel at the given location and color.

    Parameters
    @@ -342,8 +345,8 @@ BIOS text mode fonts.

    -
    -blit_buffer(buffer, x, y, width, height)[source]
    +
    +blit_buffer(buffer, x, y, width, height)[source]

    Copy buffer to display at the given location.

    Parameters
    @@ -359,8 +362,8 @@ BIOS text mode fonts.

    -
    -rect(x, y, w, h, color)[source]
    +
    +rect(x, y, w, h, color)[source]

    Draw a rectangle at the given location, size and color.

    Parameters
    @@ -376,8 +379,8 @@ BIOS text mode fonts.

    -
    -fill_rect(x, y, width, height, color)[source]
    +
    +fill_rect(x, y, width, height, color)[source]

    Draw a rectangle at the given location, size and filled with color.

    Parameters
    @@ -393,8 +396,8 @@ BIOS text mode fonts.

    -
    -fill(color)[source]
    +
    +fill(color)[source]

    Fill the entire FrameBuffer with the specified color.

    Parameters
    @@ -404,8 +407,8 @@ BIOS text mode fonts.

    -
    -line(x0, y0, x1, y1, color)[source]
    +
    +line(x0, y0, x1, y1, color)[source]

    Draw a single pixel wide line starting at x0, y0 and ending at x1, y1.

    Parameters
    @@ -421,8 +424,8 @@ BIOS text mode fonts.

    -
    -vscrdef(tfa, vsa, bfa)[source]
    +
    +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]
    +
    +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]
    +
    +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.

    @@ -479,8 +482,8 @@ fonts are supported.

    -
    -bitmap(bitmap, x, y, index=0)[source]
    +
    +bitmap(bitmap, x, y, index=0)[source]

    Draw a bitmap on display at the specified column and row

    Parameters
    @@ -496,8 +499,8 @@ module

    -
    -write(font, string, x, y, fg=micropython.const, bg=micropython.const)[source]
    +
    +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

    @@ -515,8 +518,8 @@ at the specified column and row

    -
    -write_width(font, string)[source]
    +
    +write_width(font, string)[source]

    Returns the width in pixels of the string if it was written with the specified font

    diff --git a/lib/st7789py.py b/lib/st7789py.py index 23c9f9e..072836f 100644 --- a/lib/st7789py.py +++ b/lib/st7789py.py @@ -164,11 +164,11 @@ class ST7789(): 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 @@ -177,7 +177,7 @@ class ST7789(): - 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. @@ -187,6 +187,9 @@ class ST7789(): "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/sphinx/Makefile b/sphinx/Makefile new file mode 100644 index 0000000..85b43a1 --- /dev/null +++ b/sphinx/Makefile @@ -0,0 +1,26 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +update: + # Update documentation on my webserver using rsync over ssh + # /usr/bin/rsync --progress --delete -e 'ssh -i ~/.ssh/id_rsa' -avz build/html/ penfold.owt.com:/htdocs/st7789py/ + # update docs directory of this repo using rsync + /usr/bin/rsync --progress --delete -avz build/html/ ../docs/ + \ No newline at end of file diff --git a/sphinx/requires.txt b/sphinx/requires.txt new file mode 100644 index 0000000..d5b9a8e --- /dev/null +++ b/sphinx/requires.txt @@ -0,0 +1,6 @@ +# additional sphinx plug-ins, install using pip3 +sphinx-prompt +sphinxcontrib.napoleon +sphinxcontrib.napoleon +sphinxcontrib.globalsubs +sphinx_rtd_theme diff --git a/sphinx/source/_static/vga1_16x16.png b/sphinx/source/_static/vga1_16x16.png new file mode 100644 index 0000000..053c26e Binary files /dev/null and b/sphinx/source/_static/vga1_16x16.png differ diff --git a/sphinx/source/_static/vga1_16x32.png b/sphinx/source/_static/vga1_16x32.png new file mode 100644 index 0000000..a1e5076 Binary files /dev/null and b/sphinx/source/_static/vga1_16x32.png differ diff --git a/sphinx/source/_static/vga1_8x16.png b/sphinx/source/_static/vga1_8x16.png new file mode 100644 index 0000000..1da28b3 Binary files /dev/null and b/sphinx/source/_static/vga1_8x16.png differ diff --git a/sphinx/source/_static/vga1_8x8.png b/sphinx/source/_static/vga1_8x8.png new file mode 100644 index 0000000..8af6ec7 Binary files /dev/null and b/sphinx/source/_static/vga1_8x8.png differ diff --git a/sphinx/source/_static/vga1_bold_16x16.png b/sphinx/source/_static/vga1_bold_16x16.png new file mode 100644 index 0000000..1df216b Binary files /dev/null and b/sphinx/source/_static/vga1_bold_16x16.png differ diff --git a/sphinx/source/_static/vga1_bold_16x32.png b/sphinx/source/_static/vga1_bold_16x32.png new file mode 100644 index 0000000..5a6de89 Binary files /dev/null and b/sphinx/source/_static/vga1_bold_16x32.png differ diff --git a/sphinx/source/_static/vga2_16x16.png b/sphinx/source/_static/vga2_16x16.png new file mode 100644 index 0000000..8d3947e Binary files /dev/null and b/sphinx/source/_static/vga2_16x16.png differ diff --git a/sphinx/source/_static/vga2_16x32.png b/sphinx/source/_static/vga2_16x32.png new file mode 100644 index 0000000..1f0f5bb Binary files /dev/null and b/sphinx/source/_static/vga2_16x32.png differ diff --git a/sphinx/source/_static/vga2_8x16.png b/sphinx/source/_static/vga2_8x16.png new file mode 100644 index 0000000..c76c26b Binary files /dev/null and b/sphinx/source/_static/vga2_8x16.png differ diff --git a/sphinx/source/_static/vga2_8x8.png b/sphinx/source/_static/vga2_8x8.png new file mode 100644 index 0000000..c06e565 Binary files /dev/null and b/sphinx/source/_static/vga2_8x8.png differ diff --git a/sphinx/source/_static/vga2_bold_16x16.png b/sphinx/source/_static/vga2_bold_16x16.png new file mode 100644 index 0000000..3fc37b0 Binary files /dev/null and b/sphinx/source/_static/vga2_bold_16x16.png differ diff --git a/sphinx/source/_static/vga2_bold_16x32.png b/sphinx/source/_static/vga2_bold_16x32.png new file mode 100644 index 0000000..e527303 Binary files /dev/null and b/sphinx/source/_static/vga2_bold_16x32.png differ diff --git a/sphinx/source/conf.py b/sphinx/source/conf.py new file mode 100644 index 0000000..ceec124 --- /dev/null +++ b/sphinx/source/conf.py @@ -0,0 +1,219 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('../../examples')) +sys.path.insert(0, os.path.abspath('../../lib')) + +autodoc_mock_imports = [ + 'micropython', + 'ustruct', + 'machine', + 'board', + 'network', + 'esp', + 'uos', + 'btree', +] +autodoc_member_order = 'bysource' +# -- Project information ----------------------------------------------------- + +project = u'st7789py' +copyright = u'2020, Russ Hughes' +author = u'Russ Hughes' + +# The short X.Y version +version = u'' +# The full version, including alpha/beta/rc tags +release = u'0.1.0' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinxcontrib.napoleon', + 'sphinxcontrib.globalsubs', + 'sphinx.ext.autosummary', + 'sphinx.ext.autosectionlabel', + 'sphinx-prompt', + 'sphinx_rtd_theme', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +#html_theme = 'alabaster'] +html_show_copyright = False +html_theme = 'sphinx_rtd_theme' +html_theme_options = { + 'canonical_url': '', + 'logo_only': False, + 'display_version': True, + 'prev_next_buttons_location': 'bottom', + 'style_external_links': True, + 'style_nav_header_background': '#2980B9', + # Toc options + 'collapse_navigation': False, + 'sticky_navigation': True, + 'navigation_depth': 4, + 'includehidden': True, + 'titles_only': False +} +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'st7789pydoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'st7789py.tex', u'st7789py Documentation', + u'Russ Hughes', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'st7789py', u'st7789py Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'st7789py', u'st7789py Documentation', + author, 'st7789py', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for todo extension ---------------------------------------------- + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True diff --git a/sphinx/source/examples.rst b/sphinx/source/examples.rst new file mode 100644 index 0000000..49461bf --- /dev/null +++ b/sphinx/source/examples.rst @@ -0,0 +1,72 @@ +Example Programs +================ + +These examples run on the LilyGo TTGO-T-Display available from the usual +locations. See https://github.com/Xinyuan-LilyGO/TTGO-T-Display for more +information. + + +ttgo_lines.py +------------- + +.. literalinclude:: ../../examples/ttgo_lines.py + :linenos: + :language: python + + +ttgo_hello.py +------------- + +.. literalinclude:: ../../examples/ttgo_hello.py + :linenos: + :language: python + + +ttgo_fonts.py +------------- + +.. literalinclude:: ../../examples/ttgo_fonts.py + :linenos: + :language: python + + +ttgo_scroll.py +-------------- + +.. literalinclude:: ../../examples/ttgo_scroll.py + :linenos: + :language: python + + +toasters.py +----------- + +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. + +.. literalinclude:: ../../examples/toasters/toasters.py + :linenos: + :language: python + + +chango.py +--------- + +Test for font2bitmap converter for the driver. +See the font2bitmap program in the utils directory. + +.. literalinclude:: ../../examples/truetype/chango.py + :linenos: + :language: python + + +noto_fonts.py +------------- + +Test for font2bitmap converter for the driver. +See the font2bitmap program in the utils directory. + +.. literalinclude:: ../../examples/truetype/noto_fonts.py + :linenos: + :language: python + diff --git a/sphinx/source/fonts.rst b/sphinx/source/fonts.rst new file mode 100644 index 0000000..c334f96 --- /dev/null +++ b/sphinx/source/fonts.rst @@ -0,0 +1,152 @@ +Fonts +===== + +Two type of fonts are supported by this driver fixed size bitmap fonts +converted from PC Bios images using the font_from_romfont utility and fixed or proportional fonts converted from True-Type fonts using the font2bitmap utility. + +The rom fonts are available in 128 and 256 PC character sets in 8x8, 8x16, 16x6 and 16x32 pixel sizes. They written using the text method. + +The True-Type fonts can be converted to any size as long as the widest +character is 256 pixels or less. They are written using the write method. + +Pre-compiling the font files to .mpy files will significantly reduce the memory required for the fonts. + +Rom Font Conversion +------------------- + +The `utils` directory contains the font_from_romfont.py program used to convert PC BIOS bitmap fonts from the font-bin directory of spacerace's +https://github.com/spacerace/romfont repo. + +The utility converts all romfont bin files in the specified -input-directory (-i) and writes python font files to the specified -output-directory (-o). + +Characters included can be limited by using the -first-char (-f) and -last-char (-l) options. + +Example: + + font_from_romfont -i font-bin -o fonts -f 32 -l 127 + + +.. literalinclude:: romfont.py + :linenos: + :language: python + :caption: Sample converted romfont font module. + + +True-Type Font Conversion +------------------------- + +The `utils` directory contains the `font2bitmap.py` program used to convert True-Type font into bitmap font modules. Use the -h option to see details of the available options. The `font2bitmap.py` program uses font handling classes from Dan Bader blog post on using freetype +http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python and +the negative glyph.left fix from peterhinch's font conversion program +https://github.com/peterhinch/micropython-font-to-py. + +The utility requires the python freetype module. + +Example use: + +- ./font2bitmap NotoSans-Regular.ttf 32 -s "0123456789ABCEDF" +- ./font2bitmap.py Chango-Regular.ttf 16 -c 0x20-0x7f + + +.. literalinclude:: truetype.py + :linenos: + :language: python + :caption: Sample converted TrueType font module. + + + +8x8 Rom Fonts +------------- + +.. figure:: _static/vga1_8x8.png + :align: center + + vga1_8x8.py: 128 Character 8x8 Font + +| + +.. figure:: _static/vga2_8x8.png + :align: center + + vga2_8x8.py: 256 Character 8x8 Font + +| + +8x16 Rom Fonts +-------------- + +.. figure:: _static/vga1_8x16.png + :align: center + + vga1_8x16.py: 128 Character 8x16 Font + +| + +.. figure:: _static/vga2_8x16.png + :align: center + + vga2_8x16.py: 256 Character 8x16 Font + +| + +16x16 Rom Fonts +--------------- + +.. figure:: _static/vga1_16x16.png + :align: center + + vga1_16x16.py: 128 Character 16x16 Thin Font + +| + +.. figure:: _static/vga1_bold_16x16.png + :align: center + + vga1_bold_16x16.py: 128 Character 16x16 Bold Font + +| + +.. figure:: _static/vga2_16x16.png + :align: center + + vga2_16x16.py: 256 Character 16x16 Thin Font + +| + +.. figure:: _static/vga2_bold_16x16.png + :align: center + + vga2_bold_16x16.py: 256 Character 16x16 Bold Font + +| + +16x32 Rom Fonts +--------------- + +.. figure:: _static/vga1_16x32.png + :align: center + + vga1_16x32.py: 128 Character 16x32 Thin Font + +| + +.. figure:: _static/vga1_bold_16x32.png + :align: center + + vga1_bold_16x32.py: 128 Character 16x32 Bold Font + +| + +.. figure:: _static/vga2_16x32.png + :align: center + + vga2_16x32.py: 256 Character 16x32 Thin Font + +| + +.. figure:: _static/vga2_bold_16x32.png + :align: center + + vga2_bold_16x32.py: 256 Character 16x32 Bold Font + +| diff --git a/sphinx/source/index.rst b/sphinx/source/index.rst new file mode 100644 index 0000000..b1f6d73 --- /dev/null +++ b/sphinx/source/index.rst @@ -0,0 +1,24 @@ +st7789py Driver +=============== + +st7789 tft driver in MicroPython based on devbis' st7789py_mpy module from +https://github.com/devbis/st7789py_mpy. + +I added support for display rotation, scrolling and drawing text using 8 and 16 +bit wide bitmap fonts with heights that are multiples of 8. Included are 12 +bitmap fonts derived from classic pc text mode fonts. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + self + st7789py + examples + fonts + +Index +===== + +* :ref:`genindex` diff --git a/sphinx/source/romfont.py b/sphinx/source/romfont.py new file mode 100644 index 0000000..d52825c --- /dev/null +++ b/sphinx/source/romfont.py @@ -0,0 +1,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) diff --git a/sphinx/source/st7789py.rst b/sphinx/source/st7789py.rst new file mode 100644 index 0000000..9f4b014 --- /dev/null +++ b/sphinx/source/st7789py.rst @@ -0,0 +1,5 @@ +st7789py Reference +================== + +.. automodule:: st7789py + :members: diff --git a/sphinx/source/truetype.py b/sphinx/source/truetype.py new file mode 100644 index 0000000..38e53d5 --- /dev/null +++ b/sphinx/source/truetype.py @@ -0,0 +1,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)