Fancy Clock
From GMod Wiki
Contents |
A Fancier Clock
Fancy Clock: A Fancier Clock |
Description: | Displays the time... stylishly. |
Original Author: | Entoros |
Created: | December 28, 2008 |
Notes: | This version is set to Central Time, just FYI. |
Getting the Parts
To start out, we need to spawn all of the components necessary to make the holo circle happen. It'll be mostly in expression for now, but I can put on the regular gates if y'all want. If you're not sure where to place things, look at the image. So, to start out, follow these steps:
- Spawn a 2x4 tiled plate (from PHX, but not the metal kind).
- On the plate, spawn four 7-Segment Displays in a row with the top color as black, and the bottom as green.
- In between the two middle 7-Segments, spawn two wire Indicators to make the colon (Value On: 1, Green; Value Off: 0, Black)
- Spawn four 7-Segment decoders (Gate - Selection) underneath each 7-Segment display.
- Next, spawn an OS Time chip (Gate - Time) and a Time/Date decoder (Gate - Selection).
- Create an Expression 2 chip with the following code:
@name Clock @inputs Hours Minutes Seconds @outputs Hours1 Hours2 Minutes1 Minutes2 Seconds1 Seconds2 Flash @persist
if(Hours >= 12){Hours1 = floor((Hours-12)/10)} elseif(Hours == 0){Hours1 = 1} else{Hours1 = floor((Hours)/10)} Hours2 = Hours-12
Minutes1 = floor(Minutes/10) Minutes2 = Minutes
Seconds1 = floor(Seconds/10) Seconds2 = Seconds
interval(500) if(Flash){Flash = 0} else{Flash = 1}
If you choose to make it a clock that shows seconds aswell it should look like this | Giant Clock.jpg
Wiring the Components
Now that everything's just awaiting to be wired, let's get cracking.
- Wire the "A" of each segment on the 7-Segment Display to the corresponding letter on the decoder below.
- Wire the "Time" of the Time/Date Decoder to the OS Time chip.
- Wire the "Hours" of the Expression 2 to the "Hours" of the Time/Date Decoder, "Minutes" to "Minutes", etc.
- Wire the "A" of each decoder to its corresponding output of the Expression 2; i.e. the first segment goes to the Hours1, the second to the Hours2, and so on.
- Wire the "A" of the Indicator to the "Flash" of the Expression 2.
The Finished Product
The clock should be complete now, with it's own blinking colon in the middle. If you want to make it even fancier, try the following:
- Add two extra 7-segments for the "Seconds".
- Change the 2x4 plate to black, so it shows up better.
- Add an outline to the clock, as shown.
- If you're feeling REALLY fancy, put a 2x4 glass plate in front of the 7-segments to have a true clock.
Explanation
Wondering how exactly the whole time decoder thing works? Well, if you take a look at your OS Time chip, you'll notice it goes +1 every second. It basically starts at zero (12:00 AM) and adds a second every second, so the Time Decoder just divides the total number of seconds and floors it to get the hours/minutes/seconds. The 7-Segment decoders basically display the ones digit of whatever number given, so we by flooring the number of hours divided by 10, we get the first digit. (it's 7:50 AM; 7/10 = .7, floored = 0, so the first 7-Seg shows 0). The flashing colon is just for fun.