Close

Working hard to finalize Golang webserver/hardware controller

A project log for Prometheus Alarm Clock

Possessing both the beauty of the bygone analog age and the convenience of cutting edge tech, Prometheus is the ultimate alarm clock!

andrew-leeAndrew Lee 06/13/2017 at 15:280 Comments

The updated version of the software component of my project is on the dev branch of my github repository.

Furthermore, I changed the name from Atomic Clock to Prometheus (due to the numerous inventors cup type events I applied to as Prometheus Clock Project).

In this version, golang fully takes over the tasks of both the Node web server and the Python hardware controller. The reason I did this is on the previous project log, but to summarize, there are 2 main reasons: 1) golang is faster by a huge margin over python (due to it being statically compiled much like C or C++). Also, but having one executable, it makes it alot easier to package the program, and to set up boot time loading of the program and whatnot.

Some added features:

-Every input/button has been converted to ajax calls so that the page doesn't have to reload on the client side (Except the Snooze button [the virtual Nixie Clock at the top of the UI] since the calculation to add 10 minutes to the currently running alarm needs to be done on the server side anyways).

-Using Vue.js to control the elements of the page much more efficiently (mainly vue-bind and vue-model calls to ensure that the client side only pulls the necessary data initially at load time, and the rest of the time, can recycle the already loaded elements in the vue instance). If you haven't checked out Vue, I highly recommend it. Its a solid front end framework without alot of baggage from 1.x, or a religious adherence to a specific type of application abstraction model.

-One huge issue I was having was that for some reason, my IP (on the Pi) was getting reassigned every 2 months or so. And since I keep the clock right by my bed, it was a rather tedious task to connect my Pi to hardware display and input devices just to get the new IP. Hence, I implemented an email via smtp task to send the user an email notifying them of an IP change, and the address of that IP. Although the credentials for the sender is saved in plaintext in the main.go file, it is not a huge issue for me since it is a testing account I made specifically for this purpose.

-Before, the server saved the file as "alarm.mp3" by default. Hence, the only compatible files were mp3 and m4a files that were correctly encoded. However, in the new program, I implemented a regex search to seek out the actual file name,. Hence, when an alarm sound plays, it is format agnostic, and can play most sounds (flac, wma, fla) since the sound player is implemented via the CVLC media player.

Future fixes

-Sound is still not working properly. If I hit snooze when sound is playing, the second alarm 10 minutes after does not play sound. This could be an issue regarding how I am calling CVLC and not killing the process thoroughly

-I haven't not had enough time to test whether the IP emailing functionality will work (since this happens about once every 2 months). Will update when this becomes more clear

Future Updates (additive, not fixes)

-Created soldered PCB as well as running the programs on Pi Zero W. I want to use the money I received as part of Hackaday's Seed Funding to purchase the materials to make this a single component electronic system rather than a myriad of sub-components strung together by a breadboard.

-Incorporate a voltage regulator to be able to use the same power supply to power both the Pi, and the rest of the system.

-Refractor golang code (At this point in time, I have no special training in golang, and wrote the entire thing using stackoverflow and the api reference (The entire thing is in one main.go file and its a huge mess to try to debug). I believe I can write much better (cleaner) code by learning golang in its entirety (as well as its philosophy on package hierarchies)

Discussions