Stationeers

Stationeers

Not enough ratings
7 Segment LED Display
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
157.532 KB
13 Aug, 2022 @ 12:03pm
1 Change Note ( view )

Subscribe to download
7 Segment LED Display

Description
v1.0 - 08/13/2022

Description
--------------

This IC10 script will drive any number of custom 7 Segment Color Display made out of LEDs

-each display can display one digit (0 to 9)
-each display is driven by 3 ICs
-send data from an outside source to the main ICs Setting to start
-modulate your data to change the number, the colors, toggle optional LEDs on/off etc.
-each IC only updates itself when it gets new data
-easy to scale up, just repeat the steps to build 1 display (theoretical limit of 33 displays)

Q: Why do you use LEDs and not Wall Light (Long)
A: While the other lights look good, there is one huge upside to using LEDs: Color!
If you switch normal lights ON, they only shine white light and the contrast to their OFF state is not very good.
With LEDs you can color not only the light but the color will also be applied to the 'glass' when it is OFF and painting them black when they are off is so much better for readability.

Q: Why do you daisy-chain the ICs and not send data to each of them?
A: I mainly chose this method because it is easy to set up - you only need 1 script per IC and thats it.
Then just write the data to the main one and it will work-
In practice it works very well for 4 digits, even 5 or 6 should be good.

Build Setup
--------------
LEDs:

Start by placing 14 LEDs per display to form the typical 8 shape.
Optionally place one 15th LED per display.
This could be for the : for a clock or a decimal point.
Beware, currently these optional LEDs can only be ON or OFF all at once.

ICs:
You will need to build 3 ICs per display. Build them in front of the display and side to side for making it easier to set the screws later.

IMPORTANT! ALWAYS BUILD YOUR IC HOUSINGS IN THE OPPOSITE DIRECTION OF THE DATA FLOW!
Because the more displays you build and hook up the longer the data needs to travel to reach the last display and update it.
As numbers usually will change the rightmost digit more often, data flow from right to left is recommended so build your IC housings from LEFT to RIGHT.
We will send our data to the RIGHTMOST IC first, that will be the main IC, so we want to build the Housing for this IC LAST.

Why? Because Stationeers will run the code of the ICs not in parallel but in series.
The IC in the housing that placed last will get executed first.
Thanks to zkxs!

Labels:
You will need to name your LEDs and IC Housings!
I recommend to label the ICs from right to left (same as data flow):

Rightmost IC: D1-IC1 (The main IC)
The next one to the left: D1-IC2, then next one D1-IC3 etc.
and if you have a second display the next ICs to the left would be D2-IC1, D2-IC2 etc.

Now label all the LEDs:

Start by the rightmost display
Start by naming the lower left LED LED1-1
Go up to the next LED LED1-2 and so on
If you are at the top move one column to the right and go down
Then repeat the system by basically doing a M pattern
If you plan to use the optional 15th LED I recommend naming them LEDopt1 etc.
If you have more then 1 display repeat this for the others: LED2-1, LED2-2 etc.

Screw Setup
--------------

Take a look at the LED Setup image to see how you have to set up the screws on the ICs.

If you stand in front of your first display you should have 3 ICs for this display.
Start with the left one named D1-IC3. Now set the screws in the order that you named them:
d0 to LED1-1
d1 to LED1-2
d2 to LED1-3
d3 to LED1-4
d4 to either LEDopt1 or leave it NoDevice
d5 to the next IC to the LEFT D2-IC1 or NoDevice if this is your last or only display

Then go right to IC in the middle D1-IC2:
d0 to LED1-5
.
.
d4 to LED1-9
d5 to the IC to its left D1-IC3

Then the last one D1-IC1:
d0 to LED1-10
.
.
d4 to LED1-14
d5 to D1-IC2

Now repeat that for any other displays that you have until you are finished!

Installation
--------------

Get to a computer in the network, load this script from the library and write it to every IC.
Done.

To test the displays you would have to send some data to the main IC D1-IC1 by writing to its Setting variable.

If you want to do a quick test you can do this with 2x Kit (Logic I/O) but I recommend you set up another IC and program it to send the data.

For a quick test use:
1x Logic Memory
1x Logic Writer

Logic Writers In reads from the Memory, Out goes to D1-IC1 and Out Var is Setting.
To test if all LEDs light up set the Memory to 888816700

Now all of your LEDs, including any optionals, should light up in white
If you have less than 4 displays, they will only show as many digits as they can.
Send any negative number to set all LEDs OFF, for example -1 or -888816700

Data Format
--------------

The data you send can be any whole number or even nothing. But to work with it you have to know how it is formatted:
In this example we use 123416700 as our data:

00
The 2 rightmost digits always have to be set to 00

This is the internal position counter. Don't touch it!

7
The next digit is the color when LEDs are OFF.
I would use 7 which is black

6
The next digit is the color when LEDs are ON.

0 - Blue (buggy until game patch)
1 - Grey
2 - Green
3 - Orange
4 - Red
5 - Yellow
6 - White
7 - Black
8 - Brown
9 - Khaki
Unsupported colors:
10 - Pink
11 - Purple

A note on updating colors
As the displays only update themselves if their digit changes, simply changing the color of the LEDs will not show until the number changes.
You can simply send a short 8888 number as new data for one tick but the proper way would be to add 1 to every digit of the number to display.

1
The 5th digit from the right is the switch for the optional LEDs.
0 is OFF and 1 is ON

1234
Every other digits to the left form the number that will be displayed.
Can be a any positive whole number between 0 and 999999999...

NOTICE!
ANY negative data received will set ALL LEDs to OFF.
This is the intended way as a power OFF switch.
If you want to display negative numbers you have to build a minus sign out of the optional LEDs and it ON/OFF accordingly.

Encoding Data
--------------

Now if you want to make proper use of your display hook up another IC that sends data to the main IC D1-IC1.
To encode the numbers and values you want into the data you have to multiply by the power of 10 and add to it.

A simple Script that encodes and sends data:
alias display d0 #D1-IC1
alias number r0
alias temp r1
alias data r2
define colorOn 6
define colorOff 7
define optionalLED 1
start:
move number 1234
mul data colorOn 100 #600
mul temp colorOff 1000
add data data temp #7600
mul temp optionalLED 10000
add data data temp #17600
mul temp number 100000
add data data temp #123417600
s display Setting data
yield
j start

Closing Notes
--------------

The script itself is highly golfed to have as little lines of code as possible and to switch the LEDs as fast as possible.
This makes the script very hard to read, but feel free to experiment or ask me anything on steam or in the comments.
If I could reduce the number of instruction calls further it would directly relate to better LED switching speeds.

Any other script that is running will use up processing power and slows down the displays!

I optimized this script for my Moon clock. I use a daylight sensor and the sun angle to calculate the time.
My Moon clock script will be published in the near future.

A big 'THANK YOU' to everyone in the logic-circuit-discussion channel!