Compare commits

...

3 commits

Author SHA1 Message Date
27cbc844de Send a partial update in the date example
From what I've read it's not good to always do full updates, so for examples and
testing I figure that doing a partial update of the whole screen is also good.
2023-07-12 15:13:34 -07:00
05d734c903 Fix the date example
I stopped calling the original module ‘(inkplate lowlevel)’ since I don't have
any idea for a high-level API yet.
2023-07-12 15:13:01 -07:00
b86754cb92 Add ‘guile-termios’ dependency to set the speed of the inkplate TTY
There seems to be magic going on here. Once the speed has been set for the
device once the OS (at least GNU/Linux) remembers the setting and it doesn't
have to happen again after. Since I was porting from my Emacs module, I kept
running Emacs and it kept setting the speed, which meant that my tests with
Guile kept working.

After a reboot, it stopped.

This change makes sure that the speed is set. I'm not sure if the raw is
necessary, but it's in the example, and it seems to work for now, so I'll keep
it around.
2023-07-12 15:08:31 -07:00
5 changed files with 20 additions and 7 deletions

View file

@ -23,7 +23,7 @@ if test "x$GUILD" = "x"; then
fi
dnl Hall auto-generated guile-module dependencies
GUILE_MODULE_REQUIRED([termios])
dnl Installation directories for .scm and .go files.
guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION"

View file

@ -1,4 +1,4 @@
(use-modules ((inkplate lowlevel) #:prefix inkplate:)
(use-modules ((inkplate) #:prefix inkplate:)
(srfi srfi-19))
(let ((my-dev (inkplate:open "/dev/ttyUSB0")))
@ -16,7 +16,7 @@
(inkplate:draw-rectangle my-dev 269 89 252 157 3)
(inkplate:draw-rectangle my-dev 268 88 254 159 3)
(inkplate:update my-dev)
(inkplate:partial-update my-dev 15 800 600)
(inkplate:send my-dev)
(inkplate:close my-dev))

View file

@ -23,7 +23,8 @@
("pkg-config" ,pkg-config)
("texinfo" ,texinfo)))
(inputs `(("guile" ,guile-3.0)))
(propagated-inputs `())
(propagated-inputs
`(("guile-termios" ,guile-termios)))
(synopsis "")
(description "")
(home-page "")

View file

@ -8,7 +8,7 @@
(description "")
(home-page "")
(license gpl3+)
(dependencies `())
(dependencies `(("guile-termios" (termios) ,guile-termios)))
(skip ())
(files (libraries ((scheme-file "inkplate")))
(tests ((directory "tests" ((scheme-file "inkplate")))))

View file

@ -1,6 +1,13 @@
(define-module (inkplate)
#:use-module ((ice-9 format) #:select (format))
#:use-module ((srfi srfi-9) #:select (define-record-type))
#:use-module ((termios system) #:select (termios-B115200))
#:use-module ((termios with-exceptions)
#:select (make-termios-struct
tc-get-attr!
tc-set-attr
cf-make-raw!
cf-set-speed!))
#:export (<inkplate>
make-inkplate
@ -62,8 +69,13 @@
(define (open device-path)
"Open a connection to an Inkplate on the named DEVICE-PATH."
(let ((port (open-file device-path "r+")))
(make-inkplate port port)))
(let ((port (open-file device-path "r+"))
(termios (make-termios-struct)))
(tc-get-attr! port termios)
(cf-make-raw! termios)
(cf-set-speed! termios termios-B115200)
(tc-set-attr port termios)
(make-inkplate port port)))
(define (close device)
"Close a connection to an Inkplate in DEVICE."