[personal profile] chebe
I got myself a HalloWing a few weeks back. I'd had the idea a few years ago of adding an LCD to a microcontroller as a reusable convention/conference badge, but didn't get far with it. So when I saw the HalloWing I knew it was everything I wanted all wrapped up in a gothic bow.

Arduino:
I get my HalloWing, install all the libraries, and play around with displaying a simple image. It turns out the process to do this is a bit convoluted.

First, open up Gimp, scale down your image to 128x128. Export as X BitMap Image (xbm).

Open the xbm file in a text editor. Add;
#include <avr/pgmspace.h>
to the top of the file, and replace;
static unsigned char image_bits[] = {
with
static const uint8_t PROGMEM image_bits[] = {
Save as .c format.

Include your image.c in your .ino sketch;
#include "image.c"

Include the screen library, declare and initialise your screen, then you can draw your image.

The drawXBitmap() functions exists with arguments; starting at x=0, y=0, image bits, 128, 128, a colour;
tft.drawXBitmap(0, 0, image_bits, image_width, image_height, ST77XX_GREEN);

All together the sketch looks like;
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735

#include "image.c"

#define TFT_CS     39
#define TFT_RST    37
#define TFT_DC     38
#define TFT_BACKLIGHT 7

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

void setup(void) {
  // Start TFT and fill black
  tft.initR(INITR_144GREENTAB);
  tft.setRotation(2);
  tft.fillScreen(ST77XX_BLACK);

  // Turn on backlight
  pinMode(TFT_BACKLIGHT, OUTPUT);
  digitalWrite(TFT_BACKLIGHT, HIGH);

  show_image();
}

void loop() {
}

// https://github.com/adafruit/Adafruit-GFX-Library/pull/31
void show_image() {
  tft.fillScreen(ST77XX_WHITE);
  tft.drawXBitmap(0, 0, image_bits, image_width, image_height, ST77XX_BLACK);
}


The interesting thing with this is that it is monochrome. You can pick a colour (like red, green, etc), but it is a simple on-off map.



HalloWing displaying XBitMap image in black and white
Photo by [personal profile] chebe



Which isn't quite right. I looked around and it seems that while you can write log files to the SPI Flash memory through Arduino it is wiped upon restart, so leaving a small image file to be loaded later doesn't work. At least, not without an SD card shield. I have one ordered, so I'll let you know if I can get it to work.


CircuitPython:
Until then, I guess it's time to CircuitPython it up with the HalloWing. Bonus; no need to install an IDE.

First, use Gimp to create 128x128 BitMap (bmp) images, making sure they are saved as 24-bit. Plug your HalloWing in over USB, press the Reset button twice, drag the UF2 file onto the device. Copy your bmp images, and your code.py file, to the root of the device. Done.



HalloWing displaying bitmap image in full colour
Photo by [personal profile] chebe