Close

Add shutter function

A project log for MagiClick - a Mechanical Button with screen

A multi-function button, a 0.85-inch display, support for expansion and BLE

makerm0MakerM0 02/09/2023 at 06:430 Comments

Split GIF image in frames (ezgif.com)

I use this website to convert gif files to multiple jpg files and then to .c files, use TMOS to update a picture every 100ms, and perform animations when the keys are pressed.

#include "shutter.h"
#include "img_shutter.h"
#include "img_shutter_96.h"
#include "hidconsumer.h"

#define IMG_NUM (img_shutter_96_height/img_shutter_96_width)

static uint8_t img_cnt = 0;
static uint16_t img_color;

static void init(void *data) {
    img_cnt = 0;
}

static void enter(void *data) {
    // insert code
    UG_FillScreen(C_BLACK);
    img_color = tmos_rand() >> 8;
    LCD_DrawMonoXBMFast(16, 16, img_shutter_96_width, img_shutter_96_width, img_shutter_96_bits, img_color, BLACK);

    //
    manager_setBusy(false);
}

static void loop(void *data) {
    KEY_TYPE key;
    key = HAL_KeyGet();
    switch (key) {

    case KEY1_SHORT:
        hidEmuSendConsumerReport(VOL_DOWN, 0x00);
        hidEmuSendConsumerReport(0, 0);
        img_cnt = 0;
        img_color = tmos_rand() >> 8;
        manager_startEventOnce(10);
        break;

    case KEY1_LONG:

        manager_switchToParent();
        break;

    default:
        break;
    }
}

static void event(void *data) {
    if (img_cnt < IMG_NUM) {
        LCD_DrawMonoXBMFast(16, 16, img_shutter_96_width, img_shutter_96_width, &img_shutter_96_bits[1152 * img_cnt],
                img_color, BLACK);
        manager_startEventOnce(30);
        img_cnt++;
    }
}
static void quit(void *data) {
    // insert code

    manager_stopEvent();

    //
    manager_setBusy(true);
}


Discussions