User Tools

Site Tools


projects:blinker:work_logs:7_code

This is an old revision of the document!


Code

The Plan

The message and the code to display the message on the LED must all live within the same 1024 bytes. I must strike a balance between efficient storage of the message, and efficient code to unpack and display that message. Cleverer code would let me crunch the message into less storage, but the code itself would probably take up more space to store the cleverness.

I am to hit a middle point of moderate cleverness and medium message storage density. I think a decent approach is to translate the text to Morse code outside the microcontroller, to keep the display code as small and simple as possible.

The Results

Storage

I wrote a python script that converts a provided string into a series of hex bytes in a header file that the microcontroller code uses to store the sequence.

The input `sos nbn` translates to:

uint8_t const sequence[] = {0x15, 0x77, 0x47, 0x05, 0x5c, 0x5c, 0xc5, 0x05};

If we write that out in binary in one solid blob (reversing the bit order):

1010100011101110111000101010000000111010001110101010001110100000

This is the sequence of on and off states for the LED. We can split it up like this:

  1  0  1  0  1  000 111 0 111 0 111 000  1  0  1  0  1   0000000...
|dit| |dit| |dit|   |dah| |dah| |dah|   |dit| |dit| |dit|

</code>

Video

Next Time

I don't think there's much point in trying to further improve energy efficiency of the code. The next steps might be adding features like multiple message sequences, and/or improving the space efficiency to fit more/longer messages.

projects/blinker/work_logs/7_code.1646051806.txt.gz · Last modified: 2022/02/28 12:36 by tjhowse