A blog created using Bootstrap
Something that I have always wanted to have in my room is a scrolling display like you might find on Times Square. These types of displays have always captivated me, and I had been considering if it was possible for me to have one of my own. I had purchased an Onion Omega2+ to use as a Wi-Fi hotspot and file storage solution for my dorm room. I soon purchased a LED matrix display to toy around with using the Omega as a controller. I found this to be too difficult to make work smoothly because my skill level in coding was not high enough to create a control library for the display. However, I then learned of the Arduino dock for the Omega. The biggest advantage of using an Arduino dock with your Onion Omega is the availability of software libraries that have been already written. For the matrix that I had purchased, the MD_Parola library made programming easy because of the built-in text functions.
For the Arduino side of the programming, I based my code on the Parola_Scrolling example from the library. There were several small things that I had to change to get the display to function how I wanted. The first thing that needed to change was the GPIO that were set as the output pins for the display. I could not use the hardware SPI pins because those were already occupied by one of the connections to the Omega. The second change that I made was to customize the scrolling speed and effect to my liking. I set the scroll speed to a value of 30 and I turned the scroll pause off. The biggest change that I had to make was to change the size of the message buffer so that all the text sent through the UART connection would not be cut off. I have the buffer size set to 500, but that may need to be expanded.
On the Omega side of things, I decided to use a python script that could be called by cron on a schedule. This was my first time working with web requests, so this was the biggest challenge for me. I found that the python language makes this very easy. All that I needed to do was import the urllib python module. Once you open the URL that leads you to the JSON file containing the data which you want to display you can simply use the json python module to parse the file. Once the object is created it is easy to access the data inside by simply using square brackets. The next step is to send the data formatted as you wish it to be displayed over the Omega's UART connection with the Arduino dock. This connection can be found on /dev/ttyS1. This can be easily accessed using the serial python module. The only thing you should be careful of is to not use any special unicode characters in your data, as these will not be read correctly by the MD_Parola library. Only ASCII characters should be used unless you were to create your own font for the matrix.
The next piece of work I did was deciding what data to pull down for my display. I decided that a good portion of my summer so far has been worrying about the status of bitcoin and the activation of SegWit. This prompted me to pull down the information from https://blockchain.info/stats. I used this information and my knowledge that SegWit is supposed to activate at block 481824 to calculate the number of blocks and the predicted time until SegWit activation. I found the predicted time by simply multiplying the blocks remaining by the minutes between blocks data provided by blockchain.info. I removed this feature after the activation. The other piece of data that I thought would be important to display is the weather forecast. api.weather.gov provides great text based descriptions of the day's weather forecast in json format. This is the same description you might hear on weather radio. You pass the coordinates of your current location in the URL to the forecast data. The piece that I struggled with here was how to parse the different time periods that the API provides. I found that it was most effective to use the dateutil.parser python module and compare each of the individual time windows to the current time in order to find the correct information to display.
The next problem I found was that I wanted to keep the computer running all the time, but I didn't want the display to light up the room at night. The way that I achieved this was by changing the code on the arduino side to look for the first three characters of the string it is sent to be "OFF". The arduino would then turn off the display. It took me a couple trys to get the python code right. The source code shows how I did this. I now use the Onion Omega as both an access point and an information display. I will probably add more information in the future.
It should be easy to include whatever information that would be relevant to you by writing your own script to create the text for the display. Not everybody is interested in the same information in the same format, and that is why flexible DIY projects are so great.
The Onion Omega is a very capable computer, but some things are not very easy to implement because of the limited amount of software libraries that have been created for the device. Fortunately, there is an easy solution for this. The Onion Omega is available with several dock devices that break out the device's pins for easy use with external components. Some docks even add extra features, such as the Arduino Dock. The Arduino Dock adds the full functionality of an Arduino Uno to your Onion Omega. The Omega communicates with the Arduino ATmega chip through it's various serial lines. The Omega even handles flashing programs to the chip remotely through an ssh connection handled transparently by the Arduino IDE.
The main reason that I purchased the Arduino Dock was to be able to use community provided libraries for driving a MAX2719 based LED matrix display. It would be very time consuming for me to attempt to duplicate this library for use with the Omega's GPIO. I got an example running on the Arduino in a matter of minutes. I plan to use the Arduino just for driving the display, with text coming from the Omega's UART serial output. This will allow me to create applications that pull information from the internet, such as stock prices and weather data, and the display them on a scrolling style display like you would see in Times Square.
Another advantage of the Arduino Dock is the addition of analog inputs to your project. This is useful for connecting to components such as potentiometers and temperature sensors. This is not as much as an advantage to me, because I already have a higher precision DAC that can communicate with the Omega directly through I2C. The other big advantage of working with the Arduino Dock is that you can safely use 5V inputs. This can be useful in cases where cheap 5V logic devices experience problems operating on 3.3V. However, I have not had any problems with this so far.
In this post, I will lay out the steps that I took to complete my first real project with my new Onion Omega2+. As I mentioned in my previous post, my goal for my first project with the device was to create some sort of alarm clock. I wanted to get started on this right away and did not want to buy any extra components to finish the design. Because of this, all of the parts that I used for this project came from my Elegoo Upgraded Electronics Fun Kit which I already had. However, I did have to use a USB power supply other than the one that came with this kit because it was not powerful enough to drive the Omega under heavy load. Only using this kit limited me to only being able to use individual LEDs for the time display. Because of this, I decided to display the time in a binary format. I knew that I would be able to use the shift register included in the kit to be able to represent a byte on 8 LEDs while only using 3 of the Omega's GPIO pins, so I set out to figure out the programming.
Once I knew how I was going to lay out the components on my breadboard, my next step was to learn what the best way for me to program this system would be. In my initial tests with the Omega, I had used shell scripting to cycle one LED. I knew that it would be possible for me to do my programming in this manner, but I knew it would be very difficult to control the shift register in this manner. I wanted to be able to do this with an object oriented language so that I could have a class for shift registers that I would likely use again in future projects. Looking through the Onion Omega documentation, I found that python would likely be the best language for this purpose. The Onion team already has a python library available that allows for easy control for the Omega's GPIO. I also found a tutorial in the documentation for one of the kits available with the Onion Omega that provided a class for controlling a shift register as well as an example of how to use this class. As someone whom had never written any python, I thought it would be a good idea for me to go through this code and type it out myself so that I could become more familiar with python syntax. By going through this code, I found that it would be even easier than I had previously thought to format the decimal notation times retrieved from the time functions to strings in a binary format that could be split apart and sent as individual bits to the shift register. As someone that started out using C and C++, I gained a respect for the power of using python for embed devices. The function to format an integer to an 8 bit binary representation looks like this:
Functions for retrieving the time of day from the system can be included by using the time module. This library also includes the definition for a time struct and functions for manipulating these structs. I was already familiar with most of these because they are very similar to the functions and struct in C. There is also a more modern "datetime" module that works in a more object oriented manner, but I chose not to use this because I was already familiar with the regular time module.
binaryMinutes = format(currentMinutes, '08b')
The hardest part of this project for me was grasping the concept of data structures in python. The data structure that I used to keep track of the alarm times is a list. The python list data type covers several of the data types from the C++ standard library that I am used to being separate. The list can be used as a list, stack, or a queue in python. The list can also be sorted automatically, which I make use of in my program.
As you can see, I also had to do a bit of string manipulation to get the strings in the format I wanted from out of the file. When the lines are read from the file, the newline character at the end is kept in the string. Conveniently, there is a built in python function for managing this. the "rstrip" function strips all of the whitespace characters from the end of the string. Once the strings are in this format, it is easy to compare them with the output of a "strftime" function, which is how the program checks if it is time for the alarm to go off or not.
# Set the alarm time from file alarmTime.txt inFile = open('alarmTime.txt') alarmList =  for line in inFile: # Creates a list containing time structs # Strings in file should be of format 'HH:MM' alarmString = line.rstrip() alarmList.append(alarmString) # The list should be sorted so that it is easier to evaluate alarmList.sort(key=None, reverse=True)
My plans moving forward with my Onion Omega2+ are to upgrade the clock to make it more readable. I am thinking that I could use my current components in a round layout to show the time as an analog clock, or maybe just buy some sort of numerical digit display. Meanwhile, I am going to try to apply some of my new knowledge of python to work on some simple projects with the TensorFlow machine learning libraries.
I just recently got another small prototyping computer called the Onion Omega2+ . This computer comes in a convenient package that allows you to use many different docks that allow you to connect to different peripherals. I got the breadboard dock with mine. The breadboard dock makes prototyping with the Onion Omega much easier. There is no soldering required and components can be swapped around quickly. The Onion Omega has 15 GPIOs that can be used to attach a great number of different input and output devices. Some of the pins even have built in serial communication abilities, which allow for an even greater number of components to be connected through multiplexing. The Onion Omega also supports I2C and SPI devices like those that commonly drive simple displays. The first project I have planned for my Omega involves using I2C to connect either 7 segment displays or some type of OLED display in order to create an alarm clock.
The Onion Omega2+ runs on a similar chipset to the VoCore, but comes in a package that is much easier to deal with. The Omega runs a distribution of Linux that is based on LEDE. This allows for the computer to be very capable, even though the device has no way of producing a useful graphical environment. In order to make the Omega easy to use, there is a web interface to the device that can be accessed through any web browser. This web interface is surprisingly complete and almost feels like the experience you would expect from a graphical shell such as Ubuntu's Unity. However, I prefer the simplicity of using the command line, which can easily be done using ssh or by using serial communication. I can tell that this device will prove to be very useful to me in the future even if just as a wireless access point; and I am excited to see what interesting projects I can think of to make use of the device.
With the new developments around Mozilla's Rust programming language and Redox OS, I thought that it would be interesting to talk about the future of kernel architecture. In the past, the future looked as though th microkernel approach would prove to be the system of choice as computers began connecting through the internet and could potentially harm your computer. Monolithic kernels we use today such as the Linux kernel could be considered insecure in respect to the way all programs are run in "Supervisor Mode". This means that every piece of the operating system is allowed direct access to the hardware. Many people that prefer to work in Linux explain their reason for using Linux to be that Linux is more secure than Microsoft Windows. The Windows NT kernel is structured as what is known as a hybrid kernel. This means that the kernel is structured like a microkernel, but still runs most of the OS in kernel space. This means that the hybrid Windows NT kernel might even be more secure than the Linux kernel. Apple's Darwin originally started as slight modifications to the Mach microkernel. Over time, Apple has made the kernel into a hybrid kernel operating in a similar way to the NT kernel.
There are still many remnants of the old microkernels that were used for research purposes. One example is the Minix kernel. The linux kernel was actually based on this system. Minux is not so useable today because it does not support a 64-bit environment. This is problematic because it limits the amount of memory the system can address. Another microkernel that has the same issues is GNU Hurd. This kernel is where the GNU utilities we often find with other Unix based systems were originally planned for. HelenOS is another microkernel based operating system that is used for research purposes. HelenOS does not suffer from the lack of support for hardware. However, has sacrificed compatibility with the majority of the software written for Unix systems. The newest addition to the list of microkernel systems is Redox OS. Redox brings all the benefits of the microkernel to modern systems while using a modern Unix-like interface. What makes Redox even more special is that it is written mostly in Rust. Rust is a programming language similar to C++, but is memory safe. The combination of Rust and the microkernel architecture will possibly make Redox the most stable operating system there is. We will just have to wait and see where this project takes us.
I just recently got something very interesting in the mail. This is something that I had ordered a couple months back and I really wasn't expecting to ever get it. This item is the VoCore2 Lite.
This tiny little board is capable of a lot more than you would think. The SoC is MediaTek's MT7688AN. This SoC is designed for use in wireless routers, so it has built in wireless capabilities as well as a built in ethernet switch. The system has 64MB of RAM and 8MB of built in NOR flash storage. The storage can be expanded by adding a SD card. The board also has GPIO that can be used to control other devices. I plan to use a relay to control a light remotely. The Vocore2 Lite will also serve me as a great portable wireless router; or maybe I will have it host a website in the future.
I am excited to get working with this new tool, but I first have to wait for the tools I need in order to wire up the system without potential damage. I will post again once I get something working. In the meantime, I am going to be working on making the PDF on this website inserted using pdf.js instead of just using a simple HTML object. This will allow for more browsers to be able to display the document.
This is my first blog post. The goal of this blog is to help me grow more familiar with using HTML and CSS with the Twitter Bootstrap. I want to become more fluent in web design so that I can use this skill in the future.
In the future, I may write more posts on this blog discussing topics that I am learning in school. This will help me gain a better understanding of these topics as I will be thinking about them in greater detail.
Here is a link to the bootstrap example page that I have based my page on: The Bootstrap Blog