Tuesday, 18 June 2019
Windows Screensaver Update
My Windows "Random" photos screensaver code hasn't really been significantly touched for many years now, but as it's working really well on a daily basis on my home PCs, I thought I'd add it to GitHub.
You can use this URL to clone: https://github.com/jscott7/PhotosScreensaver.git
(A wiki has also been started: https://github.com/jscott7/PhotosScreensaver/wiki)
As part of the process I performed a bit of a clean up. It's OK, this is a very small project!
First, the settings have an option to change the delay between photos updating, unfortunately while you could change this it wasn't being used.
The settings for the root folder for photos and delay are saved in the registry, I'm using the key HKCU\SOFTWARE\JscoPhotoScreenSaver
public static void SaveSetting(string name, object value)
{
var key = Registry.CurrentUser.CreateSubKey("SOFTWARE\\JscoPhotoScreenSaver");
if (value != null)
{
key.SetValue(name, value);
}
}
Then save the photos path to this key with:
SettingsUtilities.SaveSetting("photopath", filePathBox.Text);
To load back use:
object rootPath = SettingsUtilities.LoadSetting("photopath");
There was an inefficiency with the loading of photo files. I was duplicating this for each window. Not a problem for single monitors but it's unnecessary for multiple monitor setups. Fortunately this was easy to fix by moving the logic to the App.xaml.cs file.
Next, to install, the exe built by the project needs to be renamed to PhotosScreensaver.scr. You then right-click on it and select Install. I added a post-build step to the project to automatically perform this rename.
I also made a few tweaks to follow the MS Naming guidelines
Finally, I made use of string interpolation which is new from C# 6. Previously I used a StringBuilder to generate a debug log. This was:
log.Append("Show").Append(window.Width).Append("-").Append(window.Height).Append("-").Append(window.Left).Append("-").AppendLine(window.Top.ToString());
And now, with string interpolation it's much cleaner:
log.Append($"Show {window.Width}-{window.Height}-{window.Left}-{window.Top}");
Friday, 7 June 2019
Raspberry Pi Dashboard with Dakboard
A while ago I bought a cheap Raspberry Pi touchscreen. This like so many impulse buys spent many months gathering dust in a cupboard but given the progress of my webserver, I thought I'd try setting it up as a display.
I was inspired by the excellent Scott Handelman blog to setup a dashboard using Dakboard and my Raspberry Pi display.
Back when I first got the display, I'd set the screen to portrait mode, but with the stand I have I needed to reset it back to landscape. It took a while to remember how to do this.
First in /boot/config.txt I'd added a line display_rotate=1 which rotates by 90 degrees. I removed this and rebooted.
Unfortunately, the response to the touch screen was still in portrait mode.
To change this I had to edit /etc/X11/xorg.conf.d/99-calibration.conf
And change the SwapAxes option back from "1" to "0".
(I also needed to recalibrate, this is available from Preferences -> Calibrate TouchScreen on my device)
I then created a Dakboard account and setup a simple view; Date, RSS feed and local weather. You are then given a private URL which can be used to display this on any device.
In order to startup the Raspberry Pi displaying this page full screen with no mouse pointre, I followed the instructions on Scott Hanselman's blog.
Edit (take a copy first): ~/.config/lxsession/LXDE-pi/autostart
Replace contents with:
(There are also good instructions here)
Unfortunately, while it does look great, Dakboard doesn't quite work for me.
The ability to use a my own webservice as data input is only supported on the paid-for Premium plan. At $5.95 per month this is too much for me so I'm going to look into creating my own webpage. After all, isn't creating something all the fun!
As an aside. With a 750mA power supply the Pi shows the lightening bolt in the top right hand corner, which indicates it's underpowered. Not surprising given we're also powering the screen.
I have an 850mA supply, which is slightly better but I would need more if I wanted to avoid the computer crashing.
I was inspired by the excellent Scott Handelman blog to setup a dashboard using Dakboard and my Raspberry Pi display.
Back when I first got the display, I'd set the screen to portrait mode, but with the stand I have I needed to reset it back to landscape. It took a while to remember how to do this.
First in /boot/config.txt I'd added a line display_rotate=1 which rotates by 90 degrees. I removed this and rebooted.
Unfortunately, the response to the touch screen was still in portrait mode.
To change this I had to edit /etc/X11/xorg.conf.d/99-calibration.conf
And change the SwapAxes option back from "1" to "0".
Section "InputClass" Identifier "calibration" MatchProduct "ADS7846 Touchscreen" Option "Calibration" "145 3995 290 3945" Option "SwapAxes" "0" EndSection
(I also needed to recalibrate, this is available from Preferences -> Calibrate TouchScreen on my device)
I then created a Dakboard account and setup a simple view; Date, RSS feed and local weather. You are then given a private URL which can be used to display this on any device.
In order to startup the Raspberry Pi displaying this page full screen with no mouse pointre, I followed the instructions on Scott Hanselman's blog.
Edit (take a copy first): ~/.config/lxsession/LXDE-pi/autostart
Replace contents with:
@xset s off @xset -dpms @xset s noblank @chromium-browser --noerrdialogs --incognito --kiosk https://dakboard.com/app?p= private-url
(There are also good instructions here)
Unfortunately, while it does look great, Dakboard doesn't quite work for me.
The ability to use a my own webservice as data input is only supported on the paid-for Premium plan. At $5.95 per month this is too much for me so I'm going to look into creating my own webpage. After all, isn't creating something all the fun!
As an aside. With a 750mA power supply the Pi shows the lightening bolt in the top right hand corner, which indicates it's underpowered. Not surprising given we're also powering the screen.
I have an 850mA supply, which is slightly better but I would need more if I wanted to avoid the computer crashing.
Monday, 3 June 2019
Loading old Physics Data Files - Part 2
Previously, my attempt at running a FORTRAN program to load my old ZEUS data ntuples failed because CERNLIB isn't compatible with a 64-bit Linux OS:
For the VM host, I decided to use VirtualBox. This is easy to install on Ubuntu from the Software Center.
After downloading the 32-bit Linux Mint ISO I setup a new VM with 4MB of Memory and Dynamically Allocated Storage with 70GB Virtual Size.
After installing Mint, I reinstalled the CERNLIB packages from the Mint Software Manager and loaded up the ntuple in PAW as per my last post
Now, given this was working I could try and load the file using my FORTRAN program:
And this time, success!
There's a few points to bear in mind:
Test loading ntuple files !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LOCB/LOCF: address 0x562cca6e2c80 exceeds the 32 bit address space or is not in the data segments This may result in program crash or incorrect results Therefore we will stop here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Unfortunately, the recommendation in /usr/share/doc/libpacklib1-dev/README.64-bit to statically link didn't work for me:
Static linking is the default behavior if you use the "cernlib" script when linking, like this: # Should work everywhere: gfortran -o myprogram myprogram.F `cernlib -G Motif pawlib`
Fortunately, Linux Mint still provides a 32-bit version of the latest OS. So, at this point rather than trying to fix it in 64-bit I thought the best approach would be to setup a Virtual Machine.
For the VM host, I decided to use VirtualBox. This is easy to install on Ubuntu from the Software Center.
After downloading the 32-bit Linux Mint ISO I setup a new VM with 4MB of Memory and Dynamically Allocated Storage with 70GB Virtual Size.
After installing Mint, I reinstalled the CERNLIB packages from the Mint Software Manager and loaded up the ntuple in PAW as per my last post
Now, given this was working I could try and load the file using my FORTRAN program:
program main implicit none integer istat, NEvents, idnt real hmem common/pawc/hmem(2000000) print *, "Test loading ntuple files" call hlimit(2000000) call hropen(80,'ntuple','mc97_1.rz','',4096,istat) if (istat.ne.0) then print *, "Failed to open input file" stop endif print *, "Loaded mc96_1.rz" call hrin(10, 9999999, 0) call hnoent(10,NEvents) print *, NEvents c print *, idnt call hrend('ntuple') close(80) end program main
And this time, success!
Test loading ntuple files Loaded mc96_1.rz 51781
There's a few points to bear in mind:
- common/pawc/hmem(2000000) is required to reserve locations to a common /PAWC/, for the HBOOK working space (an array)
- call hlimit(2000000) informs HBOOK of the storage limit
- call hropen opens the direct access rz file
- call hrin(10, 9999999, 0) reads a histogram from the current directory of the direct access file into the current directory in memory. The 9999999 to to read the highest cycle
- call hnoent Gets the number of events in the in-memory identifier
Subscribe to:
Posts (Atom)