|
Ham Clock This page refers to my QST article in the October 2017 issue. All updates will be posted here. I would like to give Shoutouts to Adafruit and the Raspberry Pi Foundation for their great products, software and documentation.
News highlights: See the complete version history in the Download tab and
details in the User Guide.
|
Corrections:
http://Your-HamClock-IP/set_sattle?name=abc&t1=line1&t2=line2Like all the server commands, you can send this with most browsers or with curl or wget from the command line.
hamclock-fb0-small
Makefile target for RPi's with 7" screensSee the ESP8266 Notes tab.
See the Desktop tab.
No, it can not run natively on Windows but it can display on Windows by using an X Server. The idea is to run the HamClock program on a UNIX-like system, such as RPi or WSL (Windows Subsystem for Linux) or Cygwin, then run HamClock in such a way that it displays on the X Server running on Windows.
For example:
make -j 4 hamclock-800x480 export DISPLAY="192.168.7.129:1" ./hamclock-800x480
Note in the example above, 192.168.7.129 is the IP of the Windows machine, so change that to match your system configuration. Also note the ":1" of the DISPLAY environment variable says to use X Server display 1, which corresponds to the selection I made while running XLaunch. If you find it won't connect, it might be due to your Windows firewall. X Window servers listen on port 6000 + display_number, so in this case be sure Windows is allowing incoming connections on port 6001.
Similar answer as previous FAQ but you'll need an X server app for iPad. I find Mocha X11 works well.
I do not have a Geochron 4K but from its literature I can think of the following display functions related to ham radio that HamClock offers but Geochron does not:
Conversely, Geochron can do things HamClock can not. These items are certainly interesting but to me they do not seem specifically useful to the typical amateur radio operator:
If I have misrepresented Geochron in any way, please tell me how and I will correct immediately.
filter1 reject not by_zone 3,4,5 filter2 reject not on hf/cw filter3 reject on hf/rtty filter4 reject on hf/ssb filter5 reject info ft8
No. Each size requires its own custom fonts, symbols, maps and solar images in order to take full advantage of the higher resolutions. Otherwise, these would be very pixelated if they were just multiples of the base images. Plus, if the aspect ratio changes, the layout would need to be rebalanced. This is why all sizes are multiples of 2 of the base size in order to maintain the same layout proportions.
Because displaying location only to a whole degree, or any finite precision, can be ambiguous. Suppose you use the Setup screen to enter location 40N and 100.1W. This is in grid square DN90. But this location will be rounded to 40N 100W for display and this location is in grid square EN00. Just looking at the rounded HamClock display values you can't tell what the original location is, so HamClock gives you the choice of selecting the grid according to your intended usage.
The reason this happens is because grid squares increase from west to east, starting at 180W, and the major longitude grid boundaries are on even integral values. Thus 100W is in one grid and 100.1W is in a different grid. This becomes easier to see when using signed notation. You might expect moving from -100 to -100.1 would stay in the same grid but it doesn't because it is more westward and crosses the boundary at -100. But there is no ambiguity going from -101 to -101.1 because these are both near the center of the same grid, DN90. There is also no grid change going from the eastern longitude of positive 100 to 100.1 because the numeric increase is eastward and both locations are in the same grid, ON00.
The exact same thing happens with latitudes except they grow northwards from 90S and grid boundaries are on every integral line.
In addition to being set from the Setup screen, fractional coordinates can also result when setting location with other methods as well, such as IP Geolocation, gpsd or the remote web socket interface -- in all cases the full precision is maintained internally but only displayed to whole degrees. However, if you set a location by tapping the map or tapping the coordinate values to increment or decrement them then HamClock discards any fractional coordinate values so these methods never lead to a grid square ambiguity.
Among its other features, the HamClock is also a web server on port 8080. This allows you to remotely control your HamClock over a network using a browser or command line tool such as curl or wget.
To try the following examples, you will need a computer on the same network as your HamClock. Here we will use curl but the same URLs will work in your browser as well (although some browsers are getting more paranoid about accessing a web site with http and you may be asked to trust the site).
Start by querying HamClock for a list of all its commands as follows: (actually any unrecognized command will produce this help text)
curl 'http://192.168.7.101:8080/help'
The output will be a list of all supported commands as follows:
Syntax | Summary |
---|---|
get_capture.bmp | Save screen as bmp file |
get_config.txt | Report current HamClock configuration settings |
get_de.txt | Report DE info |
get_dx.txt | Report DX info |
get_dxspots.txt | Report current list of DX cluster spots |
get_satellite.txt | Report current satellite position, if one is defined |
get_sensors.txt | Generate list of sensor values, if one is attached |
get_stopwatch.txt | Report stopwatch state and timer value |
get_sys.txt | Report some basic HamClock system information |
get_time.txt | Report HamClock's idea of UTC |
set_displayOnOff?on|off | Turn display on or off |
set_displayTimes?on=HR:MN&off=HR:MN&idle=mins | Set DE display on and off times and idle duration |
set_newde?lat=X&lng=Y | Define a new DE location using latitude/longitude |
set_newdegrid?AB12 | Define a new DE location using its maidenhead grid square |
set_newdx?lat=X&lng=Y | Define a new DX location using latitude/longitude |
set_newdxgrid?AB12 | Define a new DX location using its maidenhead grid square |
set_pane?Pane[123]=one from below
Pane1=SSN,XRAY,Flux,KP,VOACAP,DEWx,Moon
|
Set what is displayed in a given plot pane |
set_satname?abc|none | Select satellite from built-in list, or none |
set_sattle?name=abc&t1=line1&t2=line2 | Define a satellite using TLE values |
set_stopwatch?countdown=mins | Set count down timer and start |
set_time?ISO=YYYY-MM-DDTHH:MM:SS | Set UTC to the given time |
set_time?Now | Set UTC to current time from network |
set_time?unix=secs_since_1970 | Set UTC to the given UNIX time |
set_touch?x=X&y=Y&hold=[0,1] | Virtually touch, or hold, screen coordinate X, Y; scaled to 800 x 480 |
set_voacap?band=[80-10,off] | Set VOACAP map band, or turn off |
restart | Restart HamClock |
updateVersion | Check for new version and update if found |
any command not recognized | Show this help |
Examples:
Get the current clock UTC time:
curl 'http://192.168.7.101:8080/get_time.txt'
Set display to shut off at 10 PM and back on at 8 AM, DE time, with 10 minutes idle time:
curl 'http://192.168.7.101:8080/set_displayTimes?on=8:00&off=22:00&idle=10'
Set a new DE location from latitude and longitude:
curl 'http://192.168.7.101:8080/set_newde?lat=40.7&lng=-74'
Save the current display to a file named hcscreen.bmp:
curl 'http://192.168.7.101:8080/get_capture.bmp' > hcscreen.bmp
Set satellite to ISS and report current ephemeris with respect to DE:
curl 'http://192.168.7.101:8080/set_satname?ISS'
Set Pane 3 to show NOAA Space weather:
curl 'http://192.168.7.101:8080/set_pane?Pane3=NOAA_SpaceWx
Toggle the screen lock padlock
curl 'http://192.168.7.101:8080/set_touch?x=224&y=132'
It is additional status and diagnostic information HamClock writes to the process stdout. You will see this when you start the program from the terminal command line. But, using normal shell syntax, you can save it to a file like this:
hamclock-800x480 > log.txt
or throw it away like this:
hamclock-800x480 > /dev/null
Then in either case, just to get even more geeky, since you have avoided displaying the diagnostics on the terminal you might as well run the program in the background to get a shell prompt immediately again to do something else by appending an & like this:
hamclock-800x480 > /dev/null &
If you run hamclock on RPi using a desktop shortcut, the diagnostic output goes to
/home/pi/.cache/lxsession/LXDE-pi/run.log
Sudo stands for "super-user do". In UNIX, the super user refers to extra privileges bestowed on the root user. Rather than actually logging out and logging back in as user root to gain these privileges, this command arranges for you to have these greater privileges just long enough to run the command that follows on the same line. After that command completes, you are again restricted back to the normal privileges of your current user login.
Another effect of the sudo command is to temporarily change the HOME directory to /root
.
HamClock creates and uses a working directory named .hamclock
(note the leading dot)
and places this in the HOME directory. HOME for the normal pi user is /home/pi
.
Thus, if you run hamclock without sudo it uses /home/pi/.hamclock
but if you run it with sudo it uses /root/.hamclock
and files therein are not
accessible to the normal pi user.
This duality can cause much confusion so beware.
The reason for using sudo in the first place is that HamClock requires super-user privileges to perform certain external IO and networking functions. Those with sufficient UNIX/linux administrative experience can make adjustments so hamclock could run without root privileges. But in the interest of providing the simplest and most enjoyable experience possible for the majority of users, the instructions for HamClock just use sudo throughout.
Now you know the rest of the story.
No. RSS feed formats are surprisingly inconsistent so I perform all the heavy lifting on my server and only send the plain titles to the HamClock. Plus, most now use https which uses too much memory for the little ESP processor.
That said, if you have a feed in mind that is of general interest to the global ham community, send me your suggestion and I will consider adding it to the server processing.
No. The list is maintained on my server which performs all the heavy lifting of discovery and updating, sending only the TLEs to the HamClock.
That said, if you have a satellite in mind that is of general interest to the global ham community, send me your suggestion and I will consider adding it to the server list.
As of Version 2.52, the background map images are downloaded and stored as local files as needed. In previous versions they were embedded within the executable image and were thus immutable and limited by size of non-volatile memory.
This meant the ESP HamClocks could only ever support one map style, and even that was only at half the available screen resolution. ESP HamClocks now use the extended FLASH file system to store the map images at full resolution. The improved resolution is especially apparent in the night portion of the Terrain style map. Unfortunately, more pixels and slower FLASH access means the display update rate on the ESP is about 30% slower but the added flexibility and visual results seem worth it.
The UNIX versions of HamClock store their map files in ~/.hamclock
.
There is essentially no limit to the number of files that can be stored.
Note if you run with sudo, this refers to root's home directory, not your login home.
If you run HamClock without a network connection, you will be limited to map styles already downloaded.
The maps are stored in .bmp format, version 4, using 16 bit RG565 pixels. There are separate files for day and night for each map style. HamClock uses these to render the two sunlit regions and blends them in a 12° band to match civil twilight.
As of version 2.54, this same mechanism is also used to provide the VOACAP global propagation reliability maps. Again, limited storage on the ESP means only one set of the standard background images can be stored when the reliability maps are in use.
To update itself, HamClock asks the support server if there is a newer version available. If so, for the ESP systems, this is a binary file that is downloaded directly into FLASH and that's all there is to it.
For the Desktop UNIX systems, this is a zip file containing the source code.
The zip is downloaded into /tmp; exploded; make
is run with the same target as
the basename of the currently running hamclock program; and the resulting program file
effectively overwrites the currently running program file. This creates two challenges: how to
find the full path of the program file to a running program and
how to update its program file while it is still running.
To find the program file full path, hamclock first checks the argv[0] path given when it was executed. If this is already a full path, indicated by beginning with a slash (/), we are done. If not, then a test is made whether a file with that name exists with respect to the current working directory of hamclock. If so, we are done. If it still is not found, then the argv[0] name is checked for in each of the directories named in the PATH environment variable. If still not found, the update fails.
It is not possible on UNIX to modify the program file of a running program (even as root).
So instead, hamclock does it indirectly by first removing the program file then copying in
the new one created by make
with the same name.
To remove the current program file, hamclock needs write permission on
its containing directory because removing a file actually just edits its out of its
containing directory. If hamclock does not have this permission, the update fails.
Copying in the new file then edits the same name back into the same
directory, so it looks like it was overwritten when actually it was deleted and added again.
Meanwhile, hamclock can continue to run because a deleted file still actually exists until
the last process with it open closes it or exits, even if it is not named by any directory.
For some unknown reason, this feature does not work the first time you try it after flashing the ESP Huzzah via USB from your computer. Use the reset button on Huzzah once then the padlock will work from then on. This issue does not occur if the Huzzah was reflashed remotely.
RPi Header pin | BME label |
---|---|
1 | Vin |
3 | SDI |
5 | SCK |
9 | GND |
sudo apt-get install i2c-tools
sudo raspi-config
and set the following options:
Interface Options: I2C: enabled
sudo i2cdetect -y 1you should see 77 in lower right corner of matrix; then
sudo i2cdump -y 1 0x77 byou should see a matrix of different numbers, not just all XX
Click and hold the padlock for 3 seconds, then select Exit.
sudo halt
Send a polite note to me at ecdowney@clearskyinstitute.com.
Contributed by Joeri van Dooren, ure@on3ure.be
Contributed by Hans Klausmann, dl5raz@gmx.de
# This little python script reads live dx cluster messages from a running hamclock # and shows the QRZ page for each station. It can run on any pc at the local network # Requirements: # 1. a running hamclock with internet connection # 2. a configured DX Cluster # 3. adjust the ip-nr below: ...wgetto ip-nr of hamclock # 4. adjust the time.sleep(15) to your needs # 5. chmod +x dx.py # usage: python ./dx.py import webbrowser import os import time #os.system('wget ajust below ! os.system('wget 192.168.178.68/get_dxspots.txt -O dxspots.txt -q') my_file = open("./dxspots.txt","r") lines = my_file.read().splitlines() i=0 for line in lines: i=i+1 call = line[9:17] if i > 1: print(line) url = "https://www.qrz.com/lookup/"+call webbrowser.open_new_tab(url) time.sleep(15) elif i == 1: print(line) my_file.close()
Seed planted by Barry, N0NZ, n0nz@arrl.net
#!/bin/bash # handy wrapper to send commands to HamClock # set to your HamClock host or IP HOST=hamclock.local # changed from 80 to 8080 as of HamClock version 2.56 PORT=8080 # show error msg and usage summary then exit. # arg1 = name of erroneous command, if any # arg2 = number of expected arguments, if any function usage { (( $# == 1 )) && echo "Error: unknown command: $1" (( $# > 1 )) && echo "Error: $1 requires $2 argument(s)" echo "Usage:" $(basename $0) "cmd [_arg1_ _arg2_ ... ]" echo " voacap _band_" echo " dxgrid _GRID_" echo " setpane _number_ _contents_" exit 1 } case $1 in voacap) [ $# -eq 2 ] || usage $1 1 curl "http://$HOST:$PORT/set_voacap?band=$2" ;; dxgrid) [ $# -eq 2 ] || usage $1 1 curl "http://$HOST:$PORT/set_newdxgrid?$2" ;; setpane) [ $# -eq 3 ] || usage $1 2 curl "http://$HOST:$PORT/set_pane?Pane$2=$3" ;; *) usage $1 ;; esac
There is no reason whatsoever you would ever need to do this,
but someone asked if they could edit the eeprom config file.
So, since I enjoy writing perl,
I couldn't resist writing hceeprom.pl
to do exactly that.
You can download it contained within this zip file
hceeprom.zip.
Save the script in the ESPHamClock source code directory and make it executable as usual.
This location is required because the script
uses the HamClock.h and nvram.cpp source files to find the symbolic
names and lengths of the various parameters saved in eeprom.
It also, of course, needs to know the location of the eeprom file itself, which it looks for in
~/.hamclock/eeprom
.
The type of the parameter is not saved in the eeprom file, so the script also needs to know
the data type, denoted with d for decimal (or hex), f for float or s for string.
Run the script with no args or -help for a usage summary:
Purpose: read or modify HamClock's config file at /Users/ecdowney/.hamclock/eeprom Usage: hceeprom.pl NV_XXX {dfs} [value] where: NV_XXX is one of the names in the NV_Name enum in HamClock.h one of d, f or s to indicate value is type decimal, float or string optional value to write, or read if absent
Remember, you are hacking a file not intended for human consumption, so you can very easily mess things up. There's no error checking, no explanation for what the parameters mean, no checking for consistency among related parameters (such as lat/lng and grid square), etc etc; you are literally just modifying raw byte storage. At the very least, I suggest you save a copy before making changes, just in case or, if you really mess up, just delete it altogether and HamClock will create a new one containing all default values. And surely it goes without saying, you should never edit the file while HamClock is running.
Alright, let's try it! Here are a few examples:
Read the call sign:
./hceeprom.pl NV_CALLSIGN s NV_CALLSIGN = WB0OEW
Set a new call sign:
./hceeprom.pl NV_CALLSIGN s AB1XYZ NV_CALLSIGN = AB1XYZ
Set DX latitude to 23.4 degrees south:
./hceeprom.pl NV_DX_LAT f -23.4 NV_DX_LAT = -23.4
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Other versions might work but these are the versions I am using now.
Set the port to match the USB connection of your Huzzah.
To use a 9" ER-TFTM090-2 from buydisplay.com:
Select these options during purchase:
This is the wiring list:
EP = ESP Huzzah BM = BME280 sensor PC = photo cell DP = display EP_SCL BM_SCK EP_SDA BM_SDI EP_3V BM_VIN EP_GND BM_GND EP_ADC PC_1, 330k EP_GND PC_2 EP_3V 330k EP_SCK DP_8 EP_MO DP_7 EP_MI DP_6 EP_2 DP_5 EP_16 DP_11 EP_USB DP_3, 4, 37, 38 EP_GND DP_1, 2, 13, 31, 39, 40
Pros:
Cons:
The display stand from Adafruit can be made to work with a little ingenuity but is not perfect for the LCD. Send suggestions for better ideas and I will post here.
If you find your display idea works better when the cable exits from the top, there is an option in the Setup screen that allows you to flip the display upside down.
Here is how I built my first two prototypes:
|
|
||||
|
|
HamClock was originally developed for the ESP8266 such as the Adafruit Huzzah. But after we created a porting layer, it may now also be built for Raspberry Pi, macOS, linux, Ubuntu, FreeBSD or most any other UNIX-like system. There are two basic configurations:
Instructions for each configuration are below, but first a few preliminaries:
$HOME/.hamclock/eeprom
. Removing this file and restarting HamClock will
reset it back to all default values.
Note the value of $HOME is /home/pi under the normal RPi login, or /root if using sudo.
cd curl -o ESPHamClock.zip http://www.clearskyinstitute.com/ham/HamClock/ESPHamClock.zip unzip ESPHamClock.zip cd ESPHamClock make -j 4 hamclock-800x480 sudo ./hamclock-800x480
make
command above will build HamClock at 800x480 pixels for X11.
Type make help
for a list of other sizes available.
Then redo the make
and sudo
commands again substituting
the preferred size.
sudo ./hamclock-800x480 > hamclock.log 2>&1 &
hamclock.desktop
to your Desktop folder with this command:
cp hamclock.desktop ~/Desktop
If you would like HamClock to start automatically when you log in,
make sure you have an autostart directory then
copy hamclock.desktop
into there with these commands:
mkdir -p ~/.config/autostart cp hamclock.desktop ~/.config/autostart
The sample hamclock.desktop
file assumes you made hamclock-800x480 so edit the Exec
line if you have chosen a different size program name.
xrandr --output HDMI-1 --scale 0.833x0.92I computed 0.833 from 1600/1920 but 0.92 was found experimentally to account for the extra menu bar height. With care, this technique can come quite close but don't expect perfection.
I know this works fine with a mouse pointer, but may have coordinate issues with a touch screen.
make -j 4 hamclock-800x480 mkdir -p ~/Desktop/HamClock.app/Contents/MacOS cp hamclock-800x480 ~/Desktop/HamClock.app/Contents/MacOS cp hamclock.plist ~/Desktop/HamClock.app/ContentsTo give it a proper icon:
Get Info
If anyone knows how to stop the dock icon from bouncing forever, other than disabling dock opening animation for all apps, please let me know.
This is also referred to as the fb0 configuration.
Note: This configuration is intended for applications where the entire RPi display is dedicated to HamClock. There is no GUI infrastructure and thus no VNC, screen saver or other nice GUI controls. You must use ssh as instructed to perform everything from the command line. Do not try to use the RPi display for these commands.
sudo raspi-config
one time and set the following options:
cd curl -o ESPHamClock.zip http://www.clearskyinstitute.com/ham/HamClock/ESPHamClock.zip unzip ESPHamClock.zip cd ESPHamClock make -j 3 hamclock-fb0-1600x960 sudo ./hamclock-fb0-1600x960
sudo apt-get update sudo apt-get -y install make g++ libx11-dev
sudo apt install curl make g++ xorg-dev
make
command above will build HamClock at 1600x960 pixels for fb0.
If you want the smaller size 800x480 for the 7" display, redo the make
and sudo
commands with hamclock-fb0-800x480
.
Type make help
for a list of other fb0 sizes available.
sudo nano /boot/config.txt
sudo reboot
sudo fbset -depth 32
cd ESPHamClock
sudo ./hamclock-fb0-1600x960
sudo ./hamclock-fb0-1600x960 > hamclock.log 2>&1 &
sudo bash -c "echo 0 > /sys/class/graphics/fbcon/cursor_blink"
crontab -e
@reboot cd ESPHamClock; sudo ./hamclock-fb0-800x480 > hamclock.log 2>&1
hamclock-fb0-800x480
therein. Adjust as necessary
to match the configuration you specified in your make
command.
This example also saves the diagnostic output but if you would rather just discard it,
change the log file name to /dev/null
like so:
@reboot cd ESPHamClock; sudo ./hamclock-fb0-800x480 > /dev/null 2>&1
man 5 crontab