1
0
Fork 0

Compare commits

..

3 commits

Author SHA1 Message Date
8b2782e00b Show a random tip from Pragmatic Thinking & Learning 2023-07-08 00:09:52 -07:00
6da42d558e Add custom wrapping function for displaying text
Setting text wrapping to true will wrap the text to the beginning of the line
again. This function just returns a list of strings that can be tweaked to
provide the lists of the right length, this way I can make sure that the text
continues in the right place on the next line.
2023-07-07 23:41:19 -07:00
48ce1ba157 Add ‘--reset’ command-line option
Passing this option will cause a full update command to be sent to the Inkplate
instead of a partial update command.

A full update cleans up any residual display from previous partial updates, but
causes more wear on the eink display. It causes a big flash of all black to
happen before sending the updated display. I shouldn't be used all the time.
2023-07-07 23:16:12 -07:00
2 changed files with 82 additions and 9 deletions

View file

@ -14,3 +14,7 @@ Put the =inkplate-display= script anywhere in your =$PATH=.
* Usage
Run the =inkplate-display= script without any arguments. This script assumes that your Inkplate is connected, running in peripheral mode, and that the file descriptor is located at =/dev/ttyUSB0=.
The following command-line arguments are available:
- =--reset= :: Causes a full screen update to be sent to the Inkplate instead of a partial one. Clears any artifacts from previous partial updates, but is harder on the display so shouldn't be used all the time.

View file

@ -17,7 +17,71 @@
;; this program. If not, see <https://www.gnu.org/licenses/>.
(use-modules ((inkplate) #:prefix inkplate:)
(srfi srfi-19))
(srfi srfi-19)
(srfi srfi-1))
(define tips
'("Always consider the context."
"Use rules for novices, intuition for experts."
"Know what you don't know."
"Learn by watching and imitating."
"Keep practicing in order to remain expert."
"Avoid formal methods if you need creativity, intuition, or inventiveness."
"Learn the skill of learning."
"Capture all ideas to get more of them."
"Learn by synthesis as well as by analysis."
"Strive for good design; it really works better."
"Rewire your brain with belief and constant practice."
"Add sensory experience to engage more of your brain."
"Lead with R-mode; follow with L-mode."
"Use metaphor as the meeting place between L-mode and R-mode."
"Cultivate humor to build stronger metaphors."
"Step away from the keyboard to solve hard problems."
"Change your viewpoint to solve the problem."
"Watch the outliers: \"rarely\" doesn't mean \"never.\""
"Be comfortable with uncertainty."
"Trust ink over memory; every mental read is a write."
"Hedge your bets with diversity."
"Allow for different bugs in different people."
"Act like you've evolved: breathe, don't hiss."
"Trust intuition, but verify."
"Create SMART objectives to reach your goals."
"Plan your investment in learning deliberately."
"Discover how you learn best."
"Form study groups to learn and teach."
"Read deliberately."
"Take notes with both R-mode and L-mode."
"Write on: documenting is more important than documentation."
"See it. Do it. Teach it."
"Play more in order to learn more."
"Learn from similarities; unlearn from differences."
"Explore, invent, and apply in your environment--safely."
"See without judging and then act."
"Give yourself permission to fail; its the path to success."
"Groove your mind for success."
"Learn to pay attention."
"Make thinking time."
"Use a wiki to manage information and knowledge."
"Establish rules of engagement to manage interruptions."
"Send less email, and youll receive less email."
"Choose your own tempo for an email conversation."
"Mask interrupts to maintain focus."
"Use multiple monitors to avoid context switching."
"Optimize your personal workflow to maximize context."
"Grab the wheel. You cant steer on autopilot."))
(define (my-wrap text max-length)
(reverse
(map string-trim
(fold
(λ (item accumulator)
(let* ((current-line (car accumulator))
(new-line (format #f "~a ~a" current-line item)))
(if (> (string-length new-line) max-length)
(cons item accumulator)
(cons new-line (cdr accumulator)))))
'("")
(string-split text #\ )))))
(let* ((my-dev (inkplate:open "/dev/ttyUSB0"))
(date (current-date))
@ -100,17 +164,22 @@
(inkplate:set-text-size my-dev 4)
(inkplate:print my-dev (inkplate:convert-string-to-hex "S")))
(inkplate:set-cursor my-dev 265 15)
(inkplate:set-text-size my-dev 3)
(inkplate:set-text-wrap my-dev #f)
(inkplate:print my-dev (inkplate:convert-string-to-hex "Choose your own tempo for an"))
(inkplate:set-cursor my-dev 265 45)
(inkplate:set-text-size my-dev 3)
(inkplate:set-text-wrap my-dev #f)
(inkplate:print my-dev (inkplate:convert-string-to-hex "email conversation"))
(let loop ((lines (my-wrap (list-ref tips (random (length tips)
(random-state-from-platform)))
29))
(x 265)
(y 15))
(inkplate:set-cursor my-dev x y)
(inkplate:print my-dev (inkplate:convert-string-to-hex (car lines)))
(unless (null? (cdr lines))
(loop (cdr lines) x (+ 30 y))))
(if (member "--reset" (command-line))
(inkplate:update my-dev)
(inkplate:partial-update my-dev 15 800 600))
(inkplate:partial-update my-dev 15 800 600)
(inkplate:send my-dev)
(inkplate:close my-dev))