I have sucessfully made a bigger project work. Its a nixie-clock that has a lot of features.
Sadly, i'm more the person that likes to design pcb-boards and solder things on it :-[, programming is very nice and interesting and also one of the bigger tasks in a project. So for my mainly programming isn't the real "hobby" - its more a means for the purpose for me : .
Five months ago i made my first trying sketch for this project, and now the code is in a state were it operates correctly and whats "okay" in my eyes. Before this project i only had done very basic or relatively uncomplex sketches and projects.
First i used the Arduino-IDE then i switched to a Software calles "Sloeber" (Eclipse-Based) since this software displays the errors in real time and you have this nice "function tree" where you can hop to functions in the code.
I know that there are alot of thins in the code that might not be "nice" or to common rules of coding, and that there is a lot of potential to make it better. My main problem that i currently see is, that there is not much space left for anything, so future expanding of functions might be difficult.
Maybe alot of things can made better,faster and more efficient, but my knowledge of coding is not that high.
I have uploaded the complete project on my website:
and the code is also on Github
Mabye someone here in the forum would like to help me improve the code?
My main problem that i currently see is, that there is not much space left for anything, so future expanding of functions might be difficult.
Sure, there's several K of program space and ~100 bytes of RAM that could be removed. What are the numbers now?
You can delete checkSerial. It's never called, and it's a little dangerous. It won't affect your numbers because it was probably optimized out, though.
-dev:
Sure, there's several K of program space and ~100 bytes of RAM that could be removed. What are the numbers now?
You can delete checkSerial. It's never called, and it's a little dangerous. It won't affect your numbers because it was probably optimized out, though.
This is currently not in use, but will be at a later time,when the Windows CMD part is finished. checkSerial will then be used to set time via cmd window.
The clock looks very nice. The main comment I have about the design is instead of recommending a separate third party NTP device, it may be better to incorporate it into your own development. That has the advantage that the clock control parameters (time zone, time server, 12/24hour display etc. etc. ) can all be set via a web browser instead of through the rotary switch. Infra red is also a convenient way of entering parameters, time setting etc.
CrossRoads:
Going by the old engineering mantra "If it ain't broke, keep fixing it until it is" I see.
Can always move to a processor with more memory or more IO, like from a '328P to a '1284P.
The reality is you won't save much programming space unless you are doing something incredibly inefficient, so buying more capable hardware probably is the right answer. Not that you shouldn't improve your code (since there are some weird ways of doing things in there), but it may not get you what you want.
Anyways, here is an example of something you can improve and save a few instructions.
//note that case 0 & 3 above both do nothing, hence the inequality check, but based
//on my understanding of the code you could even drop the inequality check
if(bulbMode == 3 && bulbOne != bulbTwo)
{
//all you do is swap the states of the booleans, so much cleaner here
bulbOne = !bulbOne;
bulbTwo = !bulbTwo;
}
void gpsSerialInit() {
//This function loads saved baud-rate and initializes the gps_port.
 byte bdrt = readEEPROM(STORAGE_ADDRESS, EEPROM_BDRT);
 switch (bdrt) {
 case 1:
  gps_port.begin(9600);
  break;
 case 2:
  gps_port.begin(4800);
  break;
 case 3:
  gps_port.begin(19200);
  break;
 case 4:
  gps_port.begin(38400);
  break;
 case 5:
  gps_port.begin(57600);
  break;
 case 6:
  gps_port.begin(115200);
  break;
}
with something like:
void gpsSerialInit() {
//This function loads saved baud-rate and initializes the gps_port.
 byte bdrt = readEEPROM(STORAGE_ADDRESS, EEPROM_BDRT);
 gps_port.begin(4800L * (bdrt+1) );
}
The actual formula to use the exact same EEPROM values is a little different, as it would involve both a multiplication by 2 or 3, and a multiplication by a power of two.
But you could use it as is, and just store the appropriate multiplier in EEPROM at the time when it is configured. I didn't look to see how you do that.
You have some other giant switch case statements that could be made more memory efficient by using table look-up. You can put the tables in program memory. However, it will make the program more difficult to read and maintain.
The ntp device is only my personal choice since gps cant be received inside building, it is kind of a "gps emulator" since it sends out fake gps messages, to to devices it looks just like a gps. It was mainly designed for exisiting clocks that use gps. I wanted to make it possible to either use gps or this ntp thing. I don't know on what the nwts is based...