Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Rifqi Abdillah
Published © GPL3+

Candy Pages: Reading Rewards for Little Bookworms

Embark on sweet reading journeys with Candy Pages! Explore, read, and earn delightful rewards for young bookworms.

IntermediateFull instructions provided2 days143

Things used in this project

Hardware components

Wio Terminal
Seeed Studio Wio Terminal
×1
Keypad 4x4
×1
USB Cable, USB Type C Plug
USB Cable, USB Type C Plug
×1
SparkFun Snappable Protoboard
SparkFun Snappable Protoboard
×1

Software apps and online services

Arduino IDE
Arduino IDE
Google Colab
Canva
Solidworks

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)
3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Candy Page CAD

You can build your own Candy Page :D

Code

Bitmap Converter 24-bit to 16 bit

Python
Convert your image to use it at Wio Terminal
from PIL import Image
import array
import os


def rgb332(r, g, b):
    r = r >> 5
    g = g >> 5
    b = b >> 6
    c = r << 5 | g << 2 | b
    return [c]


def rgb565(r, g, b):
    r = r >> 3
    g = g >> 2
    b = b >> 3
    c = r << 11 | g << 5 | b
    return [c >> 8, c & 0xff]


def convert(cvt, path, subpath):
    subpath = os.path.join(path, subpath)
    if not os.path.exists(subpath):
        os.mkdir(subpath)

    for _, _, filesnames in os.walk(path):
        for file in filesnames:
            if (os.path.splitext(file)[-1] != '.bmp'):
                continue
            im = Image.open(os.path.join(path, file))
            width, height = im.size
            v = [cvt(r, g, b) for (r, g, b) in im.getdata()]
            b = bytearray()
            b.append(width & 0xff)
            b.append(width >> 8)
            b.append(height & 0xff)
            b.append(height >> 8)
            for pair in v:
                for i in pair:
                    b.append(i)
            f = open(os.path.join(subpath, file), "wb")
            f.write(b)
            f.close()
        break

def choose():
    option = int(input("Enter (1) for 8-bit colour convert, Enter (2) for 16-bit colour convert\n"))
    if option == 1:
        pathname = 'rgb332'
        return rgb332, pathname
    elif option == 2:
        pathname = 'rgb565'
        return rgb565, pathname
    else:
        print("Invalid input!")

rgbtype, pathname = choose();
convert(rgbtype, 'bmp', pathname)

Candy Page Code

Code and Picture Background for Candy Page

Credits

Rifqi Abdillah

Rifqi Abdillah

11 projects β€’ 10 followers
Lecturer in Informatics & Electronics Engineering. Passionate about Machine Learning, Edge Computing, Image Processing, and IoT.

Comments