3D Xmas Tree for Raspberry Pi

This was a very nice weekend project that I highly recommend that was created by the folks over at the PiHut. I have the working video above showing you how it works, the AsciiCast to show you how to set this up via the command just below this text.

Here is a direct link to the AsciiCast.

As a bonus, I have another video at the extreme bottom that will show you how to do this from the GUI on a Raspberry Pi. So many ways to set this up to cater to all of the different people out there. 🙂

The easiest way to control your 3D Christmas board is with Thonny. This is pre-installed in Raspbian Stretch.

So you can click on the Raspberry icon > Programming > Thonny.

Once Thonny is open paste the following code into it and then click on “Run”

from gpiozero import LEDBoard
from gpiozero.tools import random_values
from signal import pause
tree = LEDBoard(*range(2,28),pwm=True)
for led in tree:
 led.source_delay = 0.25
 led.source = random_values()
pause()

Once you have done that it will prompt you to give the code you just pasted a file name (e.g. xmas.py).

It will save the code as that file name and it will then run the code. You can then start and stop the code as you wish.

7-Zip benchmark on Raspberry Pi

The 7-Zip Benchmark command

7zip

Measures speed of the CPU and checks RAM for errors.

You can install 7-Zip from the Raspbian Desktop – this is how:

  • Click on the Raspberry in the top left of your screen:
  • Go down to “Preferences” –> and click on “Add / Remove Software”:
  • When the new window opens, type “p7zip” in the search box and hit enter
  • Click both of the checkboxes for “p7zip” (they should be the last 2 choices)

You can also install 7-Zip from the command line:

sudo apt-get install p7zip

Syntax

b [number_of_iterations] [-mmt{N}] [-md{N}] [-mm={Method}]

There are two tests:

  1. Compressing with LZMA method
  2. Decompressing with LZMA method

The benchmark shows a rating in MIPS (million instructions per second). The rating value is calculated from the measured CPU speed and it is normalized with results of Intel Core 2 CPU with multi-threading option switched off. So if you have Intel Core 2 Duo, rating values must be close to real CPU frequency.

You can change the upper dictionary size to increase memory usage by -md{N} switch. Also, you can change the number of threads by -mmt{N} switch.

The Dict column shows the dictionary size. For example, 21 means 2^21 = 2 MB.

The Usage column shows the percentage of time the processor is working. It’s normalized for a one-thread load. For example, 180% CPU Usage for 2 threads can mean that average CPU usage is about 90% for each thread.

The R / U column shows the rating normalized for 100% of CPU usage. That column shows the performance of one average CPU thread.

Avr shows averages for different dictionary sizes.

Tot shows averages of the compression and decompression ratings.

Compression speed and rating strongly depend on memory (RAM) latency.

Decompression speed and rating strongly depend on the integer performance of the CPU. For example, the Intel Pentium 4 has big branch misprediction penalty (which is an effect of its long pipeline) and pretty slow multiply and shift operations. So, the Pentium 4 has pretty low decompressing ratings.

You can run a CRC calculation benchmark by specifying -mm=crc. That test shows the speed of CRC calculation in MB/s. The first column shows the size of the block. The next column shows the speed of CRC calculation for one thread. The other columns are results for multi-threaded CRC calculation.

With -mm=* switch you can run a complex benchmark. It tests hash calculation methods, compression and encryption codecs of 7-Zip. Note that the tests of LZMA have a big weight in “total” results. And the results are normalized with AMD K8 CPU in a complex benchmark.

Examples:

#Runs the benchmark once - takes about 75 seconds on my
#Raspberry Pi 3B+ so please be patient...
7zr b
#You can run and save the output to a file if you wish
#You will not see it running this time while the benchmark
#is running - again please be patient for about 75 seconds
7zr b > 7zip-basic-benchmark-example.txt
#To view the output later or to share it with others
cat 7zip-basic-benchmark-example.txt
#Runs the benchmark twice and give you an average of the
#2 tests - this takes about 150 seconds for this test
7zr b ; 7zr b
#Runs the complete 7-zip benchmark - please be patient...
#There is more information @ http://www.single-board.com 
7zr b -mm=*
#Runs the benchmark 30 times and gives you an average
#This test takes a very long time on the Raspberry Pi
#Watch my YouTube video to see all the cores working on
#Conky - and I am using SimpleScreenRecorder and 
#Asciinema to record everything your seeing today.
7zr b 30
Asciinema
Asciinema

Click here for a direct link to the Asciicast in a new window.

To learn how to install Asciinema click here.

Here is the Asciicast:

NOTE: first 70 seconds don’t show anything as I was showing how to install 7-Zip through the Raspberry Pi GUI. You can see that in the YouTube video below.

To watch this YouTube video of the whole process in a new window, click here.

SimpleScreenRecorder
Simple Screen Recorder

Otherwise, click on the video below and enjoy!

NOTE 1:

I use several different software programs and hardware at the same time in this video. This is a culmination of hardware and software that I have used in my previous Asciicast, blogs, and videos. If you want to ask me specific questions I am always available via email, just be patient 🙂

NOTE 2:

If you are interested in testing Single Board Computers like I am, you might just want to head over to “Performance Analysis Methodology” and read what is there. It is very interesting and worth the time if you’re serious about accurate results and not just a stack of data.

Asciinema – record your Terminal sessions

I have been working at learning a new program called Asciinema which will allow you to record Terminal sessions and share them on the Internet. For someone like me that wants to share everything that I learn with you this is an extremely valuable tool. I am excited to introduce you to this awesome program.

Asciinema
Asciinema

Asciinema is a fast, light-weight and open source Terminal recording tool. Asciinema not just records your Terminal activities, but also helps you to share them on the web if necessary. You can share the recordings by copying its URL and sending it to a friend or posting it on a social network. It is easy to use and in just about 10 minutes you will be a pro at using it.

Asciinema tool could be useful in the following situations:

  • The online trainers can record and share the Terminal session when teaching Linux commands to the students.
  • The students can share their Terminal activities to their online tutors when they have been given a command-line assignment.
  • The junior admins can record and share their Terminal activities to the remote technical support or subject matter experts when looking for help.
  • Technical writers or bloggers can record the terminal activities and use them while writing a book or blog post.

The possibilities are endless. Whatever it is, when it comes it to record a terminal session, Asciinema comes in handy! In this guide, we’ll be discussing how to install Asciinema in Mint and Raspbian and how to record your Terminal sessions using it. Also, we will see how to share the recorded terminal sessions on the web.

Install Asciinema

The good thing is the developers have packaged asciinema for almost all Linux distributions, and it’s available in the official repositories of many Linux distros. I have installed this on both Mint and Raspbian with excellent results.

sudo apt-get install asciinema

To install asciinema on Unix and other operating systems, refer the asciinema installation page: https://asciinema.org/docs/installation

Record Terminal Sessions using Asciinema

The usage is trivial. When you run “asciinema” without any argument, it will display the help section. Now, let us record a terminal session. To do so, run:

asciinema rec

Once you run the above command, you will see the following output.

~ Asciicast recording started.
~ Hit Ctrl-D or type “exit” to finish.

Now, your Terminal activities is being recorded and saved in the file called “test” in the current working directory.

Let us type some random commands.

df -h

ls -l

lscpu

pwd

uname -a

#In Raspbian on your Raspberry Pi type:

vcgencmd measure_temp

That’s enough. To finish the recording, press “CTRL+D” or type “exit”.

When the recording is ended, you will see the following message.

~ Asciicast recording finished.

You can copy and paste directly out of this window.

The direct link to this asciicast is:

https://asciinema.org/a/174219

 

Uploading the record session to asciinema.org site

Since we didn’t specify filename for the recording, you will asked to upload the resulting recording to asciinema.org website, so you can share it to your friends or social media or add it to your own blog/website.

Just share it to your colleague or friend or whoever wants to view your Terminal session in their web browser. Or, you can view it on your own browser itself.

Once your friend entered the above URL in their browser’s address bar, they can be able to see your recording.

To learn more you can check out the https://asciinema.org/ website. It is a small community right now but I believe that if enough people that use the Raspberry Pi’s with the Raspbian system that this will become a vibrant community.

I will be using Asciinema as I believe this to be a great teaching tool. Share this with your friends so we can all benefit from this unique way of sharing.