Compile locally and run on raspberry pi via Clion

Background

Compiling C/C++ code on the raspberry pi is very slow, I have some code I am writing that compiles in less than 5 seconds on the laptop but can take 30 minutes on the raspberry pi. This is pretty annoying and slows down testing of code tweaks.

I have found a way of automating this quite successfully via Clion (Commerical software from Jetbrains).

Raspberry pi tools

Firstly we need to get the raspberry pi compile toolchain.

https://github.com/raspberrypi/tools

Git clone this somewhere on your local filesystem.

Read more…

Please share πŸ™‚
error

CherryTree custom codeblock background

A ramble of why…..

…..i want to change the background colour of CherryTree’s codeblocks.

I use Linux as my OS of choice and have for many years. One thing that has been missing is a really good all round note application. I have always wanted something like Onenote but for the past few years I have discovered how powerful markdown is. The use of the ‘`’ (back tick) to insert command line or code in the middle of a document is extremely useful, I find it so much easier to read because it breaks down the text into a consumable form.

These days there are a lot of Electron markdown note taking apps popping up, this isn’t necessarily a bad thing but I find electron apps don’t look very good at all in Linux. I use typora at work on my Mac and it looks native. The same application just looks pretty bad under Ubuntu. Yes it does look worse because it is a Snap but even under fedora it isn’t great.

Read more…

Please share πŸ™‚
error

Raspberry Pi 20×4 LCD i2c C++ Driver

Introduction

I have written a C++ driver for the common 20×4 LCD using i2c on the Raspberry Pi. These LCDs are based onΒ HD47780. Most examples I found are using the pins directly and not through i2c. I2c uses a lot less pins than directly connecting the LCD. I originally wrote this in C and then decided to convert to C++, as I am re-learning C++!

Breadboard Layout

Read more…

Please share πŸ™‚
error

Route certain traffic via WiFi in Windows – Powershell

Disclaimer:

I WOULD NOT RECOMMEND USING THIS CODE TO CIRCUMVENT FIREWALLS ETC AT YOUR PLACE OF WORK. THE SAMPLE CODE ON BLOG.MONOTOK.ORG IS PROVIDED β€œAS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MONOTOK OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Problem:

Sometimes you might need to send certain traffic destined to a FQDN via the WiFi network while the rest of the traffic goes via the Ethernet. An example could be that a certain destination is only reachable via the Ethernet or WiFi but you want the rest of the traffic to go via the other interface.

Windows routing table uses several metrics to decide which interface traffic takes. Normally when both the Ethernet and WiFi are connected, the Ethernet will be preferred over the WiFi; this is decided via the Metric number. This is automatically generated by Windows unless changed, for example the Ethernet will be 10 and the WiFi will be 30. The lower number is preferred. You can also assign a metric to a static route inserted into the routing table however the routes metric is added to the interface metric. This prevents the route overriding the Ethernet even if you make the interfaces the same metric and then remove the WiFi default route (Windows kept inserting it again anyway).

Read more…

Please share πŸ™‚
error

Char Pointers in C

The Code:

I decided to write a quick bit of code to reinforce my understanding of char pointers in C; especially Char** as I recently confused myself. Firstly lets get straight to the code as it is the best way to learn. The code comments should explain what each line is doing however additional explanation of the steps is provided further down the page.

Read more…

Please share πŸ™‚
error

Weather Station using Raspberry Pi & Arduino

Introduction

This post will be extensive so will be separated into 3 parts to make it easier to write and read. I have spent the last couple of months developing a weather station; both for the fun of it and to improve my understanding of the C programming language. The weather station will perform quite a few tasks. It comes in 3 separate bits; several remote sensors that transmit their temperature, location and battery status over an RF link, a receiver module that receives the data over the RF link and the raspberry pi main station which talks over I2C to the receiver unit to get the data. The raspberry pi then processes this information to display on an LCD screen. It has five buttons; one switches between all remote sensors and it’s self, 2nd switches between the data&time, IP address and WiFi signal strength, 3rd switches between Celsius and Fahrenheit, 4th turns the display backlight on/off and 5th safely turns the raspberry pi off. All of the code is written in C, both the raspberry pi and arduino.

Read more…

Please share πŸ™‚
error