Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add small bytecode language for watchfaces #2092

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

pipe01
Copy link
Contributor

@pipe01 pipe01 commented Jul 7, 2024

I've implemented a small bytecode assembly language intended for making watchfaces without recompiling InfiniTime. Right now it's only a proof of concept and I'm open to any ideas and improvements. The program is currently being loaded from a hardcoded path in the external LittleFS file system, but the idea is to let users choose any fle. It's also not very optimized for memory, as it's only a proof of concept.

You can try a sample out in InfiniEmu, currently the ASM screen is the app with the eye icon. The firmware is running the following assembly code, which only takes 78 bytes when compiled:

showStatusIcons

createLabel
dup
storeLocal 0

push #0
push %TEXT_FONT
push #4
setStyleLocalFont

createLabel
dup
dup
dup
storeLocal 1

push date
loadString
setLabelText

push #0
push #0
push #60
setObjectAlign

push #0
push %TEXT_COLOR
push #0x999999
setStyleLocalColor

startPeriodicRefresh

refresh:
    loadLocal 0
    dup
    pushCurrentTime
    push format
    loadString
    formatDateTime
    setLabelText

    realignObject

    waitRefresh
    push refresh
    jump

format: .str %H:%M
date: .str MON 6 FEB 2024

Copy link

github-actions bot commented Jul 7, 2024

Build size and comparison to main:

Section Size Difference
text 383180B 5972B
data 940B 0B
bss 63556B 0B

@everypizza1
Copy link
Contributor

It looks like the battery and charging icons are duplicated when you exit, at least in the emulator:
duplicate

@pipe01
Copy link
Contributor Author

pipe01 commented Jul 8, 2024

Oh you're right, it isn't being cleaned up.

@0x0000ff
Copy link

0x0000ff commented Aug 4, 2024

That's cool. I'm not too clued up on assembly, but is there an assembler available for this or did you hand-write the machine code?

@pipe01
Copy link
Contributor Author

pipe01 commented Aug 4, 2024

I'm using a crude assembler written in Go, I'll release a proper one if this PR gets merged or if you want to toy around with it. Maybe some visual programming thing would be cool too, but that's just an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants