I’ve always loved the retro feel seven segment displays give off and I feel they are an awesome fit for the aesthetic of “Objects in Space”. Today I was able to overcome a problem that was stumping me for a while… How to display 2 dynamic length integer variables on the same display with blank leading digit padding…. now that’s a mouthful. I’m happy to say I did crack it and manage to come up with something that looks good!
I’m kind of taking a “More is More” approach for building this console. I want new users to be somewhat overwhelmed by all the displays, LEDs, switches, ect. So Id love to have many of these displays on the panel displaying a wealth of info. Not all of which will be immediately useful when playing the game, but in in “reality” would be found in a spaceship bridge. I’m also thinking having an auxiliary panel somewhere displaying the players bank funds on a 7-seg display would be cool…. somehow making it fit “plausible lore” as well.
Nothing too exciting today. I cut two support pieces out of half inch MDF and brought my my two side walls together. Now that it can stand on it’s own I can finally set it up on a table and get a good sense of its size, it feels just right! I did also buy some 1/4 inch MDF that will become the face of the panel, but work on that will begin later on.
I have cleaned up my code from my previous post and want to make it available for anyone to try out themselves. This code drives two 5v volt meters much like the developers have in their MkII console.
Remember to set “hardware=true” in your game’s config file or else it wont work!
/* Objects in Space Panel Meters
This example displays telemetry from the game on an LCD and 5v panel meters.
It uses the built-in LiquidCrystal library - see
https://www.arduino.cc/en/Reference/LiquidCrystal for details.
DISPLAYS POWER FLOW AND TOTAL POWER AS A PWM ON THE LCD SCREEN AND
PASSES IT TO PWM PINS 9 AND 10 FOR USE ON 5V PANEL METERS.
The LCD is only used to display data for debuging purposes and can be
omitted without affecting the meters.
CODE BY DAK47922 - http://www.wolfpack.xyz/blog
int flow; //Declare our variables as integers
// Initialise the LiquidCrystal library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Create an ObjectsInSpace object. The first parameter is the
// serial interface to use. The second is the number of values
// we're requesting from the game.
ObjectsInSpace OIS(Serial, 2);
pinMode(9, OUTPUT); // POWER FLOW PWM TO METER
pinMode(10, OUTPUT); // BATTERY PWM TO METER
// set up the LCD's number of columns and rows:
// specific for a 16x2 LCD screen (change this for different sizes)
Serial.begin(9600); //must be 9600
OIS.begin(); //begin the handshake/synchronisation with the game
// register the command to get the power flow from the game. (a value between -100 and 100)
// register the command to get the total power from the game. (a value between 0 and 100)
OIS.activate(); //stop syncing and ACTIVATE
OIS.update(); //required to keep getting info from the game.
// because we registered this in setup(), this gets called every time
// OIS.update() is called. therefore our info is refreshed
void powerflowCallback(int channel, int data)
flow = map(data, -100, 100, 0, 255); // Converts our -100 to 100 value to a useable PWM value (0 to 255)
lcd.setCursor(0,0); // Set the cursor to the top left of the screen (0,0)
lcd.print("FLOW PWM: "); // Prints our label on the screen plus 3 empty spaces to insure our value which can be 1, 2, or 3 digits is properly cleared and reprinted
lcd.setCursor(9,0); // Backs up 3 spaces to print our data value on the empty spaces from the previous line
lcd.print(flow); // prints our PWM value
analogWrite(9, flow); // Writes our PWM value to pin 9
void powerlevelCallback(int channel, int data)
power = map(data, 0, 99, 0, 255); // Converts our 0 to 100 value to a useable PWM value (0 to 255)
//The game never truely goes to 100 so we use a value of 99 here to ensure our guage points to full when the ship is fully charged
lcd.setCursor(0, 1); //set the cursor to the 1st position of the second row
lcd.print("BATT PWM: "); // Prints our label plus 3 empty spaces like above
lcd.setCursor(9,1); // Backs up 3 spaces to print our data value on the empty spaces from the previous line
lcd.print(power); // prints our PWM value
analogWrite(10, power); // Writes our PWM value to pin 10
My 2nd meter came in today and happily works as expected. It’s awesome to see both working in tandem displaying the correct information. There is a minor issue with the new meter however… when the needle is near the middle of the guage it contacts the inside plastic. Fixing it should be straightforward. Nothing else to report yet, won’t be doing any panel work today. The only other items left to arrive for now are my torpedo launch buttons and the safety cover for them. I do have 2 “tools” on the way but aren’t directly related to this build. I will do a write up when they arrive.
Not too much new to report today, I did receive my magnetic reed switches. You probably know them as the security switches used on doors and windows. Essentially is a switch that closes when subjected to a magnetic field, more on how I plan to incorporate them into my ship later.
I did buy some half inch MDF and cut it with my new jigsaw to make up the 2 side panels of one console tower. I decided to use a design similar how the developers made their console.
My design merges each tower and its “foot” panel into one piece.I also decided to increase the angle of that foot panel. the devs use a 5 degree angle whereas mine will be 15 degrees. The face of the panels will be using 1/4 inch MDF
On an unrelated side note While I was at work today I was able to accomplish something i’ve been trying to do for a while now. I was able to download an Image from the International space station via radio as it passed over head, very cool! They will be transmitting for three more days so I hope to receive more.
Well one of them has anyway, 2 days ahead of schedule! I rushed into work with arduino in hand to test it with a coworker. (I get most of my items shipped to my workplace)
I am pleased to report it works natively with my code without any modification. In this video you can see it represent my total available ship power. The only small issue is that the needle isn’t perfectly smooth in its motion. this can be explained by me using rounded integers as a PWM value. this may be fixed by substituting my custom made math formula in favor using the map() function I mentioned in my previous post… but tbh i’m just nitpicking.
I also started drafting up some console designs this morning. I would love for all the panels to be nice and close and within arms reach, mimicking the feel of a somewhat bulkier fighter jet cockpit…. I foresee a lot of complicated cutting angles in my future! More to report on that later. I cant wait tor my second meter to arrive and have them both runing in tandem. I’ll also have to start looking into taking them apart and making a custom meter faceplate, fun stuff ahead!
So in my adventures with this arduino project I’ve mainly been doing system testing by building small circuits. I am going to use some panel meters to display my ships batteries and power flow. I bought two 5v meters from aliexpress for this purpose. They have yet to arrive but I THINK I have come up with some code that will work. The game outputs the data in two ranges. 0 to 100 and -100 to 100. Initially I figured I would need to mathematically convert those ranges to 0 to 255 so I can use PWM to drive the meters. I spent some time putting a system in place to convert the data…….. then the next day I discovered arduino already has a method of doing this built it. Behold the map() function. Oh well, I’ll switch it over later.
I also was able to drive a MAX7219 seven segment display to display my ships current heading.
Initially I thought this would be the hardest thing to code because of the way the LedControl.h library works. However I discovered the DigitLedDisplay.h it provides a super simple way do display multi digit numbers and even custom characters via binary. I want to have a bunch of these displays display things like, ship heading, motion heading, player money etc.
I do have some other hardware on the way as well such as torpedo buttons with safety covers, more displays, meters, and some minor tools. Oh! And a pair of magnetic Reed switches for a cool idea I have but more on that later down the road. :3
Today I also bought myself a decent jigsaw…. it was a long time coming hehe. I suppose I’ll have to get some of the structural MDF soon. Having the materials really helps me to plan… weirdly enough.