Laser Projector Digital Clock


#1

Using Laser Projectors and some really shoddy code, I got a digital clock to work.

Unfortunately, using 8 laser projectors is a terrible idea both economically and performance-wise. :sweat_smile:

Also, the hit effect decals seem to be missing, so it’s hard to read the numbers through the laser beams.


Starcade's Digital Display for laser projector
#2

Dude, that’s a really neat idea.


#3

I can’t claim the idea, it was mentioned in the Developer Stream last Friday.

Twitch Archives

https://youtu.be/wj_mKVYjAzY?t=47m3s


#4

Ah. Well, it’s still neat, though.


#5

Oh my! I only meant making an analog clock, because you could write fairly simple code for the hands. This looks really complex, how big must the code be?

Yeah, this was due to a last-minute critical bug that they had to be left out until we figure out a solution. They will make a return, hopefully very soon.


#6

It’s probably a lot longer than it needs to be as this was a bit of a test and I’m a scrub.

Here’s the code for anyone interested or that want to mess with it.
This will display the units part of the seconds of the current time.

The code
# Keep position the same
x' = x;
y' = y;

# Define each segment of the clock face
top = (y<-80);                    # Top Segment
top_left = (((x>80)+(y<0))>1);    # Upper Left Segment
top_right = (((x<-80)+(y<0))>1);  # Upper Right Segment
middle = (((y>-10)+(y<10))>1);    # Middle Segment
bot_left = (((x>80)+(y>0))>1);    # Bottom Left Segment
bot_right = (((x<-80)+(y>0))>1);  # Bottom Right Segment
bot = (y>80);                     # Bottom Segment

# Define each number using the segments
m0 = top + top_left + top_right + bot_left + bot_right + bot;           # Number 0
m1 = top_left + bot_left;                                               # Number 1
m2 = top + top_right + middle + bot_left + bot;                         # Number 2
m3 = top + top_right + middle + bot_right + bot;                        # Number 3
m4 = top_left + top_right + middle + bot_right;                         # Number 4
m5 = top + top_left + middle + bot_right + bot;                         # Number 5
m6 = top + top_left + middle + bot_left + bot_right + bot;              # Number 6
m7 = top + top_right + bot_right;                                       # Number 7
m8 = top + top_left + top_right + middle + bot_left + bot_right + bot;  # Number 8
m9 = top + top_left + top_right + middle + bot_right;                   # Number 9

# Calculate time
#hours = floor( time / 3600 );
#mins = floor( time / 60 % 60 );
secs = floor( time % 60 );
number = secs % 10;

# Work out which number should be displayed
v0 = (((number>-1)+(number<1))>1)*m0;
v1 = (((number>0)+(number<2))>1)*m1;
v2 = (((number>1)+(number<3))>1)*m2;
v3 = (((number>2)+(number<4))>1)*m3;
v4 = (((number>3)+(number<5))>1)*m4;
v5 = (((number>4)+(number<6))>1)*m5;
v6 = (((number>5)+(number<7))>1)*m6;
v7 = (((number>6)+(number<8))>1)*m7;
v8 = (((number>7)+(number<9))>1)*m8;
v9 = (((number>8)+(number<10))>1)*m9;

# Display the number
v = v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9;

Awesome. Maybe it will make this a lot more legible.

It would also be cool to control the alpha of both the beam and decal separately, although I know this may make things unrealistic. It could help create some cool effects.


#7

That’s really clever.

Also, you can change the brightness of the beams by using the opacity slider, which doesn’t affect the laser points… that are not there for the time being :stuck_out_tongue:


#8

Update to the Digital Clock. I got it working in HH:MM format in 1 Laser Projector. Now that there’s endpoints, the numbers are considerably more legible. This code was written before the new expressions and if statements were added, so it’s quite a mess.


Laser Coordinates: Rectangular Grid
Grid Size: 20x20
The code (really bad):

# Keep positions the same
x' = x;
y' = y;

# Colours to help with legibility
# COLOURS ARE SLIGHTLY BROKEN(?!)
col_t_l = 0;
col_t_r = 10;
col_b_l = 30;
col_b_r = 40;

# Convert coords into more simple x and y
fake_x = abs(((x>0)*(100-x))+((x<0)*(-x)));
fake_y = abs(((y>0)*(y))+((y<0)*(100+y)));

# Define the 4 areas of the clock
area_t_l = ((x>0)+(y<0)) > 1;
area_t_r = ((x<0)+(y<0)) > 1;
area_b_l = ((x>0)+(y>0)) > 1;
area_b_r = ((x<0)+(y>0)) > 1;

# Define the 8 segments of the time_s_2s
seg_t =   (fake_y<20);
seg_t_l = ((fake_x<20)+(fake_y<50))>1;
seg_t_r = ((fake_x>80)+(fake_y<50))>1;
seg_m   = ((fake_y>40)+(fake_y<60))>1;
seg_b_l = ((fake_x<20)+(fake_y>50))>1;
seg_b_r = ((fake_x>80)+(fake_y>50))>1;
seg_b   = (fake_y>80);

# Define 0 to 9 using the segments
num_0 = seg_t   + seg_t_l + seg_t_r + seg_b_l + seg_b_r + seg_b;
num_1 = seg_t_l + seg_b_l;
num_2 = seg_t   + seg_t_r + seg_m   + seg_b_l + seg_b;
num_3 = seg_t   + seg_t_r + seg_m   + seg_b_r + seg_b;
num_4 = seg_t_l + seg_t_r + seg_m   + seg_b_r;
num_5 = seg_t   + seg_t_l + seg_m   + seg_b_r + seg_b;
num_6 = seg_t   + seg_t_l + seg_m   + seg_b_l + seg_b_r + seg_b;
num_7 = seg_t   + seg_t_r + seg_b_r;
num_8 = seg_t   + seg_t_l + seg_t_r + seg_m   + seg_b_l + seg_b_r + seg_b;
num_9 = seg_t   + seg_t_l + seg_t_r + seg_m   + seg_b_r;

# Define the time
    # Hours (all, tens, units)
time_h   = floor( time / 3600 );
time_h_1 = floor( time_h / 10 );
time_h_2 = ( time_h % 10 );
    # Minutes (all, tens, units)
time_m   = floor( time / 60 % 60 );
time_m_1 = floor( time_m / 10 );
time_m_2 = ( time_m % 10 );
    # Seconds (all, tens, units)
time_s   = floor( time % 60 );
time_s_1 = floor( time_s / 10 );
time_s_2 = ( time_s % 10 );

# Top Left (Hours -> Tens)
final_t_l_0 = (((time_h_1>-1)+(time_h_1<1))>1)*num_0*area_t_l;
final_t_l_1 = (((time_h_1>0)+(time_h_1<2))>1)*num_1*area_t_l;
final_t_l_2 = (((time_h_1>1)+(time_h_1<3))>1)*num_2*area_t_l;
final_t_l_3 = (((time_h_1>2)+(time_h_1<4))>1)*num_3*area_t_l;
final_t_l_4 = (((time_h_1>3)+(time_h_1<5))>1)*num_4*area_t_l;
final_t_l_5 = (((time_h_1>4)+(time_h_1<6))>1)*num_5*area_t_l;
final_t_l_6 = (((time_h_1>5)+(time_h_1<7))>1)*num_6*area_t_l;
final_t_l_7 = (((time_h_1>6)+(time_h_1<8))>1)*num_7*area_t_l;
final_t_l_8 = (((time_h_1>7)+(time_h_1<9))>1)*num_8*area_t_l;
final_t_l_9 = (((time_h_1>8)+(time_h_1<10))>1)*num_9*area_t_l;

# Top Right (Hours -> Units)
final_t_r_0 = (((time_h_2>-1)+(time_h_2<1))>1)*num_0*area_t_r;
final_t_r_1 = (((time_h_2>0)+(time_h_2<2))>1)*num_1*area_t_r;
final_t_r_2 = (((time_h_2>1)+(time_h_2<3))>1)*num_2*area_t_r;
final_t_r_3 = (((time_h_2>2)+(time_h_2<4))>1)*num_3*area_t_r;
final_t_r_4 = (((time_h_2>3)+(time_h_2<5))>1)*num_4*area_t_r;
final_t_r_5 = (((time_h_2>4)+(time_h_2<6))>1)*num_5*area_t_r;
final_t_r_6 = (((time_h_2>5)+(time_h_2<7))>1)*num_6*area_t_r;
final_t_r_7 = (((time_h_2>6)+(time_h_2<8))>1)*num_7*area_t_r;
final_t_r_8 = (((time_h_2>7)+(time_h_2<9))>1)*num_8*area_t_r;
final_t_r_9 = (((time_h_2>8)+(time_h_2<10))>1)*num_9*area_t_r;

# Bottom Left (Minutes -> Tens)
final_b_l_0 = (((time_m_1>-1)+(time_m_1<1))>1)*num_0*area_b_l;
final_b_l_1 = (((time_m_1>0)+(time_m_1<2))>1)*num_1*area_b_l;
final_b_l_2 = (((time_m_1>1)+(time_m_1<3))>1)*num_2*area_b_l;
final_b_l_3 = (((time_m_1>2)+(time_m_1<4))>1)*num_3*area_b_l;
final_b_l_4 = (((time_m_1>3)+(time_m_1<5))>1)*num_4*area_b_l;
final_b_l_5 = (((time_m_1>4)+(time_m_1<6))>1)*num_5*area_b_l;
final_b_l_6 = (((time_m_1>5)+(time_m_1<7))>1)*num_6*area_b_l;
final_b_l_7 = (((time_m_1>6)+(time_m_1<8))>1)*num_7*area_b_l;
final_b_l_8 = (((time_m_1>7)+(time_m_1<9))>1)*num_8*area_b_l;
final_b_l_9 = (((time_m_1>8)+(time_m_1<10))>1)*num_9*area_b_l;

# Bottom Right (Minutes -> Units)
final_b_r_0 = (((time_m_2>-1)+(time_m_2<1))>1)*num_0*area_b_r;
final_b_r_1 = (((time_m_2>0)+(time_m_2<2))>1)*num_1*area_b_r;
final_b_r_2 = (((time_m_2>1)+(time_m_2<3))>1)*num_2*area_b_r;
final_b_r_3 = (((time_m_2>2)+(time_m_2<4))>1)*num_3*area_b_r;
final_b_r_4 = (((time_m_2>3)+(time_m_2<5))>1)*num_4*area_b_r;
final_b_r_5 = (((time_m_2>4)+(time_m_2<6))>1)*num_5*area_b_r;
final_b_r_6 = (((time_m_2>5)+(time_m_2<7))>1)*num_6*area_b_r;
final_b_r_7 = (((time_m_2>6)+(time_m_2<8))>1)*num_7*area_b_r;
final_b_r_8 = (((time_m_2>7)+(time_m_2<9))>1)*num_8*area_b_r;
final_b_r_9 = (((time_m_2>8)+(time_m_2<10))>1)*num_9*area_b_r;

# Add it all up...
v_store = final_t_l_0+ final_t_l_1 + final_t_l_2 + final_t_l_3 + final_t_l_4 + final_t_l_5 + final_t_l_6 + final_t_l_7 + final_t_l_8 + final_t_l_9;
v_store = v_store + final_t_r_0+ final_t_r_1 + final_t_r_2 + final_t_r_3 + final_t_r_4 + final_t_r_5 + final_t_r_6 + final_t_r_7 + final_t_r_8 + final_t_r_9;
v_store = v_store + final_b_l_0+ final_b_l_1 + final_b_l_2 + final_b_l_3 + final_b_l_4 + final_b_l_5 + final_b_l_6 + final_b_l_7 + final_b_l_8 + final_b_l_9;
v_store = v_store + final_b_r_0+ final_b_r_1 + final_b_r_2 + final_b_r_3 + final_b_r_4 + final_b_r_5 + final_b_r_6 + final_b_r_7 + final_b_r_8 + final_b_r_9;

# Apply it to v
v = v_store;

# Apply colours
h = (col_t_l * area_t_l) + (col_t_r * area_t_r) + (col_b_l * area_b_l) + (col_b_r * area_b_r);
s = 1;

Todo:

  • Update to new If statements
  • Fix colours
  • Add spacing between numbers
  • (Try add flashing : somewhere)

#9

Holy fuck, that’s incredible.


#10

oh ok
it has barely been out for a week and this is what we get


Party Plaza
I uhh... started a thing
#11

Another Update. I think this is it. The end result. What it’s all been leading to. This.

Finally, HH:MM:SS time format in a single Laser Projector. It comes equipped with a few colour presets and scaling customisation.

Here’s the code for all your time-telling needs. I may try clean up/optimise this in the future.

###########################################################
# LASER PROJECTOR										  #
# DIGITAL CLOCK											  #
# - BOT Dan												  #
#														  #
# SETTINGS:												  #
# - Shape: Rectangular Grid								  #
# - Grid Size: 20 x 20									  #
# - Colour: White										  #
#														  #
# /!\ IF THE CLOCK/LASERS APPEARS INCORRECTLY, 			  #
# /!\ TRY ADDING SOME SPACES TO THE LINE BELOW (ABOUT 4)  #
# /!\ ALSO, MAKE SURE YOU HAVN'T DELETED A (;)			  #
# ->
#														  #
# Set the scale of the clock here						  #
scale = 4;
#														  #
# Set the distance between numbers here					  #
gap = 2;
#														  #
# Colour settings can be found at the bottom  			  #
###########################################################


# Make 7 (6x10) display squares ( Top-left = (0,0) )
fake_z = floor( index / 60 );
fake_y = floor( ( index - ( fake_z * 60 ) ) / 6 );
fake_x = ( index % 6 );

# Place the lasers into the display squares
x' = -( fake_x * scale + ( fake_z * ( 6 * scale + gap ) ) );
x' = x' - floor( fake_z / 2 ) * ( 2 * scale + gap );
x' = x' + ( 20 * scale ) + ( 3 * gap );
y' = ( fake_y * scale );
y' = y' - ( 5 * scale );

# Break up the 7th display square into 2 colon columns
fake_x = if( ( index>=360 & index<=379 ),
	( index % 2 ),
	fake_x);
fake_y = if( ( index>=360 & index<=379 ),
	floor( ( index - 360 ) / 2),
	fake_y);
	
fake_x = if( ( index>=380 & index<=399 ),
	( index % 2 ),
	fake_x);
fake_y = if( ( index>=380 & index<=399 ),
	floor( ( index - 380 ) / 2),
	fake_y);

# Position these 2 colon columns
x' = if( ( index>=360 & index<=379 ),
	-( fake_x * scale + ( 2 * ( 6 * scale + gap ) ) ) + ( 20 * scale ) + ( 3 * gap ),
	x' );
y' = if( ( index>=360 & index<=379 ),
	fake_y * scale - ( 5 * scale ),
	y' );
	
x' = if( ( index>=380 & index<=399 ),
	-( fake_x * scale + ( 4 * ( 6 * scale + gap ) ) ) + ( - floor( 3 / 2 ) * ( 2 * scale + gap ) ) + ( 20 * scale ) + ( 3 * gap ),
	x' );
y' = if( ( index>=380 & index<=399 ),
	fake_y * scale - ( 5 * scale ),
	y' );

# Define the 7 segments of a number and the ":"
seg_t =   (fake_y<=1);
seg_t_l = ((fake_x<=1) & (fake_y<=4));
seg_t_r = ((fake_x>=4) & (fake_y<=4));
seg_m   = ((fake_y>=4) & (fake_y<=5));
seg_b_l = ((fake_x<=1) & (fake_y>=5));
seg_b_r = ((fake_x>=4) & (fake_y>=5));
seg_b   = (fake_y>=8);
seg_dot = ( fake_y >= 2 & fake_y <=3 ) | ( fake_y >= 6 & fake_y <= 7 );

# Define 0 to 9 using the segments
num_0 = seg_t   + seg_t_l + seg_t_r + seg_b_l + seg_b_r + seg_b;
num_1 = seg_t_l + seg_b_l;
num_2 = seg_t   + seg_t_r + seg_m   + seg_b_l + seg_b;
num_3 = seg_t   + seg_t_r + seg_m   + seg_b_r + seg_b;
num_4 = seg_t_l + seg_t_r + seg_m   + seg_b_r;
num_5 = seg_t   + seg_t_l + seg_m   + seg_b_r + seg_b;
num_6 = seg_t   + seg_t_l + seg_m   + seg_b_l + seg_b_r + seg_b;
num_7 = seg_t   + seg_t_r + seg_b_r;
num_8 = seg_t   + seg_t_l + seg_t_r + seg_m   + seg_b_l + seg_b_r + seg_b;
num_9 = seg_t   + seg_t_l + seg_t_r + seg_m   + seg_b_r;

# Define the time
    # Hours (all, tens, units)
time_h   = floor( time / 3600 );
time_h_1 = floor( time_h / 10 );
time_h_2 = ( time_h % 10 );
    # Minutes (all, tens, units)
time_m   = floor( time / 60 % 60 );
time_m_1 = floor( time_m / 10 );
time_m_2 = ( time_m % 10 );
    # Seconds (all, tens, units)
time_s   = floor( time % 60 );
time_s_1 = floor( time_s / 10 );
time_s_2 = ( time_s % 10 );
	# Milliseconds
time_d   = floor( ( time % 1 ) * 10 )
	
v = 0;
# Hours -> Tens
v = if( time_h_1 == 0 & fake_z == 0, num_0, v );
v = if( time_h_1 == 1 & fake_z == 0, num_1, v );
v = if( time_h_1 == 2 & fake_z == 0, num_2, v );
v = if( time_h_1 == 3 & fake_z == 0, num_3, v );
v = if( time_h_1 == 4 & fake_z == 0, num_4, v );
v = if( time_h_1 == 5 & fake_z == 0, num_5, v );
v = if( time_h_1 == 6 & fake_z == 0, num_6, v );
v = if( time_h_1 == 7 & fake_z == 0, num_7, v );
v = if( time_h_1 == 8 & fake_z == 0, num_8, v );
v = if( time_h_1 == 9 & fake_z == 0, num_9, v );

# Hourv -> Units
v = if( time_h_2 == 0 & fake_z == 1, num_0, v );
v = if( time_h_2 == 1 & fake_z == 1, num_1, v );
v = if( time_h_2 == 2 & fake_z == 1, num_2, v );
v = if( time_h_2 == 3 & fake_z == 1, num_3, v );
v = if( time_h_2 == 4 & fake_z == 1, num_4, v );
v = if( time_h_2 == 5 & fake_z == 1, num_5, v );
v = if( time_h_2 == 6 & fake_z == 1, num_6, v );
v = if( time_h_2 == 7 & fake_z == 1, num_7, v );
v = if( time_h_2 == 8 & fake_z == 1, num_8, v );
v = if( time_h_2 == 9 & fake_z == 1, num_9, v );

# Minutev -> Tens
v = if( time_m_1 == 0 & fake_z == 2, num_0, v );
v = if( time_m_1 == 1 & fake_z == 2, num_1, v );
v = if( time_m_1 == 2 & fake_z == 2, num_2, v );
v = if( time_m_1 == 3 & fake_z == 2, num_3, v );
v = if( time_m_1 == 4 & fake_z == 2, num_4, v );
v = if( time_m_1 == 5 & fake_z == 2, num_5, v );
v = if( time_m_1 == 6 & fake_z == 2, num_6, v );
v = if( time_m_1 == 7 & fake_z == 2, num_7, v );
v = if( time_m_1 == 8 & fake_z == 2, num_8, v );
v = if( time_m_1 == 9 & fake_z == 2, num_9, v );

# Minutev -> Units
v = if( time_m_2 == 0 & fake_z == 3, num_0, v );
v = if( time_m_2 == 1 & fake_z == 3, num_1, v );
v = if( time_m_2 == 2 & fake_z == 3, num_2, v );
v = if( time_m_2 == 3 & fake_z == 3, num_3, v );
v = if( time_m_2 == 4 & fake_z == 3, num_4, v );
v = if( time_m_2 == 5 & fake_z == 3, num_5, v );
v = if( time_m_2 == 6 & fake_z == 3, num_6, v );
v = if( time_m_2 == 7 & fake_z == 3, num_7, v );
v = if( time_m_2 == 8 & fake_z == 3, num_8, v );
v = if( time_m_2 == 9 & fake_z == 3, num_9, v );

# Minutev -> Tens
v = if( time_s_1 == 0 & fake_z == 4, num_0, v );
v = if( time_s_1 == 1 & fake_z == 4, num_1, v );
v = if( time_s_1 == 2 & fake_z == 4, num_2, v );
v = if( time_s_1 == 3 & fake_z == 4, num_3, v );
v = if( time_s_1 == 4 & fake_z == 4, num_4, v );
v = if( time_s_1 == 5 & fake_z == 4, num_5, v );
v = if( time_s_1 == 6 & fake_z == 4, num_6, v );
v = if( time_s_1 == 7 & fake_z == 4, num_7, v );
v = if( time_s_1 == 8 & fake_z == 4, num_8, v );
v = if( time_s_1 == 9 & fake_z == 4, num_9, v );

# Minutev -> Units
v = if( time_s_2 == 0 & fake_z == 5, num_0, v );
v = if( time_s_2 == 1 & fake_z == 5, num_1, v );
v = if( time_s_2 == 2 & fake_z == 5, num_2, v );
v = if( time_s_2 == 3 & fake_z == 5, num_3, v );
v = if( time_s_2 == 4 & fake_z == 5, num_4, v );
v = if( time_s_2 == 5 & fake_z == 5, num_5, v );
v = if( time_s_2 == 6 & fake_z == 5, num_6, v );
v = if( time_s_2 == 7 & fake_z == 5, num_7, v );
v = if( time_s_2 == 8 & fake_z == 5, num_8, v );
v = if( time_s_2 == 9 & fake_z == 5, num_9, v );

# Dots
v = if( time_d < 5 & fake_z == 6, seg_dot, v );

s = 1;
h = 0;

###########################################################
# OTHER SETTINGS AT THE TOP								  #
#														  #
# COLOUR SETTINGS:										  #
# - [1] Block Colour									  #
# - [2] Rainbow - Full									  #
# - [3] Rainbow - Horizontal							  #
# - [4] Rainbow - Vertical								  #
#														  #
# Set this to one of the numbers above					  #
colour_type = 1;
#														  #
# If using block colour, set your colour here (0-360)     #
colour_block = 0;
# 														  #
# If using rainbow, change the cycle speed here			  #
colour_speed = 100;
#														  #
# If using rainbow, change the stretch of colour		  #
colour_stretch = 1;
# 														  #
# /!\ IF THE CLOCK/LASERS APPEARS INCORRECTLY, 			  #
# /!\ TRY ADDING SOME SPACES TO THE LINE BELOW (ABOUT 4)  #
# /!\ ALSO, MAKE SURE YOU HAVN'T DELETED A (;)			  #
# ->
#														  #
###########################################################

h = if( colour_type == 1, colour_block, h );
h = if( colour_type == 2, time*colour_speed, h );
h = if( colour_type == 3, time*colour_speed + x'*colour_stretch, h );
h = if( colour_type == 4, time*colour_speed + y'*colour_stretch, h );

This needs to be run on a Rectangular Grid mode with a Grid Size of 20x20.


#12

Holy fuck, that’s awesome.