OBSOLETE - replaced by https://github.com/v79/Khartoum
  • C 61.8%
  • Kotlin 37.9%
  • Makefile 0.3%
Find a file
Liam 1772b3db83
spotify (#2)
* Experiments with using libcurl to fetch data from Spotify API. Grabbed a curl implementation wrapper from Kotlin Native samples website.

* Managed to get the CURL POSt request to work to get a spotify access token.

* CURL more complicated than I thought, as larger responses are spread over several chunks.
Once that resolved, quickly got a basic "currently playing" function working for spotify.
Got serialization model mostly working for json response from spotify.

* Started drawing spotify currently playing details on ePaper. Layout issues remain.
Started work on a text wrapping/truncate mode.
Various improvements of the spotify model.

* Added a simple wrapper to the posix get current time function.
Added a measure text function so we can pre-calculate how big a text string will be, useful for right-align or centering
Quick hack to handle ASCII > 126, might work.

* Spotify stuff basically working now.
Started to use the kotlinx-datetime library for date-time stuff.

* Spotify stuff basically working now.
Started to use the kotlinx-datetime library for date-time stuff.

* Null check if music isn't playing

* Got the button actions working. Don't fully understand the low/high thing but it works.

* A few little tidy ups

* Some comments.
Moved spotifyClient and spotifySecret to environment variables. Need to run app with 'sudo -E ./waveshare' for now.
2020-12-06 15:46:30 +00:00
gradle/wrapper Initial commit 2020-11-08 16:07:03 +00:00
src spotify (#2) 2020-12-06 15:46:30 +00:00
.gitignore Initial commit 2020-11-08 16:07:03 +00:00
build.gradle.kts spotify (#2) 2020-12-06 15:46:30 +00:00
gradle.properties Initial commit 2020-11-08 16:07:03 +00:00
gradlew Initial commit 2020-11-08 16:07:03 +00:00
gradlew.bat Initial commit 2020-11-08 16:07:03 +00:00
README.md Update README.md 2020-11-18 20:29:48 +00:00
settings.gradle.kts Initial commit 2020-11-08 16:07:03 +00:00

WaveShareTests

Experimenting with Waveshare ePaper for the Raspberry Pi

badge

Writing code in Kotlin Native to control and display images and text on a Waveshare ePaper HAT for the Raspbery Pi.

Makes use of the bcm2835 C library for hardware control. It recreates some of the Waveshare GUI C example functions, in Kotlin, in a library I am calling Khartoum. So far, the following functions are available:

  • setPixel - forms the basis of all drawing routines
  • drawLine
  • drawCircle
  • drawCharacter - render a single character in the ASCII 32..127 range only. A monospace font must be provided; the enum class KhFont provides two sample fonts. Forms the basis of the drawString function
  • drawString - renders a Kotlin text string, hard-wrapping at the edge of the display. Again, only ASCII 32..127 for now.
  • drawBitmap - draws the entire screen with a bitmap image, encoded as an unsigned byte array.
  • clear - reset the image to zero, and optionally change its rotation (can only rotate an empty image)

The library can work in either portrait or landscape mode.

The library should be extensible, to support a range of Waveshare ePaper displays, but for now only the 2.7 inch B three-colour display is working.

Still to do

  • High priorities:
  • Draw a bitmap at given co-ordinates, to make it easier to combine text and images
  • Load bitmaps from a file, probably a BMP file
  • Save bitmaps to a file, to ease debugging
  • Lower priorities:
  • Better wrapping of text in drawString, to avoid hard breaks in the middle of a word
  • Kerning support?

Other ideas

  • Support the hardware keys on some Waveshare ePaper HATS
  • Support partial updates (I need an epaper device which supports this before I will try)