danieljon.es

index posts opinions likes dislikes interesting cgit

Projects

Detailing a number of my personal projects

A collection of various personal projects distributed under free licenses (GPL 2/3). Other programming and IT related posts can be found on my blog.

GitHub Profile cgit

RGB Controller

C/C++, PHP, HTML, cross platform, Qt Framework, Arduino

Source code on GitHub

Using an Arduino, C/C++ and the Qt Framework I have created a controller that allows you to control the colours of an RGB LED strip.

Features:


room1 room2 room3

The project mounted on my monitor with the LED strip on the bottom rim

mounting
GUI application

RGB controller 1
  • status preview indicating current connection state
  • dropdown list populated by available serial ports
  • refresh button allowing the user to repopulate the dropdown
  • convenient connect/disconnect buttons
  • UI elements enable/disable appropriately
  • ping/pong system to keep the Arduino and host computer connected


RGB controller 2
  • sliders for modifying red, green and blue values
  • updates dynamically as you move the sliders
  • red, green and blue buttons for setting solid colours
  • off button to turn all colours off


RGB controller 3
  • allows fading of each red, green and blue channel dynamically
  • fade from and to values to allow precise fade control of each colour
  • toggle buttons to begin/end the fade of each colour individually
  • sliders to modify the speed of each colour individually
  • single slider that changes all colours speed at once, confirm button


RGB controller 4
  • presets stored locally in a text file and is parsed
  • dropdown menu listing all saved presets
  • button to load the current selected presets values
  • reload button allowing users to reload presets if changed externally
  • allows the user to save the current colour values, requires a name to be given
  • delete button to delete the currently selected preset, confirmation box displays


RGB controller 5
  • IRC bot allows commands from a single user, example "!send off;red=255;blue=255"
  • input boxes for the server, port, channel and bot name
  • automatically detects disconnections and attempts to reconnect


RGB controller 6
  • socket server allowing external client to connect and issue their own commands
  • default port of 3001


RGB controller 7
  • Information log showing messages from the application/Arduino
  • shows number of ping/pong exchanges
  • allows sending raw commands to the Arduino


Headless server application

Server application 1


Web controller

Web controller 1

Inventory system (new version)

C++, Qt, Python, MySQL

Source code available on GitHub

This is a complete re-write of my PHP/HTML/CSS/MySQL inventory system described in another post on this page. This project is not finished and is currently being worked on.

Using the Qt framework and C++ I have created a desktop application that can be used to manage and view an inventory of products. The program connects to a local or remote MySQL server which it uses to retrieved and add/modify data.

The interface is entirely dynamic. Interface elements are created on-the-fly as required and destroyed appropriately. The interface is split into two section, the top is a tabbed interface that provides different pages for interface elements. The bottom section is always visible and contains the results retrieved from the database.

Included is a Python script written to convert and transfer the old database content into the newer, more appropriate one.

The entire interface in the filter tab
filter tab

The database tab
database tab


Inventory system (old version)

PHP, Javascript, HTML, CSS, MySQL

Source code available upon request under GPL3

Someone I know requested an inventory system after finding none of the available solutions fit their needs. Using PHP and Javascript for the logic and HTML/CSS for the front end I developed an inventory system to their specifications. The data is stored in a MySQL database.

It includes (multiple) image uploading, adding, editing, deleting and restoring items and hourly backups (detailed in my post here).

The website works fine on a phone and appropriate resizes items, though I refuse to call it "responsive", I consider that term disgusting (I deeply dislike the current state of the internet and web design in general).

The database schema (the 'images' row is a serialised PHP array):




CS:GO bomb dropping program

C++, API

Source code available upon request under GPL3

I was shown a bind for CS:GO that automatically switches to your bomb and drops it. This is great, however it has one problem: if you aren't in possesion of the bomb it throws your current weapon. Of course, me being myself this was unacceptable, I had played a few games of matchmaking with this bind and I had dropped my gun by accident too many times (I bound it to mouse3, I also press mouse3 in game sometimes). The bind in question is bind mouse3 "use weapon_c4;drop". Using Qt/C++ I created a console application that uses CSGO's game state integration to read current game information from the game client. The application is simple, when the game detects you're currently in possesion of the bomb it writes the drop bomb bind to a cfg file, when it detects you don't have the bomb, it instead does nothing, in the case of this video it prints "I don't have the bomb". The cfg file is only written if the state changes, it isn't constantly writing to the file, that would be grossly inefficient.


Raspberry Pi 4 digit 7 segment display driver

C, GPIO

Source code available on GitHub

After becoming interested in 7 segment displays and having written one that displays characters and numbers in the terminal using vt100 escape codes (source code here) I began writing a C program that drives a 4 digit 7 segment display using the Raspberry Pi's GPIO. This was written without the use of GPIO libraries through manipulating the registers.

The concept of a 7 segment display with multiple digits is pretty simple. The digits are multiplexed, meaning only one digit has its LED's turned on at a time. Turning each digit on and off fast confuses your brain into thinking they are all on at once, this is known as persistence of vision.

functions:
displayword(unsigned char str[4]) // simply display a word, use in a loop
blinkword(unsigned char str[4], int repeat) // blink word once plus any integer > 0. < 0 will blink forever
runclock(void) // display the time on the display, forever
scrollword(char *string) // scroll the string from right to left with a small buffer of extra characters
post87_2
Scrolling text:


Blinking text:


urlopener

C

Source code available on GitHub

A program written in C that takes a variable number of arguments and determines if they are a URL. If the argument is considered a URL it is parsed and checked against a list of pre-defined values that determine how the URL will be opened. The program checks the domain (plus subdomain) and file extension.

I use this program partnered with my terminal emulator - I pipe every link (or a selection with dmenu) visible in the terminal window into this program, very convenient for images and videos.


cfg parser

C, parsing

Source code available on GitHub

A simple cfg file parser written in C. The key and value pairs are stored in a singly linked list.

It handles simple cfg/ini like files with 'key=value' pairs.

Comments are ignored, they're denoted by the '#' character.

Spaces are currently treated literally. test=123 and test = 123 are DIFFERENT, the key has a space appended and the value a space prepended in the second example.

Duplicate keys are not handled currently, the cfggetvalue function will only give you the first value.

See settings.cfg for an example cfg file.

To compile type make. Run the example program by issuing ./example.

All functions return 0 on failure, this goes for getting a value, always check 0 isn't returned. If it is, that means the key was not found.

Writing back to the cfg file is NOT implemented.

main.c has a usage example, however the usage structure is like this:

// allocate memory for the cfg structure
struct cfgfile *cfg = malloc(sizeof(struct cfgfile));
// setup cfg structure passing it the cfg structure we just made and a file name
cfgsetup(cfg, "filename.cfg");

// create a buffer for our value
char buffer[256];
// collect our value, the function returns 0 on a failure (when it cannot find the key)
int val;
val = cfggetvalue(cfg, "key", buffer, sizeof(buffer));
if (val != 0)
	puts(buffer); // print our value
else
	puts("cannot find the key!");

// free all of our memory (including cfg itself)
cfgfree(cfg);

string replacment in files

C

Source code available on GitHub

Written as a convenience function for a larger project I am writing, these functions allow you to dynamically replace a string in a file with something else. Also included is a function to do it within memory.

int replaceinfile(char *originalfile, char *destinationfile, char *placeholder,
char *replacement);
// 0 = failure, 1 = success

replaceinfile("input.txt", "output.txt", "%PLACEHOLDER%", "replacement string");
input.txt
Normal text file

%PLACEHOLDER%
%PLACEHOLDER%
%PLACEHOLDER%

With lines and whatever, %PLACEHOLDER%

123%PLACEHOLDER%123	
ok %PLACEHOLDER% ok
output.txt
Normal text file

replacement string
replacement string
replacement string

With lines and whatever, replacement string

123replacement string123	
ok replacement string ok

Classic snake in C

C, ncurses

Source code available on GitHub

Made as an exercise to experiment with linked lists, written in C using ncurses. Don't mind the flashing, that is a recording artifact.


Slack logging

Python, MongoDB, Slack API, PHP, HTML

Source code on GitHub

Considering Slacks free tier doesn't provide permanent data retention this script was created to allow permanent logging of our channels.

When run 2 API calls are made, one collecting channel information (names, ID's) the second user information (user id's, names, real names etc). A subsequent API call is made for each channel requesting the message history of that channel. The number of messages requested is configurable. Once this call is complete the script runs through each message. using the timestamp as a unique identifier (this is guaranteed to be unique in only the channel requested) the message is logged to the MongoDB database. If the API indicates that the message has been edited (adds a section to the response) the script checks if that message timestamp exists in the database in the specific channel (the same timestamp can exists in two channels!), if it does not, it adds it. However, if it does already exist the message content is checked with what is stored, if they don't match the newer message is stored.

The script can convert user id's to user names (and back), the same with channel id's and names.

database credentials and other important configurable variables are stored in a .cfg file for easy configuration.


Conway's Game of Life in C using ncurses

C, ncurses, game

Source code on GitHub

Using C and the ncurses library I have created a clone of Conway's Game of Life.

The arrow keys control the cursor, pressing space changes the selected cells value (either dead or alive). Pressing 'g' begins the simulation, 's' steps the simulation by one generation and 'c' clears the field.


Website generator

Python

Source code on GitHub

Previously my website relied heavily on PHP and databases. To remedy this I created a website generator that takes input text files along with settings stored in a cfg file and output static HTML files.

Included in this static website generator is a blogging system that takes numbered text files (1.txt through x.txt) and outputs static HTML files containing the blog entries. You can configure the number of posts per page in the config file. Separate HTML files containing each post are also created allowing you to directly link to a specific blog post.

This project powers my personal website https://danieljon.es, including this page.



page generated 30-04-2019 using sitegenerator