aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinkplate-display31
1 files changed, 23 insertions, 8 deletions
diff --git a/inkplate-display b/inkplate-display
index 2c7b3ab..6ad7f03 100755
--- a/inkplate-display
+++ b/inkplate-display
@@ -17,7 +17,21 @@
;; 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 (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,19 +114,20 @@
(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 "Give yourself permission to fail; it's the path to success" 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:send my-dev)
+ (inkplate:send my-dev)
(inkplate:close my-dev))